Ejemplo n.º 1
0
 /**
  * @return string|\yii\web\Response
  */
 public function run()
 {
     $model = new Empresas();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->controller->redirect(['detalle', 'id' => $model->id]);
     } else {
         return $this->controller->render('crear', ['model' => $model]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Finds the Empresas model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Empresas the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Empresas::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function buscarInactivos($params)
 {
     $query = Empresas::find();
     $query->with(['usuario', 'franquicias', 'empresaFranquicias', 'empresaFranquicias.franquicia0']);
     $query->inactiva();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['fecha_creado' => SORT_DESC]], 'pagination' => ['pageSize' => 50]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'estado' => $this->estado, 'fecha_creado' => $this->fecha_creado, 'fecha_actualizado' => $this->fecha_actualizado]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'rnc', $this->rnc])->andFilterWhere(['like', 'logo', $this->logo])->andFilterWhere(['like', 'slogan', $this->slogan])->andFilterWhere(['like', 'web', $this->web])->andFilterWhere(['like', 'facebook', $this->facebook])->andFilterWhere(['like', 'twitter', $this->twitter])->andFilterWhere(['like', 'slug', $this->slug]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Empresas::find();
     $query->with(['usuario', 'franquicias']);
     //        $query->where(['user_id' => $user_id]);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'estado' => $this->estado, 'fecha_creado' => $this->fecha_creado, 'fecha_actualizado' => $this->fecha_actualizado]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'rnc', $this->rnc])->andFilterWhere(['like', 'logo', $this->logo])->andFilterWhere(['like', 'slogan', $this->slogan])->andFilterWhere(['like', 'web', $this->web])->andFilterWhere(['like', 'facebook', $this->facebook])->andFilterWhere(['like', 'twitter', $this->twitter])->andFilterWhere(['like', 'slug', $this->slug]);
     return $dataProvider;
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEmpresas()
 {
     return $this->hasMany(Empresas::className(), ['id_usuario' => 'idusuario']);
 }
Ejemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEmpresa()
 {
     return $this->hasOne(Empresas::className(), ['id' => 'empresa'])->viaTable('empresa_franquicia', ['franquicia' => 'id']);
 }
Ejemplo n.º 7
0
 /**
  * Obtener empresa
  * @return Empresas|null
  */
 protected function obtenerEmpresa()
 {
     if ($this->_empresa === null) {
         $this->_empresa = Empresas::findOne($this->id_empresa);
     }
     return $this->_empresa;
 }
Ejemplo n.º 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEmpresa0()
 {
     return $this->hasOne(Empresas::className(), ['id' => 'empresa']);
 }
Ejemplo n.º 9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEmpresas()
 {
     return $this->hasMany(Empresas::className(), ['id_sector' => 'id']);
 }