Ejemplo n.º 1
0
 public function scheduleCompose($idSchedule, $gamesToInsert)
 {
     $scheduleTrackService = new ScheduleTrackService();
     $scheduleTrackService->setManager($this->em);
     $scheduleRangeDateService = new ScheduleRangeDateService();
     $scheduleRangeDateService->setManager($this->em);
     $scheduleDateService = new ScheduleDateService();
     $scheduleDateService->setManager($this->em);
     $scheduleRangeService = new scheduleRangeService();
     $scheduleRangeService->setManager($this->em);
     $schedule = array();
     $numMatch = 0;
     $scheduleTracks = $scheduleTrackService->getScheduleTrackByScheduleId($idSchedule);
     $scheduleRangeDates = $scheduleRangeDateService->getScheduleRangeDateByScheduleId($idSchedule);
     foreach ($scheduleRangeDates as $scheduleRangeDate) {
         $scheduleDates = $scheduleDateService->getScheduleDateByScheduleRangeDate($scheduleRangeDate);
         $scheduleRanges = $scheduleRangeService->getScheduleRangeByScheduleRangeDate($scheduleRangeDate);
         foreach ($scheduleDates as $scheduleDate) {
             foreach ($scheduleRanges as $scheduleRange) {
                 foreach ($scheduleTracks as $scheduleTrack) {
                     $foundGame = false;
                     $numMatch = $numMatch + 1;
                     if (!is_null($gamesToInsert)) {
                         foreach ($gamesToInsert as $game) {
                             if ($game->getScheduleId() == strval($numMatch)) {
                                 $title = $game->getPair1()->getUser1()->getName();
                                 $title .= ' - ';
                                 $title .= $game->getPair1()->getUser2()->getName();
                                 $title .= ' ' . Literals::vs . ' ';
                                 $title .= $game->getPair2()->getUser1()->getName();
                                 $title .= ' - ';
                                 $title .= $game->getPair2()->getUser2()->getName();
                                 $bgColor = $game->getBgColor();
                                 $match = array('id' => strval($numMatch), 'start' => date_format($scheduleDate->getDate(), 'Y-m-d') . $scheduleRange->getFromHour(), 'end' => date_format($scheduleDate->getDate(), 'Y-m-d') . $scheduleRange->getToHour(), 'resourceId' => $scheduleTrack->getId(), 'title' => $title, 'backgroundColor' => $bgColor);
                                 $foundGame = true;
                             }
                         }
                     }
                     if (!$foundGame) {
                         $match = array('id' => strval($numMatch), 'start' => date_format($scheduleDate->getDate(), 'Y-m-d') . $scheduleRange->getFromHour(), 'end' => date_format($scheduleDate->getDate(), 'Y-m-d') . $scheduleRange->getToHour(), 'resourceId' => $scheduleTrack->getId(), 'title' => Literals::NotSet, 'backgroundColor' => Literals::NotSet);
                     }
                     $schedule[] = $match;
                 }
             }
         }
     }
     return $schedule;
 }
Ejemplo n.º 2
0
 public function testSaveScheduleRangeDate()
 {
     $sheduleRangeDateService = new ScheduleRangeDateService();
     $sheduleRangeDateService->setManager($this->em);
     $scheduleDate = $sheduleRangeDateService->saveScheduleRangeDate($this->schedule);
     $this->assertContains('' . $this->schedule->getId(), json_encode($scheduleDate));
 }