yingyongAction.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. class yingyongClassAction extends Action
  3. {
  4. public function yingyongdataAjax()
  5. {
  6. $rows = m('im_group')->getall('`type`=2','*','`sort`');
  7. $arrs = array();
  8. /*
  9. foreach($rows as $k=>$rs){
  10. $sub = m('im_group')->getall('`type`=2 and pid='.$rs['id'].'','*','`sort`');
  11. $rs['leave'] = 1;
  12. $arrs[] = $rs;
  13. foreach($sub as $k1=>$rs1){
  14. $rs1['leave'] = 2;
  15. $arrs[] = $rs1;
  16. }
  17. }*/
  18. echo json_encode(array('rows'=>$rows));
  19. }
  20. public function getdataAjax()
  21. {
  22. $rows = m('im_group')->getall('`type`=2','id,name,face,num,valid','`sort`');
  23. echo json_encode($rows);
  24. }
  25. public function loaddataAjax()
  26. {
  27. $id = (int)$this->get('id');
  28. $arr['data'] = m('im_group')->getone($id);
  29. echo json_encode($arr);
  30. }
  31. public function beforesave($table, $cans, $id)
  32. {
  33. $msg = '';
  34. $num = $cans['num'];
  35. if(m($table)->rows("`num`='$num' and `id`<>$id")>0)$msg='编号['.$num.']已存在';
  36. return array('msg'=>$msg);
  37. }
  38. public function menudataAjax()
  39. {
  40. $this->rows = array();
  41. $mid = (int)$this->get('mid');
  42. $agentnum = m('im_group')->getmou('num',$mid);
  43. $where = "and `mid`='$mid'";
  44. $this->getmenu(0, 1, $where);
  45. $modeid = (int)m('flow_set')->getmou('id',"`num`='$agentnum'");
  46. $wherearr = m('flow_where')->getrows("setid='$modeid' and `num` is not null and `status`=1",'`name`,`num`','`pnum`,`sort`');
  47. $barr[] = array('num'=>'','name'=>'-选择-');
  48. foreach($wherearr as $k=>$rs){
  49. $wherearr[$k]['name'] = ''.$rs['num'].'.'.$rs['name'].'';
  50. $barr[] = $wherearr[$k];
  51. }
  52. echo json_encode(array(
  53. 'totalCount'=> 0,
  54. 'rows' => $this->rows,
  55. 'agentnum' => $agentnum,
  56. 'modeid' => $modeid,
  57. 'wherearr' => $barr,
  58. ));
  59. }
  60. private function getmenu($pid, $oi, $wh='')
  61. {
  62. $db = m('im_menu');
  63. $menu = $db->getall("`pid`='$pid' $wh order by `sort`",'*');
  64. foreach($menu as $k=>$rs){
  65. $sid = $rs['id'];
  66. $rs['level'] = $oi;
  67. $rs['stotal'] = $db->rows("`pid`='$sid' $wh ");
  68. $this->rows[] = $rs;
  69. $this->getmenu($sid, $oi+1, $wh);
  70. }
  71. }
  72. public function yingyongbefore($table)
  73. {
  74. return array(
  75. 'order' => '`valid` desc,`sort` asc'
  76. );
  77. }
  78. public function yingyongafter($table, $rows)
  79. {
  80. foreach($rows as $k=>$rs){
  81. if($rs['valid']=='0')$rows[$k]['status']=0;
  82. }
  83. return array(
  84. 'rows' => $rows
  85. );
  86. }
  87. }