/** * Default index search method * @param $params * @return ActiveDataProvider */ public function search($params) { $query = Message::find(); $query->joinWith('source'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes['sourceMessage'] = ['asc' => ['source.message' => SORT_ASC], 'desc' => ['source.message' => SORT_DESC]]; $dataProvider->getSort()->attributes['sourceCategory'] = ['asc' => ['source.category' => SORT_ASC], 'desc' => ['source.category' => SORT_DESC]]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); if ($this->translation) { $t = addslashes($this->translation); $query->where("translation like '%{$t}%'"); } if ($this->translationUpdate === 'is null') { $query->where('translation is null'); } if ($this->translationUpdate === 'is not null') { $query->where('translation is not null'); } if ($this->translation) { $query->andWhere(['like', 'translation', '%' . $this->translation . '%', false]); } if ($this->sourceMessage) { $query->andFilterWhere(['like', 'source.message', $this->sourceMessage]); } if ($this->language) { $query->andWhere(['language' => $this->language]); } if ($this->sourceCategory) { $query->andFilterWhere(['like', 'source.category', $this->sourceCategory]); } return $dataProvider; }
public function search($params) { $query = Domicilio::find()->joinWith(['perfil', 'perfil.alumno'])->joinWith('pais')->joinWith('provincia')->joinWith('ciudad')->andWhere(['alumno.id' => $params['alumno_id']]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes = array_merge($dataProvider->getSort()->attributes, ['pais_nombre' => ['asc' => ['pais.nombre' => SORT_ASC], 'desc' => ['pais.nombre' => SORT_DESC], 'label' => Yii::t('app', 'País')], 'provincia_nombre' => ['asc' => ['provincia.nombre' => SORT_ASC], 'desc' => ['provincia.nombre' => SORT_DESC], 'label' => Yii::t('app', 'Provincia')], 'ciudad_nombre' => ['asc' => ['ciudad.nombre' => SORT_ASC], 'desc' => ['ciudad.nombre' => SORT_DESC], 'label' => Yii::t('app', 'Ciudad')]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'domicilio.principal' => $this->principal]); $query->andFilterWhere(['like', 'direccion', $this->direccion])->andFilterWhere(['like', 'cp', $this->cp])->andFilterWhere(['like', 'pais.nombre', $this->pais_nombre])->andFilterWhere(['like', 'provincia.nombre', $this->provincia_nombre])->andFilterWhere(['like', 'ciudad.nombre', $this->ciudad_nombre]); return $dataProvider; }
/** * @param array|null $params * * @return ActiveDataProvider */ public function search($params) { $query = MarketOrder::find()->joinWith(['staStation', 'invTypes']); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!$this->load($params) && !$this->validate()) { return $dataProvider; } $dataProvider->getSort()->attributes['stationName'] = ['asc' => ['staStations.stationName' => SORT_ASC], 'desc' => ['staStations.stationName' => SORT_DESC]]; $dataProvider->getSort()->attributes['typeName'] = ['asc' => ['invTypes.typeName' => SORT_ASC], 'desc' => ['invTypes.typeName' => SORT_DESC]]; $query->andFilterWhere(['stationID' => $this->stationID])->andFilterWhere(['like', 'stationName', $this->getAttribute('stationName')])->andFilterWhere(['like', 'typeName', $this->getAttribute('typeName')])->andFilterWhere(['orderState' => $this->orderState])->andFilterWhere(['characterID' => $this->characterID]); return $dataProvider; }
public function search($params) { $query = Provincia::find()->joinWith('pais'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes = array_merge($dataProvider->getSort()->attributes, ['pais_nombre' => ['asc' => ['pais.nombre' => SORT_ASC], 'desc' => ['pais.nombre' => SORT_DESC], 'label' => Yii::t('app', 'País')]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'pais.nombre', $this->pais_nombre]); return $dataProvider; }
public function getSort($className = 'CSort') { if (($sort = parent::getSort($className)) !== false) { $sort->attributes = $this->attributes; } return $sort; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Users::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $sort = $dataProvider->getSort(); $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Имя офиса']; $dataProvider->setSort($sort); $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'); $query->joinWith(['questionlist_office']); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); if ($this->roleName) { $this->profile_office_role = $this->roleName; } $query->andFilterWhere(['like', 'profile_id', $this->profile_id])->andFilterWhere(['like', 'profile_office_role', $this->profile_office_role]); if ($this->scenario == 'managerSearch') { $userRoles = Users::findAll(['profile_id' => Yii::$app->user->identity->username, 'profile_office_role' => 'commercial_director']); $userRegions = array_values(ArrayHelper::map($userRoles, 'region_id', 'region_id')); $query->andFilterWhere(['like', 'profile_office_role', 'manager']); $query->andFilterWhere(['in', 'questionlist_users_offices.region_id', $userRegions]); } $query->joinWith(['office' => function ($q) { $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]); }]); $query->joinWith(['region' => function ($q) { $q->andFilterWhere(['like', 'questionlist_region.name', $this->regionName]); }]); return $dataProvider; }
/** * Creates data provider instance with search query applied * @param array $params * @return ActiveDataProvider */ public function search($params) { $query = self::find()->select(['user.*', "CONCAT(user.first_name,' ', user.last_name) AS fullName"])->from(['user' => static::tableName()]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes += ['fullName' => ['asc' => ['fullName' => SORT_ASC], 'desc' => ['fullName' => 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(['user.id' => $this->id, 'user.logins_count' => $this->logins_count, 'user.is_active' => $this->is_active]); $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'user.password', $this->password])->andFilterWhere(['like', "CONCAT(user.first_name,' ', user.last_name)", $this->fullName])->andFilterWhere(['like', 'user.phone', $this->phone]); if (!empty($this->created_at)) { $range = explode(' - ', $this->created_at); if (!empty($range[0]) && !empty($range[1])) { $query->andWhere('user.created_at BETWEEN :prt1 AND :prt2', [':prt1' => strtotime($range[0]), ':prt2' => strtotime($range[1])]); } } if (!empty($this->last_login_at)) { $range = explode(' - ', $this->last_login_at); if (!empty($range[0]) && !empty($range[1])) { $query->andWhere('user.last_login_at BETWEEN :prt3 AND :prt4', [':prt3' => strtotime($range[0]), ':prt4' => strtotime($range[1])]); } } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Users::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $sort = $dataProvider->getSort(); $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Имя офиса']; $dataProvider->setSort($sort); $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'); $query->joinWith(['questionlist_office']); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); if ($this->roleName) { $this->profile_office_role = $this->roleName; } $query->andFilterWhere(['like', 'profile_id', $this->profile_id])->andFilterWhere(['like', 'profile_office_role', 'manager']); $query->joinWith(['office' => function ($q) { $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]); }]); $query->joinWith(['region' => function ($q) { $q->andFilterWhere(['like', 'questionlist_region.name', $this->regionName]); }]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = AnswerList::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $sort = $dataProvider->getSort(); $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Отделение']; $sort->attributes['statusName'] = ['asc' => ['status' => SORT_ASC], 'desc' => ['status' => SORT_DESC], 'label' => 'Статус']; $dataProvider->setSort($sort); $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'); $query->joinWith(['questionlist_office']); return $dataProvider; } $query->joinWith('questionList'); $query->andFilterWhere(['id' => $this->id, 'question_list_id' => $this->question_list_id, 'scores' => $this->scores, 'date' => $this->date]); $query->andFilterWhere(['>=', 'date_from', $this->date_from])->andFilterWhere(['<=', 'date_to', $this->date_to]); if (!$this->statusName) { $query->andFilterWhere(['not like', 'status', 'archive']); } else { $query->andFilterWhere(['like', 'status', $this->statusName]); } $query->joinWith(['office' => function ($q) { $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]); }]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Value::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['attribute'] = ['asc' => [Attribute::tableName() . '.presentation' => SORT_ASC], 'desc' => [Attribute::tableName() . '.presentation' => SORT_DESC]]; if (!($this->load($params) && $this->validate())) { $dataProvider->getSort() !== false ? $query->joinWith(['eAttribute']) : $query->with('eAttribute'); return $dataProvider; } else { $query->joinWith(['eAttribute']); } $query->andFilterWhere(['like', 'value', $this->value]); $query->andFilterWhere(['like', Attribute::tableName() . '.presentation', $this->attribute]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProductType::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['parentName'] = ['asc' => ['parent.name' => SORT_ASC], 'desc' => ['parent.name' => SORT_DESC]]; if (!($this->load($params) && $this->validate())) { $dataProvider->getSort() !== false ? $query->joinWith(['parentRelation']) : $query->with('parentRelation'); return $dataProvider; } else { $query->joinWith(['parentRelation']); } $query->andFilterWhere(['like', '{{%product_types}}.name', $this->name]); $query->andFilterWhere(['like', 'parent.name', $this->parentName]); return $dataProvider; }
/** * Searching menu * * @param array $params * @return ActiveDataProvider */ public function search($params) { $query = self::find()->from(self::tableName()); $dataProvider = new ActiveDataProvider(['query' => $query]); $sort = $dataProvider->getSort(); $sort->attributes['name'] = ['asc' => ['name' => SORT_ASC], 'desc' => ['name' => SORT_DESC], 'label' => 'name']; $sort->attributes['locale'] = ['asc' => ['locale' => SORT_ASC], 'desc' => ['locale' => SORT_DESC], 'label' => 'locale']; $sort->attributes['url'] = ['asc' => ['url' => SORT_ASC], 'desc' => ['url' => SORT_DESC], 'label' => 'url']; $sort->defaultOrder = ['name' => SORT_ASC]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['like', 'lower(name)', strtolower($this->name)])->andFilterWhere(['like', 'lower(locale)', strtolower($this->locale)])->andFilterWhere(['like', 'lower(url)', strtolower($this->url)]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = $this->find()->select(['id' => 'record.id', 'license' => 'record.license', 'lat' => 'record.lat', 'lng' => 'record.lng', 'state_id' => 'record.state_id', 'infraction_date' => 'record.infraction_date', 'created_at' => 'record.created_at', 'elapsedTime' => self::SQL_SELECT_ELAPSED_TIME, 'fullName' => self::SQL_SELECT_FULL_NAME])->from(['record' => static::tableName()])->joinWith(['user' => function ($query) { $query->from('User user'); }]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes['fullName'] = ['asc' => ['fullName' => SORT_ASC], 'desc' => ['fullName' => SORT_DESC]]; $dataProvider->getSort()->attributes['created_at'] = ['asc' => ['record.created_at' => SORT_ASC], 'desc' => ['record.created_at' => SORT_DESC]]; $dataProvider->getSort()->attributes['elapsedTime'] = ['asc' => ['elapsedTime' => SORT_ASC], 'desc' => ['elapsedTime' => 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(['id' => $this->id, 'user_id' => $this->user_id, 'state_id' => $this->state_id, 'infraction_date' => $this->infraction_date, 'record.created_at' => $this->created_at]); $query->andFilterWhere(['like', 'license', $this->license])->andFilterWhere(['like', 'lat', $this->lat])->andFilterWhere(['like', 'lng', $this->lng]); $query->andFilterWhere(['like', self::SQL_SELECT_FULL_NAME, $this->fullName]); $query->andFilterWhere(['like', self::SQL_SELECT_ELAPSED_TIME, $this->elapsedTime]); if ($statuses = $this->getAvailableStatuses()) { $query->andFilterWhere(['in', 'status_id', $statuses]); } return $dataProvider; }
public function search($params) { $query = Card::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { // $query->joinWith('cardStatus'); return $dataProvider; } $sort = $dataProvider->getSort(); $sort->attributes['attributes']['status'] = ['asc' => ['card.status' => SORT_ASC], 'desc' => ['card.status' => SORT_DESC], 'label' => 'Статус', 'default' => SORT_ASC]; $dataProvider->setSort($sort); $query->andFilterWhere(['no' => $this->no, 'creation_date' => $this->creation_date, 'deactivation_date' => $this->deactivation_date, 'activity_date' => $this->activity_date, 'sum' => $this->sum, 'status' => $this->status]); $query->andFilterWhere(['like', 'sn', $this->sn]); return $dataProvider; }
public function search($params) { $query = MenuModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->leftJoin(['parent' => '{{%menu}}'], '{{%menu}}.parent=parent.id'); $sort = $dataProvider->getSort(); $sort->attributes['menuParent.name'] = ['asc' => ['parent.name' => SORT_ASC], 'desc' => ['parent.name' => SORT_DESC], 'label' => 'parent']; $sort->attributes['order'] = ['asc' => ['parent.order' => SORT_ASC, '{{%menu}}.order' => SORT_ASC], 'desc' => ['parent.order' => SORT_DESC, '{{%menu}}.order' => SORT_DESC], 'label' => 'order']; $sort->defaultOrder = ['menuParent.name' => SORT_ASC]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'parent' => $this->parent]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'route', $this->route])->andFilterWhere(['like', 'parent.name', $this->parent_name]); return $dataProvider; }
/** * Searching menu * @param array $params * @return \yii\data\ActiveDataProvider */ public function search($params) { $query = MenuModel::find()->from(MenuModel::tableName() . ' t')->joinWith(['menuParent' => function ($q) { $q->from(MenuModel::tableName() . ' men_parent'); }]); $dataProvider = new ActiveDataProvider(['query' => $query]); $sort = $dataProvider->getSort(); $sort->attributes['menuParent.men_nombre'] = ['asc' => ['men_parent.men_nombre' => SORT_ASC], 'desc' => ['men_parent.men_nombre' => SORT_DESC], 'label' => 'men_parent']; $sort->attributes['men_orden'] = ['asc' => ['men_parent.men_orden' => SORT_ASC, 't.men_orden' => SORT_ASC], 'desc' => ['men_parent.men_orden' => SORT_DESC, 't.men_orden' => SORT_DESC], 'label' => 'men_orden']; $sort->defaultOrder = ['menuParent.men_nombre' => SORT_ASC]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['t.men_id' => $this->id, 't.men_parent' => $this->men_parent]); $query->andFilterWhere(['like', 'lower(t.men_nnombre)', strtolower($this->men_nombre)])->andFilterWhere(['like', 't.men_url', $this->men_url])->andFilterWhere(['like', 'lower(men_parent.men_nombre)', strtolower($this->parent_name)]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Model::find(); $query->joinWith(['authorModel']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes['author'] = ['asc' => [ITables::AUTHORS . '.first_name' => SORT_ASC, ITables::AUTHORS . '.last_name' => SORT_ASC], 'desc' => [ITables::AUTHORS . '.first_name' => SORT_DESC, ITables::AUTHORS . '.last_name' => SORT_DESC]]; $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'author_id' => $this->author_id, 'release_date' => $this->release_date, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['ILIKE', 'name', $this->name])->andFilterWhere(['ILIKE', 'preview_path', $this->preview_path])->andWhere(ITables::AUTHORS . '.first_name ILIKE \'%' . $this->author . '%\' OR ' . ITables::AUTHORS . '.last_name ILIKE \'%' . $this->author . '%\''); if ($this->release_date_start && $this->release_date_end) { $this->release_date_start = strtotime($this->release_date_start); $this->release_date_end = strtotime($this->release_date_end); if ($this->release_date_start === $this->release_date_end) { $this->release_date_end += 24 * 60 * 60; } $query->andWhere('release_date BETWEEN ' . (int) $this->release_date_start . ' AND ' . (int) $this->release_date_end); } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { // Если админ, то выбираем все опросы. if ($isAdmin = Users::findOne(['profile_id' => Yii::$app->user->identity->username, 'profile_office_role' => 'admin'])) { $officeIds = ArrayHelper::map(Office::find()->all(), 'id', 'id'); } elseif ($isCommercialDirector = Users::findAll(['profile_id' => Yii::$app->user->identity->username, 'profile_office_role' => 'commercial_director'])) { // берем ID отделений, где регион отделения === региону, где пользователь коммерч.директор $regionIds = ArrayHelper::map($isCommercialDirector, 'region_id', 'region_id'); $officeIds = ArrayHelper::map(Office::findAll(['region_id' => $regionIds]), 'id', 'id'); } else { // берем ID отделений, где пользователь является управляющим, или где он назначен им. $officeIds = $this->getOffiсeIds(Yii::$app->user->identity->username); } $query = AnswerList::find()->joinWith('questionList')->where(['do_id' => $officeIds]); //$query = AnswerList::find()->innerJoinWith('questionList'); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $sort = $dataProvider->getSort(); $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Отделение']; $sort->attributes['statusName'] = ['asc' => ['status' => SORT_ASC], 'desc' => ['status' => SORT_DESC], 'label' => 'Статус']; $dataProvider->setSort($sort); $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'); $query->joinWith(['questionlist_office']); return $dataProvider; } $query->andFilterWhere(['questionlist_answer_list.id' => $this->id, 'question_list_id' => $this->question_list_id, 'scores' => $this->scores]); $query->andFilterWhere(['>=', 'date_from', $this->date_from])->andFilterWhere(['<=', 'date_to', $this->date_to]); if ($this->statusName) { $query->andFilterWhere(['like', 'status', $this->statusName]); } else { $query->andFilterWhere(['not like', 'status', 'archive']); } $query->joinWith(['office' => function ($q) { $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]); }]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { // берем ID отделений, где пользователь является управляющим, или где он назначен им. $officeIds = $this->getOffiсeIds(Yii::$app->user->identity->username); $query = AnswerList::find()->innerJoinWith('questionList')->where(['do_id' => $officeIds]); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $sort = $dataProvider->getSort(); $sort->attributes['officeName'] = ['asc' => ['office.name' => SORT_ASC], 'desc' => ['office.name' => SORT_DESC], 'label' => 'Отделение']; $sort->attributes['statusName'] = ['asc' => ['status' => SORT_ASC], 'desc' => ['status' => SORT_DESC], 'label' => 'Статус']; $dataProvider->setSort($sort); $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'); $query->joinWith(['office']); return $dataProvider; } $query->andFilterWhere(['answer_list.id' => $this->id, 'question_list_id' => $this->question_list_id]); $query->andFilterWhere(['like', 'status', $this->statusName])->andFilterWhere(['like', 'list_name', $this->list_name])->andFilterWhere(['>=', 'date_from', $this->date_from])->andFilterWhere(['<=', 'date_to', $this->date_to]); $query->joinWith(['office' => function ($q) { $q->andFilterWhere(['like', 'office.name', $this->officeName]); }]); return $dataProvider; }
public function initDataProvider() { $this->search = new Search(CmsContentElement::className()); $this->dataProvider = $this->search->getDataProvider(); if ($this->enabledPaging == Cms::BOOL_Y) { $this->dataProvider->getPagination()->defaultPageSize = $this->pageSize; $this->dataProvider->getPagination()->pageParam = $this->pageParamName; $this->dataProvider->getPagination()->pageSizeLimit = [(int) $this->pageSizeLimitMin, (int) $this->pageSizeLimitMax]; } else { $this->dataProvider->pagination = false; } if ($this->orderBy) { $this->dataProvider->getSort()->defaultOrder = [$this->orderBy => (int) $this->order]; } return $this; }
/** * Lists all Paramfund models. * @return mixed */ public function actionIndex() { $historyModel = new HistoryParamfund(); $historyModel->TAHUN_MULAI = date('Y'); $historyModel->TAHUN_AKHIR = $historyModel->TAHUN_MULAI; $historyModel->TRIWULAN_MULAI = 'I'; if (date('m') >= 9) { $historyModel->TRIWULAN_AKHIR = 'IV'; } else { if (date('m') >= 6) { $historyModel->TRIWULAN_AKHIR = 'III'; } else { if (date('m') >= 3) { $historyModel->TRIWULAN_AKHIR = 'II'; } else { $historyModel->TRIWULAN_AKHIR = 'I'; } } } if ($historyModel->load(Yii::$app->request->post())) { $emitenKodes = $historyModel->EMITEN_KODES; if (!$emitenKodes) { $emitenKodes = []; } $tahunMulai = $historyModel->TAHUN_MULAI; $tahunAkhir = $historyModel->TAHUN_AKHIR; $tahuns = []; for ($i = $tahunMulai; $i <= $tahunAkhir; $i++) { $tahuns[] = $i; } $triwulanMulai = $historyModel->TRIWULAN_MULAI; $triwulanAkhir = $historyModel->TRIWULAN_AKHIR; $triwulans = []; if ($triwulanMulai == 'I' and $triwulanAkhir == 'IV') { $triwulans = ['I', 'II', 'III', 'IV']; } else { if ($triwulanMulai == 'I' and $triwulanAkhir == 'III') { $triwulans = ['I', 'II', 'III']; } else { if ($triwulanMulai == 'I' and $triwulanAkhir == 'II') { $triwulans = ['I', 'II']; } else { if ($triwulanMulai == 'II' and $triwulanAkhir == 'IV') { $triwulans = ['II', 'III', 'IV']; } else { if ($triwulanMulai == 'II' and $triwulanAkhir == 'III') { $triwulans = ['II', 'III']; } else { if ($triwulanMulai == 'III' and $triwulanAkhir == 'IV') { $triwulans = ['III', 'IV']; } else { if ($triwulanMulai == $triwulanAkhir) { $triwulans = [$triwulanMulai]; } } } } } } } $dataProviders = []; foreach ($emitenKodes as $kode) { $emitenModel = $this->getEmiten($kode); if ($emitenModel) { $query = Paramfund::find()->where(['TAHUN' => $tahuns, 'TRIWULAN' => $triwulans, 'EMITEN_KODE' => $kode]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->defaultOrder = ['TAHUN' => SORT_ASC, 'TRIWULAN' => SORT_ASC]; $dataProviders[$kode] = $dataProvider; } } if (!empty($dataProviders)) { $session = Yii::$app->session; $session->set('dataProviders', $dataProviders); return $this->render('index', ['historyModel' => $historyModel, 'dataProviders' => $dataProviders]); } else { return $this->render('index', ['historyModel' => $historyModel]); } } else { return $this->render('index', ['historyModel' => $historyModel]); } }
public function search($params) { $query = Alumno::find()->joinWith('perfil')->joinWith('perfil.sexo')->joinWith('perfil.tipoDocumento'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes = array_merge($dataProvider->getSort()->attributes, ['perfilApellido' => ['asc' => ['perfil.apellido' => SORT_ASC], 'desc' => ['perfil.apellido' => SORT_DESC], 'label' => Yii::t('app', 'Apellido')], 'perfilNombre' => ['asc' => ['perfil.nombre' => SORT_ASC], 'desc' => ['perfil.nombre' => SORT_DESC], 'label' => Yii::t('app', 'Nombre')], 'tipoDocumentoAbreviatura' => ['asc' => ['tipo_documento.abreviatura' => SORT_ASC], 'desc' => ['tipo_documento.abreviatura' => SORT_DESC], 'label' => Yii::t('app', 'Tipo de Documento')], 'perfilNumeroDocumento' => ['asc' => ['perfil.numero_documento' => SORT_ASC], 'desc' => ['perfil.numero_documento' => SORT_DESC], 'label' => Yii::t('app', 'Documento')], 'sexoDescripcion' => ['asc' => ['sexo.descripcion' => SORT_ASC], 'desc' => ['sexo.descripcion' => SORT_DESC], 'label' => Yii::t('app', 'Sexo')], 'perfilTelefono' => ['asc' => ['perfil.telefono' => SORT_ASC], 'desc' => ['perfil.telefono' => SORT_DESC], 'label' => Yii::t('app', 'Teléfono')], 'perfilEmail' => ['asc' => ['perfil.email' => SORT_ASC], 'desc' => ['perfil.email' => SORT_DESC], 'label' => Yii::t('app', 'Email')]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'perfil.apellido', $this->perfilApellido])->andFilterWhere(['like', 'perfil.nombre', $this->perfilNombre])->andFilterWhere(['like', 'tipo_documento.abreviatura', $this->tipoDocumentoAbreviatura])->andFilterWhere(['like', 'perfil.numero_documento', $this->perfilNumeroDocumento])->andFilterWhere(['like', 'perfil.tipo_documento.abreviatura', $this->tipoDocumentoAbreviatura])->andFilterWhere(['like', 'perfil.email', $this->perfilEmail]); return $dataProvider; }