optionAction.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. class optionClassAction extends Action
  3. {
  4. public function getlistAjax()
  5. {
  6. $num = $this->request('num');
  7. $name = $this->request('name');
  8. $key = $this->post('key');
  9. $id = $this->option->getnumtoid($num, $name, false);
  10. $this->option->update("`pid`=1,`name`='行政选项'","`num`='goods'"); //行政选项移动到数据选项下
  11. if(isempt($key)){
  12. $where = "a.`pid`='$id'";
  13. }else{
  14. $where = "1=1 and a.`name` is not null and (a.`name` like '%$key%' or a.`num`='$key') ";
  15. }
  16. $rows = $this->db->getall("select *,(select count(1) from `[Q]option` where pid=a.id)as stotal from `[Q]option` a where $where order by a.`sort`, a.`id`");
  17. echo json_encode(array(
  18. 'totalCount'=> $this->db->count,
  19. 'rows' => $rows,
  20. 'pid' => $id
  21. ));
  22. }
  23. public function getfileAjax()
  24. {
  25. $mtype = $this->request('mtype');
  26. $mid = $this->request('mid');
  27. $rows = m('file')->getfile($mtype, $mid);
  28. echo json_encode($rows);
  29. }
  30. public function gettreedataAjax()
  31. {
  32. $num = $this->get('num');
  33. if($num=='')exit('error;');
  34. if(!contain($num, 'gerenvcard_') && ISMORECOM && $cnum=m('admin')->getcompanynum())$num.='_'.$cnum.'';//多单位时个人通讯不用加单位编号
  35. $pid = $this->option->getnumtoid($num,''.$num.'选项', false);
  36. $rows = $this->option->gettreedata($pid);
  37. $rows = array(
  38. 'rows' => $rows,
  39. 'pid' => $pid
  40. );
  41. $this->returnjson($rows);
  42. }
  43. public function deloptionAjax()
  44. {
  45. $id = (int)$this->post('id','0');
  46. $stable = $this->post('stable');
  47. $delbo = true;
  48. if($delbo)if($this->option->rows("`pid`='$id'")>0)$delbo=false;
  49. if(!$delbo)$this->showreturn('','有下级分类不允许删除',201);
  50. $this->option->delete($id);
  51. if($stable!='')m($stable)->update('`typeid`=0', "`typeid`='$id'");
  52. $this->showreturn();
  53. }
  54. //分类移动
  55. public function movetypeAjax()
  56. {
  57. $id = (int)$this->post('id','0');
  58. $toid = (int)$this->post('toid','0');
  59. $lx = (int)$this->post('lx','0');
  60. $spath = $this->db->getpval('[Q]option','pid','pid', $toid,'],[');
  61. $spath = '['.$spath.']';
  62. if(contain($spath,'['.$id.']')){
  63. echo '不能移动到自己的下级';
  64. }else{
  65. $this->option->update('pid='.$toid.'', $id);
  66. echo 'ok';
  67. }
  68. }
  69. public function downshuafter($table, $rows)
  70. {
  71. $db = m($table);
  72. foreach($rows as $k=>$rs){
  73. $dcount = $db->rows('pid='.$rs['id'].'');
  74. if($dcount>0)$rows[$k]['dcount'] = $dcount;
  75. }
  76. return array(
  77. 'rows' => $rows
  78. );
  79. }
  80. }
粤ICP备19079148号