kqdkjlModel.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. class flow_kqdkjlClassModel extends flowModel
  3. {
  4. protected $flowcompanyidfieds = 'uid'; //多单位用这个关联
  5. public $dateobj,$typearr;
  6. public function initModel()
  7. {
  8. $this->dateobj = c('date');
  9. $this->typearr = explode(',','在线打卡,考勤机,手机定位,手动添加,异常添加,数据导入,接口导入,企业微信打卡,钉钉打卡,中控考勤机');//0-9
  10. }
  11. /**
  12. * 显示条件过滤
  13. */
  14. protected function flowbillwhere($uid, $lx)
  15. {
  16. $atype = $lx;
  17. $dt1 = $this->rock->post('dt1');
  18. $dt2 = $this->rock->post('dt2');
  19. $key = $this->rock->post('key');
  20. $s = '';
  21. $s = ' and a.`uid`='.$this->adminid.'';
  22. //全部下属打卡
  23. if($lx=='down' || $lx=='dwdown'){
  24. $s = 'and '.$this->adminmodel->getdownwheres('b.id', $uid, 0);
  25. }
  26. if($atype=='all')$s ='';
  27. if(!isempt($dt1))$s.=" and a.`dkdt`>='$dt1'";
  28. if(!isempt($dt2))$s.=" and a.`dkdt`<='$dt2 23:59:59'";
  29. if(!isempt($key))$s.=" and (b.`name` like '%$key%' or b.`deptallname` like '%$key%' or b.`ranking` like '%$key%')";
  30. $fields = 'a.*,b.`name`,b.`deptname`';
  31. $tabls = $this->mtable;
  32. $table = '`[Q]'.$tabls.'` a left join `[Q]userinfo` b on a.uid=b.id';
  33. return array(
  34. 'where' => $s,
  35. 'table' => $table,
  36. 'order' => 'a.`id` desc',
  37. 'fields'=> $fields
  38. );
  39. }
  40. //替换
  41. public function flowrsreplace($rs)
  42. {
  43. $week = $this->dateobj->cnweek($rs['dkdt']);
  44. $rs['week'] = $week;
  45. $rs['type'] = $this->typearr[$rs['type']];
  46. if($week=='六' || $week=='日')$rs['ishui']= 1;
  47. return $rs;
  48. }
  49. public function flowdaorutestdata()
  50. {
  51. $barr[] = array(
  52. 'base_name' => '管理员',
  53. 'dkdt' => '2016-08-08 12:00:01',
  54. );
  55. $barr[] = array(
  56. 'base_name' => '大乔',
  57. 'dkdt' => '2017-08-22 08:55:01',
  58. );
  59. return $barr;
  60. }
  61. //导入之前判断
  62. public function flowdaorubefore($rows)
  63. {
  64. $inarr = array();
  65. $uarr = array();
  66. $dtobj = c('date');
  67. foreach($rows as $k=>$rs){
  68. $name = $rs['base_name'];
  69. $dkdt = $rs['dkdt'];
  70. if(isempt($name) || isempt($dkdt))continue;
  71. $dkdt = str_replace('/','-', $dkdt);
  72. if(!$dtobj->isdate($dkdt))continue;
  73. if(isset($uarr[$name])){
  74. $uid = $uarr[$name];
  75. }else{
  76. $usar = $this->adminmodel->getrows("`name`='$name'",'id');
  77. if($this->db->count!=1)continue;
  78. $uid = $usar[0]['id'];
  79. $uarr[$name] = $uid;
  80. }
  81. if($this->rows("`uid`='$uid' and `dkdt`='$dkdt'")>0)continue;
  82. $inarr[] = array(
  83. 'uid' => $uid,
  84. 'dkdt' => $dkdt,
  85. 'type' => 5,
  86. );
  87. }
  88. return $inarr;
  89. }
  90. /**
  91. * 首页考勤打卡记录
  92. */
  93. public function homekqtotal()
  94. {
  95. $dt = $this->rock->date;
  96. $where= $this->adminmodel->getcompanywhere(5,'a.');
  97. $uarr = $this->db->getall('select a.id from `[Q]admin` a left join `[Q]userinfo` b on a.id=b.id where b.`iskq`=1 and a.`status`=1 '.$where.'');
  98. $uids = '0';
  99. $uarrs = array();
  100. foreach($uarr as $k=>$rs){
  101. $uids.=','.$rs['id'].'';
  102. $uarrs[$rs['id']] = '未打卡';
  103. }
  104. $rows = $this->db->getall("SELECT * FROM `[Q]kqanay` where `uid` in($uids) and `dt`='$dt' and sort=0");
  105. foreach($rows as $k=>$rs){
  106. $state = $rs['state'];
  107. if(!isempt($rs['states']))$state = $rs['states'];
  108. $uarrs[$rs['uid']] = $state;
  109. }
  110. $ztarr = array();
  111. foreach($uarrs as $uid=>$zt){
  112. if(!isset($ztarr[$zt]))$ztarr[$zt]=0;
  113. $ztarr[$zt]++;
  114. }
  115. $rows = array();
  116. $data = array();
  117. foreach($ztarr as $zt=>$vs){
  118. $rows[] = array(
  119. 'value' => $vs,
  120. 'name' => $zt
  121. );
  122. $data[] = $zt;
  123. }
  124. return array(
  125. 'rows' => $rows,
  126. 'data' => $data,
  127. 'dt' => $dt,
  128. );
  129. }
  130. }
粤ICP备19079148号