User_smsgroup_adminAction.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. $condition = "where uid='{$_SESSION['user_infos']['id']}' and group_name='{$item['name']}'";
  24. $count = $admin->selectSmsCustomerCount($condition);
  25. $count = empty($count) ? 0 : $count;
  26. $item['count'] = $count;
  27. }
  28. $this->assign('info',$info);
  29. $this->assign('error',$error);
  30. $this->assign('list',$list);
  31. $this->assign('uname',$uname);
  32. $this->display('index.html');
  33. }
  34. function add(){
  35. $admin = new AdvertAdminAction();
  36. $data['uid'] = $_SESSION['user_infos']['id'];
  37. $data['name'] = trim($_POST['name']);
  38. if(!empty($_POST['name']) ){
  39. $is_exist = $admin->select_usergroup_byName($data['name'],$data['uid']);
  40. if(!empty($is_exist)){
  41. $info = "该客户分组名已存在";
  42. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  43. exit();
  44. }else{
  45. $add = $admin->add_sms_user_group($data);
  46. if($add){
  47. $info = "添加客户分组成功";
  48. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  49. exit();
  50. }else{
  51. $info = "添加客户分组失败";
  52. }
  53. }
  54. }else{
  55. $info = "客户分组名称不能为空";
  56. }
  57. $this->assign('info',$info);
  58. $this->display('add.html');
  59. }
  60. public function delete(){
  61. $admin = new AdvertAdminAction();
  62. $id = $_REQUEST['id'];
  63. $uid = $_SESSION['user_infos']['id'];
  64. $group_name = trim($_REQUEST['group_name']);
  65. if(!empty($id)){
  66. $where = " uid = '$uid' and id='$id'";
  67. $delete = $admin->deleteSmsUserGroupMsg($where);
  68. //删除对应的客户信息
  69. $delete_c = $admin->deleteSmsCustomerByGroup($group_name, $uid);
  70. $info = "删除客户分组成功";
  71. }else{
  72. $error = "删除客户分组失败";
  73. }
  74. header("Location:/?a=user_smsgroup_admin&m=index&info=$info&error=$error");
  75. exit();
  76. }
  77. //批量删除用户分组
  78. public function batch_delete(){
  79. $admin = new AdvertAdminAction();
  80. $uid = $_SESSION['user_infos']['id'];
  81. $id_array = $_POST['id_array'];
  82. $count = count($id_array);
  83. if($count==1){
  84. $id = $id_array[0];
  85. $where = " uid = '$uid' and id='$id'";
  86. $one_info = $admin->select_usergroup_byId($id, $uid);
  87. $delete = $admin->deleteSmsUserGroupMsg($where);
  88. $delete_c = $admin->deleteSmsCustomerByGroup($one_info['name'], $uid);
  89. $info = "删除成功";
  90. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  91. exit();
  92. }else if($count>1){
  93. $in_array = implode(',',$id_array);
  94. $group_name_list = $admin->select_batch_sms_group($in_array, $uid);
  95. foreach($group_name_list as $nlist){
  96. $delete_c = $admin->deleteSmsCustomerByGroup($nlist['name'], $uid);
  97. }
  98. $delete = $admin->deleteBatchSmsUserGroup($in_array,$uid);
  99. $info = "删除成功";
  100. header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
  101. exit();
  102. }
  103. }
  104. //end
  105. }
  106. ?>