Ejemplo n.º 1
0
 private function getDaysList($lessons_array, $week)
 {
     $items = array();
     for ($day = 1; $day <= $this->days; $day++) {
         $dayTitle = Html::tag('th', Lesson::getDayName($day), ['class' => 'center-align grey-color', 'colspan' => '5']);
         $items[] = Html::tag('tr', $dayTitle);
         $lesson = new Lesson();
         foreach ($this->attributes as $attr) {
             $label = $lesson->getAttributeLabel($attr);
             $items[] = Html::tag('th', $label, ['class' => 'center-align']);
         }
         $items[] = $this->getLessonsList($lessons_array, $this->week, $day);
     }
     return Html::tag('tr', implode("\n", $items));
 }
Ejemplo n.º 2
0
 /** 
  * Creates data provider instance with search query applied 
  * 
  * @param array $params 
  * 
  * @return ActiveDataProvider 
  */
 public function search($params)
 {
     $query = Lesson::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'groupName' => ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC], 'label' => 'groupName'], 'disciplineName' => ['asc' => ['discipline.name' => SORT_ASC], 'desc' => ['discipline.name' => SORT_DESC], 'label' => 'disciplineName'], 'teacherFullname' => ['asc' => ['user.last_name' => SORT_ASC, 'user.first_name' => SORT_ASC, 'user.middle_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC, 'user.first_name' => SORT_DESC, 'user.middle_name' => SORT_DESC], 'label' => 'teacherFullname'], 'lessonTypeName' => ['asc' => ['lesson_type.name' => SORT_ASC], 'desc' => ['lesson_type.name' => SORT_DESC], 'label' => 'lessonTypeName'], 'week', 'day', 'time', 'auditory']]);
     $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, 'ghd_id' => $this->ghd_id, 'lesson_type_id' => $this->lesson_type_id, 'week' => $this->week, 'day' => $this->day, 'time' => $this->time, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'auditory', $this->auditory]);
     $query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.group' => function ($q) {
         $q->where('group.name LIKE "%' . $this->groupName . '%" ');
     }]);
     $query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.discipline' => function ($q) {
         $q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
     }]);
     $query->joinWith('teacherHasDiscipline')->joinWith('teacherHasDiscipline.teacher')->joinWith(['teacherHasDiscipline.teacher.user' => function ($q) {
         $q->where('user.first_name LIKE "%' . $this->teacherFullname . '%" ' . 'OR user.last_name LIKE "%' . $this->teacherFullname . '%"' . 'OR user.middle_name LIKE "%' . $this->teacherFullname . '%"');
     }]);
     $query->joinWith(['lessonType' => function ($q) {
         $q->where('lesson_type.name LIKE "%' . $this->lessonTypeName . '%" ');
     }]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Finds the Lesson model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Lesson the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Lesson::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 /**
  * @get lessons
  */
 public function getLessons()
 {
     return $this->hasMany(Lesson::className(), ['ghd_id' => 'id']);
 }
Ejemplo n.º 5
0
    
    <?php 
$ghd_id_arr = array();
foreach ($ghd as $grouphasdisc) {
    array_push($ghd_id_arr, $grouphasdisc->id);
}
$lessons = Lesson::find()->where(['ghd_id' => $ghd_id_arr])->orderBy('week ASC, day ASC, time ASC')->all();
$schedule = array();
for ($week = 1; $week <= 2; $week++) {
    $schedule[$week][] = Html::beginTag('table', ['class' => 'table table-bordered center-align']);
    $schedule[$week][] = Html::beginTag('tr');
    $schedule[$week][] = Html::tag('th', 'День недели', ['class' => 'center-align']);
    $schedule[$week][] = Html::tag('th', 'Неделя - ' . $week, ['class' => 'center-align', 'colspan' => '4']);
    for ($day = 1; $day <= 6; $day++) {
        $schedule[$week][] = Html::beginTag('tr');
        $schedule[$week][] = Html::tag('th', Lesson::getDayName($day), ['class' => 'center-align lesson-day', 'colspan' => '5']);
        $schedule[$week][] = Html::beginTag('tr');
        $schedule[$week][] = Html::tag('th', "Предмет", ['class' => 'center-align']);
        $schedule[$week][] = Html::tag('th', 'Время', ['class' => 'center-align']);
        $schedule[$week][] = Html::tag('th', 'Преподаватель', ['class' => 'center-align']);
        $schedule[$week][] = Html::tag('th', 'Аудитория', ['class' => 'center-align']);
        $schedule[$week][] = Html::tag('th', 'Тип занятия', ['class' => 'center-align']);
        $schedule[$week][] = Html::endTag('tr');
        $schedule[$week][] = Html::beginTag('tr');
        foreach ($lessons as $lesson) {
            $schedule[$week][] = Html::beginTag('tr');
            if ($week == $lesson->week and $day == $lesson->day) {
                $schedule[$week][] = Html::tag('td', $lesson->groupHasDiscipline->discipline->name);
                $schedule[$week][] = Html::tag('td', $lesson->time);
                $schedule[$week][] = Html::tag('td', $lesson->teacher->user->fullname);
                $schedule[$week][] = Html::tag('td', $lesson->auditory);
Ejemplo n.º 6
0
 public function getLesson()
 {
     return Lesson::find()->all();
 }
Ejemplo n.º 7
0
</h1>
   <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
 
   <div class="btn-group">
    <?php 
echo Html::button('Добавить занятие', ['value' => Url::to(['//lesson/create']), 'class' => 'btn btn-success modalButton']);
?>
     
    <?php 
echo Html::button('Управление типами', ['value' => Url::to(['//lesson-type/index']), 'class' => 'btn btn-primary modalButton']);
?>
         
   </div>
   <?php 
Pjax::begin(['enablePushState' => false]);
?>
   <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => 'table-responsive'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'groupName', 'disciplineName', ['attribute' => 'lessonTypeName', 'filter' => ArrayHelper::map(\common\models\LessonType::find()->all(), 'name', 'name')], 'teacherFullname', ['attribute' => 'week', 'filter' => [1 => 1, 2 => 2]], ['attribute' => 'day', 'value' => function ($model) {
    return $model->dayRealName;
}, 'filter' => Lesson::getDaysList()], ['attribute' => 'time', 'filter' => ArrayHelper::map(Lesson::find()->select('time')->distinct()->all(), 'time', 'time')], 'auditory', ['class' => 'common\\components\\ActionColumn']]]);
?>
   <?php 
Pjax::end();
?>
</div>
<?php 
Modal::begin(['header' => '', 'id' => 'modal', 'size' => 'modal-lg']);
echo "<div id='modalContent'></div>";
Modal::end();
Ejemplo n.º 8
0
 public static function getLessonsList($arr)
 {
     $group = isset($arr['group']) ? $arr['group'] : null;
     $teacher = isset($arr['teacher']) ? $arr['teacher'] : null;
     if ($group !== null) {
         if (!isset($arr['semester'])) {
             $semester = Group::findOne($group)->currentSemester;
         } else {
             $semester = GroupSemesters::find()->where(['group_id' => $arr['group'], 'semester_number' => $arr['semester']])->one();
         }
         if (!$semester) {
             return false;
         }
         $lessons = Lesson::find()->joinWith('groupHasDiscipline', true, "INNER JOIN")->where(['group_has_discipline.group_id' => $group])->andWhere(['group_has_discipline.semester_number' => $semester->semester_number])->orderBy('week ASC, day ASC, time ASC')->all();
         return $lessons;
     } elseif ($teacher !== null) {
         $lessons = Lesson::find()->select('lesson.*')->innerJoin("teacher_has_discipline thd", "`thd`.`id` = `lesson`.`thd_id`")->innerJoin("group_has_discipline ghd", '`ghd`.`id` = `lesson`.`ghd_id`')->innerJoin("group g", '`g`.`id` = `ghd`.`group_id`')->innerJoin("group_semesters gs", '`gs`.`group_id` = `g`.`id` AND `ghd`.`semester_number`  = `gs`.`semester_number`')->where(['<=', 'gs.begin_date', date('U')])->andWhere(['>=', 'gs.end_date', date('U')])->andWhere(['thd.teacher_id' => $teacher])->orderBy('week ASC, day ASC, time ASC, id ASC')->all();
         return $lessons;
     }
 }
Ejemplo n.º 9
0
//if(!$ghd) {  throw new NotFoundHttpException('Страница не найдена.');}
$this->title = 'Расписание группы ' . $model->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">

    <h3><?php 
echo "Расписание группы: " . Html::a($model->name, ['//group/view', 'id' => $model->id]);
?>
</h3>

    <?php 
/*
    $ghd_id_arr = array();
    foreach ($ghd as $grouphasdisc){
        array_push($ghd_id_arr,$grouphasdisc->id);
    };
    $lessons = Lesson::find()->where(['ghd_id' => $ghd_id_arr])->orderBy('week ASC, day ASC, time ASC')->all(); */
$lessons = Lesson::getLessonsList(['group' => $group]);
echo Tabs::widget(['options' => ['class' => 'nav nav-pills nav-justified'], 'items' => [['label' => 'Неделя - 1', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 1])], ['label' => 'Неделя - 2', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 2])]]]);
?>

