1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Model;
- use think\response\Json;
- class AbroadApply extends Model
- {
- public function advancedStartAbroadApply($id,$orgId,$userId,$formJson,$extra){
- $formJson = json_decode($formJson,true);
- $data = [
- 'org_id' => $orgId,
- 'user_id' => $userId,
- 'apply_id' => $id,
- 'dep_id' => $extra['depId'],
- 'create_time' => date('Y-m-d H:i:s'),
- 'status' => 0,
- 'year' => date('Y')
- ];
- foreach ($formJson as $k=>$v){
- if($v['componentName'] == 'ddabroadfield'){
- foreach ($v['components'] as $key=>$val){
- switch ($val['idx']){
- case '0':
- $data['address'] = isset($val['values'])?$val['values']:'';
- break;
- case '1':
- $data['reason'] = isset($val['values'])?$val['values']:'';
- break;
- case '2':
- $values2 = isset($val['values2'])?$val['values2']:[];
- $data['new'] = implode(',',$values2);
- break;
- case '3':
- $values2 = isset($val['values2'])?$val['values2']:[];
- $data['borrow'] = implode(',',$values2);
- break;
- case '4':
- $values2 = isset($val['values2'])?$val['values2']:[];
- if($values2){
- $data['holiday_start'] = $values2[0];
- $data['holiday_end'] = $values2[1];
- }
- break;
- }
- }
- break;
- }
- }
- $ret = Db::name('abroad_apply')->insert($data);
- return $ret?true:false;
- }
- public function advancedEndAbroadApply($id,$orgId,$userId,$formJson){
- $data = [
- 'update_time' => date('Y-m-d H:i:s'),
- 'status' => 1
- ];
- // 生成编号
- $maxsn = Db::name('abroad_apply')->where('year',date('Y'))->max('sn');
- $maxsn = $maxsn?$maxsn+1:1;
- $data['sn'] = $maxsn;
- $data['year'] = date('Y');
- $ret = Db::name('abroad_apply')->where('apply_id',$id)->update($data);
- return $ret?true:false;
- }
- public function advancedDisagreeAbroadApply($id){
- $data = [
- 'update_time' => date('Y-m-d H:i:s'),
- 'status' => 2
- ];
- $ret = Db::name('abroad_apply')->where('apply_id',$id)->update($data);
- return $ret?true:false;
- }
- }
|