Esempio 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;
 }
Esempio n. 2
0
 public function testSaveScheduleTrack()
 {
     $scheduleTrackService = new ScheduleTrackService();
     $scheduleTrackService->setManager($this->em);
     $scheduleTrack = $scheduleTrackService->saveScheduleTrack($this->schedule, 3);
     $this->assertContains('Track 3', json_encode($scheduleTrack));
 }