Exemplo n.º 1
0
 /**
  * 
  * @param unknown $entity
  * @param EntityManager $em
  */
 public function syncVolsPlanified(EPlanDeVols $entity, EntityManager $em)
 {
     $daylist = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche');
     $days = $entity->getDaysArray();
     //Calcul period
     $begin = $entity->getStartAt();
     $end = $entity->getEndAt();
     $end = $end->modify('+1 day');
     $period = array();
     while ($begin < $end) {
         $period[] = \DateTime::createFromFormat('d/m/Y H:i:s', $begin->format('d/m/Y H:i:s'));
         $begin->modify('+1 day');
     }
     foreach ($entity->getVols() as $singleVols) {
         //$singleVols = new Vols();
         //Delete all unsed VP
         $volsPlanifiedListToUpdate = $em->getRepository('AppCoreBundle:VolsPlanified')->findByOptions(array('numeroVols' => $singleVols->getNumeroVols()));
         foreach ($volsPlanifiedListToUpdate as $vp) {
             //TODO check if below to the period
             $em->remove($vp);
             $em->flush();
         }
         foreach ($period as $daytime) {
             $dayOfTheWeek = $this->DayToNum($daytime->format("D"));
             if (in_array($daylist[$dayOfTheWeek], $days)) {
                 $flightAt = $daytime->setTime($singleVols->getEscaleDepart()->getAeroportAt()->format('H'), $singleVols->getEscaleDepart()->getAeroportAt()->format('i'), 0);
                 //var_dump($daytime->format("D, d/m"),$singleVols->getNumeroVols());
                 $volsPlanifiedList = $em->getRepository('AppCoreBundle:VolsPlanified')->findByOptions(array('numeroVols' => $singleVols->getNumeroVols(), 'date' => $flightAt));
                 if (!count($volsPlanifiedList)) {
                     $volsPlanified = new VolsPlanified();
                     $volsPlanified->setFlightAt($flightAt);
                     $volsPlanified->setStatus($em->getRepository('AppCoreBundle:StatutVols')->findOneBy(array('code' => 'vols-pret')));
                     $singleVols->addVolsPlanified($volsPlanified);
                     $em->persist($singleVols);
                     $em->flush();
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public function isAvailablePlanDeVolsByAgenceEmail(PlanDeVols $pdv)
 {
     if (in_array($this->getSystemId(), array_keys($pdv->getShowRulesByAgenceEmail()))) {
         return true;
     }
     return false;
 }