Exemplo n.º 1
0
 /**
  * Finds the Jobs model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Jobs the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Jobs::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionApproveprocess()
 {
     $session = new Session();
     $session->open();
     if (\Yii::$app->request->post()) {
         $count = User::find()->where(['username' => $_POST['Jobapprove']['username']])->count();
         $uid = User::find()->where(['username' => $_POST['Jobapprove']['username']])->all();
         $isuser = User::findOne(['username' => $_POST['Jobapprove']['username']]);
         $ispwd = $isuser->validatePassword($_POST['Jobapprove']['password']);
         if ($count <= 0 || $ispwd == false) {
             $session = new Session();
             $session->open();
             $session->setFlash('msg', 'คุณไม่มีสิทธิอนุมัติใบสั่งงานนี้');
             $model = new Jobapprove();
             $pagename = "reqdevice";
             //  return $this->render('approvefail');
             return $this->render('index', ['model' => $model]);
         }
         foreach ($uid as $value) {
             $roleid = $value->roleid;
         }
         $depid = \backend\Models\Assignroledetail::findAll(['roleid' => $roleid]);
         $approve = false;
         $res = 0;
         foreach ($depid as $did) {
             foreach ($session['recid'] as $idd) {
                 $model2 = Jobs::findOne($idd);
                 $userdep = User::findOne(['id' => $model2->requestby]);
                 if ($userdep->departmentid == $did->departmentid) {
                     $model2->jobstatus = 2;
                     if ($model2->save()) {
                         $res = 1;
                     }
                 }
             }
         }
         if ($res == 1) {
             $session = new Session();
             $session->open();
             $session->setFlash('msg', 'อนุมัติใบสั่งงานเรียบร้อย');
             unset($session['recid']);
             if ($session['module'] == 'device') {
                 unset($session['module']);
                 unset($session['department']);
                 return $this->redirect(['reqdevice/index']);
             } else {
                 if ($session['module'] == 'report') {
                     unset($session['module']);
                     unset($session['department']);
                     return $this->redirect(['reqreport/index']);
                 } else {
                     if ($session['module'] == 'user') {
                         unset($session['module']);
                         unset($session['department']);
                         return $this->redirect(['requser/index']);
                     }
                 }
             }
         } else {
             $session = new Session();
             $session->open();
             $session->setFlash('msg', 'คุณไม่มีสิทธิอนุมัติใบสั่งงานนี้');
             $model = new Jobapprove();
             $pagename = "reqdevice";
             //    return $this->render('approvefail');
             return $this->render('index', ['model' => $model]);
         }
         // echo var_dump($ispwd);return;
     }
     //        else {
     //            $session = new Session();
     //            $session->open();
     //            $session->setFlash('msg', 'คุณไม่มีสิทธิอนุมัติใบสั่งงานนี้');
     //            $model = new Jobapprove();
     //            $pagename = "reqdevice";
     //            //    return $this->render('approvefail');
     //            return $this->render('index', ['model' => $model]);
     //        }
 }
Exemplo n.º 3
0
 public function actionEndjob()
 {
     if (\Yii::$app->request->post()) {
         //echo 'okddkd';
         $session = new Session();
         $session->open();
         //                $res = 0;
         foreach ($session['recid'] as $id) {
             echo $id;
             $model = Jobs::findOne($id);
             if ($_POST['closetype'] == 1) {
                 $model->jobstatus = 100;
             } else {
                 $model->jobstatus = 3;
             }
             $model->usdef1 = $_POST['rem'];
             if ($model->save()) {
                 $res = 1;
             }
         }
         if ($res == 1) {
             unset($session['recid']);
             if ($session['module'] == 'adashboard') {
                 unset($session['module']);
                 \Yii::$app->getSession()->setFlash('success', 'ดำเนินการเรียบร้อย');
                 return $this->redirect(['adashboard/index']);
             } else {
                 if ($session['module'] == 'report') {
                     unset($session['module']);
                     \Yii::$app->getSession()->setFlash('success', 'ดำเนินการเรียบร้อย');
                     return $this->redirect(['reqreport/index']);
                 } else {
                     if ($session['module'] == 'user') {
                         unset($session['module']);
                         \Yii::$app->getSession()->setFlash('success', 'ดำเนินการเรียบร้อย');
                         return $this->redirect(['requser/index']);
                     } else {
                         if ($session['module'] == 'camera') {
                             unset($session['module']);
                             \Yii::$app->getSession()->setFlash('success', 'ดำเนินการเรียบร้อย');
                             return $this->redirect(['reqcamera/index']);
                         } else {
                             if ($session['module'] == 'telephone') {
                                 unset($session['module']);
                                 \Yii::$app->getSession()->setFlash('success', 'ดำเนินการเรียบร้อย');
                                 return $this->redirect(['reqtelephone/index']);
                             } else {
                                 if ($session['module'] == 'restore') {
                                     unset($session['module']);
                                     \Yii::$app->getSession()->setFlash('success', 'ดำเนินการเรียบร้อย');
                                     return $this->redirect(['reqsetore/index']);
                                 } else {
                                     if ($session['module'] == 'program') {
                                         unset($session['module']);
                                         \Yii::$app->getSession()->setFlash('success', 'ดำเนินการเรียบร้อย');
                                         return $this->redirect(['reqprogram/index']);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }