public function actionChamdiem() { $this->allowUser(2); $searchModel = new WorkSearch(); $dataProvider = $searchModel->chamdiem(Yii::$app->request->queryParams); if (Yii::$app->request->post('hasEditable')) { $workId = Yii::$app->request->post('editableKey'); $timesheetId = Work::findOne($workId)->timesheet_id; $model = Timesheet::findOne($timesheetId); $out = Json::encode(['output' => '', 'message' => '']); $post = current($_POST['Work']); foreach ($post as $postname => $value) { if ($postname == "timesheet.point") { $model->point = $value; if ($value != null) { $model->status = 1; } else { $model->status = 0; } } if ($postname == "timesheet.director_comment") { $model->director_comment = $value; } } if ($model->validate()) { $model->save(); } echo $out; return; } return $this->render('chamdiem', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * Finds the Timesheet model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Timesheet the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Timesheet::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }