Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $additionaly = null)
 {
     if ($additionaly === null) {
         $query = WorkList::find();
     } else {
         $query = $additionaly;
     }
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'work_type_id' => $this->work_type_id, 'teacher_id' => $this->teacher_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * @get work list
  */
 public function getWorkList()
 {
     return $this->hasMany(WorkList::className(), ['teacher_id' => 'id']);
 }
Esempio n. 3
0
<?php

use yii\bootstrap\Html;
use yii\widgets\Pjax;
use yii\widgets\ActiveForm;
use common\models\WorkList;
use yii\helpers\ArrayHelper;
use common\models\WorkHistory;
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$this->title = 'Редактирование названия курсовой работы';
$workList = ArrayHelper::map(WorkList::find()->where(['teacher_id' => $model->teacher_id, 'work_type_id' => $model::TYPE_TERM])->all(), 'id', 'name', 'teacher.user.fullname');
$oldList = ArrayHelper::map($model->workHistory, 'id', 'name');
?>
<p>
    <h2><?php 
echo $this->title;
?>
</h2>
</p>
<div class="container-fluid">
<?php 
Pjax::begin(['enablePushState' => false, 'id' => 'begin-term']);
$form = ActiveForm::begin(['id' => 'begin-graduate-form', 'options' => ['class' => 'form-horizontal', 'data-pjax' => true]]);
?>
    <div class="form-group">
        <?php 
echo Html::label('Изменить название');
Esempio n. 4
0
 public function actionEditGraduate()
 {
     $workModel = Work::find()->where(['student_id' => Yii::$app->user->identity->student->id])->andWhere(['work_type_id' => Work::TYPE_GRADUATE])->one();
     if (Yii::$app->request->post()) {
         $workModel->editGraduate(Yii::$app->request->post());
         return $this->redirect(['graduate']);
     }
     $workList = \common\models\WorkList::find()->where(['teacher_id' => $workModel->teacher_id, 'work_type_id' => Work::TYPE_GRADUATE])->all();
     $teachers = \common\models\Teacher::find()->all();
     return $this->renderAjax('edit_graduate', ['workModel' => $workModel, 'workList' => $workList, 'teachers' => $teachers]);
 }
Esempio n. 5
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.');
     }
 }
Esempio n. 6
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;
     }
 }
Esempio n. 7
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]);
         }
     }
 }