private function makeImportForm(Tournament $tournament)
 {
     $tournaments = $tournament->getHost()->getTournaments();
     $tournamentList = array();
     foreach ($tournaments as $tmnt) {
         if ($tmnt->getId() != $tournament->getId()) {
             $tournamentList[$tmnt->getId()] = $tmnt->getName();
         }
     }
     $formDef = $this->createFormBuilder(array('tournament' => ''));
     $formDef->add('tournament', 'choice', array('label' => 'FORM.TOURNAMENTIMPORT.TOURNAMENT.PROMPT', 'help' => 'FORM.TOURNAMENTIMPORT.TOURNAMENT.HELP', 'choices' => $tournamentList, 'empty_value' => 'FORM.TOURNAMENTIMPORT.DEFAULT', 'required' => false, 'disabled' => false, 'translation_domain' => 'admin'));
     $formDef->add('cancel', 'submit', array('label' => 'FORM.TOURNAMENTIMPORT.CANCEL', 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times'));
     $formDef->add('save', 'submit', array('label' => 'FORM.TOURNAMENTIMPORT.SUBMIT', 'translation_domain' => 'admin', 'icon' => 'fa fa-check'));
     return $formDef->getForm();
 }
 private function listEnrolled(Tournament $tmnt, Club $club)
 {
     $host = $tmnt->getHost();
     $enrolled = $this->get('logic')->listEnrolledByClub($tmnt->getId(), $club->getId());
     $enrolledList = array();
     /* @var $enroll Enrollment */
     foreach ($enrolled as $enroll) {
         $enrolledList[$enroll->getCategory()->getId()][] = $enroll;
     }
     $classMap = array();
     $categoryMap = array();
     /* @var $category Category */
     foreach ($tmnt->getCategories() as $category) {
         $classification = $category->getClassification() . $category->getAge();
         $classMap[$classification] = $classification;
         $cls = $category->getGender() . $classification;
         $categoryMap[$cls][] = $category;
     }
     return array('host' => $host, 'tournament' => $tmnt, 'club' => $club, 'classifications' => $classMap, 'enrolled' => $enrolledList, 'categories' => $categoryMap);
 }
 private function makeResultForm(Tournament $tournament)
 {
     $categories = array();
     foreach ($tournament->getCategories() as $category) {
         $categories[$category->getId()] = $this->get('translator')->trans('CATEGORY', array(), 'tournament') . " " . $category->getName() . " - " . $this->get('translator')->transChoice('GENDER.' . $category->getGender() . $category->getClassification(), $category->getAge(), array('%age%' => $category->getAge()), 'tournament');
     }
     $playgroundList = $this->get('logic')->listPlaygroundsByTournament($tournament->getId());
     $playgrounds = array();
     foreach ($playgroundList as $playground) {
         $playgrounds[$playground->getId()] = $playground->getName();
     }
     $formDef = $this->createFormBuilder();
     $formDef->add('matchno', 'text', array('label' => 'FORM.MATCHPLANNING.MATCHNO', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.MATCHNO', 'icon' => 'fa fa-lg fa-tag', 'translation_domain' => 'admin'));
     $formDef->add('date', 'text', array('label' => 'FORM.MATCHPLANNING.DATE', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.DATE', 'icon' => 'fa fa-lg fa-calendar', 'translation_domain' => 'admin'));
     $formDef->add('category', 'choice', array('label' => 'FORM.MATCHPLANNING.CATEGORY', 'choices' => $categories, 'empty_value' => 'FORM.MATCHPLANNING.DEFAULT', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.CATEGORY', 'icon' => 'fa fa-lg fa-sitemap', 'translation_domain' => 'admin'));
     $formDef->add('group', 'choice', array('label' => 'FORM.MATCHPLANNING.GROUP', 'choices' => array(), 'empty_value' => 'FORM.MATCHPLANNING.DEFAULT', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.GROUP', 'icon' => 'fa fa-lg fa-bookmark', 'translation_domain' => 'admin'));
     $formDef->add('playground', 'choice', array('label' => 'FORM.MATCHPLANNING.PLAYGROUND', 'choices' => $playgrounds, 'empty_value' => 'FORM.MATCHPLANNING.DEFAULT', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.PLAYGROUND', 'icon' => 'fa fa-lg fa-futbol-o', 'translation_domain' => 'admin'));
     return $formDef->getForm();
 }
 private function validateData(Tournament $tournament, &$parseObj)
 {
     $match = $this->get('match')->getMatchByNo($tournament->getId(), $parseObj['id']);
     if ($match == null) {
         throw new ValidationException("BADMATCH", "tournament=" . $tournament->getId() . " match=" . $parseObj['id']);
     }
     $qmh = $this->get('match')->getQMatchRelationByMatch($match->getId(), false);
     $teamA = $this->getTeam($qmh->getGroup(), $parseObj, 'teamA');
     $qma = $this->get('match')->getQMatchRelationByMatch($match->getId(), true);
     $teamB = $this->getTeam($qma->getGroup(), $parseObj, 'teamB');
     $parseObj['match'] = $match;
     $parseObj['teamA'] = $teamA;
     $parseObj['teamB'] = $teamB;
 }
 private function validateData(Tournament $tournament, &$parseObj)
 {
     $playground = $this->get('logic')->getPlaygroundByNo($tournament->getId(), $parseObj['playground']);
     if ($playground == null) {
         throw new ValidationException("BADPLAYGROUND", "tournament=" . $tournament->getId() . " no=" . $parseObj['playground']);
     }
     $group = $this->get('logic')->getGroupByCategory($tournament->getId(), $parseObj['category'], $parseObj['group']);
     if ($group == null) {
         throw new ValidationException("BADGROUP", "tournament=" . $tournament->getId() . " category=" . $parseObj['category'] . " group=" . $parseObj['group']);
     }
     $groupRA = $this->get('logic')->getGroupByCategory($tournament->getId(), $parseObj['category'], $parseObj['teamA']['group']);
     if ($group == null) {
         throw new ValidationException("BADGROUP", "tournament=" . $tournament->getId() . " category=" . $parseObj['category'] . " group=" . $parseObj['teamA']['group']);
     }
     $groupRB = $this->get('logic')->getGroupByCategory($tournament->getId(), $parseObj['category'], $parseObj['teamB']['group']);
     if ($group == null) {
         throw new ValidationException("BADGROUP", "tournament=" . $tournament->getId() . " category=" . $parseObj['category'] . " group=" . $parseObj['teamB']['group']);
     }
     $parseObj['playground'] = $playground;
     $parseObj['group'] = $group;
     $parseObj['teamAgroup'] = $groupRA;
     $parseObj['teamBgroup'] = $groupRB;
 }
 public function removeMatchSchedules(Tournament $tournament)
 {
     // wipe matchalternatives
     $qba = $this->em->createQuery("delete from " . $this->entity->getRepositoryPath('MatchAlternative') . " m " . "where m.matchschedule in (select ms.id " . "from " . $this->entity->getRepositoryPath('MatchSchedule') . " ms " . "where ms.tournament=:tournament)");
     $qba->setParameter('tournament', $tournament->getId());
     $qba->getResult();
     // wipe matchschedules
     foreach ($this->listMatchSchedules($tournament) as $ms) {
         $this->em->remove($ms);
     }
     $this->em->flush();
 }