public function ligneFraisChambres(Saison $saison, $ch, &$tab, $nuitees) { $codes = array('ARRANGEMENT', 'PRIX-BASE', 'SUPP-SINGLE', 'REDUC-3LIT', 'REDUC-4LIT', 'SUPP-AUTRE-CHAMBRE', 'REDUC-1ENF-1ADULTE-AGE-1', 'REDUC-1ENF-1ADULTE-AGE-2', 'REDUC-1ENF-2ADULTES-AGE-1', 'REDUC-1ENF-2ADULTES-AGE-2', 'REDUC-1ENF-SEPARER-AGE-1', 'REDUC-2ENF-1ADULTE-AGE-1', 'REDUC-2ENF-1ADULTE-AGE-2', 'REDUC-2ENF-2ADULTES-AGE-1', 'REDUC-2ENF-2ADULTES-AGE-2', 'REDUC-1ENF-SEPARER-AGE-1', 'REDUC-2ENF-SEPARER-AGE-2'); $nbrJours = $nuitees; $nbrAdultes = count($tab['adultes']); $nbrEnfants = count($tab['enfants']); $arr = $tab['details']['arrangement']; foreach ($saison->getFraisChambres() as $fraisChambre) { if ($fraisChambre->getChambre()->getId() == $ch) { for ($i = 0; $i < $nbrAdultes; $i++) { for ($j = 0; $j < $nbrJours; $j++) { $tab['adultes'][$i]['jours'][$j]['lignes'][] = array('code' => 'FRAIS-CHAMBRE', 'name' => 'Frais ' . $fraisChambre->getChambre()->getLibelle(), 'achat' => number_format($fraisChambre->getPrixAchat($nbrAdultes, $nbrEnfants, $arr, 'Adulte', $i + 1), 3, '.', ''), 'vente' => number_format($fraisChambre->getPrixVente($nbrAdultes, $nbrEnfants, $arr, 'Adulte', $i + 1), 3, '.', '')); } for ($j = 0; $j < $nbrJours; $j++) { $nbrLigne = count($tab['adultes'][$i]['jours'][$j]['lignes']); for ($l = 0; $l < $nbrLigne; $l++) { if (in_array($tab['adultes'][$i]['jours'][$j]['lignes'][$l]['code'], $codes)) { $tab['adultes'][$i]['jours'][$j]['lignes'][$l]['achat'] = 0; $tab['adultes'][$i]['jours'][$j]['lignes'][$l]['vente'] = 0; } } } } for ($i = 0; $i < $nbrEnfants; $i++) { for ($j = 0; $j < $nbrJours; $j++) { $tab['enfants'][$i]['jours'][$j]['lignes'][] = array('code' => 'FRAIS-CHAMBRE', 'name' => 'Frais ' . $fraisChambre->getChambre()->getLibelle(), 'achat' => number_format($fraisChambre->getPrixAchat($nbrAdultes, $nbrEnfants, $arr, 'Enfant', $i + 1), 3, '.', ''), 'vente' => number_format($fraisChambre->getPrixVente($nbrAdultes, $nbrEnfants, $arr, 'Enfant', $i + 1), 3, '.', '')); } for ($j = 0; $j < $nbrJours; $j++) { $nbrLigne = count($tab['enfants'][$i]['jours'][$j]['lignes']); for ($l = 0; $l < $nbrLigne; $l++) { if (in_array($tab['enfants'][$i]['jours'][$j]['lignes'][$l]['code'], $codes)) { $tab['enfants'][$i]['jours'][$j]['lignes'][$l]['achat'] = 0; $tab['enfants'][$i]['jours'][$j]['lignes'][$l]['vente'] = 0; } } } } } } }
public function contingentAction(Saison $saison) { $em = $this->getDoctrine()->getManager(); $session = $this->getRequest()->getSession(); $form = $this->createForm(new SaisonContingentType(), new SaisonContingent()); $request = $this->getRequest(); if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { $data = $form->getData(); if ($saison->isInPeriode($data->getDebut()->format('Y-m-d'), $data->getFin()->format('Y-m-d'))) { $em->persist($data->setSaison($saison)); $em->flush(); $session->getFlashBag()->add('success', "Le contingent a été ajouté avec succées"); return $this->redirect($this->generateUrl('saison_contingent', array('id' => $saison->getId()))); } else { $form->get('debut')->addError(new FormError("Erreur dans les dates")); $form->get('fin')->addError(new FormError("Erreur dans les dates")); } } } return $this->render('BackHotelTunisieBundle:Saisons:contingent.html.twig', array('form' => $form->createView(), 'saison' => $saison, 'hotel' => $saison->getHotel())); }