/** * Creates a new Docworkflow model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Docworkflow(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
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']); } } }