/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Disciplina::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(['iddisciplina' => $this->iddisciplina, 'opcao' => $this->opcao, 'curso_idcurso' => $this->curso_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]); } }
/** * @return \yii\db\ActiveQuery */ public function getDisciplina() { return $this->hasOne(Disciplina::className(), ['iddisciplina' => 'iddisciplina']); }
/** * Finds the Disciplina model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Disciplina the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Disciplina::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php $horarioArray = ArrayHelper::map(\backend\models\Horario::find()->orderBy('descricao')->where(['exame_idexame' => $model->calendario->exame_idexame])->all(), 'idhorario', 'descricao'); ?> <?php echo $form->field($model, 'horario_idhorario')->dropDownList($horarioArray, ['prompt' => '---- Selecione um Horário ----'])->label('Horário'); ?> <?php $predioArray = ArrayHelper::map(\backend\models\Predio::find()->orderBy('nome')->where(['unidade' => 1])->all(), 'idpredio', 'nome'); ?> <?php echo $form->field($model, 'predio_idpredio')->dropDownList($predioArray, ['prompt' => '---- Selecione uma Unidade ----'])->label('Unidade'); ?> <?php $disciplinaArray = ArrayHelper::map(\backend\models\Disciplina::find()->orderBy('nome')->all(), 'iddisciplina', 'nome'); ?> <?php echo $form->field($model, 'disciplina_iddisciplina')->dropDownList($disciplinaArray, ['prompt' => '---- Selecione uma Disciplina ----'])->label('Disciplina'); ?> <?php echo $form->field($model, 'segunda_chamada')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getDisciplinas() { return $this->hasMany(Disciplina::className(), ['opcao' => 'id']); }