Esempio n. 1
0
 public function actionCreate()
 {
     $model = new FormGastos();
     $msg = null;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $table = new Gastos();
             $table->ID_VIAJE = $model->id_viaje;
             $table->NOMBRE_GASTO = $model->nombregasto;
             $table->MONTO_GASTO = $model->montogasto;
             $table->FECHA_GASTO = $model->fechagasto;
             if ($table->insert()) {
                 $msg = "Registro guardado correctamente";
                 $model->id_viaje = null;
                 $model->nombregasto = null;
                 $model->montogasto = null;
                 $model->fechagasto = null;
             } else {
                 $msg = "Ha ocurrido un error";
             }
         } else {
             $model->getErrors();
         }
     }
     return $this->render("create", ['model' => $model, 'msg' => $msg]);
 }
Esempio n. 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGastos()
 {
     return $this->hasMany(Gastos::className(), ['ID_ESTADO_GASTO' => 'ID_ESTADO_GASTO']);
 }