Example #1
0
 protected function findModel($id)
 {
     if (($model = Jobs::find()->where(['and', 'id=' . $id, 'status=' . Status::STATUS_ACTIVE])->One()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('你所查找的网页不存在');
     }
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Jobs::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'company_id' => $this->company_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'zhiweiming', $this->zhiweiming])->andFilterWhere(['like', 'gongzuodiqu', $this->gongzuodiqu])->andFilterWhere(['like', 'zhiweixinzi', $this->zhiweixinzi])->andFilterWhere(['like', 'xueliyaoqiu', $this->xueliyaoqiu])->andFilterWhere(['like', 'zhaopinrenshu', $this->zhaopinrenshu])->andFilterWhere(['like', 'gongzuoxingzhi', $this->gongzuoxingzhi])->andFilterWhere(['like', 'xingbieyaoqiu', $this->xingbieyaoqiu])->andFilterWhere(['like', 'gongzuojingyan', $this->gongzuojingyan])->andFilterWhere(['like', 'jingzhengyoushi', $this->jingzhengyoushi])->andFilterWhere(['like', 'zhiweimiaoshu', $this->zhiweimiaoshu]);
     return $dataProvider;
 }
 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]);
     //        }
 }
Example #4
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.');
     }
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getJob()
 {
     return $this->hasOne(Jobs::className(), ['recid' => 'jobid']);
 }
 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']);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }