public function emerg()
 {
     if (session('?uid')) {
         $database = M('user');
         $user = $database->where('uid = :uid')->bind(':uid', session('uid'))->find();
         $this->assign('user', $user);
     } else {
         $this->redirect('User/login', array('returnURL' => base64_encode(__SELF__)));
     }
     if (IS_POST) {
         $database = M('order');
         if (!$database->autoCheckToken($_POST)) {
             $this->error('令牌验证错误');
         }
         if (!empty(I('post.tel'))) {
             M('user')->where('uid=:uid')->bind(':uid', session('uid'))->save(array('tel' => I('post.tel')));
         }
         $data['area'] = I('post.area/d');
         //校区
         if (!selectCheck($data['area'])) {
             $this->error('参数非法');
         }
         $data['location'] = I('post.location');
         //地点
         $data['description'] = I('post.description');
         //描述
         $data['user'] = session('uid');
         //用户
         $data['order'] = creatOrderSn($data['area']);
         //工单号
         $data['time'] = time();
         //时间
         $data['status'] = 0;
         //状态 未处理0 处理中1 已处理2
         $data['emerg'] = 1;
         //是否紧急 普通0 紧急1
         $add = $database->strict(true)->data($data)->filter('strip_tags')->add();
         if ($add) {
             $this->success('报修提交成功', U('User/order'));
         } else {
             $this->error('报修提交失败');
         }
     } else {
         $tips = M('setting')->where("`key`='tips'")->find();
         $tips = json_decode($tips['value'], true);
         $this->assign('tips', $tips['emerg']);
         $data = menu();
         $this->assign('data', json_encode($data));
         $this->display('emerg');
     }
 }
Example #2
0
 public function setting()
 {
     if (!session('?uid')) {
         $this->redirect('login');
     }
     //获取站点配置
     $global = M('setting')->where("`key`='global'")->find();
     $global = json_decode($global['value'], true);
     //是否开启快速报修
     $this->assign('quickreport', $global['quickreport']);
     $database = M('user');
     if (IS_POST) {
         if (!$database->autoCheckToken($_POST)) {
             $this->error('令牌验证错误');
         }
         $data['area'] = I('post.area/d');
         if (!selectCheck($data['area'])) {
             $this->error('参数非法');
         }
         $data['building'] = I('post.building/d');
         if (!selectCheck($data['area'], $data['building'])) {
             $this->error('参数非法');
         }
         $data['location'] = I('post.location');
         $data['tel'] = I('post.tel');
         if (!empty(I('post.password'))) {
             $data['salt'] = salt();
             $data['pssword'] = sha1(C('DB_PREFIX') . I('post.password') . '_' . $data['salt']);
         }
         $update = $database->where('uid=:uid')->bind(':uid', session('uid'))->filter('strip_tags')->save($data);
         if ($update) {
             $this->success('个人信息更新成功');
         } else {
             $this->error('个人信息无更新或失败');
         }
     } else {
         $user = $database->where('uid=:uid')->bind(':uid', session('uid'))->find();
         $data = menu();
         $this->assign('data', json_encode($data));
         $this->assign('user', $user);
         $this->display('setting');
     }
 }