/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $way = null) { if ($way == null) { $query = GivenTask::find(); } else { $query = $way; } $query->joinWith('user'); $query->joinWith('groupHasDiscipline'); $query->joinWith('task'); $query->joinWith('student')->joinWith('student.group'); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['status' => SORT_ASC, 'given_date' => SORT_DESC]]]); $dataProvider->setSort(['attributes' => ['studentFullname' => ['asc' => ['user.last_name' => SORT_ASC, 'user.middle_name' => SORT_ASC, 'user.first_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC, 'user.middle_name' => SORT_DESC, 'user.first_name' => SORT_DESC]], 'teacherFullname' => ['asc' => ['user.last_name' => SORT_ASC, 'user.middle_name' => SORT_ASC, 'user.first_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC, 'user.middle_name' => SORT_DESC, 'user.first_name' => SORT_DESC]], 'group' => ['asc' => ['student.group.name' => SORT_ASC], 'desc' => ['student.group.name' => SORT_DESC]], 'id', 'status']]); $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; } $query->andFilterWhere(['id' => $this->id, 'given_task.given_date' => $this->given_date, 'given_task.teacher_id' => $this->teacher_id, 'given_task.status' => $this->status, 'given_task.result' => $this->result, 'given_task.complete_date' => $this->complete_date]); $query->andFilterWhere(['like', 'comment', $this->comment])->andFilterWhere(['like', 'group_key', $this->group_key])->andFilterWhere(['like', 'task.name', $this->task_id]); //->andFilterWhere(['like','user.last_name',$this->student_id]); $query->joinWith(['task' => function ($q) { $q->where('task.name LIKE "%' . $this->taskName . '%" '); }]); $query->joinWith('student')->joinWith(['student.user as suser' => function ($q) { $q->where('suser.first_name LIKE "%' . $this->studentFullname . '%" ' . 'OR suser.last_name LIKE "%' . $this->studentFullname . '%"' . 'OR suser.middle_name LIKE "%' . $this->studentFullname . '%"'); }]); $query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.discipline' => function ($q) { $q->where('discipline.name LIKE "%' . $this->disciplineName . '%" '); }]); $query->joinWith('teacher')->joinWith(['teacher.user as tuser' => function ($q) { $q->where('tuser.first_name LIKE "%' . $this->teacherFullname . '%" ' . 'OR tuser.last_name LIKE "%' . $this->teacherFullname . '%"' . 'OR tuser.middle_name LIKE "%' . $this->teacherFullname . '%"'); }]); $query->joinWith('student')->joinWith(['student.group as sgroup' => function ($q) { $q->where('sgroup.name LIKE "%' . $this->group . '%"'); }]); return $dataProvider; }
public function getNewTasksCheckCount() { return GivenTask::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->andWhere(['status' => '1'])->count(); }
/** * @get given tasks */ public function getGivenTasks() { return $this->hasMany(GivenTask::className(), ['task_id' => 'id']); }
public function actionExersicelistbytype($id) { $arr = GivenTask::listToArray($id); $exersices = Exercise::find()->where(['subject_id' => $arr])->all(); return $this->renderAjax('_exersicelistbytype', ['exersices' => $exersices]); }
/** * @get given task */ public function getGivenTask() { return $this->hasOne(GivenTask::className(), ['id' => 'given_task_id']); }
/** * Finds the GivenTask model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return GivenTask the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = GivenTask::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getTasksCount() { return GivenTask::find()->where(['student_id' => $this->id])->count(); }
public static function newTakenTasksCount() { return GivenTask::find()->where(['student_id' => Yii::$app->user->identity->student->id])->andWhere(['!=', 'status', '3'])->count(); }
public function actionPdfTask($id) { $model = GivenTask::findOne($id); return $this->render('pdf-task', ['model' => $model]); $content = $this->renderPartial('pdf-task', ['model' => $model]); $pdf = Yii::$app->pdf; $pdf->options = ['title' => $model->task->name]; //$content = preg_replace("/$$([^&]*)$$/", 1488,$content); //preg_match("/($$)(.*)($$)/", $content, $eq); $pdf->content = $content; $pdf->render(); //return $this->render('pdf-task-view',['mod' => $pdf]); }