/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $newquery = null)
 {
     $query = GroupHasDiscipline::find();
     if ($newquery) {
         $query = $newquery;
     }
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'semester_number', 'semesterNumber' => ['asc' => ['group_semesters.semester_number' => SORT_ASC], 'desc' => ['group_semesters.semester_number' => SORT_DESC]], 'groupName' => ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC]], 'disciplineName' => ['asc' => ['discipline.name' => SORT_ASC], 'desc' => ['discipline.name' => SORT_DESC]]]]);
     $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, 'discipline_id' => $this->discipline_id, 'group_id' => $this->group_id, 'group_has_discipline.semester_number' => $this->semester_number]);
     $query->joinWith(['semester' => function ($q) {
         $q->where('group_semesters.semester_number LIKE "%' . $this->semesterNumber . '%" ');
     }]);
     $query->joinWith(['group' => function ($q) {
         $q->where('group.name LIKE "%' . $this->groupName . '%" ');
     }]);
     $query->joinWith(['discipline' => function ($q) {
         $q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
     }]);
     return $dataProvider;
 }
예제 #2
0
 public function actionThd()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $ghd_id = $parents[0];
             $model = GroupHasDiscipline::findOne($ghd_id);
             foreach (\yii\helpers\ArrayHelper::map($model->teacherHasDiscipline, 'id', 'teacher.user.fullname') as $key => $element) {
                 $out[] = ['id' => $key, 'name' => $element];
             }
             // the getSubCatList function will query the database based on the
             // cat_id and return an array like below:
             // [
             //    ['id'=>'<sub-cat-id-1>', 'name'=>'<sub-cat-name1>'],
             //    ['id'=>'<sub-cat_id_2>', 'name'=>'<sub-cat-name2>']
             // ]
             echo Json::encode(['output' => $out, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
예제 #3
0
 public function checkStudent($id)
 {
     return GroupHasDiscipline::find()->joinWith('group')->joinWith('group.students')->andWhere(['student.id' => $id])->andWhere(['group_has_discipline.id' => $this->id])->count();
 }
예제 #4
0
 public function isTeacherHasDiscipline($id)
 {
     $isTeacherHasDiscipline = GroupHasDiscipline::find()->joinWith('teacherHasDiscipline')->where(['group_has_discipline.id' => $id])->andWhere(['teacher_has_discipline.teacher_id' => $this->id])->count();
     return $isTeacherHasDiscipline;
 }
예제 #5
0
<?php

use yii\helpers\Html;
use yii\widgets\ListView;
use common\models\Lesson;
use common\models\GroupHasDiscipline;
use yii\helpers\Url;
use yii\web\NotFoundHttpException;
use yii\bootstrap\Tabs;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$date = new DateTime();
$todayDate = $date->format("Y-m-d");
$ghd = GroupHasDiscipline::find()->where(['group_id' => $group])->andWhere(['<=', 'start_date', $todayDate])->andWhere(['>=', 'end_Date', $todayDate])->all();
if (!$ghd) {
    throw new NotFoundHttpException('Страница не найдена.');
}
$this->title = 'Расписание группы ' . $ghd[0]->group->name;
$this->params['breadcrumbs'][] = ['label' => 'Информация', 'url' => Url::to(['site/information'])];
$this->params['breadcrumbs'][] = ['label' => 'Расписание', 'url' => Url::to(['lesson/index'])];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="lesson-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
예제 #6
0
 /**
  * @get grops has discipline
  */
 public function getGroupHasDisciplines()
 {
     return $this->hasMany(GroupHasDiscipline::className(), ['discipline_id' => 'id']);
 }
예제 #7
0
 public function getCurrentDisciplines()
 {
     return $this->hasMany(GroupHasDiscipline::className(), ['group_id' => 'id'])->where(['semester_number' => $this->currentSemester->semester_number]);
 }
예제 #8
0
 /**
  * @get ghd
  */
 public function getGroupHasDiscipline()
 {
     return $this->hasOne(GroupHasDiscipline::className(), ['id' => 'ghd_id']);
 }
예제 #9
0
 public function actionTermCreateGroup($group = null, $discipline = null)
 {
     if ($group && $discipline && Yii::$app->user->can('teacher')) {
         if (Yii::$app->user->identity->teacher->isTeacherHasDiscipline($discipline)) {
             $groupModel = Group::findOne($group);
             $disciplineModel = \common\models\GroupHasDiscipline::findOne($discipline);
             $errors = false;
             foreach ($groupModel->students as $student) {
                 $model = new Work();
                 $model->scenario = Work::SCENARIO_TERM;
                 $model->ghd_id = $disciplineModel->discipline_id;
                 $model->student_id = $student->id;
                 $model->teacher_id = Yii::$app->user->identity->teacher->id;
                 $model->work_type_id = Work::TYPE_TERM;
                 if ($model->validate()) {
                     $model->save();
                     $model->id = $model->getPrimaryKey();
                 } else {
                     $errors = true;
                 }
             }
             if (!$errors) {
                 return 'Создано';
             } else {
                 return 'Произошла ошибка';
             }
         }
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Finds the GroupHasDiscipline model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return GroupHasDiscipline the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = GroupHasDiscipline::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #11
0
use kartik\depdrop\DepDrop;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\models\Lesson */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="lesson-form">

    <?php 
$form = ActiveForm::begin();
?>
 
    
    <?php 
echo $model->isNewRecord ? $form->field($model, 'ghd_id')->dropDownList(ArrayHelper::map(GroupHasDiscipline::find()->all(), 'id', 'groupSemDisc'), ['prompt' => '--Выберите дисциплину--']) : "";
?>
    

    <?php 
echo $model->isNewRecord ? $form->field($model, 'thd_id')->widget(DepDrop::classname(), ['options' => ['id' => 'thd_id-id'], 'pluginOptions' => ['depends' => ['lesson-ghd_id'], 'placeholder' => '...', 'url' => Url::to(['/lesson/thd'])]]) : $form->field($model, 'thd_id')->dropDownList(ArrayHelper::map($model->groupHasDiscipline->teacherHasDiscipline, 'teacher.id', 'teacher.user.fullname'));
?>
    
    <?php 
echo $form->field($model, 'lesson_type_id')->dropDownList(ArrayHelper::map(LessonType::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'week')->dropDownList(['1' => 1, '2' => 2]);
?>