Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Personas::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['cuenta' => ['asc' => ['cuenta' => SORT_ASC], 'desc' => ['cuenta' => SORT_DESC], 'label' => 'Empresa']]]);
     $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');
         // Join con Empresa
         $query->joinWith(['empresa']);
         return $dataProvider;
     }
     $query->andFilterWhere(['idpersonas' => $this->idpersonas, 'empresas_id' => $this->empresas_id, 'fecha_reunion' => $this->fecha_reunion]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'cargo', $this->cargo])->andFilterWhere(['like', 'telefono', $this->telefono])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'direccion', $this->direccion])->andFilterWhere(['like', 'asistente', $this->asistente]);
     // Filtro por empresa
     $query->joinWith(['empresas' => function ($q) {
         $q->where('empresas.cuenta LIKE "%' . $this->cuenta . '%"');
     }]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     /*		
      Yii::trace($params);
      Yii::trace($params['_tog8aa5d80b']);
      if ($params['_tog8aa5d80b'] == 'all') { $params['_tog8aa5d80b']='page';}
     */
     $query = Personas::find()->joinWith('tipoDoc');
     // se usa el nombre de la relación en Personas
     $pageSize = isset($_GET['per-page']) ? $_GET['per-page'] : \Yii::$app->params['personas.defaultPageSize'];
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize], 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'enableMultiSort' => true]]);
     // Agregado a mano, para que incluya el ordenamiento por tipo de documento
     $dataProvider->sort->attributes['tipoDoc'] = ['asc' => ['tiposdoc.desc_tipo_doc_abr' => SORT_ASC], 'desc' => ['tiposdoc.desc_tipo_doc_abr' => SORT_DESC]];
     $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;
     }
     $query->andFilterWhere(['personas.id' => $this->id, 'id_tipo_doc' => $this->tipoDoc, 'estado' => $this->estado]);
     $query->andFilterWhere(['like', 'apellido', $this->apellido])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'nombre2', $this->nombre2])->andFilterWhere(['like', 'nro_doc', $this->nro_doc]);
     return $dataProvider;
 }