private function saveUbicacionExterna($acervo_id, $ubicacion, $finicio, $fcierre) { $fi = $finicio; $ff = $fcierre; if (isset($acervo_id) && is_array($ubicacion) && array_key_exists('ubicacion', $ubicacion) && isset($ubicacion['ubicacion']) && trim($ubicacion['ubicacion']) != '') { if (isset($finicio) && strlen($finicio) > 0) { list($dia, $mes, $anio) = explode("/", $finicio); $fi = $anio . '-' . $mes . '-' . $dia; } if (isset($fcierre) and strlen($fcierre) > 0) { list($dia2, $mes2, $anio2) = explode("/", $fcierre); $ff = $anio2 . '-' . $mes2 . '-' . $dia2; } // var_dump($finicio); // var_dump($fcierre);die(); $ue = new \app\models\UbicacionExterna(); $ue->acervo_id = $acervo_id; $ue->fechaInicio = $fi; $ue->fechaCierre = $ff; $ue->ubicacion = $ubicacion['ubicacion']; if ($ue->save()) { return $ue; } } return false; }
/** * Creates a new UbicacionExterna model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UbicacionExterna(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }