AttendanceReissue.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\common\model;
  3. use app\hander\HelpHander;
  4. use think\Db;
  5. use think\Model;
  6. class AttendanceReissue extends Model
  7. {
  8. public function advancedStartReissue($id,$orgId,$userId,$formJson){
  9. $formJson = json_decode($formJson,true);
  10. $data = [
  11. 'org_id' => $orgId,
  12. 'user_id' => $userId,
  13. 'apply_id' => $id,
  14. 'create_time' => date('Y-m-d H:i:s'),
  15. 'status' => 0,
  16. ];
  17. foreach ($formJson as $k=>$v){
  18. if($v['componentName'] == 'ddremakecardfield'){
  19. foreach ($v['components'] as $key=>$val){
  20. switch ($val['idx']){
  21. case '0':
  22. $dtime = json_decode($val['values'],true);
  23. $data['kq_time'] = $dtime['id'];
  24. break;
  25. case '1':
  26. $data['signtime'] = $val['values'];
  27. break;
  28. }
  29. }
  30. break;
  31. }
  32. }
  33. $data['month'] = date('Ym',strtotime($data['kq_time']));
  34. $ret = Db::name('attendance_reissue')->insert($data);
  35. return $ret?true:false;
  36. }
  37. public function advancedEndReissue($id,$orgId,$userId,$formJson){
  38. $info = Db::name('attendance_reissue')->where('apply_id',$id)->find();
  39. $data = [
  40. 'update_time' => date('Y-m-d H:i:s'),
  41. 'status' => 1
  42. ];
  43. // 更新考勤记录
  44. $res = model('AttendanceRecord')->reissue($userId,$orgId,$info['kq_time'],$info['signtime']);
  45. if(!$res){
  46. return false;
  47. }
  48. $ret = Db::name('attendance_reissue')->where('apply_id',$id)->update($data);
  49. return $ret?true:false;
  50. }
  51. public function advancedDisagreeReissue($applyId){
  52. $data = [
  53. 'update_time' => date('Y-m-d H:i:s'),
  54. 'status' => 2
  55. ];
  56. $ret = Db::name('attendance_reissue')->where('apply_id',$applyId)->update($data);
  57. return $ret?true:false;
  58. }
  59. }