/**
  * 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;
 }
 public function checkStudent($id)
 {
     return GroupHasDiscipline::find()->joinWith('group')->joinWith('group.students')->andWhere(['student.id' => $id])->andWhere(['group_has_discipline.id' => $this->id])->count();
 }
Exemple #3
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;
 }
Exemple #4
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>
 public function actionStudentfromghd()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $cat_id = $parents[0];
             $ghd = \common\models\GroupHasDiscipline::find()->where(['id' => $cat_id])->one();
             $students = $ghd->group->students;
             $out = \yii\helpers\ArrayHelper::map($students, 'id', 'user.fullname');
             $arr = array();
             foreach ($out as $key => $o) {
                 $arr[$key]['id'] = $key;
                 $arr[$key]['name'] = $o;
             }
             echo Json::encode(['output' => $arr, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
Exemple #6
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]);
?>