Exemplo n.º 1
0
 /**
  * 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()]);
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $task
  * @param int $league_key
  * @param int $match_key
  * @return array|bool
  */
 public static function updateMatchHistoryAdv($task, $league_key = 0, $match_key = 0)
 {
     //$res = true;
     //echo'<pre>';var_dump($task);echo'</pre>';//die;
     switch ($task) {
         case 'updateMatchesResults':
             $res = self::updateMatchesResultsAdv($league_key, $match_key);
             break;
         default:
             $res = self::updateDotaMatchesPlayersSummaries();
             if ($res === true) {
                 $res = self::updateDotaMatchesHeroesSummaries();
             }
             if ($res === true) {
                 $res = self::updateDotaEventPlayerStat();
             }
             if ($res === true) {
                 $res = self::updateDotaEventHeroStat();
             }
             if ($res === true) {
                 $res = self::updateDotaDraftScores();
             }
             if ($res === true) {
                 $res = self::updateDotaDraftPrizes();
             }
             if ($res === true) {
                 $dota_last_update = LastStatUpdate::LoadDota();
                 $dota_last_update->save();
             }
             break;
     }
     return $res;
 }