/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Docworkflow::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith('document')->joinWith(['userReceive' => function ($q) { $q->from('user receive'); }])->joinWith('docStatus')->joinWith(['userRelease' => function ($q) { $q->from('user release'); }]); //$query->joinWith('document')->joinWith('userRelease')->joinWith('userReceive'); $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(['timeAccepted' => $this->timeAccepted, 'timeRelease' => $this->timeRelease]); $query->andFilterWhere(['like', 'docWorkflowComment', $this->docWorkflowComment])->andFilterWhere(['like', 'totalTimeSpent', $this->totalTimeSpent])->andFilterWhere(['like', 'document.documentName', $this->document_id])->andFilterWhere(['like', 'receive.userLName', $this->user_receive])->andFilterWhere(['like', 'docstatus.docStatusName', $this->docStatus_id])->andFilterWhere(['like', 'docworkflow.id', $this->id])->andFilterWhere(['like', 'release.userLName', $this->user_release]); return $dataProvider; }
public function actionRelease($id) { $model = $this->findModel($id); $workflowid = ArrayHelper::getValue(Docworkflow::find()->where(['document_id' => $id])->orderBy(['id' => SORT_DESC])->one(), 'id'); //print_r($workflowid . ' level0 ' . $model->user_id); if ($model->load(Yii::$app->request->post())) { //$userid1 = 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' => $model->user_id])->one(), 'userFName'); $userLName = ArrayHelper::getValue(User::find()->where(['id' => $model->user_id])->one(), 'userLName'); $section = ArrayHelper::getValue(Section::find()->where(['id' => $sectionid])->one(), 'sectionName'); $documentname = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'documentName'); $pendingdoc = new Pendingdoc(); $pendingdoc->pendingDocFName = $userLName . ', ' . $userFName; $pendingdoc->pendingDocSection = $section; $pendingdoc->pendingDocName = $documentname; if ($workflowid == null) { if ($pendingdoc->save()) { print_r('level3'); return $this->redirect(['index']); //return $this->redirect('index.php?r=pendingdoc'); } } else { $workflow1 = new Docworkflow(); $workflow1 = $this->findModelWorkflow($workflowid); //$workflow1->id = $workflowid; $workflow1->timeRelease = date('Y-m-d H:i:s'); //$workflow1->totalTimeSpent = date('Y-m-d H:i:s'); $workflow1->user_release = $model->user_id; print_r('level1'); if ($workflow1->save()) { print_r('level2'); if ($pendingdoc->save()) { print_r('level3'); return $this->redirect(['index']); //return $this->redirect('index.php?r=pendingdoc'); } } } } else { return $this->renderAjax('release', ['model' => $model]); } }