groupAction.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. class groupClassAction extends Action
  3. {
  4. public function groupusershow($table)
  5. {
  6. $s = 'and 1=2';
  7. $gid = (int)$this->post('gid','0');
  8. if($gid>0){
  9. $s = " and ( id in( select `sid` from `[Q]sjoin` where `type`='gu' and `mid`='$gid') or id in( select `mid` from `[Q]sjoin` where `type`='ug' and `sid`='$gid') )";
  10. }
  11. return array(
  12. 'where' => $s,
  13. 'fields'=> 'id,user,name,deptname,ranking'
  14. );
  15. }
  16. public function groupafter($table, $rows)
  17. {
  18. $nosq = 'select `id` from `[Q]admin` where `status`=1';
  19. m('sjoin')->delete("`type`='gu' and `sid` not in($nosq)");
  20. m('sjoin')->delete("`type`='ug' and `mid` not in($nosq)");
  21. $carr = m('admin')->getcompanyinfo(0,5);
  22. $dbs = m('company');
  23. foreach($rows as $k=>$rs){
  24. $gid = $rs['id'];
  25. $s = "( id in( select `sid` from `[Q]sjoin` where `type`='gu' and `mid`='$gid') or id in( select `mid` from `[Q]sjoin` where `type`='ug' and `sid`='$gid') )";
  26. $rows[$k]['utotal'] = $this->db->rows('[Q]admin', $s);
  27. $companyname = '';
  28. if($rs['companyid']>0 && getconfig('companymode'))$companyname = $dbs->getmou('name', $rs['companyid']);
  29. $rows[$k]['companyname'] = $companyname;
  30. }
  31. return array(
  32. 'rows' => $rows,
  33. 'carr' => $carr,
  34. );
  35. }
  36. public function saveuserAjax()
  37. {
  38. $gid = (int)$this->post('gid','0');
  39. $sid = c('check')->onlynumber($this->post('sid','0'));
  40. $dbs = m('sjoin');
  41. $dbs->delete("`mid`='$gid' and `type`='gu' and `sid` in($sid)");
  42. $this->db->insert('[Q]sjoin','`type`,`mid`,`sid`', "select 'gu','$gid',`id` from `[Q]admin` where `id` in($sid)", true);
  43. m('admin')->updateinfo('and a.`id` in('.$sid.')');
  44. echo 'success';
  45. }
  46. public function deluserAjax()
  47. {
  48. $gid = (int)$this->post('gid','0');
  49. $sid = c('check')->onlynumber($this->post('sid','0'));
  50. $dbs = m('sjoin');
  51. $dbs->delete("`mid`='$gid' and `type`='gu' and `sid`='$sid'");
  52. $dbs->delete("`sid`='$gid' and `type`='ug' and `mid`='$sid'");
  53. m('admin')->updateinfo('and a.`id` in('.$sid.')');
  54. echo 'success';
  55. }
  56. }
粤ICP备19079148号