Beispiel #1
0
 /**
  * Дополнительная модель discipline_name
  * к существующей модели discipline
  * @return mixed
  */
 public function actionCreateAdditive($idParent)
 {
     /* @var $disciplines array */
     /* @var $disciplineName DisciplineName */
     $disciplines = Discipline::find()->where(['block' => Discipline::DISCIPLINE_CHOICE, 'id_program' => $idParent])->select(['id', "concat([[code_first]],'.',[[code_last]]) as code"])->orderBy('cast([[code_last]] as unsigned)')->asArray()->all();
     $disciplines = ArrayHelper::map($disciplines, 'id', 'code');
     $disciplineName = new DisciplineName();
     $disciplineName->id_program_main = $idParent;
     if ($disciplineName->load(Yii::$app->request->post()) && $disciplineName->save()) {
         return 'Item is succesfully created.';
         // alert message
     } else {
         return $this->renderAjax('updateAdditive', ['disciplines' => $disciplines, 'disciplineName' => $disciplineName]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Discipline::find();
     // 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]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($id_program, $params)
 {
     $query = DisciplineName::find()->where(['id_program_main' => $id_program]);
     $subQueryDiscipline = Discipline::find()->select('*,
                       cast([[code_last]] as decimal(10,3)) as [[code_last_num]]');
     $subQuerySemester = DisciplineSemester::find()->select('id_discipline, MIN(semester) as min_semester')->groupBy('id_discipline');
     $query->innerJoin(['discMain' => $subQueryDiscipline], 'discMain.id = discipline_name.id_discipline')->leftJoin(['discSemester' => $subQuerySemester], 'discSemester.id_discipline = discipline_name.id_discipline');
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10, 'pageSizeParam' => false]]);
     $provider->setSort(['attributes' => ['name', 'disciplineCode' => ['asc' => ['discMain.code_first' => SORT_ASC, 'discMain.code_last_num' => SORT_ASC, 'suffix' => SORT_ASC], 'desc' => ['discMain.code_first' => SORT_DESC, 'discMain.code_last_num' => SORT_DESC, 'suffix' => SORT_DESC], 'label' => 'DisciplineCode'], 'kind', 'block', 'disciplineSemesters' => ['asc' => ['discSemester.min_semester' => SORT_ASC], 'desc' => ['discSemester.min_semester' => SORT_DESC], 'label' => 'DisciplineSemester']], 'defaultOrder' => ['disciplineCode' => SORT_ASC]]);
     if (!($this->load($params) && $this->validate())) {
         return $provider;
     }
     $query->andWhere('name LIKE "%' . $this->name . '%" ');
     $query->andWhere('discMain.code_first LIKE "%' . $this->disciplineCode . '%" ');
     if (is_numeric($this->kind)) {
         $query->andWhere('discMain.kind = ' . $this->kind);
     }
     if (is_numeric($this->block)) {
         $query->andWhere('discMain.block = ' . $this->block);
     }
     return $provider;
 }
Beispiel #4
0
 public function getDisciplineList()
 {
     $discipline = Discipline::find()->select('discipline.*')->leftJoin('group_has_discipline', 'group_has_discipline.discipline_id = discipline.id')->leftJoin('teacher_has_discipline', '`teacher_has_discipline`.`ghd_id` = `group_has_discipline`.`id`')->where(['teacher_has_discipline.teacher_id' => Yii::$app->user->identity->teacher->id])->all();
     return $discipline;
 }
Beispiel #5
0
$this->title = 'Дисциплины';
$this->params['breadcrumbs'][] = ['label' => 'Образовательные программы', 'url' => ['/program', 'idParent' => $program->id_faculty]];
$this->params['breadcrumbs'][] = $this->title;
?>
<h2>Дисциплины</h2>
<h3>
    Образовательная программа: <?php 
echo "{$program->fullName}";
?>
</h3>

<p>
    <?php 
echo Html::a('Новая дисциплина', ['create', 'idParent' => $idParent], ['class' => 'btn btn-success actionCreate']);
?>
    <?php 
if (Discipline::find()->where(['block' => Discipline::DISCIPLINE_CHOICE])->exists()) {
    echo Html::a('Дополнительная дисциплина по выбору', ['create-additive', 'idParent' => $idParent], ['class' => 'btn btn-success actionCreate']);
}
?>
</p>

<?php 
Pjax::begin(['options' => ['id' => 'pjaxWrap']]);
echo GridView::widget(['dataProvider' => $provider, 'columns' => ['disciplineCode', 'name', ['attribute' => 'disciplineSemesters', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    return Html::a($model->disciplineSemesters ? $model->disciplineSemesters : 'Не заполнено', ['semester/index', 'idParent' => $model->id_discipline], ['data-pjax' => '0']);
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}{delete}{file}', 'buttons' => ['update' => 'actionUpdate', 'delete' => 'actionDelete', 'file' => 'actionFile']]]]);
?>

<?php 
Pjax::end();
Beispiel #6
0
 public function getDisciplineList()
 {
     return Discipline::find()->select('discipline.*')->joinWith('groupHasDisciplines')->where(['group_has_discipline.group_id' => $this->id])->all();
 }
Beispiel #7
0
    }
}
?>

<div class="group-has-discipline-form">
    
    <?php 
$form = ActiveForm::begin(['id' => 'project-form', 'enableAjaxValidation' => true]);
?>
    
    <?php 
echo $form->field($model, 'teacherHasDiscipline')->widget(MultipleInput::className(), ['min' => 1, 'columns' => [['name' => 'teacher_id', 'type' => 'dropDownList', 'defaultValue' => 1, 'items' => ArrayHelper::map(\common\models\Teacher::find()->all(), 'id', 'user.fullname')]]]);
?>

    <?php 
echo $form->field($model, 'discipline_id')->dropDownList(ArrayHelper::map(Discipline::find()->all(), 'id', 'name'));
?>

    <?php 
echo $model->isNewRecord ? $form->field($model, 'group_id')->dropDownList(ArrayHelper::map(Group::find()->all(), 'id', 'name'), ['prompt' => '-Группа-', 'onchange' => '
                $.post( "' . Yii::$app->urlManager->createUrl('group-has-discipline/semlist?id=') . '"+$(this).val(), function( data ) {
                  $( "select#grouphasdiscipline-semester_id" ).html( data );
                });
            ', 'class' => 'form-control']) : "";
?>

    <?php 
echo $model->isNewRecord ? $form->field($model, 'semester_number')->widget(DepDrop::classname(), ['options' => ['id' => 'semester_number'], 'pluginOptions' => ['depends' => ['grouphasdiscipline-group_id'], 'placeholder' => 'Выберите группу...', 'url' => Url::to(['/group-has-discipline/semesters'])]]) : $form->field($model, 'semester_number')->dropDownList($semesterList);
?>

    <div class="form-group">