/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cathedra::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('faculty');
     $dataProvider->setSort(['attributes' => ['cathedra_name' => ['asc' => ['cathedra_name' => SORT_ASC], 'desc' => ['cathedra_name' => SORT_DESC], 'label' => 'Факультет/спеціальність'], 'id_faculty' => ['asc' => ['faculty.faculty_name' => SORT_ASC], 'desc' => ['faculty.faculty_name' => SORT_DESC], 'label' => 'Факультет/спеціальність']]]);
     $query->andFilterWhere(['cathedra_id' => $this->cathedra_id, 'id_edbo' => $this->id_edbo, 'id_deanery' => $this->id_deanery]);
     $query->andFilterWhere(['like', 'cathedra_name', $this->cathedra_name])->andFilterWhere(['like', 'faculty.faculty_name', $this->id_faculty]);
     return $dataProvider;
 }
Example #2
0
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\module\handbook\models\TeachersOtherCathedra;
use app\module\handbook\models\Cathedra;
/* @var $this yii\web\View */
/* @var $model app\module\handbook\models\Teachers */
$this->title = $model->teacher_name;
$this->params['breadcrumbs'][] = ['label' => 'Викладачі', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$optionsId = TeachersOtherCathedra::findAll(['id_teacher' => $model->teacher_id]);
for ($i = 0; $i < count($optionsId); $i++) {
    $optionName[] = Cathedra::findAll(['cathedra_id' => $optionsId[$i]['id_cathedra']]);
    $optionsArray[] = $optionName[$i][0]['cathedra_name'] . " ";
}
$optionsString = implode($optionsArray);
?>
<div class="teachers-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Оновити', ['update', 'id' => $model->teacher_id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Видалити', ['delete', 'id' => $model->teacher_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCathedra()
 {
     return $this->hasOne(Cathedra::className(), ['cathedra_id' => 'id_cathedra']);
 }
Example #4
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\module\handbook\models\Cathedra;
use app\module\handbook\models\Faculty;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $model app\module\handbook\models\Speciality */
/* @var $form yii\widgets\ActiveForm */
$all_faculty = Faculty::find()->orderBy('faculty_name ASC')->all();
foreach ($all_faculty as $af) {
    $tmp_cathedra = Cathedra::find()->where(['id_faculty' => $af['faculty_id']])->orderBy('cathedra_name ASC')->all();
    foreach ($tmp_cathedra as $tc) {
        $all_cathedra[$tc['cathedra_id']] = $tc['cathedra_name'] . " / " . $af['faculty_name'];
    }
}
?>

<div class="speciality-form">

    <?php 
$form = ActiveForm::begin();
?>

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

    <?php 
 /**
  * Finds the Cathedra model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Cathedra the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cathedra::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }