예제 #1
0
 public function getPassager()
 {
     $passager = $this->em->getRepository('BackUserBundle:Client')->findOneBy(array('passager' => TRUE));
     if (!$passager) {
         $passager = new Client();
     }
     $passager->setPassager(TRUE)->setNomPrenom('Passager')->setTel1('No Tel')->setTel2('No tel')->setAdresse('No Address');
     $this->em->persist($passager);
     $this->em->flush();
     return $passager->setNomPrenom(NULL)->setTel1(NULL)->setTel2(NULL)->setAdresse(NULL);
 }
예제 #2
0
 public function saveReservation(Periode $periode, Client $client, $data, $source)
 {
     $supplements = array();
     $coordoonnes = array($client->getNomPrenom(), $client->getTel1(), $client->getTel2(), $client->getAdresse());
     $tarifCommercial = $this->em->getRepository('BackCommercialBundle:Tarif')->find(1);
     $reservation = new Reservation();
     $reservation->setClient($client)->setCoordonnees($coordoonnes)->setEtat(1)->setPeriode($periode)->setProgramme($periode->getProgramme());
     if ($tarifCommercial && $tarifCommercial->getTimbre()) {
         $reservation->setTimbre($tarifCommercial->getMontantTimbre());
     }
     if ($source == 'frontoffice') {
         $reservation->setFrontOffice(TRUE);
     }
     $this->em->persist($reservation);
     $x = 0;
     $nbrAdulte = $data['adultes'];
     $nbrEnfant = $data['enfants'];
     for ($i = 1; $i <= $nbrAdulte; $i++) {
         $reservationPersonne = new ReservationPersonne();
         $reservationPersonne->setReservationA($reservation)->setNomPrenom($data['Anom_' . $i]);
         $this->em->persist($reservationPersonne);
         $reservationLigne = new ReservationLigne();
         $reservationLigne->setPersonne($reservationPersonne)->setLibelle('Prix Adulte')->setCode('PrixAdulte')->setAchat($periode->getPrixAdulteAchat())->setVente($periode->getPrixAdulteVente());
         $this->em->persist($reservationLigne);
         foreach ($periode->getSupplements() as $supp) {
             if ($supp->getObligatoire() || isset($data['supplement' . $supp->getId()])) {
                 if ($i == 1) {
                     $supplements[] = $supp->getId();
                 }
                 $reservationLigne = new ReservationLigne();
                 $reservationLigne->setPersonne($reservationPersonne)->setLibelle($supp->getLibelle())->setCode('SupplementAdulte')->setAchat($supp->getAdulteAchat())->setVente($supp->getAdulteVente());
                 $this->em->persist($reservationLigne);
             }
         }
     }
     for ($i = 1; $i <= $nbrEnfant; $i++) {
         $reservationPersonne = new ReservationPersonne();
         $reservationPersonne->setReservationE($reservation)->setNomPrenom($data['Enom_' . $i])->setAge($data['Eage_' . $i]);
         $this->em->persist($reservationPersonne);
         $reservationLigne = new ReservationLigne();
         $reservationLigne->setPersonne($reservationPersonne)->setLibelle('Prix Enfant')->setCode('PrixEnfant')->setAchat($periode->getPrixEnfantAchat())->setVente($periode->getPrixEnfantVente());
         $this->em->persist($reservationLigne);
         foreach ($periode->getSupplements() as $supp) {
             if ($supp->getObligatoire() || isset($data['supplement' . $supp->getId()])) {
                 $reservationLigne = new ReservationLigne();
                 $reservationLigne->setPersonne($reservationPersonne)->setLibelle($supp->getLibelle())->setCode('SupplementEnfant')->setAchat($supp->getEnfantAchat())->setVente($supp->getEnfantVente());
                 $this->em->persist($reservationLigne);
             }
         }
     }
     $this->em->persist($reservation->setSupplements($supplements));
     $this->em->flush();
     return $reservation->getId();
 }
예제 #3
0
 public function addUserAction(Client $client)
 {
     $em = $this->getDoctrine()->getManager();
     $session = $this->getRequest()->getSession();
     if (is_null($client->getUser())) {
         $user = new User();
         $user->setEmail($client->getEmail());
         $form = $this->createForm(new RegistrationFormType(), $user, array('validation_groups' => array('Registration')))->remove('groups');
     } else {
         $user = $client->getUser();
         $form = $this->createForm(new RegistrationFormType(), $user, array('validation_groups' => array('Profile')))->remove('plainPassword')->remove('groups');
     }
     if ($this->getRequest()->isMethod('POST')) {
         $form->submit($this->getRequest());
         if ($form->isValid()) {
             $user = $form->getData();
             $em->persist($user->setEnabled(TRUE)->setClient($client));
             $em->flush();
             $session->getFlashBag()->add('success', " Client traité avec succès ");
             return $this->redirect($this->generateUrl('back_crm_client_profil_user', array('id' => $client->getId())));
         }
     }
     return $this->render('BackUserBundle:client:profil\\user.html.twig', array('form' => $form->createView(), 'client' => $client));
 }
예제 #4
0
 public function saveReservation(Pack $pack, Client $client, $data, $source)
 {
     $periode = $pack->getPeriode();
     $supplements = array();
     $circuits = array();
     $frais = array();
     $chambres = array(array('single', 1, $pack->getSingleAchat(), $pack->getSingleVente()), array('double', 2, $pack->getDoubleAchat(), $pack->getDoubleVente()), array('triple', 3, $pack->getTripleAchat(), $pack->getTripleVente()), array('quadruple', 4, $pack->getQuadrupleAchat(), $pack->getQuadrupleVente()));
     $coordoonnes = array($client->getNomPrenom(), $client->getTel1(), $client->getTel2(), $client->getAdresse());
     $tarifCommercial = $this->em->getRepository('BackCommercialBundle:Tarif')->find(1);
     $reservation = new Reservation();
     $reservation->setClient($client)->setCoordonnees($coordoonnes)->setEtat(1)->setPack($pack)->setVoyage($periode->getVoyage());
     if ($tarifCommercial && $tarifCommercial->getTimbre()) {
         $reservation->setTimbre($tarifCommercial->getMontantTimbre());
     }
     if ($source == 'frontoffice') {
         $reservation->setFrontOffice(TRUE);
     } else {
         $reservation->setResponsable($this->container->get('security.context')->getToken()->getUser());
     }
     $this->em->persist($reservation);
     $x = 0;
     foreach ($chambres as $ch) {
         for ($i = 1; $i <= $data['chambre' . $ch[0]]; $i++) {
             $reservationChambre = new ReservationChambre();
             $reservationChambre->setReservation($reservation)->setType($ch[1]);
             $this->em->persist($reservationChambre);
             for ($p = 1; $p <= $ch[1]; $p++) {
                 $x++;
                 $reservationPersonne = new ReservationPersonne();
                 $reservationPersonne->setChambre($reservationChambre)->setNomPrenom($data[$ch[0] . '_nom_' . $i . '_' . $p])->setPassport($data[$ch[0] . '_passport_' . $i . '_' . $p]);
                 if ($data[$ch[0] . '_age_' . $i . '_' . $p] != 'adulte') {
                     $reservationPersonne->setAge($data[$ch[0] . '_age_' . $i . '_' . $p])->setEnfant(TRUE);
                 } else {
                     $reservationPersonne->setAge(NULL)->setEnfant(FALSE);
                 }
                 $this->em->persist($reservationPersonne);
                 $reservationLigne = new ReservationLigne();
                 $reservationLigne->setPersonne($reservationPersonne)->setLibelle('Logement chambre ' . $ch[0])->setCode('chambre_' . $ch[0])->setAchat($ch[2])->setVente($ch[3]);
                 $this->em->persist($reservationLigne);
                 foreach ($pack->getSupplements() as $supp) {
                     if ($supp->getObligatoire() || isset($data['supplement' . $supp->getId()])) {
                         if ($x == 1) {
                             $supplements[] = $supp->getId();
                         }
                         $reservationLigne = new ReservationLigne();
                         $reservationLigne->setPersonne($reservationPersonne)->setLibelle($supp->getLibelle())->setCode('Supplement')->setAchat($supp->getAdulteAchat())->setVente($supp->getAdulteVente());
                         $this->em->persist($reservationLigne);
                     }
                 }
                 foreach ($periode->getCircuits() as $supp) {
                     if ($supp->getObligatoire() || isset($data['circuit' . $supp->getId()])) {
                         if ($x == 1) {
                             $circuits[] = $supp->getId();
                         }
                         $reservationLigne = new ReservationLigne();
                         $reservationLigne->setPersonne($reservationPersonne);
                         if (!$reservationPersonne->getEnfant()) {
                             $reservationLigne->setAchat($supp->getAdulteAchat())->setVente($supp->getAdulteVente())->setCode('CircuitAdl')->setLibelle($supp->getLibelle() . ' adulte');
                         } else {
                             $reservationLigne->setAchat($supp->getEnfantAchat())->setVente($supp->getEnfantVente())->setCode('CircuitEnf')->setLibelle($supp->getLibelle() . ' enfant');
                         }
                         $this->em->persist($reservationLigne);
                     }
                 }
                 foreach ($periode->getFrais() as $supp) {
                     if ($supp->getObligatoire() || isset($data['frai' . $supp->getId()])) {
                         if ($x == 1) {
                             $frais[] = $supp->getId();
                         }
                         $reservationLigne = new ReservationLigne();
                         $reservationLigne->setPersonne($reservationPersonne);
                         if (!$reservationPersonne->getEnfant()) {
                             $reservationLigne->setAchat($supp->getAdulteAchat())->setVente($supp->getAdulteVente())->setCode('FraisDiversAdl')->setLibelle($supp->getLibelle() . ' adulte');
                         } else {
                             $reservationLigne->setAchat($supp->getEnfantAchat())->setVente($supp->getEnfantVente())->setCode('FraisDiversEnf')->setLibelle($supp->getLibelle() . ' enfant');
                         }
                         $this->em->persist($reservationLigne);
                     }
                 }
             }
         }
     }
     $this->em->persist($reservation->setSupplements($supplements)->setCircuits($circuits)->setFrais($frais));
     $this->em->flush();
     return $reservation->getId();
 }
예제 #5
0
 public function getSaisonByClient($date, \Back\UserBundle\Entity\Client $client)
 {
     if (is_null($client->getAmicale())) {
         return $this->getSaisonPromotionByDate($date);
     }
     $currentSaison = $this->saisonBase;
     $Verif = FALSE;
     foreach ($this->saisons as $saison) {
         //get saison amicale
         if ($saison->getType() == 3) {
             foreach ($saison->getPeriodes() as $periode) {
                 if ($periode->getDateDebut()->format('Y-m-d') <= $date && $periode->getDateFin()->format('Y-m-d') >= $date && $saison->getId() > $currentSaison->getId()) {
                     foreach ($saison->getAmicales() as $amicale) {
                         if ($amicale->getId() == $client->getAmicale()->getId()) {
                             $currentSaison = $saison;
                             $Verif = TRUE;
                         }
                     }
                 }
             }
         }
     }
     if (!$Verif) {
         return $this->getSaisonPromotionByDate($date);
     } else {
         return $currentSaison;
     }
 }