private function makeMatchForm($matchForm, Category $category, $noofgroups)
 {
     $groupnames = array();
     /* @var $group Group */
     foreach ($category->getGroups() as $group) {
         $groupnames[$group->getId()] = $group->getName();
     }
     $show = true;
     $formDef = $this->createFormBuilder($matchForm);
     switch ($noofgroups) {
         case 1:
             $formDef->add('strategy', 'choice', array('label' => 'FORM.QMATCHPLANNING.GROUP.ONE', 'placeholder' => false, 'choices' => array('option1' => 'FORM.QMATCHPLANNING.RADIO.GROUP1.OPTION1', 'option2' => 'FORM.QMATCHPLANNING.RADIO.GROUP1.OPTION2'), 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin', 'expanded' => true, 'multiple' => false));
             break;
         case 2:
             $formDef->add('strategy', 'choice', array('label' => 'FORM.QMATCHPLANNING.GROUP.TWO', 'placeholder' => false, 'choices' => array('option1' => 'FORM.QMATCHPLANNING.RADIO.GROUP2.OPTION1', 'option2' => 'FORM.QMATCHPLANNING.RADIO.GROUP2.OPTION2', 'option3' => 'FORM.QMATCHPLANNING.RADIO.GROUP2.OPTION3'), 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin', 'expanded' => true, 'multiple' => false));
             break;
         case 3:
             $formDef->add('strategy', 'choice', array('label' => 'FORM.QMATCHPLANNING.GROUP.THREE', 'placeholder' => false, 'choices' => array('option1' => 'FORM.QMATCHPLANNING.RADIO.GROUP3.OPTION1', 'option2' => 'FORM.QMATCHPLANNING.RADIO.GROUP3.OPTION2'), 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin', 'expanded' => true, 'multiple' => false));
             break;
         case 4:
             $formDef->add('strategy', 'choice', array('label' => 'FORM.QMATCHPLANNING.GROUP.FOUR', 'placeholder' => false, 'choices' => array('option1' => 'FORM.QMATCHPLANNING.RADIO.GROUP4.OPTION1', 'option2' => 'FORM.QMATCHPLANNING.RADIO.GROUP4.OPTION2'), 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin', 'expanded' => true, 'multiple' => false));
             break;
     }
     $formDef->add('cancel', 'submit', array('label' => 'FORM.MATCH.CANCEL.CHG', 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times'));
     $formDef->add('save', 'submit', array('label' => 'FORM.MATCH.SUBMIT.CHG', 'translation_domain' => 'admin', 'icon' => 'fa fa-check'));
     return $formDef->getForm();
 }
 private function makeMatchForm(MatchForm $matchForm, Category $category, $classification, $action)
 {
     $groupnames = array();
     foreach ($category->getGroups() as $group) {
         if ($group->getClassification() < $classification && $group->getClassification() < Group::$BRONZE) {
             $groupnames[$group->getId()] = $this->get('translator')->trans('GROUP', array(), 'tournament') . " " . $group->getName();
         }
     }
     $show = $action != 'del';
     $formDef = $this->createFormBuilder($matchForm);
     $formDef->add('groupA', 'choice', array('label' => 'FORM.MATCH.QHOME.GROUP', 'choices' => $groupnames, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin'));
     $formDef->add('rankA', 'text', array('label' => 'FORM.MATCH.QHOME.RANK', 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin'));
     $formDef->add('groupB', 'choice', array('label' => 'FORM.MATCH.QAWAY.GROUP', 'choices' => $groupnames, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin'));
     $formDef->add('rankB', 'text', array('label' => 'FORM.MATCH.QAWAY.RANK', 'required' => false, 'disabled' => !$show, 'translation_domain' => 'admin'));
     $formDef->add('cancel', 'submit', array('label' => 'FORM.MATCH.CANCEL.' . strtoupper($action), 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times'));
     $formDef->add('save', 'submit', array('label' => 'FORM.MATCH.SUBMIT.' . strtoupper($action), 'translation_domain' => 'admin', 'icon' => 'fa fa-check'));
     return $formDef->getForm();
 }
Example #3
0
 private function addTeam(Category $category, Group $group, Club $club, $division, User $user)
 {
     $team = new Team();
     $team->setName($club->getName());
     $team->setColor($category->getName() . $group->getName() . ($group->getGroupOrder()->count() + 1));
     $team->setDivision($division);
     $team->setVacant(false);
     $team->setClub($club);
     $club->getTeams()->add($team);
     $this->em->persist($team);
     $grouporder = new GroupOrder();
     $grouporder->setGroup($group);
     $grouporder->setTeam($team);
     $team->getGroupOrder()->add($grouporder);
     $group->getGroupOrder()->add($grouporder);
     $this->em->persist($grouporder);
     $enrollment = new Enrollment();
     $enrollment->setTeam($team);
     $enrollment->setCategory($category);
     $enrollment->setDate(Date::getDate(new DateTime()));
     $enrollment->setUser($user);
     $team->getEnrollments()->add($enrollment);
     $category->getEnrollments()->add($enrollment);
     $user->getEnrollments()->add($enrollment);
     $this->em->persist($enrollment);
 }
 public function isCategoryAllowed(Category $category)
 {
     return count($this->categories) == 0 || isset($this->categories[$category->getId()]);
 }
 private function checkForm($form, Category $category)
 {
     if ($form->isValid()) {
         if ($category->getName() == null || trim($category->getName()) == '') {
             $form->addError(new FormError($this->get('translator')->trans('FORM.CATEGORY.NONAME', array(), 'admin')));
         }
         if ($category->getGender() == null) {
             $form->addError(new FormError($this->get('translator')->trans('FORM.CATEGORY.NOGENDER', array(), 'admin')));
         }
         if ($category->getClassification() == null) {
             $form->addError(new FormError($this->get('translator')->trans('FORM.CATEGORY.NOCLASSIFICATION', array(), 'admin')));
         }
         if ($category->getAge() == null || trim($category->getAge()) == '') {
             $form->addError(new FormError($this->get('translator')->trans('FORM.CATEGORY.NOAGE', array(), 'admin')));
         }
         if ($category->getMatchtime() == null || trim($category->getMatchtime()) == '') {
             $form->addError(new FormError($this->get('translator')->trans('FORM.CATEGORY.NOMATCHTIME', array(), 'admin')));
         }
     }
     return $form->isValid();
 }
 public function findTeamByCategory(Category $category, $name, $division)
 {
     $qb = $this->em->createQuery("select t " . "from " . $this->entity->getRepositoryPath('Enrollment') . " e, " . $this->entity->getRepositoryPath('Team') . " t " . "where e.category=:category and " . "e.team=t.id and " . "t.name=:name and " . "t.division=:division");
     $qb->setParameter('category', $category->getId());
     $qb->setParameter('name', $name);
     $qb->setParameter('division', $division);
     return $qb->getResult();
 }
 private function importCategories(Tournament $source_tournament, Tournament $tournament)
 {
     $em = $this->getDoctrine()->getManager();
     $cconversion = array();
     /* @var $category Category */
     foreach ($source_tournament->getCategories() as $category) {
         $new_category = new Category();
         $new_category->setTournament($tournament);
         $new_category->setName($category->getName());
         $new_category->setGender($category->getGender());
         $new_category->setClassification($category->getClassification());
         $new_category->setAge($category->getAge());
         $new_category->setMatchtime($category->getMatchtime());
         $em->persist($new_category);
         $cconversion[$category->getId()] = $new_category;
         foreach ($category->getGroups() as $group) {
             $new_group = new Group();
             $new_group->setCategory($new_category);
             $new_group->setName($group->getName());
             $new_group->setClassification($group->getClassification());
             $em->persist($new_group);
         }
     }
     $em->flush();
     return $cconversion;
 }
 private function populateQMatches(Category $category, $strategy)
 {
     $matchList = array();
     uksort($strategy, function ($k1, $k2) {
         preg_match('/(?<group>\\d+):(?<litra>\\d+[AB]*)/', $k1, $v1);
         preg_match('/(?<group>\\d+):(?<litra>\\d+[AB]*)/', $k2, $v2);
         if ($v1["group"] == $v2["group"]) {
             return $v1["litra"] - $v2["litra"];
         }
         return $v1["group"] - $v2["group"];
     });
     foreach ($strategy as $key => $matches) {
         preg_match('/(?<classification>\\d+):(?<litra>\\d+[AB]*)/', $key, $group);
         foreach ($matches as $match) {
             if ($category->getTrophys() < 3 && $group['classification'] == Group::$BRONZE) {
                 continue;
             }
             $qmp = new QMatchPlan();
             $qmp->setClassification($group['classification']);
             $qmp->setLitra($group['litra']);
             preg_match('/(?<classification>\\d+):(?<litra>\\d+)(?<branch>[AB]*)r(?<rank>\\d+)/', $match[0], $team);
             $qmp->setRelA(new QRelation($team['classification'], $team['litra'], $team['rank'], isset($team['branch']) ? $team['branch'] : ''));
             preg_match('/(?<classification>\\d+):(?<litra>\\d+)(?<branch>[AB]*)r(?<rank>\\d+)/', $match[1], $team);
             $qmp->setRelB(new QRelation($team['classification'], $team['litra'], $team['rank'], isset($team['branch']) ? $team['branch'] : ''));
             $qmp->setFixed(false);
             $matchList[] = $qmp;
         }
     }
     return $matchList;
 }