reimplatAction.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. class reimplatClassAction extends Action
  3. {
  4. public function setsaveAjax()
  5. {
  6. $this->option->setval('reimplat_purl@-7', $this->post('purl'));
  7. $this->option->setval('reimplat_cnum@-7', $this->post('cnum'));
  8. $this->option->setval('reimplat_secret@-7', $this->post('secret'));
  9. $this->option->setval('reimplat_devnum@-7', $this->post('devnum'));
  10. $this->option->setval('reimplat_huitoken@-7', $this->post('huitoken'));
  11. return 'ok';
  12. }
  13. public function getsetAjax()
  14. {
  15. $arr= array();
  16. $arr['purl'] = $this->option->getval('reimplat_purl');
  17. $arr['cnum'] = $this->option->getval('reimplat_cnum');
  18. $arr['secret'] = $this->option->getval('reimplat_secret');
  19. $arr['devnum'] = $this->option->getval('reimplat_devnum');
  20. $arr['huitoken'] = $this->option->getval('reimplat_huitoken');
  21. $arr['huiurl'] = ''.URL.'api.php?m=reimplat';
  22. if(COMPANYNUM)$arr['huiurl'].='&dwnum='.COMPANYNUM.'';
  23. echo json_encode($arr);
  24. }
  25. //获取信呼系统上部门
  26. public function deptdataAjax()
  27. {
  28. $this->rows = array();
  29. $this->getdept(0, 1);
  30. $this->returnjson(array(
  31. 'totalCount'=> 0,
  32. 'rows' => $this->rows
  33. ));
  34. }
  35. private function getdept($pid, $oi)
  36. {
  37. $db = m('dept');
  38. $menu = $db->getall("`pid`='$pid' order by `sort`",'*');
  39. foreach($menu as $k=>$rs){
  40. $sid = $rs['id'];
  41. $rs['level'] = $oi;
  42. $rs['stotal'] = $db->rows("`pid`='$sid'");
  43. $rs['zt'] = 1;
  44. $this->rows[] = $rs;
  45. $this->getdept($rs['id'], $oi+1);
  46. }
  47. }
  48. public function deptwxdataAjax()
  49. {
  50. $barr = m('reimplat:dept')->getdeptlist();
  51. if(!$barr['success'])return $barr;
  52. $rows = $barr['data'];
  53. $this->returnjson(array(
  54. 'totalCount'=> 0,
  55. 'rows' => $rows
  56. ));
  57. }
  58. //微信上用户操作
  59. public function beforeusershow($table)
  60. {
  61. $fields = 'id,name,`user`,deptname,status,tel,ranking,superman,loginci,deptid,sex,mobile,email,sort,face';
  62. $fields.=',deptids,deptnames';
  63. $s = '';
  64. $key = $this->post('key');
  65. if($key!=''){
  66. $s = " and (`name` like '%$key%' or `user` like '%$key%' or `ranking` like '%$key%' or `deptname` like '%$key%' ";
  67. $s.=" or `deptnames` like '%$key%'";
  68. $s.= ')';
  69. }
  70. return array(
  71. 'fields'=> $fields,
  72. 'where' => $s
  73. );
  74. }
  75. private function isgcstr($urs, $purs)
  76. {
  77. if(!$urs || !$purs)array(0,'');
  78. $isgc = 0;
  79. $isgcstr = '';
  80. if($urs['mobile']!=$purs['mobile']){$isgc = 1;$isgcstr = '手机号';}
  81. if($urs['deptid']!=$purs['deptid']){$isgc = 1;$isgcstr = '部门';}
  82. if($urs['ranking']!=$purs['position']){$isgc = 1;$isgcstr = '职位';}
  83. if($urs['name']!=$purs['name']){$isgc = 1;$isgcstr = '姓名';}
  84. if($urs['email']!=$purs['email']){$isgc = 1;$isgcstr = '邮箱';}
  85. if($urs['tel']!=$purs['tel']){$isgc = 1;$isgcstr = '办公电话';}
  86. return array($isgc, $isgcstr);
  87. }
  88. public function afterusershow($table, $rows)
  89. {
  90. $obj = m('reimplat:dept');
  91. foreach($rows as $k=>$rs){
  92. $iscj = 0;
  93. $yurs = $obj->getuinfo($rs['user']);
  94. if($yurs){
  95. $iscj = 1;
  96. $rows[$k]['isgz'] = $yurs['status'];
  97. $nars = $this->isgcstr($rs, $yurs);
  98. $rows[$k]['isgc'] = $nars[0];
  99. $rows[$k]['isgcstr'] = $nars[1];
  100. }
  101. $rows[$k]['iscj'] = $iscj;
  102. $rows[$k]['yurs'] = $yurs;
  103. $rows[$k]['mobile'] = substr($rs['mobile'],0,3).'****'.substr($rs['mobile'],-4);
  104. }
  105. $noarr = $obj->notinadmin();
  106. return array('rows'=>$rows,'notstr'=>join(',', $noarr));
  107. }
  108. public function reloaduserAjax()
  109. {
  110. return m('reimplat:dept')->getuserlist();
  111. }
  112. public function delalluserAjax()
  113. {
  114. return m('reimplat:dept')->deleteuserall();
  115. }
  116. public function updateuserAjax()
  117. {
  118. $id = (int)$this->get('id','0');
  119. $urs = m('admin')->getone($id,'`user`,`name`,`ranking`,`superman`,`isvcard`,`tel`,`mobile`,`email`,`deptid`,`deptname`,`sex`,`sort`,`pingyin`');
  120. $barr = m('reimplat:dept')->userupdate($urs);
  121. return $barr;
  122. }
  123. public function updatealldeptAjax()
  124. {
  125. $barr = m('reimplat:dept')->deptallupdate();
  126. return $barr;
  127. }
  128. public function agentdataAjax()
  129. {
  130. $barr =m('reimplat:agent')->listdata();
  131. $rows = array();
  132. if($barr['success'])$rows = $barr['data'];
  133. $this->returnjson(array(
  134. 'totalCount'=> 0,
  135. 'rows' => $rows
  136. ));
  137. }
  138. public function sendmsgAjax()
  139. {
  140. $name = $this->post('name');
  141. $msg = $this->post('msg');
  142. return m('reimplat:agent')->sendxiao($this->adminid, $name, $msg);
  143. }
  144. public function senduserAjax()
  145. {
  146. $id = (int)$this->post('id');
  147. $msg = $this->post('msg');
  148. return m('reimplat:agent')->sendxiao($id, '', $msg);
  149. }
  150. }
粤ICP备19079148号