Exemplo n.º 1
0
 public function actionCrearTViaje()
 {
     PermisosController::permisoAdministrador();
     $model = new TipoViajeForm();
     $msg = null;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $table = new TipoViaje();
             $table->NOMBRE_TIPO_DE_VIAJE = $model->nombre_tipo_viaje;
             $table->MONTO_MAXIMO = $model->monto_maximo;
             if ($table->insert()) {
                 $msg = '<div class="alert alert-success" role="alert"><strong>Guardado!</strong> Tipo de viaje agregado correctamente.</div>';
                 $model->nombre_tipo_viaje = null;
                 $model->monto_maximo = null;
             } else {
                 $msg = '<div class="alert alert-danger" role="alert"><strong>Error!</strong> No se pudo agregar el Tipo de Viaje.</div>';
             }
             $table = new TipoViaje();
             $model = $table->find()->all();
             return $this->render("tipo-viaje", ["model" => $model, 'msg' => $msg]);
         } else {
             $model->getErrors();
         }
     }
     return $this->render("crear-tipo-viaje", ['model' => $model, 'msg' => $msg]);
 }