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; }
/** * @return \yii\db\ActiveQuery */ public function getUbicacionExternas() { return $this->hasMany(UbicacionExterna::className(), ['acervo_id' => 'id']); }
public function actionUpdateIngreso($id) { // Return if (Yii::$app->request->post('saveClose') == 2) { $model = $this->findModel($id); $dataprovider = new ArrayDataProvider(['allModels' => Multimedia::findAll(['objetos_id' => $model->id])]); //Obtener Ubicaciones Externas $dataprovider_ue = new ArrayDataProvider(['allModels' => UbicacionExterna::findAll(['acervo_id' => $model->id])->orderBy('fechaInicio DESC')]); return $this->redirect(['ingreso/update', 'id' => $model->ingreso_id, 'dataprovider' => $dataprovider, 'dataProviderUbicacionExterna' => $dataprovider_ue]); } return $this->createOrUpdate($id, NULL, TRUE); }
/** * Finds the UbicacionExterna model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UbicacionExterna the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UbicacionExterna::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }