kaoqinjAction.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. class kaoqinjClassAction extends Action
  3. {
  4. public function kqjsndelAjax()
  5. {
  6. $id = (int)$this->post('id');
  7. m('kqjsn')->delete("`id`='$id'");
  8. showreturn();
  9. }
  10. public function kqjcmddelAjax()
  11. {
  12. $id = c('check')->onlynumber($this->post('id'));
  13. m('kqjcmd')->delete("`id` in ($id)");
  14. showreturn();
  15. }
  16. //设备搜索
  17. public function kqjsnbefore($table)
  18. {
  19. $key = $this->post('key');
  20. $where = '';
  21. if(!isempt($key))$where = " and (`num`='$key' or `name` like '%$key%' or `company` like '%$key%')";
  22. return $where;
  23. }
  24. //设备搜索命令
  25. public function kqjcmdbefore($table)
  26. {
  27. $optdt= date('Y-m-d H:i:s', time()-10*60);
  28. m($table)->update('status=5',"`status`=0 and `optdt`<'$optdt'");
  29. $key = $this->post('key');
  30. $snid = (int)$this->post('snid','0');
  31. $where = '';
  32. if(!isempt($key))$where = " and (`num`='$key' or `name` like '%$key%' or `company` like '%$key%')";
  33. if($snid>0){
  34. $where.=" and a.`snid`='$snid'";
  35. }
  36. return array(
  37. 'where' => $where,
  38. 'table' => '`[Q]kqjcmd` a left join `[Q]kqjsn` b on a.`snid`=b.`id`',
  39. 'fields'=> 'a.*,b.`name`,b.`num`,b.`company`'
  40. );
  41. }
  42. public function kqjcmdafter($table,$rows)
  43. {
  44. $cmds = m('kqjcmd');
  45. $time = time();
  46. foreach($rows as $k=>$rs){
  47. $zt = $rs['status'];
  48. if($zt=='0')$zt = '<font color="blue">待发送</font>';
  49. if($zt=='1')$zt = '<font color="green">处理成功</font>';
  50. if($zt=='2')$zt = '<font color="#ff6600">已请求</font>';
  51. if($zt=='3')$zt = '<font color="red">处理失败</font>';
  52. if($zt=='5')$zt = '<font color="#888888">已过期</font>';
  53. $rows[$k]['atype'] = $cmds->cmdtype($rs['atype']);
  54. if($rs['status']=='5'){
  55. $rows[$k]['ishui'] = 1;
  56. }
  57. $rows[$k]['status'] = $zt;
  58. }
  59. $kqsnarr = array();
  60. if($this->loadci==1){
  61. $where1 = m('admin')->getcompanywhere(1);
  62. $kqsnarr = m('kqjsn')->getall('status=1 '.$where1.'','id,name,num','sort');
  63. foreach($kqsnarr as $k=>$rs){
  64. $kqsnarr[$k]['name'] = ''.$rs['id'].'.'.$rs['name'].'('.$rs['num'].')';
  65. }
  66. }
  67. return array(
  68. 'rows' => $rows,
  69. 'kqsnarr' => $kqsnarr
  70. );
  71. }
  72. //发送设备命令
  73. public function sendcmdAjax()
  74. {
  75. $ids = $this->get('ids');
  76. $type = $this->get('type');
  77. $ida = explode(',', $ids);
  78. $oi = 0;
  79. $msg = '';
  80. foreach($ida as $id1){
  81. $barr = m('kqjcmd')->send($id1, $type);
  82. if($barr['success']){
  83. $oi++;
  84. }else{
  85. if(substr($type,0,6)=='advert')return $barr;
  86. $msg .= ''.$barr['msg'].';';
  87. }
  88. }
  89. if($oi==0 && $msg!='')return returnerror($msg);
  90. return returnsuccess('成功发送'.$oi.'条命令,可到[考勤机命令查看]下查看结果<font color=red>'.$msg.'</font>');
  91. }
  92. //考勤机上人员管理
  93. public function kquserafter($table,$rows)
  94. {
  95. $snid = (int)$this->post('snid','0');
  96. $deptsdata = array();
  97. if($rows && $snid>0 && $snrs = m('kqjcmd')->getsninfo($snid)){
  98. $userids = $snrs['userids'];
  99. $deptids = $snrs['deptids'];
  100. $useridf = ','.$userids.','; //判断是否在考勤机上
  101. $uids = '';
  102. foreach($rows as $k=>$rs){
  103. if(contain($useridf,','.$rs['id'].',')){
  104. $kqjzt = '<font color=green>已上传</font>';
  105. }else{
  106. $kqjzt = '';//'<font color=red>未上传</font>';
  107. }
  108. $fingerprint1 = '';//'<font color=red>未采集</font>';
  109. $fingerprint2 = '';//'<font color=#888888>未采集</font>';
  110. $headpic = '';//'<font color=#888888>无</font>';
  111. $rows[$k]['fingerprint1'] = $fingerprint1;
  112. $rows[$k]['fingerprint2'] = $fingerprint2;
  113. $rows[$k]['headpic'] = $headpic;
  114. $rows[$k]['kqjzt'] = $kqjzt;
  115. $uids .= ','.$rs['id'].'';
  116. }
  117. $uids = substr($uids, 1);
  118. //显示已存在部门
  119. if(!isempt($deptids)){
  120. $detpros = m('dept')->getdeptrows($deptids);
  121. $deptsdata = $this->depttreeshu($detpros,'0');
  122. }
  123. //判断指纹是否存在
  124. $zwarr = $this->db->getarr('[Q]kqjuser','`snid`='.$snid.' and `uid` in('.$uids.')','fingerprint1,fingerprint2,headpic','uid');
  125. if($zwarr)foreach($rows as $k=>$rs){
  126. if(isset($zwarr[$rs['id']])){
  127. $ztrs = $zwarr[$rs['id']];
  128. if(!isempt($ztrs['fingerprint1'])){
  129. $rows[$k]['fingerprint1'] = '<font color=green>已采集</font>';
  130. }
  131. if(!isempt($ztrs['fingerprint2'])){
  132. $rows[$k]['fingerprint2'] = '<font color=green>已采集</font>';
  133. }
  134. if(!isempt($ztrs['headpic']) && file_exists($ztrs['headpic'])){
  135. $rows[$k]['headpic'] = '<img onclick="$.imgview({url:this.src})" src="'.$ztrs['headpic'].'" height="24">';
  136. }
  137. }
  138. }
  139. $barr['nocunid'] = m('kqjcmd')->getnosys($snid);
  140. $barr['nocunid'] = join(',', $barr['nocunid']);
  141. }
  142. $barr['rows'] = $rows;
  143. if($this->loadci==1){
  144. $drows = m('dept')->getdata('sd');
  145. $fid = '0';
  146. if(ISMORECOM)$fid = $drows[0]['pid'];
  147. $barr['deptdata'] = $this->depttreeshu($drows, $fid);
  148. $where1 = m('admin')->getcompanywhere(1);
  149. $kqsnarr = m('kqjsn')->getall('status=1 '.$where1.'','id,name,num','sort');
  150. foreach($kqsnarr as $k=>$rs){
  151. $kqsnarr[$k]['name'] = ''.$rs['id'].'.'.$rs['name'].'('.$rs['num'].')';
  152. }
  153. $barr['kqsnarr'] = $kqsnarr;
  154. }
  155. $barr['deptsdata'] = $deptsdata;
  156. return $barr;
  157. }
  158. public function kquserbefore($table)
  159. {
  160. $key = $this->post('key');
  161. $snid = (int)$this->post('snid','0');
  162. $detpid = (int)$this->post('deptid','0');
  163. $where = '';
  164. if(!isempt($key))$where = m('admin')->getkeywhere($key);
  165. if($detpid>1){
  166. $where.= " and instr(`deptpath`,'[$detpid]')>0";
  167. }
  168. if(ISMORECOM)$where .=' and `companyid` in('.m('admin')->getcompanyid().')';
  169. return array(
  170. 'fields'=>'id,name,deptname,ranking,status,face',
  171. 'where'=>$where,
  172. 'order'=> 'sort'
  173. );
  174. }
  175. //组织结构活动得到树形数据
  176. private function depttreeshu($rows, $pid)
  177. {
  178. $barr = array();
  179. foreach($rows as $k=>$rs){
  180. if($rs['pid']==$pid){
  181. $rs['children'] = $this->depttreeshu($rows, $rs['id']);
  182. $rs['expanded'] = $pid=='0';
  183. $barr[] = $rs;
  184. }
  185. }
  186. return $barr;
  187. }
  188. //人员到设备上信息管理
  189. public function sendusercmdAjax()
  190. {
  191. $uids = $this->get('uids'); //人员ID
  192. $snid = $this->get('snid');
  193. $type = $this->get('type');
  194. $gtype = (int)$this->post('gtype','0'); //0选中,1全部
  195. if($gtype==1)$uids = '0';
  196. $barr = m('kqjcmd')->send($snid, $type, $uids);
  197. if($barr['success'])$barr['data'] = '命令已发送,可到[考勤机命令查看]下查看结果';
  198. return $barr;
  199. }
  200. }
粤ICP备19079148号