</div>


<?php 
Modal::begin(['header' => '', 'id' => 'modal', 'size' => 'modal-lg']);
echo "<div id='modalContent'></div>";
Modal::end();
Ejemplo n.º 10
0
<?php

use common\widgets\Schedule;
use common\models\Lesson;
use yii\bootstrap\Tabs;
use yii\bootstrap\Html;
/* 
 * 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.
 */
$lessons = Lesson::getLessonsList(['group' => $model->id]);
echo Tabs::widget(['options' => ['class' => 'nav nav-pills nav-justified'], 'items' => [['label' => 'Неделя - 1', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 1])], ['label' => 'Неделя - 2', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 2])]]]);
Ejemplo n.º 11
0
<?php

use yii\helpers\Html;
use common\models\Lesson;
use yii\bootstrap\Tabs;
use common\widgets\Schedule;
use yii\helpers\Url;
$model = Yii::$app->user->identity->student->group;
//Дисциплины
$this->beginBlock('disciplines');
echo Html::beginTag('ul', ['class' => 'list-group']);
foreach ($model->currentDisciplines as $ghd) {
    $teachers = array();
    foreach ($ghd->teacherHasDiscipline as $thd) {
        $teachers[] = $thd->teacher;
    }
    echo Html::beginTag('li', ['class' => 'list-group-item']);
    echo Html::a($ghd->discipline->name, Url::to(['//group-has-discipline', 'id' => $ghd->id]));
    echo " Преподаватели:";
    foreach ($teachers as $teacher) {
        echo Html::button($teacher->user->fullname, ['value' => Url::to(['user/view', 'id' => $teacher->user->id]), 'class' => 'btn-link modalButton']);
    }
    echo Html::endTag('li');
}
echo Html::endTag('ul');
$this->endBlock('disciplines');
$lessons = Lesson::getLessonsList(['teacher' => Yii::$app->user->identity->student->id]);
$schedule = Tabs::widget(['options' => ['class' => 'nav nav-pills nav-justified'], 'items' => [['label' => 'Неделя - 1', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 1])], ['label' => 'Неделя - 2', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 2])]]]);
echo Tabs::widget(['options' => ['class' => 'nav nav-pills nav-justified'], 'items' => [['label' => 'Дисциплины', 'content' => $this->render('/group/_disciplines', ['model' => $model])], ['label' => 'Расписание', 'content' => $schedule]]]);
Ejemplo n.º 12
0
$date = new DateTime();
$todayDate = $date->format("Y-m-d");
$Teacher = Teacher::findOne($teacher);
if (!$Teacher) {
    throw new NotFoundHttpException('Страница не найдена.');
}
//if(!$ghd) { echo Html::tag('h3','Расписания данной группы не существует или оно еще не заполнено!');    return;}
$this->title = 'Расписание преподавателя ' . $Teacher->user->fullname;
$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">

    <h3><?php 
