| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 | <?php /** * 客户分组 */require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');class User_group_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_user_group($where);		foreach($list as &$ls){			$condition = "where uid='{$_SESSION['user_infos']['id']}' and group_name='{$ls['name']}'";			$countArr = $admin->select_usergroup_count($condition);			$count = $countArr['count'];			$count = empty($count) ? 0  : $count;			$ls['count'] = $count;			$ls['add_time'] = date('Y-m-d H:i:s',$ls['add_time']);			$ls['update_time'] = date('Y-m-d H:i:s',$ls['update_time']);		}		$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']);		$data['add_time'] = time();		$data['update_time'] = time();		if($_POST['name']){			if(!empty($_POST['name']) ){				$is_exist = $admin->select_group_byName($data['name'],$data['uid']);				if(!empty($is_exist)){					$info = "该客户分组名已存在";					header("Location:/?a=user_group_admin&m=index&info=$info");					exit();				}else{					$add = $admin->add_user_group($data);					if($add){						$info = "添加客户分组成功";						header("Location:/?a=user_group_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_one_user_group($id,$uid);			$data['name']         = trim($_POST['name']);		$data['position']         = trim($_POST['position']);		$data['update_time'] = time();				if($_POST['name']){			if(!empty($_POST['name'])){				$is_exist = $admin->select_group_byName($data['name'],$uid);				if(!empty($is_exist) && $one_info['name']!=$data['name']){					$info = "修改客户分组失败:分组名已存在";					header("Location:/?a=user_group_admin&m=index&info=$info");					exit();				}else{					$update = $admin->update_user_group($data, $id,$uid);					if($update){						$info = "修改客户分组成功";						header("Location:/?a=user_group_admin&m=index&info=$info");						exit();					}else{						$info = "修改失败";					}				}			}else{				$info = "客户分组不能为空";			}		}			$one_info 		= $admin->select_one_user_group($id,$uid);				$this->assign('id',$id);		$this->assign('one_info',$one_info);		$this->assign('info',$info);		$this->display('update.html');	}	//客户分组详情	public function group_list(){		require_once (ONU_ROOT . "frame/Page.class.php");		$admin = new AdvertAdminAction();		$uid   = $_SESSION['user_infos']['id'];		$info  = $_REQUEST['info'];		$page     = $_REQUEST['page']?$_REQUEST['page']:1;		$pageSize = 20;		$n        = ($page-1)*$pageSize;		$limit = " $n,$pageSize";		$user_group_id = $_REQUEST['id'];		$group_name     = $_REQUEST['gname'];		$where = " where uid='$uid' and group_name='$group_name' ";		$username = $_REQUEST['username'];		if(!empty($username)){			$where.=" and uname='$username'";		}		$all_total = $admin->select_usergroup_count($where);		$all_total = $all_total['count'];		$p = new Page($all_total,$pageSize);		$pp = $p->fpage();		//查询客户分组里的所有客户		$order_list = $admin->select_usergroup_info($where,$limit);		//分组名		$user_group_name = $admin->select_user_group("where id='$user_group_id'");		$user_group_name = $user_group_name[0]['name'];		$this->assign('info',$info);		$this->assign('user_group_name',$user_group_name);		$this->assign('user_group_id',$user_group_id);		$this->assign('page',$page);		$this->assign('list',$order_list);		$this->assign("show",$pp);		$this->assign("username",$username);		$this->display('group_list.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->deleteUserGroupMsg($where);			//删除对应的客户信息			$delete_c = $admin->deleteCustomerByGroup($group_name,$uid);			$info = "删除客户分组成功";		}else{			$error = "删除客户分组失败";		}		header("Location:/?a=user_group_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_one_user_group($id,$uid);			$delete = $admin->deleteUserGroupMsg($where);			$group_name     = $one_info['name'];			//删除对应的客户信息			$delete_c = $admin->deleteCustomerByGroup($group_name,$uid);			$info = "删除成功";			header("Location:/?a=user_group_admin&m=index&info=$info");			exit();		}else if($count>1){			$in_array = implode(',',$id_array);			$group_name_list = $admin->select_batch_user_group($in_array,$uid);			foreach($group_name_list as $nlist){				$delete_c = $admin->deleteCustomerByGroup($nlist['name'],$uid);			}			$delete = $admin->deleteBatchUserGroup($in_array,$uid);			$info = "删除成功";			header("Location:/?a=user_group_admin&m=index&info=$info");			exit();		}	}	//end}?>
 |