Ejemplo n.º 1
0
 public function updateleaderAction()
 {
     $this->view->disable();
     $manager = $this->session->get('Manager');
     if (empty($manager)) {
         $this->dataReturn(array('error' => '获取用户信息失败,请重新登陆'));
         return;
     }
     $project_id = $manager->project_id;
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'add') {
         $data = array();
         $data[] = $this->request->getPost('name', 'string');
         try {
             PmDB::insertLeader($data, $project_id);
         } catch (Exception $e) {
             $this->dataReturn(array('error' => '记录插入失败'));
             return;
         }
         $this->dataReturn(array('flag' => true));
         return;
     } else {
         if ($oper == 'edit') {
             //edit
             $id = $this->request->getPost('id', 'int');
             $manager = Manager::findFirst($id);
             //$manager ->username       = $this->request->getPost('username', 'string');
             $manager->name = $this->request->getPost('name', 'string');
             $manager->password = $this->request->getPost('password', 'string');
             try {
                 PmDB::updateManager($manager);
             } catch (Exception $e) {
                 $this->dataReturn(array('error' => '记录更新失败'));
                 return;
             }
             $this->dataReturn(array('flag' => true));
             return;
         } else {
             if ($oper == 'del') {
                 #删除可选择多项
                 $ids = $this->request->getPost('id', 'string');
                 #删除未加限制
                 $id_array = explode(',', $ids);
                 $managers = $this->modelsManager->createBuilder()->from('Manager')->where('project_id = ' . $project_id . " AND role = 'L'")->inWhere('id', $id_array)->getQuery()->execute();
                 try {
                     PmDB::deleteManagers($managers);
                 } catch (Exception $e) {
                     $this->dataReturn(array('error' => '记录删除失败'));
                     return;
                 }
                 $this->dataReturn(array('flag' => true));
                 return;
             } else {
                 //add ...
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function updateleaderAction()
 {
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         $id = $this->request->getPost('id', 'int');
         $manager = Manager::findFirst($id);
         $manager->name = $this->request->getPost('name', 'string');
         $manager->password = $this->request->getPost('password', 'string');
         $manager->project_id = $this->request->getPost('project_id', 'int');
         if (!$manager->save()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
     if ($oper == 'del') {
         $id = $this->request->getPost('id', 'int');
         $manager = Manager::findFirst($id);
         if (!$manager->delete()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function usermanagerAction()
 {
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         $id = $this->request->getPost('id', 'int');
         $username = $this->request->getPost('username', 'string');
         $password = $this->request->getPost('password', 'string');
         $auth = $this->request->getPost('auth', 'int');
         $name = $this->request->getPost('name', 'string');
         $phone = $this->request->getPost('phone', 'int');
         $email = $this->request->getPost('email', 'email');
         $id_num = $this->request->getPost('id_num', 'string');
         $manager = Manager::findFirst($id);
         $manager->username = $username;
         $manager->password = hash('sha256', $password);
         $manager->auth = $auth;
         $manager->name = $name;
         $manager->id_num = $id_num;
         $manager->phone = $phone;
         $manager->email = $email;
         if (!$manager->save()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
     if ($oper == 'del') {
         $id = $this->request->getPost('id', 'int');
         $manager = Manager::findFirst($id);
         if (!$manager->delete()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
 }
Ejemplo n.º 4
0
 public static function checkUsername($username)
 {
     $manager = Manager::findFirst(array("username=:username:"******"bind" => array("username" => $username)));
     return $manager;
 }
Ejemplo n.º 5
0
 public function updateAction()
 {
     $this->view->disable();
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         //edit
         //修改之前应该判断数据库中是否已经存在记录 -- 目前在前端进行判定2015-9-12
         $id = $this->request->getPost('id', 'int');
         $project = Project::findFirst($id);
         $project->name = $this->request->getPost('name', 'string');
         #项目开始时间不可变更
         $project->begintime = $this->request->getPost('begintime', 'string');
         $project->endtime = $this->request->getPost('endtime', 'string');
         $project->description = $this->request->getPost('description', 'string');
         $manager = Manager::findFirst(array('project_id=?0', 'bind' => array($id)));
         $manager->name = $this->request->getPost('manager_name', 'string');
         $manager->username = $this->request->getPost('manager_username', 'string');
         $manager->password = $this->request->getPost('manager_password', 'string');
         #时间检查
         if (strtotime($project->begintime) >= strtotime($project->endtime)) {
             $this->dataReturn(array('error' => '项目结束时间与开始时间冲突'));
             return;
         }
         try {
             AdminDB::updateManager($manager);
             AdminDB::updateProject($project);
         } catch (Exception $e) {
             $this->dataReturn(array('error' => '项目信息更新失败'));
             return;
         }
         $this->dataReturn(array('flag' => true));
         return;
     } else {
         if ($oper == 'del') {
             //del
             //需要添加判断是否能被删除 --目前还未添加相应的判定
             $id = $this->request->getPost('id', 'int');
             $project_info = Project::findFirst($id);
             if (!isset($project_info->id)) {
                 $this->dataReturn(array('error' => '项目编号不存在'));
                 return;
             } else {
                 #判断项目状态,如果不是项目的初始状态则禁止删除
                 if ($project_info->state != 0) {
                     $this->dataReturn(array('error' => '项目经理已配置了项目,不能被删除'));
                     return;
                 } else {
                     try {
                         AdminDB::delproject($id);
                     } catch (Exception $e) {
                         $this->dataReturn(array('error' => '项目删除失败'));
                         return;
                     }
                     $this->dataReturn(array('flag' => true));
                     return;
                 }
             }
         } else {
             //
         }
     }
 }
Ejemplo n.º 6
0
 public function newpasswordAction()
 {
     $this->view->disable();
     if ($this->session->has('reset') && $this->request->isPost()) {
         if ($this->session->get('reset') == 'resetpass') {
             $password = $this->request->getPost('password', 'string');
             $id = $this->session->get('reset_id');
             $manager = Manager::findFirst($id);
             if ($manager != false) {
                 $manager->password = hash('sha256', $password);
                 if ($manager->save()) {
                     $this->session->remove("reset");
                     $this->session->remove("reset_id");
                     $this->flash->success('成功修改密码');
                 } else {
                     foreach ($manager->getMessages() as $message) {
                         $this->flash->error($message);
                     }
                 }
             } else {
                 $this->flash->error("用户不存在");
             }
         }
     }
     $this->response->redirect('managerlogin');
 }