Ejemplo n.º 1
0
 /**
  * Calendrier constructor.
  *
  * Génère chaque jours du calendrier pour une période scolaire donnée
  *
  * @param PeriodInterface $period
  * @param function - $closureIsDayOff
  */
 public function __construct(PeriodInterface $yearPeriod, $closureIsDayOff)
 {
     $this->yearPeriod = $yearPeriod;
     $this->days = array();
     $period = new Period($this->yearPeriod->getFirstDate(), new \DateTimeImmutable($this->yearPeriod->getLastDate()->format('Y-m') . '-31'));
     foreach ($period->getDayIterator() as $currentDay) {
         $d = new Day($currentDay);
         $d->setOff($closureIsDayOff($d));
         if (!$yearPeriod->isIncluded($d->getDate())) {
             $d->setOff(true);
         }
         $this->days[$d->getMonth()][$d->getDay()] = $d;
     }
 }
Ejemplo n.º 2
0
 /**
  * DaysOfWeeks constructor.
  * @param Period $periode
  * @param GestyScheduler $scheduler
  */
 public function __construct(Period $periode, GestyScheduler $scheduler)
 {
     $this->periode = $periode;
     foreach ($this->periode->getDayIterator() as $currentDay) {
         $d = new Day($currentDay);
         if (!$scheduler->isDayOff($currentDay, ActivityType::TAP)) {
             $this->list_jours_tap[$d->getWeekDay()][] = $currentDay->format('Y-m-d');
         }
         if (!$scheduler->isDayOff($currentDay, ActivityType::GARDERIE_MORNING)) {
             $this->list_jours_garderie[$d->getWeekDay() . '-1'][] = $currentDay->format('Y-m-d');
         }
         if (!$scheduler->isDayOff($currentDay, ActivityType::GARDERIE_EVENING)) {
             $this->list_jours_garderie[$d->getWeekDay() . '-2'][] = $currentDay->format('Y-m-d');
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param $activityTypeConstant
  * @param \DateTimeInterface $dateDay
  * @return bool
  */
 public static function isDayOff($activityTypeConstant, \DateTimeInterface $dateDay)
 {
     $d = new Day($dateDay);
     $daysOff = self::$daysOfWeekOff[$activityTypeConstant];
     return \in_array($d->getWeekDay(), $daysOff);
 }
Ejemplo n.º 4
0
 /**
  * @param \DateTimeInterface $date
  * @param array $options with index to which the weekstat will be assigned.
  * @return bool
  */
 public function isDayOff(\DateTimeInterface $date, array $options)
 {
     if (\in_array($date, $this->datesDayOff)) {
         return true;
     }
     foreach ($this->periodsDayOff as $periodDayOff) {
         if ($periodDayOff->isIncluded($date)) {
             return true;
         }
     }
     if (isset($options['index'])) {
         $index = $options['index'];
         $d = new Day($date);
         if (\in_array($d->getWeekDay(), $this->weekUsualDaysOff[$index])) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 5
0
 /**
  * @covers ::getWeekDayFrom
  *
  * @dataProvider provideDateTimeWithWeekDays
  * @param   \DateTime $date
  * @param   string $expectedWeekDay
  */
 public function testGetWeekDayFromReturnWeekDay(\DateTime $date, $expectedWeekDay)
 {
     $this->assertEquals($expectedWeekDay, Day::getWeekDayFrom($date));
 }
 /**
  * @param $options
  * @return WeekStats
  */
 public function getWeekMeals($options)
 {
     $dates = $this->getWeekDates($options);
     $statsLunch = new WeekStats();
     foreach ($dates['days'] as $day) {
         // compte le nombre d'élèves inscrits à la cantine
         // qui ne sont pas :
         // en sortie scolaire ce jour là
         // inscrits en voyage scolaire (non annulé) ce jour là
         $query = $this->createQueryBuilder('l')->select('COUNT(l)')->join('l.eleve', 'e')->where('DATE(l.date) = :date_day')->andWhere('e.regimeSansPorc = :pork')->setParameter(':date_day', $day->format('Y-m-d'))->setParameter(':pork', $options['without_pork']);
         $query = $this->excludePupilsTravellingAt($query, 'e', $day);
         $totalCurrentDay = $query->getQuery()->getSingleScalarResult();
         $statsLunch->setTotalDay(Day::getWeekDayFrom($day), $totalCurrentDay);
     }
     return $statsLunch;
 }