User_smsgroup_adminAction.class.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * 客户分组
  4. */
  5. require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
  6. require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
  7. class User_smsgroup_adminAction extends Action{
  8. public function __construct(){
  9. parent::__construct();
  10. if(empty($_SESSION['mds_user'])){
  11. header("Location:/?a=index&m=admin_login");
  12. exit();
  13. }
  14. }
  15. function index(){
  16. $admin = new AdvertAdminAction();
  17. $where = "where uid='{$_SESSION['user_infos']['id']}'";
  18. $uname = $_SESSION['user_infos']['uname'];
  19. $info = $_REQUEST['info'];
  20. $error = $_REQUEST['error'];
  21. $list = $admin->select_sms_user_group($where);
  22. foreach($list as &$item) {
  23. $where .= " and group_name='{$item['name']}'";
  24. echo $where . "<br />";
  25. $count = $admin->selectSmsCustomerCount($where);
  26. $count = empty($count) ? 0 : $count;
  27. $item['count'] = $count;
  28. }
  29. $this->assign('info',$info);
  30. $this->assign('error',$error);
  31. $this->assign('list',$list);
  32. $this->assign('uname',$uname);
  33. $this->display('index.html');
  34. }
  35. function add(){
  36. $admin = new AdvertAdminAction();
  37. $data['uid'] = $_SESSION['user_infos']['id'];
  38. $data['name'] = trim($_POST['name']);
  39. if(!empty($_POST['name']) ){
  40. $is_exist = $admin->select_usergroup_byName($data['name'],$data['uid']);
  41. if(!empty($is_exist)){
  42. $info = "该客户分组名已存在";
  43. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  44. exit();
  45. }else{
  46. $add = $admin->add_sms_user_group($data);
  47. if($add){
  48. $info = "添加客户分组成功";
  49. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  50. exit();
  51. }else{
  52. $info = "添加客户分组失败";
  53. }
  54. }
  55. }else{
  56. $info = "客户分组名称不能为空";
  57. }
  58. $this->assign('info',$info);
  59. $this->display('add.html');
  60. }
  61. public function delete(){
  62. $admin = new AdvertAdminAction();
  63. $id = $_REQUEST['id'];
  64. $uid = $_SESSION['user_infos']['id'];
  65. $group_name = trim($_REQUEST['group_name']);
  66. if(!empty($id)){
  67. $where = " uid = '$uid' and id='$id'";
  68. $delete = $admin->deleteSmsUserGroupMsg($where);
  69. //删除对应的客户信息
  70. $delete_c = $admin->deleteSmsCustomerByGroup($group_name, $uid);
  71. $info = "删除客户分组成功";
  72. }else{
  73. $error = "删除客户分组失败";
  74. }
  75. header("Location:/?a=user_smsgroup_admin&m=index&info=$info&error=$error");
  76. exit();
  77. }
  78. //批量删除用户分组
  79. public function batch_delete(){
  80. $admin = new AdvertAdminAction();
  81. $uid = $_SESSION['user_infos']['id'];
  82. $id_array = $_POST['id_array'];
  83. $count = count($id_array);
  84. if($count==1){
  85. $id = $id_array[0];
  86. $where = " uid = '$uid' and id='$id'";
  87. $delete = $admin->deleteSmsUserGroupMsg($where);
  88. $info = "删除成功";
  89. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  90. exit();
  91. }else if($count>1){
  92. $in_array = implode(',',$id_array);
  93. $delete = $admin->deleteBatchSmsUserGroup($in_array,$uid);
  94. $info = "删除成功";
  95. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  96. exit();
  97. }
  98. }
  99. //end
  100. }
  101. ?>