Esempio n. 1
0
 /**
  * @return Poule
  */
 public function getPoule()
 {
     if (!$this->poule) {
         $this->poule = Poule::getByNefubId($this->poule_nefub_id);
     }
     return $this->poule;
 }
Esempio n. 2
0
 /**
  * 
  * @param int $nefubId
  */
 public function showPoule($nefubId)
 {
     $this->subdirectory = '/poule';
     $this->path = '/' . $nefubId;
     $this->template = '/poule/poule.tpl';
     if ($this->getClearRender()) {
         $oPoule = Poule::getByNefubId($nefubId);
         if ($oPoule) {
             if ($oPoule->getCompetition()->getGenre()->nefub_name == 'jeugd' || $oPoule->getCompetition()->getGenre()->nefub_name == 'beker') {
                 $oPagePoule = Poule::getSingle(array('competition_nefub_id' => $oPoule->getCompetition()->nefub_id), 'nefub_id');
             } else {
                 $oPagePoule = $oPoule;
             }
             $this->assign('oPoule', $oPoule);
             $this->assign('oPagePoule', $oPagePoule);
             $this->assign('hasRanking', $oPoule->hasRanking());
         } else {
             $this->redirect();
         }
     }
     $this->showOutput();
 }
Esempio n. 3
0
 public function updateTeams()
 {
     $aPoules = Poule::getAll(array('season_nefub_id' => Season::getInstance()->nefub_id), 'competition_nefub_id');
     foreach ($aPoules as $oPoule) {
         $aPouleTeams = $oPoule->getPouleTeams();
         foreach ($aPouleTeams as $oPouleTeam) {
             $team = $this->getAPITeamDetails($oPouleTeam->team_nefub_id);
             $oTeam = Team::getByNefubId($team->ID);
             if (!$oTeam) {
                 $oTeam = new Team();
                 $oTeam->nefub_id = $team->ID;
                 $oTeam->name = $team->Name;
                 $oTeam->competition_nefub_id = $oPoule->competition_nefub_id;
                 $oTeam->season_nefub_id = $oPoule->getCompetition()->season_nefub_id;
                 $oTeam->club_nefub_id = $team->Club->ID;
                 $oTeam->color_shirt = $team->Dress->Shirt;
                 $oTeam->color_shorts = $team->Dress->Short;
                 self::put('Team ' . $team->Name . ' toegevoegd');
                 $oTeam->save();
             }
             if (isset($team->Players) && is_array($team->Players)) {
                 foreach ($team->Players as $teamPlayer) {
                     $this->convertTeamPerson($teamPlayer, $oTeam);
                 }
             } else {
                 self::put('Geen spelers gevonden voor ' . $team->Name);
             }
             $this->retrieveClub($team->Club);
             $this->retrieveTeamGames($team, 'schedule');
             $query = "SELECT COUNT(Game.nefub_id) as countGames\n\t\t\t\t\t\t\tFROM Game\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(team1_nefub_id = '" . $team->ID . "'\n\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\tteam2_nefub_id = '" . $team->ID . "')\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tGame.date <= CURDATE()";
             $rows = Database::select_rows_by_query($query);
             $playedGames = $rows[0]['countGames'];
             $bRetrieveResults = false;
             if ($playedGames) {
                 // Als er geen oude wedstrijden in de DB staan, vermoedelijk zijn ze dan niet eerder opgehaald.
                 $query .= " AND Game.actions_retrieved = 0";
                 $rows = Database::select_rows_by_query($query);
                 $gamesToRetrieve = $rows[0]['countGames'];
                 $bRetrieveResults = $gamesToRetrieve != 0;
             }
             if ($bRetrieveResults) {
                 $this->retrieveTeamGames($team, 'results');
             } else {
                 self::put('Resultaten voor ' . $oTeam->name . ' hoeven niet vernieuwd te worden');
             }
             $oTeam->save();
             $this->retrievedTeamNefubIds[$oPouleTeam->team_nefub_id] = true;
         }
     }
 }
Esempio n. 4
0
 /**
  * 
  * @return array
  */
 public function getPoules()
 {
     return Poule::getAll(array('competition_nefub_id' => $this->nefub_id), 'sorting');
 }
Esempio n. 5
0
 /**
  * 
  * @param Poul $poule
  * @param Team $oTeam
  * @return PouleTeam
  */
 private function convertPouleTeam(stdClass $poule, Team $oTeam)
 {
     $oPoule = Poule::getByNefubID($poule->ID);
     if (!$oPoule) {
         $oPoule = new Poule();
         $oPoule->nefub_id = $poule->ID;
         self::put('Fout: poule ' . $oPoule->nefub_id . ' toegevoegd:' . $oPoule->name . ' bij toevoegen van personen');
     }
     $oPoule->name = $poule->Name;
     // copy info from team
     $oPoule->competition_nefub_id = $oTeam->competition_nefub_id;
     $oPoule->season_nefub_id = Season::getInstance()->nefub_id;
     $oPoule->save();
     $oPouleTeam = PouleTeam::getByNefubID($oTeam->nefub_id, $oPoule->nefub_id);
     if (!$oPouleTeam) {
         $oPouleTeam = new PouleTeam();
         $oPouleTeam->poule_nefub_id = $oPoule->nefub_id;
         $oPouleTeam->team_nefub_id = $oTeam->nefub_id;
         $oPouleTeam->save();
         self::put('Team ' . $oTeam->name . ' aan poule ' . $oPoule->nefub_id . ' toegevoegd:' . $oPoule->name);
     }
     return $oPouleTeam;
 }
Esempio n. 6
0
 protected function showPoules()
 {
     switch ($this->mode) {
         case 'bewerken':
             $oPoule = Poule::getByNefubId($this->editId);
             $this->editObject($oPoule);
             break;
         default:
             $this->assign('aPoules', Poule::getAll(array('season_nefub_id' => Season::getInstance()->nefub_id), 'name'));
             $this->showCompetitionDependentView('/poules.tpl');
     }
 }