echo "Расписание преподавателя: " . Html::button($Teacher->user->fullname, ['class' => 'btn btn-lg btn-link modalButton', 'value' => Url::to(['//teacher/view', 'id' => $Teacher->id])]);
?>
</h3>
    
    
    <?php 
//$lessons = Lesson::find()->where(['teacher_id' => $teacher])->orderBy('week ASC, day ASC, time ASC')->all();
$lessons = Lesson::getLessonsList(['teacher' => $teacher]);
echo Tabs::widget(['options' => ['class' => 'nav nav-pills nav-justified'], 'items' => [['label' => 'Неделя - 1', 'content' => Schedule::widget(['scenario' => Schedule::SCENARIO_TEACHER, 'lessons' => $lessons, 'week' => 1])], ['label' => 'Неделя - 2', 'content' => Schedule::widget(['scenario' => Schedule::SCENARIO_GROUP, 'lessons' => $lessons, 'week' => 2])]]]);
?>

</div>
<?php 
Modal::begin(['header' => '', 'id' => 'modal', 'size' => 'modal-lg']);
echo "<div id='modalContent'></div>";
Modal::end();
Ejemplo n.º 13
0
$this->params['breadcrumbs'][] = ['label' => 'Расписание', 'url' => Url::to(['lesson/index'])];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="lesson-index">
    
    <h3><?php 
