AbroadApply.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\common\model;
  3. use app\hander\HelpHander;
  4. use think\Db;
  5. use think\Model;
  6. use think\response\Json;
  7. class AbroadApply extends Model
  8. {
  9. public function advancedStartAbroadApply($id,$orgId,$userId,$formJson,$extra){
  10. $formJson = json_decode($formJson,true);
  11. $data = [
  12. 'org_id' => $orgId,
  13. 'user_id' => $userId,
  14. 'apply_id' => $id,
  15. 'dep_id' => $extra['depId'],
  16. 'create_time' => date('Y-m-d H:i:s'),
  17. 'status' => 0,
  18. 'year' => date('Y')
  19. ];
  20. foreach ($formJson as $k=>$v){
  21. if($v['componentName'] == 'ddabroadfield'){
  22. foreach ($v['components'] as $key=>$val){
  23. switch ($val['idx']){
  24. case '0':
  25. $data['address'] = isset($val['values'])?$val['values']:'';
  26. break;
  27. case '1':
  28. $data['reason'] = isset($val['values'])?$val['values']:'';
  29. break;
  30. case '2':
  31. $values2 = isset($val['values2'])?$val['values2']:[];
  32. $data['new'] = implode(',',$values2);
  33. break;
  34. case '3':
  35. $values2 = isset($val['values2'])?$val['values2']:[];
  36. $data['borrow'] = implode(',',$values2);
  37. break;
  38. case '4':
  39. $values2 = isset($val['values2'])?$val['values2']:[];
  40. if($values2){
  41. $data['holiday_start'] = $values2[0];
  42. $data['holiday_end'] = $values2[1];
  43. }
  44. break;
  45. }
  46. }
  47. break;
  48. }
  49. }
  50. $ret = Db::name('abroad_apply')->insert($data);
  51. return $ret?true:false;
  52. }
  53. public function advancedEndAbroadApply($id,$orgId,$userId,$formJson){
  54. $data = [
  55. 'update_time' => date('Y-m-d H:i:s'),
  56. 'status' => 1
  57. ];
  58. // 生成编号
  59. $maxsn = Db::name('abroad_apply')->where('year',date('Y'))->max('sn');
  60. $maxsn = $maxsn?$maxsn+1:1;
  61. $data['sn'] = $maxsn;
  62. $data['year'] = date('Y');
  63. $ret = Db::name('abroad_apply')->where('apply_id',$id)->update($data);
  64. return $ret?true:false;
  65. }
  66. public function advancedDisagreeAbroadApply($id){
  67. $data = [
  68. 'update_time' => date('Y-m-d H:i:s'),
  69. 'status' => 2
  70. ];
  71. $ret = Db::name('abroad_apply')->where('apply_id',$id)->update($data);
  72. return $ret?true:false;
  73. }
  74. }