1
0

kqdkjlModel.php 3.6 KB

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