echo "Архив расписания группы: " . Html::a($groupModel->name, ['//group/view', 'id' => $groupModel->id]);
?>
        <?php 
echo Html::encode($formatter->asDate($semesterModel->begin_date) . "-" . $formatter->asDate($semesterModel->end_date));
?>
</h3>
    <?php 
/*
    $ghd_id_arr = array();
    foreach ($ghd as $grouphasdisc){
        array_push($ghd_id_arr,$grouphasdisc->id);
    };
    $lessons = Lesson::find()->where(['ghd_id' => $ghd_id_arr])->orderBy('week ASC, day ASC, time ASC')->all(); */
$lessons = Lesson::getLessonsList(['group' => $group, 'semester' => $semester]);
echo Tabs::widget(['items' => [['label' => 'Неделя - 1', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 1])], ['label' => 'Неделя - 2', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 2])]]]);
?>

</div>



<?php 
Modal::begin(['header' => '', 'id' => 'modal', 'size' => 'modal-lg']);
echo "<div id='modalContent'></div>";
Modal::end();
Ejemplo n.º 14
0
use yii\grid\GridView;
use yii\bootstrap\Nav;
use yii\bootstrap\Tabs;
use yii\helpers\Url;
use yii\bootstrap\Modal;
use common\widgets\Schedule;
use common\models\Lesson;
use common\widgets\CommentsWidget;
use yii\helpers\Markdown;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = $model->discipline->name . ":" . $model->group->name;
$this->params['breadcrumbs'][] = ['label' => $model->group->name, 'url' => Url::to(['//group/view', 'id' => $model->group->id])];
$this->params['breadcrumbs'][] = $this->title;
$this->beginBlock('schedule');
$lessons = Lesson::find()->where(['ghd_id' => $model->id])->all();
echo Tabs::widget(['options' => ['class' => 'nav nav-pills nav-justified'], 'items' => [['label' => 'Неделя - 1', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 1])], ['label' => 'Неделя - 2', 'content' => Schedule::widget(['scenario' => 'group', 'lessons' => $lessons, 'week' => 2])]]]);
$this->endBlock('schedule');
$this->beginBlock('desk');
echo CommentsWidget::widget(['class_name' => $model::className(), 'item_id' => $model->id]);
$this->endBlock('desk');
?>
<div class="group-has-discipline-index">

    <h2><?php 
echo Html::encode($this->title);
?>
</h2>
    <div class='row'>
        <div class="col-md-3">
            <?php 
Ejemplo n.º 15
0
    

    <?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]);
?>

    <?php 
echo $form->field($model, 'day')->dropDownList(Lesson::getDaysList());
?>

    <?php 
echo $form->field($model, 'time')->widget(TimePicker::classname(), ['pluginOptions' => ['defaultTime' => '8:30:00', 'showSeconds' => true, 'showMeridian' => false, 'minuteStep' => 5]]);
?>

    <?php 
echo $form->field($model, 'auditory')->textInput(['maxlength' => true]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>