gerenAction.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?php
  2. class gerenClassAction extends Action
  3. {
  4. public function getinitAjax()
  5. {
  6. $uid = $this->adminid;
  7. $carr= m('admin')->getcompanyinfo($uid);
  8. return array(
  9. 'gerentodo' => $this->option->getval('gerennotodo_'.$uid.''),
  10. 'qmimgstr' => $this->option->getval('qmimgstr_'.$uid.''),
  11. 'carr' => $carr,
  12. );
  13. }
  14. public function cogsaveAjax()
  15. {
  16. $uid = $this->adminid;
  17. $this->option->setval('gerennotodo_'.$uid.'', $this->get('gerentodo','0'));
  18. }
  19. //保存图片
  20. public function qmimgsaveAjax()
  21. {
  22. $uid = $this->adminid;
  23. $str = '';
  24. $qmimgstr = $this->post('qmimgstr');
  25. if(!isempt($qmimgstr)){
  26. if(contain($qmimgstr,'.')){
  27. $str = $qmimgstr;
  28. }else{
  29. $qma = explode(',', $qmimgstr);
  30. $str = ''.UPDIR.'/'.date('Y-m').'/'.$uid.'qming_'.rand(1000,9999).'.png';
  31. $this->rock->createtxt($str, base64_decode($qma[1]));
  32. }
  33. }
  34. $this->option->setval('qmimgstr_'.$uid.'', $str);
  35. }
  36. public function filebefore($table)
  37. {
  38. $key = $this->post('key');
  39. $atype = $this->post('atype');
  40. $dt1 = $this->post('dt1');
  41. $dt2 = $this->post('dt2');
  42. $where = 'and optid='.$this->adminid.'';
  43. if($atype=='all'){
  44. $where='';
  45. if($this->adminid>1)$where=m('admin')->getcompanywhere(3);
  46. }
  47. if($key!=''){
  48. $where.=" and (`optname` like '%$key%' or `filename` like '%$key%' or `mtype`='$key')";
  49. }
  50. if($dt1!='')$where.=" and `adddt`>='".$dt1." 00:00:00'";
  51. if($dt2!='')$where.=" and `adddt`<='".$dt2." 23:59:59'";
  52. return array(
  53. 'where' => $where,
  54. );
  55. }
  56. public function fileafter($table, $rows)
  57. {
  58. $fobj = m('file');
  59. foreach($rows as $k=>&$rs){
  60. $rs['thumbpath'] = $fobj->getthumbpath($rs);
  61. $fpath = $rs['filepath'];
  62. $status= 1;
  63. if(substr($fpath,0,4)=='http'){
  64. $status = 2;
  65. }else{
  66. if(isempt($rs['filenum']) && !file_exists($fpath))$status=0;
  67. $filepathout = arrvalue($rs, 'filepathout');
  68. if(!file_exists($fpath) && !isempt($filepathout)){
  69. if($fobj->isimg($rs['fileext']))$rs['filepath'] = $filepathout;
  70. $status=2;
  71. }
  72. }
  73. $rs['status'] = $status;
  74. }
  75. return array(
  76. 'rows' => $rows
  77. );
  78. }
  79. public function delfileAjax()
  80. {
  81. $id = c('check')->onlynumber($this->post('id','0'));
  82. m('file')->delfile($id);
  83. backmsg();
  84. }
  85. public function defaultAction()
  86. {
  87. $this->title = '修改头像';
  88. $face = $this->db->getmou($this->T('admin'),'face',"`id`='$this->adminid'");
  89. $imgurl = '';
  90. if(!$this->rock->isempt($face)){
  91. $imgurl='../../'.preg_replace("/_crop\d{4}/",'',$face);
  92. }
  93. //$face = $this->rock->repempt($face,'images/white.gif');
  94. $this->smartydata['face'] = $face;
  95. $this->smartydata['imgurl'] = $imgurl;
  96. }
  97. public function changestyleAjax()
  98. {
  99. $style = (int)$this->post('style','0');
  100. m('admin')->update('`style`='.$style.'', 'id='.$this->adminid.'');
  101. }
  102. // 信呼-修改密码
  103. public function editpassAjax()
  104. {
  105. $id = $this->adminid;
  106. if(getconfig('systype')=='demo')exit('演示上不要修改');
  107. $oldpass = $this->rock->post('passoldPost');
  108. $pasword = $this->rock->post('passwordPost');
  109. $msg = '';
  110. if($this->rock->isempt($pasword))$msg ='新密码不能为空';
  111. if($msg == ''){
  112. $oldpassa = $this->db->getmou($this->T('admin'),"`pass`","`id`='$id'");
  113. if($oldpassa != md5($oldpass))$msg ='旧密码不正确';
  114. if($msg==''){
  115. if($oldpassa == md5($pasword))$msg ='新密码不能和旧密码相同';
  116. }
  117. }
  118. if($msg == ''){
  119. if(!$this->db->record($this->T('admin'), "`pass`='".md5($pasword)."',`editpass`=`editpass`+1", "`id`='$id'"))$msg = $this->db->error();
  120. }
  121. if($msg=='')$msg='success';
  122. // 第三方会议--修改密码同时修改后台
  123. if ($msg=='success') {
  124. m('meet_sys_login')->changePassword($pasword, $oldpass);
  125. }
  126. echo $msg;
  127. }
  128. /**
  129. 保存头像
  130. */
  131. public function savefaceAjax()
  132. {
  133. $id = $this->adminid;
  134. $arr = array('face'=>$this->rock->post('facePost'));
  135. $msg = '';
  136. if(!$this->db->record($this->T('admin'),$arr, "`id`='$id'"))$msg= $this->db->error();
  137. if($msg=='')$msg='success';
  138. echo $msg;
  139. }
  140. public function todoydAjax()
  141. {
  142. m('todo')->update("status=1,`readdt`='$this->now'", "`id` in(".$this->post('s').") and `status`=0");
  143. }
  144. public function totaldaetods($table, $rows)
  145. {
  146. $wdtotal = m('todo')->rows("`uid`='$this->adminid' and `status`=0 and `tododt`<='$this->now'");
  147. return array('wdtotal'=>$wdtotal);
  148. }
  149. public function beforetotaldaetods($table)
  150. {
  151. $s = " and `uid`='$this->adminid' and `tododt`<='$this->now'";
  152. return $s;
  153. }
  154. public function getlinksAjax()
  155. {
  156. $rows = m('links')->getrows('1=1','*','`type`,`sort`');
  157. echo json_encode($rows);
  158. }
  159. //导入个人通讯录
  160. public function piliangaddAjax()
  161. {
  162. $rows = c('html')->importdata('name,unitname,tel,mobile,email,gname,address','name');
  163. $oi = 0;
  164. $db = m('vcard');
  165. foreach($rows as $k=>$rs){
  166. $rs['optdt'] = $this->now;
  167. $rs['uid'] = $this->adminid;
  168. $rs['optname'] = $this->adminname;
  169. $db->insert($rs);
  170. $oi++;
  171. }
  172. backmsg('','成功导入'.$oi.'条数据');
  173. }
  174. public function filelogs_before($table)
  175. {
  176. $where = '';
  177. $fileid = (int)$this->post('fileid','0');
  178. $where = "and `fileid`='$fileid'";
  179. return $where;
  180. }
  181. public function delfilelogsAjax()
  182. {
  183. $id = (int)$this->post('id','0');
  184. m('files')->delete($id);
  185. backmsg();
  186. }
  187. //获取背景图片
  188. public function getbeijingAjax()
  189. {
  190. $dev = $this->option->getval('beijing_'.$this->adminid.'','images/beijing/bj0.jpg');
  191. $path = ''.ROOT_PATH.'/images/beijing';
  192. if(!is_dir($path))return returnsuccess(array(
  193. 'dev' => $dev,
  194. 'rows'=> array()
  195. ));
  196. $barr = array();
  197. $bar = glob(''.$path.'/*.jpg');
  198. $isno = false;
  199. if($bar)foreach($bar as $k=>$fil1){
  200. $faiar = explode('images', $fil1);
  201. $lujg = 'images'.$faiar[1].'';
  202. if($lujg==$dev)$isno = true;
  203. $barr[] = $lujg;
  204. }
  205. if(!$isno)$barr[] = $dev;
  206. return returnsuccess(array(
  207. 'dev'=> $dev,
  208. 'rows'=>$barr
  209. ));
  210. }
  211. public function savebeijingAjax()
  212. {
  213. $val = $this->post('value');
  214. $this->option->setval('beijing_'.$this->adminid.'',$val);
  215. }
  216. }