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 } ?>