| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 | 
							- <?php 
 
- /**
 
-  * 客户分组
 
-  */
 
- require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
 
- require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
 
- class User_smsgroup_adminAction extends Action{
 
- 	
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		if(empty($_SESSION['mds_user'])){
 
- 			header("Location:/?a=index&m=admin_login");
 
- 			exit();
 
- 		}
 
- 	}
 
- 	
 
- 	function index(){
 
- 		
 
- 		$admin = new AdvertAdminAction();
 
- 		$where = "where uid='{$_SESSION['user_infos']['id']}'";
 
- 		$uname = $_SESSION['user_infos']['uname'];
 
- 		
 
- 		$info           = $_REQUEST['info'];
 
- 		$error			= $_REQUEST['error'];
 
- 		$list  = $admin->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');
 
- 	}
 
- 	function update(){
 
- 	
 
- 		$admin = new AdvertAdminAction();
 
- 		
 
- 		$id	  = $_REQUEST['id'];
 
- 		$uid  = $_SESSION['user_infos']['id'];
 
- 		
 
- 		$one_info 		= $admin->select_usergroup_byId($id,$uid);
 
- 	
 
- 		$data['name']         = trim($_POST['name']);
 
- 		$data['position']         = trim($_POST['position']);
 
- 		
 
- 		if($_POST['name']){
 
- 			if(!empty($_POST['name'])){
 
- 				$is_exist = $admin->select_usergroup_byName($data['name'],$uid);
 
- 				if(!empty($is_exist) && $one_info['name']!=$data['name']){
 
- 					$info = "修改客户分组失败:分组名已存在";
 
- 					header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
 
- 					exit();
 
- 				}else{
 
- 					$update = $admin->update_sms_user_group($data, $id,$uid);
 
- 					if($update){
 
- 						$info = "修改客户分组成功";
 
- 						header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
 
- 						exit();
 
- 					}else{
 
- 						$info = "修改失败";
 
- 					}
 
- 				}
 
- 			}else{
 
- 				$info = "客户分组不能为空";
 
- 			}
 
- 		}
 
- 	
 
- 		$one_info 		= $admin->select_usergroup_byId($id,$uid);
 
- 		
 
- 		$this->assign('id',$id);
 
- 		$this->assign('one_info',$one_info);
 
- 		$this->assign('info',$info);
 
- 		$this->display('update.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'";
 
- 			$one_info 		= $admin->select_usergroup_byId($id, $uid);
 
- 			$delete = $admin->deleteSmsUserGroupMsg($where);
 
- 			$delete_c = $admin->deleteSmsCustomerByGroup($one_info['name'], $uid);
 
- 			$info = "删除成功";
 
- 			header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
 
- 			exit();
 
- 		}else if($count>1){
 
- 			$in_array = implode(',',$id_array);
 
- 			$group_name_list = $admin->select_batch_sms_group($in_array, $uid);
 
- 			foreach($group_name_list as $nlist){
 
- 				$delete_c = $admin->deleteSmsCustomerByGroup($nlist['name'], $uid);
 
- 			}
 
- 			$delete = $admin->deleteBatchSmsUserGroup($in_array,$uid);
 
- 			$info = "删除成功";
 
- 			header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
 
- 			exit();
 
- 		}
 
- 	}
 
- 	//end
 
- }
 
- ?>
 
 
  |