Example #1
0
 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]);
 }