Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Document::find();
     $userlname = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'userLName');
     $userfname = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'userFName');
     $userfullname = $userlname . ', ' . $userfname;
     $docname = ArrayHelper::getValue(Pendingdoc::find()->where(['pendingDocFName' => $userfullname])->one(), 'pendingDocName');
     //$docname = Pendingdoc::find()->where(['pendingDocFName' => $userfullname])->one();
     //$docname = 1;
     $userid = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'id');
     //$query->where(['or', ['documentName'=>$docname], ['user_id'=>$userid]]);
     //$query->where(['INNER JOIN', 'Pendingdoc', 'Pendingdoc.pendingDocName = documentName']);
     $query->join('LEFT JOIN', 'pendingdoc', 'document.documentName = pendingdoc.pendingDocName')->where(['or', ['pendingdoc.pendingDocFName' => $userfullname], ['user_id' => $userid]]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith('priority');
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['documentTargetDate' => $this->documentTargetDate, 'category_id' => $this->category_id, 'type_id' => $this->type_id, 'user_id' => $this->user_id, 'companyAgency_id' => $this->companyAgency_id, 'section_id' => $this->section_id, 'documentCreate' => $this->documentCreate, 'documentUpdate' => $this->documentUpdate]);
     $query->andFilterWhere(['like', 'document_tracking_number', $this->document_tracking_number])->andFilterWhere(['like', 'documentName', $this->documentName])->andFilterWhere(['like', 'documentDesc', $this->documentDesc])->andFilterWhere(['like', 'documentComment', $this->documentComment])->andFilterWhere(['like', 'documentImage', $this->documentImage])->andFilterWhere(['like', 'document.id', $this->id])->andFilterWhere(['like', 'priority.priorityName', $this->priority_id]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pendingdoc::find();
     $userlname = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'userLName');
     $userfname = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'userFName');
     $userfullname = $userlname . ', ' . $userfname;
     $query->where(['pendingDocFName' => $userfullname])->one();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'pendingDocTimeRelease' => $this->pendingDocTimeRelease]);
     $query->andFilterWhere(['like', 'pendingDocFName', $this->pendingDocFName])->andFilterWhere(['like', 'pendingDocSection', $this->pendingDocSection])->andFilterWhere(['like', 'pendingDocName', $this->pendingDocName]);
     return $dataProvider;
 }
 public function actionConfirm($id)
 {
     $model = $this->findModel($id);
     $userid = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'id');
     $sectionid = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'section_id');
     $userFName = ArrayHelper::getValue(User::find()->where(['id' => $userid])->one(), 'userFName');
     $userLName = ArrayHelper::getValue(User::find()->where(['id' => $userid])->one(), 'userLName');
     $section = ArrayHelper::getValue(Section::find()->where(['id' => $sectionid])->one(), 'sectionName');
     $documentname = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'documentName');
     $model->user_id = $userid;
     $model->documentUpdate = date('Y-m-d H:i:s');
     //$pendid = 2;
     /*
     $model->load(Yii::$app->request->post());
     $model->save();
     */
     $pendingid = ArrayHelper::getValue(Pendingdoc::find()->where(['and', ['pendingDocSection' => $section], ['pendingDocName' => $documentname], ['pendingDocFName' => $userLName . ', ' . $userFName]])->one(), 'id');
     $this->findModelPending($pendingid)->delete();
     //Pendingdoc::find()->where(['and', ['pendingDocSection'=>$section], ['pendingDocName'=>$documentname], ['pendingDocFName'=>$userLName . ', ' . $userFName]])->one();
     //if(Pendingdoc()->pendingDocSection == $section && Pendingdoc()->pendingDocName == $documentname && Pendingdoc()->pendingDocFName == $userLName . ', ' . $userFName){
     //Pendingdoc::findOne($pendid)->delete();
     //}
     $document = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'id');
     if ($model->save()) {
         $workflow = new Docworkflow();
         $workflow->document_id = $document;
         $workflow->user_receive = $userid;
         $workflow->docStatus_id = 1;
         //$workflow->timeAccepted = date('Y-m-d H:i:s');
         print_r('level1');
         print_r($documentname);
         print_r($userid);
         if ($workflow->save()) {
             print_r('level2');
             return $this->redirect(['index']);
         }
     }
 }