Example #1
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;
     }
 }