public function execute($user, $item, $params) { if (Yii::$app->user->isGuest) { return false; } $role = Yii::$app->user->identity->role; if ($role == User::ROLE_ADMIN) { return true; } elseif (!isset($params['id_program'])) { return false; } elseif ($role == User::ROLE_STUDENT) { $model = StudentEducation::find()->where(['id_student' => Yii::$app->user->identity->id_student, 'year' => YearHelper::getYear()])->one(); if (!$model) { return false; } else { return $params['id_program'] == $model->id_program; } } elseif ($role == User::ROLE_LOCAL_ADMIN || $role == User::ROLE_INSPECTOR) { $model = Program::findOne($params['id_program']); if (!$model) { return false; } else { return Yii::$app->user->identity->id_faculty == $model->id_faculty; } } else { return false; } }
public function actionIndex($id_program) { $program = Program::findOne($id_program); $searchModel = new DisciplineSearch(); $dataProvider = $searchModel->search($id_program, Yii::$app->request->queryParams); Yii::$app->session->set('disciplinePage', Yii::$app->request->get('page')); return $this->render('index', ['program' => $program, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
public function actionIndex($id_program) { $id_student = Yii::$app->user->identity->id_student; $program = Program::findOne($id_program); $searchModel = new StudentSearch(); $dataProvider = $searchModel->search($id_program, $id_student, Yii::$app->request->queryParams); Yii::$app->session->set('studentPage', Yii::$app->request->get('page')); return $this->render('index', ['program' => $program, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
protected function getIdFaculty($id, $parent = false) { if ($parent) { return $id; } else { $model = Program::findOne($id); return $model->id_faculty; } }
protected function getIdFaculty($id, $parent = false) { if ($parent) { $model = Program::findOne($id); return $model->id_faculty; } else { $model = ProgramFile::find()->where(['id_file' => $id])->one(); return $this->getIdFaculty($model->id_program, true); } }
public function items($id_faculty) { $items = []; $models = Program::find()->where(['id_faculty' => $id_faculty])->orderBy('code')->all(); foreach ($models as $model) { $this->model = $model; $items[] = ['header' => $this->disciplinesLink(), 'content' => $this->programContent()]; } return $items; }
public function actionProgram($id) { /* @var $model \common\models\Program */ Yii::$app->response->format = Response::FORMAT_JSON; $programs = []; $models = Program::find()->where(['id_faculty' => $id])->all(); foreach ($models as $model) { $programs[] = $model->toArray(['id'], ['fullName']); } ArrayHelper::multisort($programs, 'fullName'); return $programs; }
/** * @return \yii\db\ActiveQuery */ public function getIdProgram() { return $this->hasOne(Program::className(), ['id' => 'id_program']); }
<?php use yii\grid\GridView; use yii\helpers\Html; use yii\widgets\Pjax; use common\models\Program; use common\models\Discipline; /* @var $this yii\web\View */ /* @var $provider yii\data\ActiveDataProvider */ /* @var $program Program */ /* @var $idParent integer */ require Yii::$app->basePath . '/views/grid/index.php'; $program = Program::findOne($idParent); $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']);
<?php use yii\grid\GridView; use yii\helpers\Html; use yii\widgets\Pjax; use common\models\Program; use common\models\Discipline; /* @var $this yii\web\View */ /* @var $provider yii\data\ActiveDataProvider */ /* @var $program Program */ /* @var $discipline Discipline */ /* @var $idParent integer */ require Yii::$app->basePath . '/views/grid/index.php'; $discipline = Discipline::findOne($idParent); $program = Program::findOne($discipline->id_program); $this->title = 'Семестры'; $this->params['breadcrumbs'][] = ['label' => 'Образовательные программы', 'url' => ['/program', 'idParent' => $program->id_faculty]]; $this->params['breadcrumbs'][] = ['label' => 'Дисциплины', 'url' => ['/discipline', 'idParent' => $discipline->id_program, 'page' => Yii::$app->session->get('disciplinePage')]]; $this->params['breadcrumbs'][] = $this->title; ?> <h2>Семестры</h2> <h3> Дисциплина: <?php echo $discipline->fullName; ?> </h3> <p> <?php echo Html::a('Новый семестр', ['create', 'idParent' => $idParent], ['class' => 'btn btn-success actionCreate']); ?>
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use common\models\Program; /* @var $this yii\web\View */ /* @var $model common\models\ProgramHeader */ /* @var $form yii\widgets\ActiveForm */ $program = new Program(); $attributes = $program->availableAttributes(); $labels = $program->attributeLabels(); $fields = []; foreach ($attributes as $attribute) { $fields[$attribute] = $labels[$attribute]; } ?> <?php $form = ActiveForm::begin(['id' => 'updateForm']); ?> <?php echo $form->field($model, 'field_shown')->dropDownList($fields); ?> <div class="form-group submitBlock"> <?php echo Html::submitButton('Сохранить', ['class' => 'btn btn-success', 'name' => 'submitButton']); ?> </div>
<?php use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\ActiveForm; use common\models\Faculty; use common\models\Program; $facultyList = Faculty::getFacultyList(); if ($model->isNewRecord) { $program = Program::find()->joinWith('idFaculty')->orderBy('faculty.name')->one(); $model->id_program = $program->id; } ?> <?php $form = ActiveForm::begin(['id' => 'updateForm']); ?> <?php echo $form->field($model, 'year')->textInput(); echo $form->field($model, 'course')->textInput(); echo $form->field($model, 'group')->textInput(['maxlength' => true]); echo $form->field($model, 'idFaculty')->dropDownList($facultyList, ['id' => 'faculties', 'data-url' => Url::to(['/student/history/program'])]); echo $form->field($model, 'id_program')->dropDownList([], ['id' => 'program']); ?> <?php // Факультет // Программа ?>
$this->params['breadcrumbs'][] = $this->title; ?> <h2>Отображение наименования</h2> <h3> Образовательная программа: <?php echo $program->fullName; ?> </h3> <p> <?php echo $program->fullContent; ?> </p> <p> <?php echo Html::a('Новое поле в наименовании', ['create', 'idParent' => $idParent], ['class' => 'btn btn-success actionCreate']); ?> </p> <?php Pjax::begin(['options' => ['id' => 'pjaxWrap']]); echo GridView::widget(['dataProvider' => $provider, 'columns' => [['attribute' => 'field_shown', 'format' => 'text', 'value' => function ($model, $key, $index, $column) { $program = new Program(); $labels = $program->attributeLabels(); return $labels[$model->field_shown]; }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}{delete}', 'buttons' => ['update' => 'actionUpdate', 'delete' => 'actionDelete']]]]); ?> <?php Pjax::end();
<?php /* @var $this yii\web\View */ /* @var $provider yii\data\ActiveDataProvider */ /* @var $student \common\models\StudentEducation */ use common\models\Program; use yii\widgets\Pjax; use yii\grid\GridView; use common\models\Discipline; use yii\helpers\Html; use yii\helpers\Url; use backend\assets\GridAsset; GridAsset::register($this); /* @var $program Program */ $program = Program::findOne($student->id_program); $this->title = 'Результаты'; $this->params['breadcrumbs'][] = ['label' => 'Образовательные программы', 'url' => ['/program', 'idParent' => $program->id_faculty]]; $this->params['breadcrumbs'][] = ['label' => 'Студенты', 'url' => ['main/index', 'idParent' => $student->id_program, 'page' => Yii::$app->session->get('studentPage')]]; $this->params['breadcrumbs'][] = $this->title; ?> <h2>Результаты</h2> <h3> Студент: <?php echo $student->studentName; ?> Курс: <?php echo $student->course; ?> </h3>
/** * @return \yii\db\ActiveQuery */ public function getProgram() { return $this->hasOne(Program::className(), ['id' => 'program_id']); }
public function getFieldShownLabel() { $program = new Program(); $labels = $program->attributeLabels(); return $labels[$this->field_shown]; }
/** * @return \yii\db\ActiveQuery */ public function getPrograms() { return $this->hasMany(Program::className(), ['id_faculty' => 'id']); }