diff --git a/app/DoctrineMigrations/Version20151222161500.php b/app/DoctrineMigrations/Version20151222161500.php
new file mode 100644
index 00000000..0baefe94
--- /dev/null
+++ b/app/DoctrineMigrations/Version20151222161500.php
@@ -0,0 +1,35 @@
+abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('CREATE TABLE intra_Manager (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, participant_id INT DEFAULT NULL, game_name VARCHAR(50) NOT NULL, payment_done TINYINT(1) NOT NULL, arrived TINYINT(1) NOT NULL, INDEX IDX_94DDEA20A76ED395 (user_id), UNIQUE INDEX UNIQ_94DDEA20BBABFC4A (participant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql('ALTER TABLE intra_Manager ADD CONSTRAINT FK_94DDEA20A76ED395 FOREIGN KEY (user_id) REFERENCES intra_User (id)');
+ $this->addSql('ALTER TABLE intra_Manager ADD CONSTRAINT FK_94DDEA20BBABFC4A FOREIGN KEY (participant_id) REFERENCES intra_Participant (id)');
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function down(Schema $schema)
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->addSql('DROP TABLE intra_Manager');
+ }
+}
diff --git a/app/DoctrineMigrations/Version20151230115740.php b/app/DoctrineMigrations/Version20151230115740.php
new file mode 100644
index 00000000..c43a256c
--- /dev/null
+++ b/app/DoctrineMigrations/Version20151230115740.php
@@ -0,0 +1,38 @@
+abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('ALTER TABLE intra_Manager ADD tournament_id INT DEFAULT NULL');
+ $this->addSql('ALTER TABLE intra_Manager ADD CONSTRAINT FK_94DDEA2033D1A3E7 FOREIGN KEY (tournament_id) REFERENCES intra_Tournament (id)');
+ $this->addSql('CREATE INDEX IDX_94DDEA2033D1A3E7 ON intra_Manager (tournament_id)');
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function down(Schema $schema)
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('ALTER TABLE intra_Manager DROP FOREIGN KEY FK_94DDEA2033D1A3E7');
+ $this->addSql('DROP INDEX IDX_94DDEA2033D1A3E7 ON intra_Manager');
+ $this->addSql('ALTER TABLE intra_Manager DROP tournament_id');
+ }
+}
diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php
new file mode 100644
index 00000000..7284b9db
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php
@@ -0,0 +1,369 @@
+getDoctrine()->getManager();
+
+ $usr = $this->get('security.context')->getToken()->getUser();
+
+ $manager = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ if ($manager === null)
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_setname',array('tournament' => $tournament->getId())));
+ else if ($tournament->getParticipantType() === 'team' && $manager->getParticipant() === null)
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_jointeamwithpassword',array('tournament' => $tournament->getId())));
+ else if (!$manager->getPaymentDone())
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_pay',array('tournament' => $tournament->getId())));
+ else
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_paydone',array('tournament' => $tournament->getId())));
+ }
+
+ /**
+ * Create a new manager related to a tournament
+ * @Route("/{tournament}/user/set")
+ * @Template()
+ */
+ public function setNameAction(Request $request, Entity\Tournament $tournament)
+ {
+ $em = $this->getDoctrine()->getManager();
+ $usr = $this->get('security.context')->getToken()->getUser();
+
+ $manager = $em->getRepository('InsaLanTournamentBundle:Manager')->findOneByUserAndPendingTournament($usr, $tournament);
+
+ if ($manager === null) {
+ $manager = new Manager();
+ $manager->setUser($usr);
+ $manager->setTournament($tournament);
+ }
+
+ $form = $this->createForm(new SetManagerName(), $manager);
+ $form->handleRequest($request);
+
+ if ($form->isValid()) {
+ $em->persist($manager);
+ $em->flush();
+
+ return $this->redirect(
+ $this->generateUrl('insalan_tournament_manager_jointeamwithpassword', array('tournament' => $tournament->getId()))
+ );
+ }
+
+ return array('form' => $form->createView(), 'selectedGame' => $tournament->getType(), 'tournamentId' => $tournament->getId());
+ }
+
+ /**
+ * Allow a new manager to join a team with name and password
+ * @Route("/{tournament}/user/setname")
+ * @Template()
+ */
+ public function joinTeamWithPasswordAction(Request $request, Entity\Tournament $tournament)
+ {
+ $em = $this->getDoctrine()->getManager();
+ $usr = $this->get('security.context')->getToken()->getUser();
+
+ // handle only team tournaments
+ if($tournament->getParticipantType() !== "team")
+ throw new ControllerException("Équipes non acceptées dans ce tournois");
+
+ // check if there is already a pending manager for this user and tournament
+ $manager = $em->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ if($manager === null)
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_setname', array('tournament' => $tournament->getId())));
+
+ $form_team = new Team();
+ $form = $this->createForm(new TeamLoginType(), $form_team); // fill name and plainPassword
+ $form->handleRequest($request);
+
+ // inspired by UserController::joinExistingTeam
+ // TODO rework this by putting the password hash into the request ?
+ $error_details = null;
+ if ($form->isValid()) {
+ try {
+ // hash password
+ $factory = $this->get('security.encoder_factory');
+ $encoder = $factory->getEncoder($usr);
+ $form_team->setPassword($encoder->encodePassword($form_team->getPlainPassword(), sha1('pleaseHashPasswords'.$form_team->getName())));
+ $team = $em
+ ->getRepository('InsaLanTournamentBundle:Team')
+ ->findOneByNameAndTournament($form_team->getName(), $tournament);
+
+ if ($team === null || $team->getTournament()->getId() !== $tournament->getId())
+ throw new ControllerException("Équipe invalide");
+
+ if ($team->getPassword() === $form_team->getPassword()) {
+ // denied if there is already a manager in the team
+ if ($team->getManager() != null)
+ throw new ControllerException("L'équipe a déjà un manager");
+
+ // Because PHP don't support polymorphism, we must get the corresponding Participant object
+ $team_participant = $em
+ ->getRepository('InsaLanTournamentBundle:Participant')->
+ findOneById($team->getId());
+ $manager->setParticipant($team_participant);
+ $team->setManager($manager);
+ $em->persist($manager);
+ $em->persist($team);
+ $em->flush();
+
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_pay', array('tournament' => $tournament->getId())));
+
+ } else
+ throw new ControllerException("Mot de passe invalide");
+ } catch (ControllerException $e) {
+ $error_details = $e->getMessage();
+ }
+
+ }
+ return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager, 'error' => $error_details, 'form' => $form->createView());
+ }
+
+ /**
+ * Allow a new manager to join a team with a specific token
+ * @Route("/team/{team}/enroll/{authToken}")
+ */
+ public function joinTeamWithToken()
+ {
+ # code ...
+ }
+
+ /**
+ * Payement doing and details for managers
+ * @Route("/{tournament}/user/pay/details")
+ * @Template()
+ */
+ public function payAction(Entity\Tournament $tournament) {
+ $em = $this->getDoctrine()->getManager();
+
+ $usr = $this->get('security.context')->getToken()->getUser();
+ $manager = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ if($tournament->isFree()) {
+ $manager->setPaymentDone(true);
+ $em->persist($manager);
+ $em->flush();
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_paydone', array("tournament" => $tournament->getId())));
+ }
+
+ return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager);
+ }
+
+ /**
+ * Paypal stuff
+ * @Route("/{tournament}/user/pay/paypal_ec")
+ */
+ public function payPaypalECAction(Entity\Tournament $tournament) {
+ $em = $this->getDoctrine()->getManager();
+
+ $usr = $this->get('security.context')->getToken()->getUser();
+ $manager = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ $paymentName = 'paypal_express_checkout_and_doctrine_orm';
+
+ $price = ($manager::ONLINE_PRICE + $tournament->getOnlineIncreaseInPrice());
+
+ $storage = $this->get('payum')->getStorage('InsaLan\UserBundle\Entity\PaymentDetails');
+ $order = $storage->createModel();
+ $order->setUser($usr);
+
+ $order['PAYMENTREQUEST_0_CURRENCYCODE'] = $tournament->getCurrency();
+ $order['PAYMENTREQUEST_0_AMT'] = $price;
+
+ $order['L_PAYMENTREQUEST_0_NAME0'] = 'Place manager pour le tournoi '.$tournament->getName();
+ $order['L_PAYMENTREQUEST_0_AMT0'] = $manager::ONLINE_PRICE;
+ $order['L_PAYMENTREQUEST_0_DESC0'] = $tournament->getDescription();
+ $order['L_PAYMENTREQUEST_0_NUMBER0'] = 1;
+
+ $order['L_PAYMENTREQUEST_0_NAME1'] = 'Majoration paiement en ligne';
+ $order['L_PAYMENTREQUEST_0_AMT1'] = $tournament->getOnlineIncreaseInPrice();
+ $order['L_PAYMENTREQUEST_0_DESC1'] = 'Frais de gestion du paiement';
+ $order['L_PAYMENTREQUEST_0_NUMBER1'] = 1;
+
+ $storage->updateModel($order);
+
+ $payment = $this->get('payum')->getPayment('paypal_express_checkout_and_doctrine_orm');
+ $captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
+ $paymentName,
+ $order,
+ 'insalan_tournament_manager_paydonetemp',
+ array('tournament' => $tournament->getId())
+ );
+
+ $order['RETURNURL'] = $captureToken->getTargetUrl();
+ $order['CANCELURL'] = $captureToken->getTargetUrl();
+ $order['INVNUM'] = $usr->getId();
+ $storage->updateModel($order);
+ return $this->redirect($captureToken->getTargetUrl());
+ }
+
+ /**
+ * Payment sum up
+ * @Route("/{tournament}/user/pay/done")
+ * @Template()
+ */
+ public function payDoneAction(Request $request, Entity\Tournament $tournament) {
+ $em = $this->getDoctrine()->getManager();
+ $usr = $this->get('security.context')->getToken()->getUser();
+ $manager = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager);
+ }
+
+ /**
+ * Perform payment validation
+ * @Route("/{tournament}/user/pay/done_temp")
+ */
+ public function payDoneTempAction(Request $request, Entity\Tournament $tournament) {
+ $em = $this->getDoctrine()->getManager();
+ $usr = $this->get('security.context')->getToken()->getUser();
+ $player = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ $token = $this->get('payum.security.http_request_verifier')->verify($request);
+ $payment = $this->get('payum')->getPayment($token->getPaymentName());
+
+ //$this->get('payum.security.http_request_verifier')->invalidate($token);
+
+ $payment->execute($status = new GetHumanStatus($token));
+
+ if ($status->isCaptured()) {
+ $player->setPaymentDone(true);
+ $em->persist($player);
+ $em->flush();
+ }
+ return $this->redirect($this->generateUrl('insalan_tournament_manager_paydone', array('tournament' => $tournament->getId())));
+ }
+
+ /**
+ * Offer offline payment choices
+ * @Route("/{tournament}/user/pay/offline")
+ * @Template()
+ */
+ public function payOfflineAction(Request $request, Entity\Tournament $tournament) {
+ $em = $this->getDoctrine()->getManager();
+ $usr = $this->get('security.context')->getToken()->getUser();
+ $manager = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager);
+ }
+
+ /**
+ * Allow a manager to drop a pending tournament registration if not managed by team
+ * @Route("/{tournament}/user/leave")
+ */
+ public function leaveAction(Entity\Tournament $tournament) {
+ $em = $this->getDoctrine()->getManager();
+
+ $usr = $this->get('security.context')->getToken()->getUser();
+ $manager = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $tournament);
+
+ if($manager->getTournament()->getParticipantType() !== "player")
+ throw new ControllerException("Not Allowed"); // must be a player only tournament
+
+ $em->remove($manager);
+ $em->flush();
+
+ return $this->redirect($this->generateUrl('insalan_tournament_user_index'));
+ }
+
+ /**
+ * Allow a manager to drop a pending tournament registration managed by teams
+ * @Route("/user/leave/team/{teamId}")
+ * @Template()
+ */
+ public function leaveTeamAction($teamId) {
+ $em = $this->getDoctrine()->getManager();
+ $team = $em
+ ->getRepository('InsaLanTournamentBundle:Team')
+ ->findOneById($teamId);
+
+ if($team === null)
+ return $this->redirect($this->generateUrl('insalan_tournament_user_index'));
+
+ // get targeted manager
+ $usr = $this->get('security.context')->getToken()->getUser();
+ $manager = $em
+ ->getRepository('InsaLanTournamentBundle:Manager')
+ ->findOneByUserAndPendingTournament($usr, $team->getTournament());
+
+ // is he part of the team roster ?
+ if($team->getManager() != $manager)
+ return $this->redirect($this->generateUrl('insalan_tournament_user_index'));
+
+ // not allowed if he paid something
+ if(!$team->getTournament()->isFree() && $manager->getPaymentDone()){
+ $this->get('session')->getFlashBag()->add('error', "Vous avez payé votre place, merci de contacter l'InsaLan si vous souhaitez vous désister.");
+ return $this->redirect($this->generateUrl('insalan_tournament_user_index'));
+ }
+ // not allowed either if registration are closed
+ if(!$team->getTournament()->isOpenedNow())
+ return $this->redirect($this->generateUrl('insalan_tournament_user_index'));
+
+ $manager->setParticipant(null);
+ $team->setManager(null);
+
+ $em->persist($team);
+ $em->remove($manager);
+ $em->flush();
+ return $this->redirect($this->generateUrl('insalan_tournament_user_index'));
+ }
+
+}
+
+?>
diff --git a/src/InsaLan/TournamentBundle/Controller/UserController.php b/src/InsaLan/TournamentBundle/Controller/UserController.php
index 56ec6921..87283c06 100644
--- a/src/InsaLan/TournamentBundle/Controller/UserController.php
+++ b/src/InsaLan/TournamentBundle/Controller/UserController.php
@@ -55,7 +55,7 @@ public function indexAction() {
}
$rawTournaments = $em->getRepository('InsaLanTournamentBundle:Tournament')->findThisYearTournaments();
- // participants can be either a single player of a team
+ // participants can be either a single player, a team or a manager
$participants = $em->getRepository('InsaLanTournamentBundle:Participant')->findByUser($usr);
$tournaments = array();
@@ -454,7 +454,7 @@ public function leaveTeamAction($teamId) {
// not allowed if he paid something
if(!$team->getTournament()->isFree() && $player->getPaymentDone()){
- $this->get('session')->getFlashBag()->add('error', "Vous avez payé votre place, merci de contacter l'équipe si vous souhaitez vous désistez.");
+ $this->get('session')->getFlashBag()->add('error', "Vous avez payé votre place, merci de contacter l'InsaLan si vous souhaitez vous désister.");
return $this->redirect($this->generateUrl('insalan_tournament_user_index'));
}
// not allowed either if registration are closed
diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php
new file mode 100644
index 00000000..2296f466
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Entity/Manager.php
@@ -0,0 +1,255 @@
+paymentDone = false;
+ $this->arrived = false;
+ }
+
+ /**
+ * Get id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Get user
+ *
+ * @return \InsaLan\UserBundle\Entity\User
+ */
+ public function getUser()
+ {
+ return $this->user;
+ }
+
+ /**
+ * Set user
+ *
+ * @param \InsaLan\UserBundle\Entity\User $user
+ * @return Manager
+ */
+ public function setUser(\InsaLan\UserBundle\Entity\User $user = null)
+ {
+ $this->user = $user;
+ return $this;
+ }
+
+ /**
+ * Get tournament
+ *
+ * @return \InsaLan\TournamentBundle\Entity\Tournament
+ */
+ public function getTournament()
+ {
+ return $this->tournament;
+ }
+
+ /**
+ * Set tournament
+ *
+ * @param \InsaLan\TournamentBundle\Entity\Tournament $tournament
+ * @return Manager
+ */
+ public function setTournament(\InsaLan\TournamentBundle\Entity\Tournament $tournament = null)
+ {
+ $this->tournament = $tournament;
+ return $this;
+ }
+
+ /**
+ * Get realted participant
+ *
+ * @return \InsaLan\UserBundle\Entity\Participant
+ */
+ public function getParticipant()
+ {
+ return $this->participant;
+ }
+
+ /**
+ * Set related participant
+ *
+ * @param \InsaLan\UserBundle\Entity\Participant $participant
+ * @return Manager
+ */
+ public function setParticipant(\InsaLan\TournamentBundle\Entity\Participant $participant = null)
+ {
+ $this->participant = $participant;
+ return $this;
+ }
+
+ /**
+ * Get gameName
+ *
+ * @return string
+ */
+ public function getGameName()
+ {
+ return $this->gameName;
+ }
+
+ /**
+ * Set gameName
+ *
+ * @param string $gameName
+ * @return Manager
+ */
+ public function setGameName($gameName)
+ {
+ $this->gameName = $gameName;
+
+ return $this;
+ }
+
+ /**
+ * Get paymentDone
+ *
+ * @return boolean
+ */
+ public function getPaymentDone()
+ {
+ return $this->paymentDone;
+ }
+
+ /**
+ * Set paymentDone
+ *
+ * @param boolean $paymentDone
+ * @return Manager
+ */
+ public function setPaymentDone($paymentDone)
+ {
+ $this->paymentDone = $paymentDone;
+
+ return $this;
+ }
+
+ public function isOk() {
+ return $this->paymentDone;
+ }
+
+ /**
+ * Set arrived
+ *
+ * @param boolean $arrived
+ * @return Manager
+ */
+ public function setArrived($arrived)
+ {
+ $this->arrived = $arrived;
+
+ return $this;
+ }
+
+ /**
+ * Get arrived
+ *
+ * @return boolean
+ */
+ public function getArrived()
+ {
+ return $this->arrived;
+ }
+
+ /**
+ * To string
+ *
+ * @return String
+ */
+ public function __toString() {
+ return $this->getName();
+ }
+
+ /**
+ * is set
+ */
+ public function isNamed($type) {
+ return $this->gameName !== null;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName() {
+ if (isset($this->gameName)) {
+ return $this->gameName;
+ } else {
+ return "Manager sans nom";
+ }
+ }
+}
diff --git a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php
new file mode 100644
index 00000000..d7f054f4
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php
@@ -0,0 +1,28 @@
+createQueryBuilder('m')
+ ->where('m.user = :user AND m.tournament = :tournament')
+ ->setParameter('user', $u)
+ ->setParameter('tournament', $t);
+
+ try {
+ return $q->getQuery()->getSingleResult();
+ } catch(\Exception $e) {
+ return null;
+ }
+ }
+}
diff --git a/src/InsaLan/TournamentBundle/Entity/Participant.php b/src/InsaLan/TournamentBundle/Entity/Participant.php
index 8fedcfe2..e7967358 100644
--- a/src/InsaLan/TournamentBundle/Entity/Participant.php
+++ b/src/InsaLan/TournamentBundle/Entity/Participant.php
@@ -50,6 +50,11 @@ abstract class Participant
*/
protected $placement;
+ /**
+ * @ORM\OneToOne(targetEntity="Manager", mappedBy="participant")
+ */
+ protected $manager;
+
public function getParticipantType() {
return "participant";
}
@@ -188,4 +193,26 @@ public function getPlacement()
{
return $this->placement;
}
+
+ /**
+ * Set manager
+ *
+ * @param integer manager
+ * @return Participant
+ */
+ public function setManager($manager)
+ {
+ $this->manager = $manager;
+ return $this;
+ }
+
+ /**
+ * Get Manager
+ *
+ * @return integer
+ */
+ public function getManager()
+ {
+ return $this->manager;
+ }
}
diff --git a/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php b/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php
index c5e15d8b..e8b47b3f 100644
--- a/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php
+++ b/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php
@@ -37,8 +37,25 @@ public function findByUser(\InsaLan\UserBundle\Entity\User $u) {
$query->execute();
$result2 = $query->getResult();
+
+ $query = $em->createQuery("
+ SELECT pa
+ FROM InsaLanTournamentBundle:Participant pa,
+ InsaLanTournamentBundle:Manager ma
+
+ JOIN ma.participant t
+
+ WHERE ma.user = :user
+ AND pa.id = t.id
+ AND pa.tournament IS NOT NULL
+ ")->setParameter('user', $u);
+
+ $query->execute();
+
+ $result3 = $query->getResult();
+
- return new ArrayCollection(array_merge($result1, $result2));
+ return new ArrayCollection(array_merge($result1, $result2, $result3));
}
@@ -53,4 +70,4 @@ public function findOneByUserAndTournament(\InsaLan\UserBundle\Entity\User $u, T
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/InsaLan/TournamentBundle/Form/SetManagerName.php b/src/InsaLan/TournamentBundle/Form/SetManagerName.php
new file mode 100644
index 00000000..fd39abe1
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Form/SetManagerName.php
@@ -0,0 +1,39 @@
+add('gameName')
+ ;
+ }
+
+ /**
+ * @param OptionsResolverInterface $resolver
+ */
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'InsaLan\TournamentBundle\Entity\Manager'
+ ));
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return 'insalan_tournamentbundle_manager';
+ }
+}
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/AfterPaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/AfterPaymentActive.html.twig
new file mode 100644
index 00000000..2fa3b880
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/AfterPaymentActive.html.twig
@@ -0,0 +1,94 @@
+{% if manager.paymentDone %}
+
+
+
+ {% if tournament.free %}
+ Votre inscription en tant que manager est validée. Si vous êtes en équipe, votre équipe sera validée quand plus de la moitié des joueurs auront validé leur inscription.
+ {% else %}
+ Votre paiement a été validé.
+ {% endif %}
+
+ Ces informations vous seront utiles plus tard :
+
+
+
+
+ Nom de votre compte insalan.fr
+ |
+
+ {{ user.username }}
+ |
+
+
+
+ Email de contact
+ |
+
+ {{ user.email }}
+ |
+
+
+
+
+ Tournoi
+ |
+
+ {{ tournament.name }}
+ |
+
+
+
+ Pseudonyme en jeu
+ |
+
+ {{ manager.name }}
+ |
+
+
+
+
+ Début du tournoi
+ |
+
+ Le {{ tournament.tournamentOpen|date('d/m/Y à H:i') }}
+ |
+
+
+
+ Fin du tournoi
+ |
+
+ Le {{ tournament.tournamentClose|date('d/m/Y à H:i') }}
+ |
+
+
+
+
+
Ok
+
+
+{% else %}
+
+
+
+ {{ counter }}
+
+ Echec du paiement
+
+
+
+ Une erreur est survenue. Vous pouvez contacter un administrateur via contact@insalan.fr ou au 06 29 57 89 95.
+
+
Réessayer
+
+{% endif %}
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig
new file mode 100644
index 00000000..c635fa94
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Prix de la place |
+ {{ constant('ONLINE_PRICE', manager) }} {{ tournament.currency }} |
+
+
+ Majoration si paiement en ligne |
+ {{ tournament.onlineIncreaseInPrice }} {{ tournament.currency }} |
+
+
+
+
+
+
+ {% if tournament.participantType == 'team' %}
+
Annuler
+ {% else %}
+
Annuler
+ {% endif %}
+
+ {% if manager.participant.validated %}
+
+
Chèque/Sur place
+
Paiement en ligne
+
+ {% else %}
+
+
L'équipe choisie n'est pas validée !
+
+ {% endif %}
+
+
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentValidated.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentValidated.html.twig
new file mode 100644
index 00000000..df282800
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentValidated.html.twig
@@ -0,0 +1,13 @@
+
+
+
+ {{ counter }}
+
+ {% if tournament.free %}
+ Tournoi gratuit, pas de paiement
+ {% else %}
+ Récapitulatif avant paiement
+ {% endif %}
+
+
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameActive.html.twig
new file mode 100644
index 00000000..b15a8ba1
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameActive.html.twig
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameValidated.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameValidated.html.twig
new file mode 100644
index 00000000..11ac4f51
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameValidated.html.twig
@@ -0,0 +1,11 @@
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/CreateJoinTeamValidated.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/CreateJoinTeamValidated.html.twig
new file mode 100644
index 00000000..798a0871
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/CreateJoinTeamValidated.html.twig
@@ -0,0 +1,9 @@
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig
new file mode 100644
index 00000000..3aeb3cd1
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig
@@ -0,0 +1,41 @@
+{% if error %}
+
+
+
+{% else %}
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/WaitPaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/WaitPaymentActive.html.twig
new file mode 100644
index 00000000..fe5a1d70
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/WaitPaymentActive.html.twig
@@ -0,0 +1,35 @@
+
+
+
+ {{ counter }}
+
+ Paiement en attente
+
+
+
+
+
Paiement par chèque
+ Vous devez envoyer un chèque de {{ constant('ONLINE_PRICE', manager) }}€ à l'ordre de
"AEIR InsaLan" par la poste à l'adresse suivante :
+
+ Vincent Giraud
+ DB104 INSA Rennes
+ 20 avenue des Buttes de Coësmes CS 70839
+ 35708 Rennes CEDEX 7
+
+ Votre inscription sera validé par le staff à la réception du chèque.
+
+
Paiement sur place
+ Le tarif manager sur place s'élève à {{ constant('ONSITE_PRICE', manager) }}€.
+ Vous pourrez régler sur place en liquide, par chèque ou par carte bancaire (avec une majoration de 1€ pour la CB).
+
+
+
Points importants
+
+ - Si vous coachez une équipe, celle-ci ne doit pas comporter de remplaçant afin que vous ayez la place de vous installer.
+
+
+
+
Ok
+
+
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/joinTeamWithPassword.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/joinTeamWithPassword.html.twig
new file mode 100644
index 00000000..a1454739
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/joinTeamWithPassword.html.twig
@@ -0,0 +1,25 @@
+{% extends 'InsaLanTournamentBundle::layout.html.twig' %}
+
+{% block body %}
+{{ parent() }}
+
+
+
+
+
+ Rejoindre le tournoi « {{ tournament.name }} » en tant que manager
+ {{ tournament.description }}
+
+
+
+
+ {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%}
+ {% include 'InsaLanTournamentBundle:Manager:JoinTeamActive.html.twig' with {'counter': 2}%}
+
+
+
+{% endblock %}
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig
new file mode 100644
index 00000000..d25a94d7
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig
@@ -0,0 +1,32 @@
+{% extends 'InsaLanTournamentBundle::layout.html.twig' %}
+
+{% block body %}
+{{ parent() }}
+
+
+
+
+
+ Inscription à « {{ tournament.name }} » en tant que manager
+ {{ tournament.description }}
+
+
+
+
+ {% if tournament.participantType == 'team' %}
+ {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%}
+ {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 2}%}
+ {% include 'InsaLanTournamentBundle:Manager:BeforePaymentActive.html.twig' with {'counter': 3}%}
+ {% else %}
+ {% include 'InsaLanTournamentBundle:Manager:ChooseGameNameValidated.html.twig' with {'counter': 1}%}
+ {# player choice must be here if not given by URL #}
+ {% include 'InsaLanTournamentBundle:Manager:BeforePaymentActive.html.twig' with {'counter': 2} %}
+ {% endif %}
+
+
+
+{% endblock %}
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig
new file mode 100644
index 00000000..19c72923
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig
@@ -0,0 +1,33 @@
+{% extends 'InsaLanTournamentBundle::layout.html.twig' %}
+
+{% block body %}
+{{ parent() }}
+
+
+
+
+
+ Inscription à « {{ tournament.name }} » en tant que manager
+ {{ tournament.description }}
+
+
+
+
+ {% if tournament.participantType == 'team' %}
+ {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%}
+ {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 2}%}
+ {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 3}%}
+ {% include 'InsaLanTournamentBundle:Manager:AfterPaymentActive.html.twig' with {'counter': 4} %}
+ {% else %}
+ {% include 'InsaLanTournamentBundle:Manager:ChooseGameNameValidated.html.twig' with {'counter': 1} %}
+ {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 2} %}
+ {% include 'InsaLanTournamentBundle:Manager:AfterPaymentActive.html.twig' with {'counter': 3} %}
+ {% endif %}
+
+
+
+{% endblock %}
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig
new file mode 100644
index 00000000..f53214c1
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig
@@ -0,0 +1,33 @@
+{% extends 'InsaLanTournamentBundle::layout.html.twig' %}
+
+{% block body %}
+{{ parent() }}
+
+
+
+
+
+ Inscription à « {{ tournament.name }} »
+ {{ tournament.description }}
+
+
+
+
+ {% if tournament.participantType == 'team' %}
+ {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1} %}
+ {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 3} %}
+ {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 4} %}
+ {% include 'InsaLanTournamentBundle:Manager:WaitPaymentActive.html.twig' with {'counter': 5} %}
+ {% else %}
+ {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1} %}
+ {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 2} %}
+ {% include 'InsaLanTournamentBundle:Manager:WaitPaymentActive.html.twig' with {'counter': 3} %}
+ {% endif %}
+
+
+
+{% endblock %}
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/setName.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/setName.html.twig
new file mode 100644
index 00000000..812df601
--- /dev/null
+++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/setName.html.twig
@@ -0,0 +1,23 @@
+{% extends 'InsaLanTournamentBundle::layout.html.twig' %}
+
+{% block body %}
+ {{ parent() }}
+
+
+
+
+
+ Inscription à un tournoi en tant que manager
+
+
+
+
+ {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameActive.html.twig' with {'counter': 1}%}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig
index 074d0eb1..3b7be2f3 100644
--- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig
+++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig
@@ -56,6 +56,16 @@
{% endfor %}
+ {% if participant.manager is not null %}
+
+ {% if participant.manager.ok %}
+ ✓
+ {% else %}
+ ✘
+ {% endif %}
+ {{ participant.manager.gameName }} [Manager]
+
+ {% endif %}
{% endif %}
@@ -85,8 +95,16 @@
{% endif %}
- {% if participant.validated == 2 %}
+ {% if participant.participantType == 'team' and participant.manager is not null and participant.manager.user == app.user %}
+ {# 2-button layout #}{% if participant.tournament.isOpenedNow %}
+ Annuler
+ Mon inscription
+ {# tournament is closed #}{% else %}
+ Inscription archivée
+ {% endif %}
+ {% else %}
+ {% if participant.validated == 2 %}
{# 2-button layout #}{% if participant.tournament.isPlaying %}
Jouer mes matchs
Mon inscription
@@ -104,14 +122,14 @@
Inscription archivée
{% endif %}
- {% else %}
- {# 2-button layout #}{% if participant.tournament.isOpenedNow %}
- Annuler
- Mon inscription
- {% endif %}
- {% endif %}{# endif validated == 2 #}
-
-
+ {# endif validated == 2 #}
+ {% else %} {# over validation status #}
+ {# 2-button layout #}{% if participant.tournament.isOpenedNow %}
+ Annuler
+ Mon inscription
+ {% endif %}
+ {% endif %}
+ {% endif %}{# endif not a manager #}
@@ -143,6 +161,8 @@
{{ t.name }}{% if t.isFull %} - COMPLET {% endif %}
+ Inscription manager
+ {% if not t.isFull %}Inscription joueur{% endif %}
{{ t.teamMinPlayer }} joueur(s)
-