/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Teachers::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     $dataProvider->setSort(['attributes' => ['id_cathedra' => ['asc' => ['cathedra.cathedra_name' => SORT_ASC], 'desc' => ['cathedra.cathedra_name' => SORT_DESC]], 'teacher_name' => ['asc' => ['teacher_name' => SORT_ASC], 'desc' => ['teacher_name' => SORT_DESC]], 'id_position' => ['asc' => ['position_name' => SORT_ASC], 'desc' => ['position_name' => SORT_DESC]], 'id_academic_status' => ['asc' => ['academic_status_name' => SORT_ASC], 'desc' => ['academic_status_name' => SORT_DESC]]]]);
     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('position');
     $query->joinWith('academicStatus');
     $query->joinWith('cathedra');
     $query->andFilterWhere(['teacher_id' => $this->teacher_id]);
     $query->andFilterWhere(['like', 'teacher_name', $this->teacher_name])->andFilterWhere(['like', 'position_name', $this->id_position])->andFilterWhere(['like', 'academic_status_name', $this->id_academic_status])->andFilterWhere(['like', 'cathedra_name', $this->id_cathedra]);
     return $dataProvider;
 }
Example #2
0
           
            <?php 
echo $form->field($model, 'all_speciality')->checkbox();
?>
        </div>
    </div>
    <?php 
echo $form->field($model, 'id_discipline')->widget(Select2::classname(), ['data' => $discipline_array, 'language' => 'uk', 'pluginOptions' => ['allowClear' => true], 'options' => ['onchange' => '
                $.post("index.php?r=timetable/lessons/teacher_by_cathedra&id=' . '"+$(this).val(), function( data ) {
                  $( "select#lessons-id_teacher" ).html( data );
                });
            ']])->label('Дисципліна');
?>
    
    <?php 
echo $form->field($model, 'id_teacher')->widget(Select2::classname(), ['data' => ArrayHelper::map(Teachers::find()->all(), 'teacher_id', 'teacher_name'), 'language' => 'uk', 'pluginOptions' => ['allowClear' => true]])->label('Викладач');
?>
    
    <?php 
echo $form->field($model, 'no_check')->checkbox(['onchange' => '
                $.post("index.php?r=timetable/lessons/class_list&id=' . '"+$(this).prop("checked")+"&seats=' . '"+' . $sig . ', function( data ) {
                  $( "select#lessons-id_classroom" ).html( data );
                });
        '])->label(false);
?>
    
    <?php 
echo $form->field($model, 'id_classroom')->widget(Select2::classname(), ['data' => $classroomsArray, 'language' => 'uk', 'pluginOptions' => ['allowClear' => true]])->label('Аудиторія і корпус');
?>
 
    
 public function actionTeacher_by_cathedra($id)
 {
     $cathedra_id = Discipline::findOne(['discipline_distribution_id' => $id]);
     $countPosts = Teachers::find()->where(['id_cathedra' => $cathedra_id['id_cathedra']])->count();
     $posts = Teachers::find()->where(['id_cathedra' => $cathedra_id['id_cathedra']])->orderBy('teacher_name ASC')->all();
     if ($countPosts > 0) {
         echo "<option>Оберіть викладача</option>";
         foreach ($posts as $post) {
             echo "<option value='" . $post->teacher_id . "'>" . $post->teacher_name . "</option>";
         }
     } else {
         echo "<option>-</option>";
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdTeacher()
 {
     return $this->hasOne(Teachers::className(), ['teacher_id' => 'id_teacher']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTeachers()
 {
     return $this->hasMany(Teachers::className(), ['id_position' => 'position_id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTeachers()
 {
     return $this->hasMany(Teachers::className(), ['id_academic_status' => 'academic_status_id']);
 }
 /**
  * Finds the Teachers model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Teachers the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Teachers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #8
0
function getTeacherName($id_teacher)
{
    $teacher = Teachers::findOne(['teacher_id' => $id_teacher]);
    return $teacher['teacher_name'];
}