/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DotaLeague::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['leagueid' => 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(['leagueid' => $this->leagueid, 'itemdef' => $this->itemdef]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name1', $this->name1])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'tournament_url', $this->tournament_url]); return $dataProvider; }
//echo'<pre>';var_dump($year_end);echo'</pre>';//die; $dd_list = []; $url_params_ = [$current_controller . '/' . $current_action, 'for' => $current_filter_for, 'year' => 'all', 'league' => $current_filter_league]; $url = Url::to($url_params_); $dd_list[$url] = 'Год'; for ($year = $year_start - 1; $year++ < $year_end;) { //$url_params_ = [$current_controller.'/'.$current_action] + $url_params + ['year'=>$year]; $url_params_ = [$current_controller . '/' . $current_action, 'for' => $current_filter_for, 'year' => $year, 'league' => $current_filter_league]; $url = Url::to($url_params_); $dd_list[$url] = $year; } //echo'<pre>';print_r($dd_list);echo'</pre>';//die; //$dd_list_active = Url::to([$current_controller.'/'.$current_action, 'for'=>$current_filter_for, 'year'=>$current_filter_year]); $dd_list_active = Url::to([$current_controller . '/' . $current_action] + $url_params); $filter_year_drop_down = Html::dropDownList('filter-year', $dd_list_active, $dd_list, ['id' => 'filter-year', 'class' => 'width-100 location-change']); $leagues_list = DotaLeague::getLeaguesListDropDown(); //echo'<pre>';print_r($leagues_list);echo'</pre>';//die; $dd_list = []; //$url_params = ['for'=>$current_filter_for]; $url_params_ = [$current_controller . '/' . $current_action, 'for' => $current_filter_for, 'year' => $current_filter_year, 'league' => 'all']; $url = Url::to($url_params_); $dd_list[$url] = 'Все турниры'; foreach ($leagues_list as $key => $league) { //$url_params_ = [$current_controller.'/'.$current_action] + $url_params + ['league'=>$key]; $url_params_ = [$current_controller . '/' . $current_action, 'for' => $current_filter_for, 'year' => $current_filter_year, 'league' => $key]; $url = Url::to($url_params_); $dd_list[$url] = $league; } //echo'<pre>';print_r($dd_list);echo'</pre>';//die; //$dd_list_active = Url::to([$current_controller.'/'.$current_action, 'for'=>$current_filter_for, 'league'=>$current_filter_league]); $filter_league_drop_down = Html::dropDownList('filter-league', $dd_list_active, $dd_list, ['id' => 'filter-league', 'class' => 'width-100 location-change']);
<?php use yii\web\View; use common\models\dota\DotaLeague; //use dosamigos\multiselect\MultiSelect; \common\assets\ChoosenSelectAsset::register($this); //русский язык подключаем $js = "jQuery('.chosen_select').chosen();"; $this->registerJs($js, View::POS_READY, 'form-league'); ?> <br> <div class="form-group"> <?php echo $form->field($model, 'league_ids')->dropDownList(DotaLeague::getLeaguesListDropDown(), [$model->league_ids, 'class' => 'chosen_select', 'multiple' => true, 'data-placeholder' => 'Укажите лиги и турниры', 'style' => 'width:100%;min-height:30px;']); ?> </div>
public function beforeValidate() { $this->start_at = DDateTimeHelper::DateToUnix($this->start_date); return parent::beforeValidate(); }
/** * @return \yii\db\ActiveQuery */ public function getLeague() { return $this->hasOne(DotaLeague::className(), ['id' => 'league_id']); }
/** * Обновляет список лиг на сайте */ public static function updateLeaguesOnSite() { $leagueids = DotaLeague::getLeagueIdsOnSite(); $rows = self::_getLeagueListing(); if (is_null($rows)) { return false; } //echo'<pre>';print_r($league_ids);echo'</pre>';die; foreach ($rows['leagues'] as $row) { if (!isset($leagueids[$row['leagueid']])) { $model = new DotaLeague(); $model->attributes = $row; $model->name1 = $row['name']; $model->save(); $leagueids[$row['leagueid']] = $row['leagueid']; //добавляем в массив имеющихся чтобы дубли не словить. } } return true; }