/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tipo::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(['idtipo' => $this->idtipo]); $query->andFilterWhere(['like', 'titulo', $this->titulo]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIdTipo() { return $this->hasOne(Tipo::className(), ['id' => 'id_tipo']); }
/** * Displays a single Puertos model. * @param integer $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); $model->tipo = Tipo::findNameById($model->tipo); return $this->render('view', ['model' => $model]); }
use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Tipo; /* @var $this yii\web\View */ /* @var $model app\models\Puertos */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="puertos-form"> <?php $form = ActiveForm::begin(); ?> <?php echo Html::activeDropDownList($model, 'tipo', ArrayHelper::map(Tipo::getTypes(), 'id', 'name'), ['class' => 'form-control']); ?> <?php echo $form->field($model, 'nombre')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'ubicacion')->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>
/** * Creates a new ItemProgramacao model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $this->validaAjax(); $this->autorizaUsuario(Yii::$app->request->get('idevento')); $model = new ItemProgramacao(); $model->notificacao = '1'; $model->evento_idevento = Yii::$app->request->get('idevento'); $model->data = filter_input(INPUT_GET, 'data'); $model->hora = filter_input(INPUT_GET, 'hora'); $model->horaFim = filter_input(INPUT_GET, 'horafim'); if ($model->horaFim == null) { $model->horaFim = date('H:i', strtotime('+2 hour', strtotime($model->hora))); } if (!($model->tipo_idtipo = filter_input(INPUT_GET, 'tipo'))) { if ($tipo = filter_input(INPUT_GET, 'titulo')) { $arrayTipo = ArrayHelper::map(Tipo::find()->all(), 'idtipo', 'titulo'); $model->tipo_idtipo = array_search($tipo, $arrayTipo); } else { return $this->redirect(['index', 'idevento' => $model->evento_idevento]); } } $arrayPalestrante = ArrayHelper::map(Palestrante::find()->all(), 'idPalestrante', 'nome'); $arrayLocal = ArrayHelper::map(Local::find()->all(), 'idlocal', 'descricao'); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { $this->mensagens('success', "Item '" . $model->titulo . "' foi Adicionado", 'O Item de Programação foi adicionado com sucesso'); return $this->redirect(['index', 'idevento' => $model->evento_idevento]); } else { $this->mensagens('danger', "Item '" . $model->titulo . "' Não Adicionado", 'Houve um erro ao adicionar Item de Programacão. Verifique os dados informados e tente novamente'); return $this->redirect(['index', 'idevento' => $model->evento_idevento]); } } else { return $this->renderAjax('create', ['model' => $model, 'arrayLocal' => $arrayLocal, 'arrayPalestrante' => $arrayPalestrante]); } }
<div class="tarea-tipo-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'idtarea_tipo')->textInput(); ?> <?php echo $form->field($model, 'idTareas')->dropDownList(ArrayHelper::map(Tareas::find()->all(), 'idTareas', 'Tarea'), ['prompt' => 'Seleccione Tarea']); ?> <?php echo $form->field($model, 'idTipo')->dropDownList(ArrayHelper::map(Tipo::find()->all(), 'idTipo', 'Tipo'), ['prompt' => 'Seleccione Tipo']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
?> <?php echo $form->field($model, 'id_examen')->dropDownList(ArrayHelper::map(Examen::find()->where(['eliminado' => 0])->all(), 'id', 'nombre'), ['prompt' => 'seleccione el examen']); ?> <?php echo $form->field($model, 'file')->fileInput(); ?> <?php echo $form->field($model, 'id_area')->dropDownList(ArrayHelper::map(Area::find()->where(['eliminado' => 0])->all(), 'id', 'nombre'), ['prompt' => 'Seleccione el area']); ?> <?php echo $form->field($model, 'id_tipo')->radioList(ArrayHelper::map(\app\models\Tipo::find()->all(), 'id', 'nombre'))->label(false); ?> <div class="row"> <div class="panel panel-default"> <div class="panel-heading"> <h4><i class="glyphicon glyphicon-question-sign"></i> Respuestas</h4></div> <div class="panel-body"> <?php DynamicFormWidget::begin(['widgetContainer' => 'dynamicform_wrapper', 'widgetBody' => '.container-items', 'widgetItem' => '.item', 'limit' => 4, 'min' => 0, 'insertButton' => '.add-item', 'deleteButton' => '.remove-item', 'model' => $modelRespuestaExamen[0], 'formId' => 'dynamic-form', 'formFields' => ['nombre_opcion', 'descripcion_respuesta', 'puntos_otorgados', 'imgfile']]); ?> <div class="container-items"><!-- widgetContainer --> <?php foreach ($modelRespuestaExamen as $i => $modelRespuestaExamen) {
/** * Finds the Tipo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Tipo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Tipo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getTipo() { return $this->hasOne(Tipo::className(), ['idtipo' => 'tipo_idtipo']); }
/** * Updates an existing Evento model. * If update is successful, the browser will be redirected to the 'view' page. * @param string $id * @return mixed */ public function actionUpdate($id) { $this->autorizaUsuario(); $model = $this->findModel($id); !$model->canAccess() ? $this->redirect(['evento/index']) : ($imagem = $model->imagem2); $arrayPalestrante = ArrayHelper::map(Palestrante::find()->all(), 'idPalestrante', 'nome'); $arrayLocal = ArrayHelper::map(Local::find()->all(), 'idlocal', 'descricao'); $arrayTipo = ArrayHelper::map(Tipo::find()->all(), 'idtipo', 'titulo'); if ($model->load(Yii::$app->request->post())) { $model->imagem2 = $model->upload(UploadedFile::getInstance($model, 'imagem2'), 'uploads/identidade/'); if ($model->imagem2 == null) { $model->imagem2 = $imagem; } if (!$model->save(true)) { return $this->render('update', ['model' => $model, 'arrayTipo' => $arrayTipo, 'arrayLocal' => $arrayLocal, 'arrayPalestrante' => $arrayPalestrante]); } $this->mensagens('success', 'Evento Atualizado', 'Evento atualizado com Sucesso'); return $this->redirect(['evento/identidade', 'idevento' => $model->idevento]); } else { return $this->render('update', ['model' => $model, 'arrayTipo' => $arrayTipo, 'arrayLocal' => $arrayLocal, 'arrayPalestrante' => $arrayPalestrante]); } }