public function actionDiscipline($id, $id_discipline_name = null)
 {
     // $id - DisciplineSemester
     $disciplineSemester = DisciplineSemester::findOne($id);
     $provider = new ActiveDataProvider(['query' => ResultHelper::DisciplineResults($id, $id_discipline_name), 'pagination' => ['pageSize' => 10, 'pageSizeParam' => false]]);
     Yii::$app->session->set('disciplineResultPage', Yii::$app->request->get('page'));
     return $this->render('discipline', ['provider' => $provider, 'disciplineSemester' => $disciplineSemester]);
 }
 protected function getIdFaculty($id, $parent = false)
 {
     if ($parent) {
         $model = Discipline::findOne($id);
         return $model->idProgram->id_faculty;
     } else {
         $model = DisciplineSemester::findOne($id);
         return $model->idDiscipline->idProgram->id_faculty;
     }
 }
 /**
  * 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;
 }
Exemple #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDisciplineSemesters()
 {
     return $this->hasMany(DisciplineSemester::className(), ['id_discipline' => 'id']);
 }
Exemple #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdDisciplineSemester()
 {
     return $this->hasOne(DisciplineSemester::className(), ['id' => 'id_discipline_semester']);
 }
 /**
  * getter for semesters
  */
 public function getDisciplineSemesters()
 {
     $id_discipline = $this->idDiscipline->id;
     $semesters = DisciplineSemester::find()->where(['id_discipline' => $id_discipline])->orderBy('semester')->indexBy('semester')->asArray()->all();
     $semesters = array_keys($semesters);
     return implode(', ', $semesters);
 }
Exemple #7
0
<h3>
    Образовательная программа: <?php 
echo "{$program->fullName}";
?>
</h3>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['disciplineCode', ['attribute' => 'name', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    return Html::a($model->name, ['/file/main/discipline', 'id' => $model->id], ['class' => 'linkedFiles']);
}], ['attribute' => 'kind', 'format' => 'text', 'value' => function ($model, $key, $index, $column) {
    return Yii::$app->params['decode']['discipline.kind'][$model->kind];
}, 'filter' => Html::activeDropDownList($searchModel, 'kind', Yii::$app->params['decode']['discipline.kind'], ['prompt' => 'Поиск', 'class' => 'form-control'])], ['attribute' => 'block', 'format' => 'text', 'value' => function ($model, $key, $index, $column) {
    return Yii::$app->params['decode']['discipline.block'][$model->block];
}, 'filter' => Html::activeDropDownList($searchModel, 'block', Yii::$app->params['decode']['discipline.block'], ['prompt' => 'Поиск', 'class' => 'form-control'])], ['attribute' => 'disciplineSemesters', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    $content = '';
    $semesters = explode(', ', $model->disciplineSemesters);
    foreach ($semesters as $semester) {
        /* @var $disciplineSemester common\models\DisciplineSemester */
        $disciplineSemester = DisciplineSemester::findOne(['id_discipline' => $model->id_discipline, 'semester' => $semester]);
        if ($disciplineSemester) {
            $options = ['style' => 'margin-right:10px;'];
            if (Yii::$app->user->can('viewFaculty', ['id_faculty' => $model->idProgram->id_faculty])) {
                $id_discipline_name = $model->idDiscipline->block == Discipline::DISCIPLINE_CHOICE ? $model->id : null;
                $content .= Html::a($semester, ['/student/result/discipline', 'id' => $disciplineSemester->id, 'id_discipline_name' => $id_discipline_name], $options);
            } else {
                $content .= Html::tag('span', $semester, $options);
            }
        }
    }
    return $content;
}]], 'summary' => '']);