hrAction.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. class hrClassAction extends runtAction
  3. {
  4. /*
  5. * 员工合同到期提醒/人事每天调动运行
  6. */
  7. public function httodoAction()
  8. {
  9. m('hr')->hrrun(); //人事每天调动/离职等运行
  10. //员工合同到期提醒
  11. $flow = m('flow')->initflow('userract');
  12. $flow->updatestate();
  13. $dtobj = c('date');
  14. $dt = $this->rock->date;
  15. $dt30 = $dtobj->adddate($dt,'d',35);
  16. $rows = m('userract')->getall("state=1 and `enddt`<='$dt30'",'id,enddt,httype,name,uname');
  17. $str = '';
  18. foreach($rows as $k=>$rs){
  19. $jg = $dtobj->datediff('d', $dt, $rs['enddt']);
  20. if($jg==30 || $jg<=7){
  21. $str.='人员['.$rs['uname'].']的【'.$rs['httype'].'.'.$rs['name'].'】将在'.$jg.'天后的'.$rs['enddt'].'到期;';
  22. }
  23. }
  24. if($str != ''){
  25. $this->todoarr = array(
  26. 'modenum' => 'userract',
  27. 'agentname' => '员工合同',
  28. 'title' => '员工合同到期提醒',
  29. 'cont' => $str,
  30. );
  31. }
  32. //生日提醒
  33. m('flow')->initflow('userinfo')->birthdaytodo();
  34. //自动从考核项目中添加
  35. m('flow')->initflow('hrcheck')->hrkaohemrun();
  36. //个人资料完善提醒
  37. return 'success';
  38. }
  39. //转正的
  40. private function updatepositive($timess)
  41. {
  42. $db = m('hrpositive');
  43. $rows = $db->getall("`status`=1 and `isover`=0",'`id`,`uid`,`entrydt`,`syenddt`,`positivedt`');
  44. foreach($rows as $k=>$rs){
  45. if(strtotime($rs['positivedt']) <= $timess){
  46. $bo = m('userinfo')->update(array(
  47. 'state' => '1',
  48. 'syenddt' => $rs['syenddt'],
  49. 'positivedt' => $rs['positivedt'],
  50. ), $rs['uid']);
  51. if($bo)$db->update("`isover`=1", $rs['id']);
  52. }
  53. }
  54. }
  55. //离职的
  56. private function updatehrredund($timess)
  57. {
  58. $db = m('hrredund');
  59. $rows = $db->getall("`status`=1 and `isover`=0",'`id`,`uid`,`quitdt`');
  60. $timess = $timess - 24*3600;//昨天
  61. foreach($rows as $k=>$rs){
  62. if(strtotime($rs['quitdt']) <= $timess){
  63. $bo = m('userinfo')->update(array(
  64. 'state' => '5',
  65. 'quitdt' => $rs['quitdt']
  66. ), $rs['uid']);
  67. m('admin')->update(array(
  68. 'quitdt' => $rs['quitdt']
  69. ), $rs['uid']);
  70. if($bo)$db->update("`isover`=1", $rs['id']);
  71. }
  72. }
  73. }
  74. //调动的
  75. private function updatehrtransfer($timess)
  76. {
  77. $db = m('hrtransfer');
  78. $mdb = m('admin');
  79. $rows = $db->getall("`status`=1 and `isover`=0",'`id`,`uid`,`effectivedt`,`newdeptid`,`tranuid`,`newdeptname`,`newranking`');
  80. $uids = '0';
  81. foreach($rows as $k=>$rs){
  82. if(strtotime($rs['effectivedt']) <= $timess){
  83. $uid = $rs['tranuid'];
  84. $bo = $mdb->update(array(
  85. 'deptid' => $rs['newdeptid'],
  86. 'deptname' => $rs['newdeptname'],
  87. 'ranking' => $rs['newranking'],
  88. ), $uid);
  89. if($bo){
  90. $db->update("`isover`=1", $rs['id']);
  91. $uids.=','.$uid;
  92. }
  93. }
  94. }
  95. if($uids != '0')$mdb->updateinfo("and `id` in($uids)");
  96. }
  97. }
粤ICP备19079148号