/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Prova::find()->orderBy('horario_idhorario'); $query->joinWith(['disciplina', 'inscricaoProvaSalas', 'calendario']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['disciplina'] = ['asc' => ['disciplina.nome' => SORT_ASC], 'desc' => ['disciplina.nome' => SORT_DESC]]; $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(['idprova' => $this->idprova, 'calendario_idcalendario' => $this->calendario_idcalendario, 'horario_idhorario' => $this->horario_idhorario, 'disciplina_iddisciplina' => $this->disciplina_iddisciplina, 'predio_idpredio' => $this->predio_idpredio, 'segunda_chamada' => $this->segunda_chamada, 'disciplina.curso_idcurso' => $this->idcurso, 'exame_idexame' => $this->idexame])->andFilterWhere(['like', 'disciplina.nome', $this->disciplina])->andFilterWhere(['like', 'inscricaoProvaSalas.sala.nome', $this->nomesala])->andFilterWhere(['like', 'disciplina.curso.nome', $this->nomecurso])->andFilterWhere(['=', 'sala_idsala', $this->idsala]); //->andFilterWhere(['=','exame_idexame', $this->idexame]) return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Prova::find()->orderBy('horario_idhorario'); $query->joinWith(['disciplina']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['disciplina'] = ['asc' => ['disciplina.nome' => SORT_ASC], 'desc' => ['disciplina.nome' => SORT_DESC]]; $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; } $vencidas = Notas::find()->from(['notas'])->where(['and', 'idcandidato = ' . $this->idcandidato, 'nota >= nota_minima'])->select('iddisciplina'); $query->andFilterWhere(['idprova' => $this->idprova, 'calendario_idcalendario' => $this->calendario_idcalendario, 'horario_idhorario' => $this->horario_idhorario, 'disciplina_iddisciplina' => $this->disciplina_iddisciplina, 'predio_idpredio' => $this->predio_idpredio, 'segunda_chamada' => $this->segunda_chamada])->andFilterWhere(['like', 'disciplina.name', $this->disciplina])->andFilterWhere(['not in', 'disciplina_iddisciplina', $vencidas]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getProvas() { return $this->hasMany(Prova::className(), ['calendario_idcalendario' => 'idcalendario']); }
/** * @return \yii\db\ActiveQuery */ public function getProvas() { return $this->hasMany(Prova::className(), ['exame_idexame' => 'idexame']); }
/** * @return \yii\db\ActiveQuery */ public function getProvas() { return $this->hasMany(Prova::className(), ['disciplina_iddisciplina' => 'iddisciplina']); }
/** * @return \yii\db\ActiveQuery */ public function getProva() { return $this->hasOne(Prova::className(), ['idprova' => 'prova_idprova']); }
public function afterSave($insert, $changedAttributes) { if ($insert) { $provasSel = Prova::find()->where('idprova in (' . implode(",", $this->provasIds) . ')')->all(); foreach ($provasSel as $p) { $this->link('provas', $p); } } parent::afterSave($insert, $changedAttributes); }
/** * Finds the Prova model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Prova the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Prova::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getProvas() { return $this->hasMany(Prova::className(), ['segunda_chamada' => 'idprova']); }
/** * @return \yii\db\ActiveQuery */ public function getProvaIdprovas() { return $this->hasMany(Prova::className(), ['idprova' => 'prova_idprova'])->viaTable('prova_has_sala', ['sala_idsala' => 'idsala']); }
/** * @return \yii\db\ActiveQuery */ public function getProvas() { return $this->hasMany(Prova::className(), ['predio_idpredio' => 'idpredio']); }