/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Curso::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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(['idcurso' => $this->idcurso]); $query->andFilterWhere(['like', 'nome', $this->nome]); return $dataProvider; }
public function actionFiltro($tipo) { $provaModel = new ProvaSearch(); $provaProvider = $provaModel->search(Yii::$app->request->queryParams); $ditems = ArrayHelper::map(Disciplina::find()->all(), 'nome', 'nome'); $citems = ArrayHelper::map(Curso::find()->all(), 'idcurso', 'nome'); $pitems = ArrayHelper::map(Predio::find()->where(['unidade' => '1'])->all(), 'idpredio', 'nome'); $sitems = ArrayHelper::map(Sala::find()->all(), 'idsala', 'nome'); $eitems = ArrayHelper::map(Exame::find()->all(), 'idexame', 'nome'); if ($provaModel->load(Yii::$app->request->get())) { return $this->render('frequencia', ['dataProvider' => $provaProvider, 'searchModel' => $provaModel]); } else { return $this->render('filtro', ['provaModel' => $provaModel, 'provaProvider' => $provaProvider, 'ditems' => $ditems, 'citems' => $citems, 'pitems' => $pitems, 'sitems' => $sitems, 'eitems' => $eitems, 'tipo' => $tipo]); } }
/** * Finds the Curso model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Curso the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Curso::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getCurso() { return $this->hasOne(Curso::className(), ['idcurso' => 'curso_idcurso']); }
?> </aside> </div> <div class="prova-index" style='clear : left'> <h1><?php echo Html::encode($this->title); ?> </h1> <?php $disciplinaArray = ArrayHelper::map(\backend\models\Disciplina::find()->orderBy('nome')->where([])->all(), 'iddisciplina', 'nome', 'curso.nome'); ?> <?php $predioArray = ArrayHelper::map(\backend\models\Predio::find()->orderBy('nome')->where(['unidade' => 1])->all(), 'idpredio', 'nome'); ?> <?php $cursoArray = ArrayHelper::map(\backend\models\Curso::find()->orderBy('nome')->where([])->all(), 'idcurso', 'nome'); ?> <?php Yii::$app->view->params['candidato'] = $model->candidato_idcandidato; ?> <?php Yii::$app->view->params['curso'] = $model->curso_idcurso; ?> <?php $form = ActiveForm::begin(['method' => 'post', 'action' => ['inscricao/create', 'idcandidato' => $model->candidato_idcandidato, 'idcurso' => $model->curso_idcurso]]); ?> <?php echo $form->errorSummary($model);