Exemple #1
0
 public function search($params)
 {
     $query = Sede::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'establecimiento_id' => $this->establecimiento_id, 'principal' => $this->principal]);
     $query->andFilterWhere(['like', 'codigo', $this->codigo])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'telefono', $this->telefono])->andFilterWhere(['like', 'telefono_alternativo', $this->telefono_alternativo])->andFilterWhere(['like', 'fax', $this->fax]);
     return $dataProvider;
 }
 /**
  * Creates a new SedeDomicilio model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param integer $establecimiento_id
  * @param integer $sede_id
  * @return mixed
  */
 public function actionCreate($establecimiento_id, $sede_id)
 {
     $sede = Sede::findOne(['establecimiento_id' => $establecimiento_id, 'id' => $sede_id]);
     $model = new Domicilio(['scenario' => 'sede']);
     // Para validar sólo lo referente a SedeDomicilio
     $model->sede = $sede;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['establecimientos/' . $sede->establecimiento_id . '/sedes/' . $sede->id . '/domicilios/view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'sede' => $sede]);
     }
 }
 public function index()
 {
     return Sede::all();
 }
Exemple #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSedes()
 {
     return $this->hasMany(Sede::className(), ['establecimiento_id' => 'id']);
 }
Exemple #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSede()
 {
     return $this->hasOne(Sede::className(), ['id' => 'sede_id']);
 }
Exemple #6
0
 /**
  * Finds the Sede model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $establecimiento_id
  * @param integer $id
  * @return Sede the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($establecimiento_id, $id)
 {
     if (($model = Sede::findOne(['establecimiento_id' => $establecimiento_id, 'id' => $id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSede()
 {
     return $this->hasOne(Sede::className(), ['id' => 'sede_id'])->viaTable('sede_domicilio', ['domicilio_id' => 'id']);
 }