select_sms_user_group($where); foreach($list as &$item) { $condition = "where uid='{$_SESSION['user_infos']['id']}' and group_name='{$item['name']}'"; $count = $admin->selectSmsCustomerCount($condition); $count = empty($count) ? 0 : $count; $item['count'] = $count; } $this->assign('info',$info); $this->assign('error',$error); $this->assign('list',$list); $this->assign('uname',$uname); $this->display('index.html'); } function add(){ $admin = new AdvertAdminAction(); $data['uid'] = $_SESSION['user_infos']['id']; $data['name'] = trim($_POST['name']); if(!empty($_POST['name']) ){ $is_exist = $admin->select_usergroup_byName($data['name'],$data['uid']); if(!empty($is_exist)){ $info = "该客户分组名已存在"; header("Location:/?a=user_smsgroup_admin&m=index&info=$info"); exit(); }else{ $add = $admin->add_sms_user_group($data); if($add){ $info = "添加客户分组成功"; header("Location:/?a=user_smsgroup_admin&m=index&info=$info"); exit(); }else{ $info = "添加客户分组失败"; } } }else{ $info = "客户分组名称不能为空"; } $this->assign('info',$info); $this->display('add.html'); } public function delete(){ $admin = new AdvertAdminAction(); $id = $_REQUEST['id']; $uid = $_SESSION['user_infos']['id']; $group_name = trim($_REQUEST['group_name']); if(!empty($id)){ $where = " uid = '$uid' and id='$id'"; $delete = $admin->deleteSmsUserGroupMsg($where); //删除对应的客户信息 $delete_c = $admin->deleteSmsCustomerByGroup($group_name, $uid); $info = "删除客户分组成功"; }else{ $error = "删除客户分组失败"; } header("Location:/?a=user_smsgroup_admin&m=index&info=$info&error=$error"); exit(); } //批量删除用户分组 public function batch_delete(){ $admin = new AdvertAdminAction(); $uid = $_SESSION['user_infos']['id']; $id_array = $_POST['id_array']; $count = count($id_array); if($count==1){ $id = $id_array[0]; $where = " uid = '$uid' and id='$id'"; $delete = $admin->deleteSmsUserGroupMsg($where); $info = "删除成功"; header("Location:/?a=user_smsgroup_admin&m=index&info=$info"); exit(); }else if($count>1){ $in_array = implode(',',$id_array); $delete = $admin->deleteBatchSmsUserGroup($in_array,$uid); $info = "删除成功"; header("Location:/?a=user_smsgroup_admin&m=index&info=$info"); exit(); } } //end } ?>