mode_hrsalaryAction.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. //薪资
  3. class mode_hrsalaryClassAction extends inputAction{
  4. protected function savebefore($table, $arr, $id, $addbo){
  5. $month = $arr['month'];
  6. $lastdt = c('date')->getenddt($month);
  7. if($lastdt>$this->date)return ''.$month.'月份超前了,还没结束呢';
  8. $uname = $arr['uname'];
  9. $xuid = $arr['xuid'];
  10. if(m($table)->rows('id<>'.$id.' and `xuid`='.$xuid.' and `month`=\''.$month.'\'')>0)return ''.$month.'月份['.$uname.']的薪资已申请过了'.$lastdt.'';
  11. }
  12. protected function saveafter($table, $arr, $id, $addbo){
  13. }
  14. public function changeunameAjax()
  15. {
  16. $xuid = (int)$this->post('xuid');
  17. $a = m('admin')->getone($xuid,'deptname,ranking');
  18. $this->returnjson($a);
  19. }
  20. public function changemonthAjax()
  21. {
  22. $xuid = (int)$this->post('xuid', $this->adminid);
  23. $month = $this->post('month');
  24. $one = m('hrsalary')->getone("`xuid`='$xuid' and `month`='$month'");
  25. $barr['mid'] = 0;
  26. $barr['xuid'] = $xuid;
  27. $barr['month'] = $month;
  28. if($one){
  29. $barr['mid'] = $one['id'];
  30. }else{
  31. }
  32. return $barr;
  33. }
  34. public function selectmonth()
  35. {
  36. $mfy = 2016;
  37. $mf1 = date('Y');
  38. for($y=$mf1;$y>=$mfy;$y--){
  39. $max = 12;
  40. if($y==$mf1)$max = (int)date('m');
  41. for($j=$max;$j>=1;$j--){
  42. $j1 = $j;
  43. if($j<10)$j1='0'.$j.'';
  44. $barr[] = array(
  45. 'name'=>''.$y.'-'.$j1.'',
  46. 'value'=>''.$y.'-'.$j1.''
  47. );
  48. }
  49. }
  50. return $barr;
  51. }
  52. /**
  53. * 薪资初始化,主要计算考勤
  54. */
  55. public function initdatasAjax()
  56. {
  57. $xuid = (int)$this->post('xuid');
  58. $month = $this->post('month');
  59. $a = m('kaoqin')->getkqtotal($xuid, $month);
  60. $lmonth = c('date')->adddate($month.'-01','m',-1,'Y-m');
  61. $sfielss= 'base,postjt,skilljt,travelbt,telbt';
  62. $flow = m('flow')->initflow('hrsalary');
  63. $lrs = $flow->getone("`xuid`='$xuid' and `month`='$month'");
  64. if(!$lrs)$lrs = $flow->getone("`xuid`='$xuid' and `status`<>5", $sfielss,'`month` desc');
  65. $sm = '';
  66. if($lrs){
  67. $sfiels = explode(',',$sfielss);
  68. foreach($sfiels as $sfie)$a[$sfie] = $lrs[$sfie];
  69. }
  70. $urs = m('admin')->getone($xuid,'quitdt,workdate');
  71. if(contain($urs['workdate'],$month))$sm.=''.$urs['workdate'].'入职;';
  72. if(contain($urs['quitdt'],$month))$sm.=''.$urs['quitdt'].'离职;';
  73. $txrs = m('hrtrsalary')->getone("`uid`='$xuid' and `effectivedt` like '$month%' and `status`=1");
  74. if($txrs){
  75. $sm.=''.$txrs['effectivedt'].'起调薪'.$txrs['floats'].';';
  76. if($lrs){
  77. $a['postjt'] = floatval($a['postjt']) + floatval($txrs['floats']);//岗位工资加起来
  78. }
  79. }
  80. //奖励
  81. $a['reward'] = floatval(m('reward')->getmou('sum(money)', "`objectid`='$xuid' and `status`=1 and `type`=0 and `applydt` like '$month%'"));
  82. //处罚
  83. $a['punish'] = floatval(m('reward')->getmou('sum(money)', "`objectid`='$xuid' and `status`=1 and `type`=1 and `applydt` like '$month%'"));
  84. if($sm!='')$a['explain'] = $sm;
  85. //读取辅助固定值
  86. /*
  87. $farrr = $flow->getfiearrs($xuid, $month);
  88. foreach($farrr as $k1=>$rs1){
  89. foreach($rs1['fieldsarr'] as $k2=>$rs2){
  90. if($rs2['type']=='0')$a[$rs2['fields']] = $rs2['devzhi'];
  91. }
  92. }*/
  93. //print_r($farrr);
  94. //读取社保公积金
  95. $rows = m('hrshebao')->getall("`status`=1 and `startdt`<='$month' and `enddt`>='$month'");
  96. if($rows){
  97. foreach($rows as $k=>$rs)$rows[$k]['xuhao']=$k+1;
  98. $gxu = m('kaoqin')->getpipeimid($xuid, $rows, 'xuhao', -1);
  99. if($gxu>0)$gxu--;
  100. if(isset($rows[$gxu])){
  101. $qrs = $rows[$gxu];
  102. $a['socials'] = $qrs['shebaogeren'];
  103. $a['socialsunit'] = $qrs['shebaounit'];
  104. $a['gonggeren'] = $qrs['gonggeren'];
  105. $a['gongunit'] = $qrs['gongunit'];
  106. }
  107. }
  108. $this->returnjson($a);
  109. }
  110. }
粤ICP备19079148号