/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DotaTeam::find()->where(['>', 'team_id', 1]); $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; } $query->andFilterWhere(['team_id' => $this->team_id, 'time_created' => $this->time_created, 'rating' => $this->rating, 'games_played_with_current_roster' => $this->games_played_with_current_roster, 'admin_account_id' => $this->admin_account_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'tag', $this->tag])->andFilterWhere(['like', 'logo', $this->logo])->andFilterWhere(['like', 'logo_sponsor', $this->logo_sponsor])->andFilterWhere(['like', 'country_code', $this->country_code])->andFilterWhere(['like', 'url', $this->url]); return $dataProvider; }
$this->title = Yii::t('app', 'Dota Players'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="dota-player-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Yii::t('app', 'Create Dota Player'), ['create'], ['class' => 'btn btn-success']); ?> <?php echo Html::a(Yii::t('app', 'Import'), ['import'], ['class' => 'btn btn-primary']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'account_id', 'steamid', 'personaname', 'realname', ['attribute' => 'team', 'format' => 'text', 'content' => function ($data) { return $data->teamName; }, 'filter' => DotaTeam::getTeamsListDropDown()], ['attribute' => 'status', 'format' => 'text', 'content' => function ($data) { return $data->statusName; }, 'filter' => DotaPlayer::getStatusValuesList()], ['class' => 'yii\\grid\\ActionColumn', 'headerOptions' => ['width' => '75']]]]); ?> </div>
<?php use yii\web\View; use common\models\dota\DotaTeam; //use dosamigos\multiselect\MultiSelect; \common\assets\ChoosenSelectAsset::register($this); $js = "jQuery('.chosen_select').chosen();"; $this->registerJs($js, View::POS_READY, 'form-teams'); ?> <br> <div class="form-group"> <?php echo $form->field($model, 'team_ids')->dropDownList(DotaTeam::getTeamsListDropDown(), [$model->team_ids, 'class' => 'chosen_select', 'multiple' => true, 'data-placeholder' => 'Укажите команды', 'style' => 'width:100%;min-height:30px;']); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getTeam() { return $this->hasOne(DotaTeam::className(), ['team_id' => 'team_id']); }
?> <?php echo $form->field($model, 'firstname')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'lastname')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'middlename')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'team_id')->dropDownList(DotaTeam::getTeamsListDropDown(), [$model->team_id, 'prompt' => '-- Select --']); ?> <?//= $form->field($model, 'profileurl')->textInput(['maxlength' => true]) ?> <?//= $form->field($model, 'timecreated')->textInput() ?> <?//= $form->field($model, 'avatar')->textInput(['maxlength' => true]) ?> <?//= $form->field($model, 'avatarmedium')->textInput(['maxlength' => true]) ?> <?//= $form->field($model, 'avatarfull')->textInput(['maxlength' => true]) ?> <?//= $form->field($model, 'country_id')->textInput() ?> <?php echo $form->field($model, 'country_id')->dropDownList(Country::getLeaguesListDropDown(), [$model->country_id]);
/** * Finds the DotaTeam model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return DotaTeam the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DotaTeam::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Updates an existing DotaEvent model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $task = Yii::$app->request->post('task', 'save'); //echo'<pre>';print_r($_POST);echo'</pre>';die; $model->league_ids = $model->selectedEventLeagues; $model->team_ids = $model->selectedEventTeams; //$model->players_list = DotaPlayer::getActivePlayersList(); if (count($model->team_ids) > 0) { $model->players_list = DotaTeam::getTeamsListWithPlayers($model->team_ids); } else { $model->players_list = []; } //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; $model->heroes_list = DotaHero::getActiveHeroesList(); $model->preparePlayersForEdit(); $model->prepareHeroesForEdit(); /* $rr = DotaEventTeam::find() ->joinWith('team') ->joinWith('') ->where(['event_id'=>$id]) echo'<pre>';print_r($model->dotaEventTeams->joinWith('dotaPlayers'));echo'</pre>';die; */ $dataProviderPlayersStat = DotaEventPlayerStat::searchPlayersStatInEvent($model->id); $dataProviderHeroesStat = DotaEventHeroStat::searchHeroesStatInEvent($model->id); //echo'<pre>';print_r($dataProviderHeroesStat->models);echo'</pre>';die; //echo'<pre>';print_r(DotaTeam::getTeamsListWithPlayers($model->team_ids));echo'</pre>';die; //$model->load(Yii::$app->request->post()); //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; if ($model->load(Yii::$app->request->post()) && $model->validate()) { //if ($model->validate()) { $event = DotaEvent::findOne($model->id); //echo'<pre>';print_r($event->dotaEventPlayerStat);echo'</pre>';die; //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; $model->save(); $DotaEventPlayerStat = Yii::$app->request->post('DotaEventPlayerStat', []); $this->checkPlayersStat($model, $DotaEventPlayerStat); $this->checkLeagues($model); //проверяем изменения в лигах $this->checkTeams($model); //проверяем изменения в командах if (!is_null($model->price_pd) && !is_null($model->price_md_p)) { $this->checkPlayers($model); } //проверяем изменения в игроках if (!is_null($model->price_hd) && !is_null($model->price_md_h)) { $this->checkHeroes($model); } //проверяем изменения в героях Yii::$app->session->setFlash('success', Yii::t('app', 'Saved')); if ($task == 'apply') { return $this->redirect(['update', 'id' => $model->id]); } else { return $this->redirect(['index']); } } else { //echo'<pre>';print_r($model);echo'</pre>';//die; return $this->render('update', ['model' => $model, 'dataProviderPlayersStat' => $dataProviderPlayersStat, 'dataProviderHeroesStat' => $dataProviderHeroesStat, 'last_update_info' => LastStatUpdate::LoadDota()]); } }
private static function _addTeamInfoInBase($data, $team_id) { $res = -1; $model = new DotaTeam(); $model->attributes = $data; $model->logo = (string) $model->logo; $model->logo_sponsor = (string) $model->logo_sponsor; $model->status = DotaTeam::DOTA_TEAM_ON_CHECKING; //echo'<pre>';print_r($model);echo'</pre>';die; $model->save(); //echo'<pre>';print_r($model);echo'</pre>';die; $res = $model->team_id; return $res; }