/**
  * Finds the Student model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Student the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findStudentModel($id)
 {
     $student = Student::findOne($id);
     if (!isset($student)) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     return $student;
 }
Exemplo n.º 2
0
 public function getAllStudentsAsMappedArray($condition = null, $userId = null)
 {
     $userId = isset($userId) ? $userId : Yii::$app->user->id;
     $models = Student::find()->where(['user_id' => $userId]);
     if (isset($condition)) {
         $models->andWhere($condition);
     }
     return ArrayHelper::map($models->all(), 'id', 'fullname');
 }
Exemplo n.º 3
0
 /**
  * Новая модель student и связанная с ней новая модель student_education
  * @return mixed
  */
 public function actionCreate($idParent = null)
 {
     /* @var $student Student */
     /* @var $studentEducation StudentEducation */
     $student = new Student();
     $studentEducation = new StudentEducation();
     $studentEducation->id_program = $idParent;
     if ($student->load(Yii::$app->request->post()) && $student->save()) {
         $studentEducation->load(Yii::$app->request->post());
         $studentEducation->id_student = $student->id;
         $studentEducation->year = YearHelper::getYear();
         $studentEducation->save();
         return 'Item is succesfully created.';
         // alert message
     } else {
         return $this->renderAjax('update', ['student' => $student, 'studentEducation' => $studentEducation]);
     }
 }
Exemplo n.º 4
0
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Student::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->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'lesson_cost' => $this->lesson_cost, 'is_active' => $this->is_active, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'avatar', $this->avatar]);
     return $dataProvider;
 }
Exemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Student::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['fullname' => ['asc' => ['user.last_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC]], 'groupName' => ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC]], 'srb']]);
     $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, 'user_id' => $this->user_id, 'group_id' => $this->group_id, 'education_start_date' => $this->education_start_date, 'education_end_date' => $this->education_end_date, 'srb' => $this->srb]);
     $query->joinWith(['user' => function ($q) {
         $q->where('user.first_name LIKE "%' . $this->fullname . '%" ' . 'OR user.last_name LIKE "%' . $this->fullname . '%"' . 'OR user.middle_name LIKE "%' . $this->fullname . '%"');
     }]);
     $query->joinWith(['group' => function ($q) {
         $q->where('group.name LIKE "%' . $this->groupName . '%" ');
     }]);
     return $dataProvider;
 }
 public function actionUpdateStudent($studentId)
 {
     $student = Student::findOne($studentId);
     $studentAppointment = null;
     if (empty($student->studentAppointments)) {
         $studentAppointment = new StudentAppointment();
         $studentAppointment->student_id = $studentId;
     } else {
         $studentAppointment = $student->studentAppointments[0];
     }
     if (!isset($student)) {
         throw new HttpException(404, 'The requested page does not exist.');
     }
     if ($student->load(Yii::$app->request->post()) && $student->save() && $studentAppointment->load(Yii::$app->request->post()) && $studentAppointment->save()) {
         if ($student->avatarManager->isImageSavedToDiskOk) {
             Yii::$app->session->setFlash('info', Yii::t('app', "{$student} updated successfully"));
         } else {
             Yii::$app->session->setFlash('info', Yii::t('app', 'There was some error uploading your avatar Image'));
         }
         return $this->redirect(['default/list-students']);
     }
     return $this->render('update-student', compact('student', 'studentAppointment'));
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStudent()
 {
     return $this->hasOne(\common\models\Student::className(), ['id' => 'student_id']);
 }
 /**
  * Finds the Student model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Student the loaded model
  * @throws HttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Student::findOne($id)) !== null) {
         return $model;
     } else {
         throw new HttpException(404, 'The requested page does not exist.');
     }
 }
Exemplo n.º 9
0
 public function getSteward()
 {
     return $this->hasOne(Student::className(), ['id' => 'steward_student_id']);
 }
Exemplo n.º 10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStudents()
 {
     return $this->hasMany(\common\models\Student::className(), ['user_id' => 'id']);
 }
Exemplo n.º 11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdStudent()
 {
     return $this->hasOne(Student::className(), ['id' => 'id_student']);
 }
Exemplo n.º 12
0
 public function actionStudentfromgroup()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $cat_id = $parents[0];
             $ghd = \common\models\Student::find()->where(['group_id' => $cat_id])->all();
             $out = \yii\helpers\ArrayHelper::map($ghd, 'id', 'user.fullname');
             $arr = array();
             foreach ($out as $key => $o) {
                 $arr[$key]['id'] = $key;
                 $arr[$key]['name'] = $o;
             }
             echo Json::encode(['output' => $arr, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
Exemplo n.º 13
0
<div class="group-form">

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

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

    <?php 
echo $form->field($model, 'speciality_id')->dropDownList(ArrayHelper::map(Speciality::find()->all(), 'id', 'name'));
?>
    
    <?php 
echo $form->field($model, 'steward_student_id')->dropDownList(ArrayHelper::map(Student::find()->where(['group_id' => $model->id])->all(), 'id', 'user.fullname'), ['prompt' => '-- Выберите студента --']);
?>
        
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Добавить' : 'Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 14
0
 public function getStudent()
 {
     return $this->hasOne(Student::className(), ['user_id' => 'id']);
 }
Exemplo n.º 15
0
 /**
  * @inheritdoc
  * Удаляем связанную дисциплину, если не осталось для нее записи с именем
  */
 public function afterDelete()
 {
     if (!static::find()->where(['id_student' => $this->id_student_cached])->exists()) {
         Student::findOne($this->id_student_cached)->delete();
     }
 }