public function index() { $this->checkLogin(); $User = new UserModel(); $Department = new DepartmentModel(); $users = $User->getUsers(); $departments = $Department->getDepartments(); $this->assign('users', $users); $this->assign('departments', $departments); $this->display(); }
public function getLogin() { $name = $_POST['username']; $user = new User(); $data = $user->where('username="******"')->find(); if ($data && $data['password'] == md5($_POST['password'])) { session(array('name' => 'admin.admin', 'expire' => 3600 * 24 * 7)); session('admin.admin', $data); //设置session $this->redirect('Admin/index', '', 0, '...'); } $this->error('用户名或密码错误,请重新登录'); }
function userdel() { $m = new UserModel(); $id = I('id'); $c = $m->alias('a')->where(array('a.id' => $id, 'status' => 1))->count(); if ($c < 1) { $this->ajaxError('用户不存在!'); } $result = $m->delete(); if ($result !== false) { $this->ajaxSuccess('删除用户成功!'); } else { $this->ajaxError('删除用户失败!'); } }
/** * 动作:修改个人资料 */ public function postPersonalInfo($id) { $user = new User(); // 实例化User对象 $user->name = $_POST['name']; $user->email = $_POST['email']; if ($_POST['password']) { $user->password = md5($_POST['password']); } if ($user->where('id=' . $id)->save()) { $_arr = is_object($user) ? get_object_vars($user) : $user; session('admin.admin', $_arr); //$this->success('编辑成功','/Index/index',1); $this->redirect('User/showEdit', array('id' => $id), 1, '编辑成功,...'); } $this->error('编辑失败'); }
function user_center() { session_start(); //判断有没有身份验证,没有的话跳转到登陆界面 if (is_null(session('authed'))) { $this->redirect('Admin/index/login'); } $user_id = session('authed'); $User = new UserModel(); $Application = new ApplicationModel(); //获取我的下线的情况。 // $underlines = $User->where('parent_id='.$user_id)->select(); // $underline_data = array(); //// $index = 0; // foreach($underlines as $line){ // $applications = $Application->where('owner_id='.$line['id'])->select(); // $user_name = $line['user_name']; // if($user_name != null){ // $underline_data[] = array( // 'user_name' => $user_name, // 'date_of_process' => null, // 'date_of_work' => $line['last_date_start_work'], // 'status' => null // ); // } // // } // $this->assign('underlines', $underline_data); //获取佣金清单,分为未支付的清单和已支付的清单 // $result = $this->get_commission($user_id); // $this->assign('unpayed_list', $result['unpayed']); // $this->assign('payed_list', $result['payed']); // // //获取佣金总额 // $unpayed_sum = 0; // $payed_sum = 0; // foreach($result['unpayed'] as $line){ // $unpayed_sum += $line['fee']; // } // foreach($result['payed'] as $line){ // $payed_sum += $line['fee']; // } // $this->assign('unpayed_sum', $unpayed_sum); // $this->assign('payed_sum', $payed_sum); // // $all_commission_unpayed = $this->get_all_commission_unpayed($user_id); // // $unpayed_member_count = count($all_commission_unpayed); // $this->assign('unpayed_member_count', $unpayed_member_count); // //// dump($unpayed_member_count); // $this->assign('all_commission_unpayed', $all_commission_unpayed); $user = $User->where('id=' . $user_id)->field('user_name')->find(); $this->assign('user', $user); if ($this->is_manager($user_id)) { $this->assign('see_public_job', 'inherit'); $this->assign('see_all_commission', 'inherit'); $this->assign('see_all_application', 'inherit'); } else { $this->assign('see_public_job', 'none'); $this->assign('see_all_commission', 'none'); $this->assign('see_all_application', 'none'); } $this->display('admin:home_page'); }
public function postGroupsList() { //新增职务 if ($_POST['new_cp_group_name']) { $new_cp_group_name = $_POST['new_cp_group_name']; $adminGroup = new AdminGroup(); if (in_array($new_cp_group_name, array('系统管理员')) || $adminGroup->where('cp_group_name="' . $new_cp_group_name . '"')->find()) { $this->redirect('Perm/showGroupsList', '', 2, '该团队职务已经存在...'); } $data['cp_group_name'] = strip_tags($new_cp_group_name); $adminGroup->add($data); } //更新职务 if ($_POST['name']) { foreach ($_POST['name'] as $cp_group_id => $cp_group_name) { $adminGroup = new AdminGroup(); $adminGroup->cp_group_name = $cp_group_name; $adminGroup->where('cp_group_id=' . $cp_group_id)->save(); } } //删除职务 if ($_POST['delete']) { $adminAccess = new AdminAccess(); $ids = $_POST['delete']; //$adminAccess->where('id='.$id)->delete(); $adminAccess->where(array('cp_group_id' => array('in', $ids)))->delete(); $user = new User(); $user->where(array('cp_group_id' => array('in', $ids)))->delete(); //User::whereIn('cp_group_id', $request->input('delete'))->delete(); $adminGroup = new AdminGroup(); $adminGroup->where(array('cp_group_id' => array('in', $ids)))->delete(); } $this->success('保存成功'); }