예제 #1
0
 public function actionBeginGraduate()
 {
     if (Yii::$app->request->isAjax) {
         $workModel = new Work();
         $workModel->scenario = Work::SCENARIO_GRADUATE;
         if (Yii::$app->request->post()) {
             $nowDate = date("U");
             $workHistory = new \common\models\WorkHistory();
             if (isset(Yii::$app->request->post()['newWorkCheckbox']) && Yii::$app->request->post()['newWorkCheckbox'] == true) {
                 $teacher = Yii::$app->request->post()['newWorkTeacher'];
                 $stringName = Yii::$app->request->post()['newWorkName'];
                 $work_list_id = null;
             } else {
                 $workFromList = \common\models\WorkList::findOne(Yii::$app->request->post()['workList']);
                 $teacher = $workFromList->teacher_id;
                 $stringName = $workFromList->name;
                 $work_list_id = $workFromList->id;
                 $workModel->reserved_id = $workFromList->id;
             }
             $workModel->work_type_id = 1;
             $workModel->teacher_id = $teacher;
             $workModel->student_id = Yii::$app->user->identity->student->id;
             $workModel->date = $nowDate;
             if ($workModel->validate()) {
                 $workModel->save();
                 $workHistory->work_id = $workModel->getPrimaryKey();
                 $workHistory->name = $stringName;
                 $workHistory->creation_date = $nowDate;
                 if ($workHistory->save()) {
                     $workModel->name = $workHistory->getPrimaryKey();
                     $iterator = $workModel->name;
                     $workModel->save();
                     if (isset($workFromList)) {
                         $workFromList->save();
                     }
                     return $this->redirect(['graduate']);
                 }
             }
         }
         $workList = \common\models\WorkList::find()->all();
         $teachers = \common\models\Teacher::find()->all();
         return $this->renderAjax('begin_graduate', ['workModel' => $workModel, 'workList' => $workList, 'teachers' => $teachers]);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
0
 public function editTerm($request)
 {
     $date = date('U');
     switch ($request['source']) {
         case "edit":
             $newWorkName = new WorkHistory();
             $newWorkName->creation_date = $date;
             $newWorkName->name = $request['editName'];
             $newWorkName->work_id = $this->id;
             if ($newWorkName->save()) {
                 $this->name = $newWorkName->getPrimaryKey();
                 $this->save();
             }
         case "new":
             $newWorkName = new WorkHistory();
             $newWorkName->creation_date = $date;
             $newWorkName->name = $request['newName'];
             $newWorkName->work_id = $this->id;
             if ($newWorkName->save()) {
                 $this->reserved_id = null;
                 $this->name = $newWorkName->getPrimaryKey();
                 $this->save();
             }
             break;
         case "history":
             $this->name = $request['oldWorkName'];
             $this->save();
             break;
         case "list":
             $newWorkName = new WorkHistory();
             $wfl = WorkList::findOne($request['listWorkName']);
             $newWorkName->creation_date = $date;
             $newWorkName->work_id = $this->id;
             $newWorkName->name = $wfl->name;
             if ($newWorkName->save()) {
                 $this->reserved_id = $wfl->id;
                 $this->name = $newWorkName->getPrimaryKey();
                 $this->save();
             }
             break;
         default:
             break;
     }
 }
예제 #3
0
 /**
  * Finds the WorkList model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return WorkList the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = WorkList::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #4
0
 public function beginGraduate($request)
 {
     $this->scenario = 'graduate';
     $nowDate = date("U");
     $workHistory = new \common\models\WorkHistory();
     if (isset(Yii::$app->request->post()['newWorkCheckbox']) && Yii::$app->request->post()['newWorkCheckbox'] == true) {
         $teacher = Yii::$app->request->post()['newWorkTeacher'];
         $stringName = Yii::$app->request->post()['newWorkName'];
         $work_list_id = null;
     } else {
         $workFromList = \common\models\WorkList::findOne(Yii::$app->request->post()['workList']);
         $teacher = $workFromList->teacher_id;
         $stringName = $workFromList->name;
         $work_list_id = $workFromList->id;
     }
     $workModel->work_type_id = 1;
     $workModel->teacher_id = $teacher;
     $workModel->student_id = Yii::$app->user->identity->student->id;
     $workModel->date = $nowDate;
     $workModel->reserved_id = $workFromList->id;
     if ($workModel->save()) {
         $workHistory->work_id = $workModel->getPrimaryKey();
         $workHistory->name = $stringName;
         $workHistory->creation_date = $nowDate;
         if ($workHistory->save()) {
             $workModel->name = $workHistory->getPrimaryKey();
             $iterator = $workModel->name;
             $workModel->save();
             if (isset($workFromList)) {
                 $workFromList->save();
             }
             return $this->renderAjax('complete_begin_graduate', ['iterator' => $iterator]);
         }
     }
 }