public function beforeSave($insert) { if (parent::beforeSave($insert)) { // $this->start = DDateTimeHelper::DateToUnix($this->date_from, $this->time_from); // $this->end = DDateTimeHelper::DateToUnix($this->date_to, $this->time_to); //echo'<pre>';print_r($this);echo'</pre>';die; return true; } else { return false; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DotaEvent::find(); $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(['id' => $this->id, 'start' => $this->start, 'end' => $this->end]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
use yii\widgets\ActiveForm; use common\models\dota\DotaEvent; /* @var $this yii\web\View */ /* @var $model common\models\dota\DotaFantasy */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="dota-fantasy-form"> <?php $form = ActiveForm::begin(); ?> <div class="row"> <div class="col-lg-4"><?php echo $form->field($model, 'event_id')->dropDownList(DotaEvent::getEventsListDropDown(), [$model->event_id]); ?> </div> <div class="col-lg-4"><?php echo $form->field($model, 'finished')->dropDownList($model->finishedValues, [$model->finished]); ?> </div> <div class="col-lg-4"></div> </div> <div class="row"> <div class="col-lg-4"><?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> </div> <div class="col-lg-4"><?php
public static function loadHeroesListOnFantasy($fantasy_id) { $event_id = DotaFantasy::getEventId($fantasy_id); $eventModel = DotaEvent::findOne($event_id); if ($eventModel === null) { return; } $rows = $eventModel->eventHeroesList; //echo'<pre>';print_r($rows);echo'</pre>';die; return $rows; }
public function getEventsList() { return DotaEvent::getEventsListDropDown(); }
/** * считает кол-во очков у ивента по заданному id * @param $id integer * */ public static function calculateScoresForEvent($id) { $event = DotaEvent::findOne($id); self::calculateScores($event); }
/** * @return \yii\db\ActiveQuery */ public function getEvent() { return $this->hasOne(DotaEvent::className(), ['id' => 'event_id']); }
/** * 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()]); } }
/** * @return bool */ public static function updateDotaDraftPrizes() { // 1. получить список активных фантазий (активность из event) $events = DotaEvent::getActualEventsList(); $event_ids = ArrayHelper::map($events, 'id', 'id'); $fantasies = DotaFantasy::getActiveFantasies($event_ids); echo '<pre>'; print_r($fantasies); echo '</pre>'; //die; $DotaDraft = new DotaDraft(); foreach ($fantasies as $fantasy) { $fantasyModel = DotaFantasy::findOne($fantasy['id']); $stat_heroes_on_event = DotaEventHeroStat::isPresentHeroesStatInEvent($fantasyModel->event_id); $stat_players_on_event = DotaEventPlayerStat::isPresentPlayersStatInEvent($fantasyModel->event_id); //echo'<pre>';print_r($fantasyModel->name);echo'</pre>';//die; //echo'<pre>';var_dump($stat_heroes_on_event);echo'</pre>';//die; //echo'<pre>';var_dump($stat_players_on_event);echo'</pre>';//die; //если статистики по матчам еще нет - дальше не обрабатываем if (DotaEventHeroStat::isPresentHeroesStatInEvent($fantasyModel->event_id) === false && DotaEventPlayerStat::isPresentPlayersStatInEvent($fantasyModel->event_id) === false) { continue; } //echo'<pre>';print_r($fantasy_id);echo'</pre>';die; $DotaFantasy = new DotaFantasy(); $places = $DotaFantasy->calculatePlacesInFantasy($fantasyModel); //echo'<pre>';print_r($places);echo'</pre>';//die; //проверка корректности расчета процентов по выйгрышу //if(PrizeMatrix::calculationIsCorrect($places) === false) return 1; $prizes = $DotaFantasy->calculatePrizesInFantasy($fantasyModel, $places); echo '<pre>'; print_r($prizes); echo '</pre>'; //die; //проверка корректности расчета сумм по выйгрышу //if(PrizeMatrix::calculationIsCorrect($places, $fantasyModel->prize_pool) === false) return 2; $DotaDraft->updatePrizeValues($prizes, $fantasy['id']); /* foreach($prizes as $user_id=>$value) { $values = [ 'prize' => $value, ]; $where = [ 'fantasy_id = ' . $fantasy['id'], 'user_id = ' . $user_id, ]; $DotaDraft->updateRow($values, $where); } */ } //die; return true; }