コード例 #1
0
ファイル: ReservationListing.php プロジェクト: Trideon/gigolo
 protected function AddOnDate(ReservationListItem $item, Date $date)
 {
     //		Log::Debug('Adding id %s on %s', $item->Id(), $date);
     $this->_reservationsByDate[$date->Format('Ymd')][] = $item;
     $this->_reservationsByDateAndResource[$date->Format('Ymd') . '|' . $item->ResourceId()][] = $item;
 }
コード例 #2
0
 public function __construct(ReservationListItem $item, $location)
 {
     parent::__construct($item->item);
     $this->item = $item;
     $this->location = $location;
     if ($this->IsBefore()) {
         $this->startDate = $this->item->StartDate()->SubtractInterval($this->item->BufferTime());
         $this->endDate = $this->item->StartDate();
     } else {
         $this->startDate = $this->item->EndDate();
         $this->endDate = $this->item->EndDate()->AddInterval($this->item->BufferTime());
     }
 }
コード例 #3
0
 public function testReservationListItemCreatesReservationSlot()
 {
     $view = new TestReservationItemView(1, Date::Parse('2011-11-22 04:34'), Date::Parse('2011-11-23 14:43'), 123);
     $item = new ReservationListItem($view);
     $this->assertEquals($view->StartDate, $item->StartDate());
     $this->assertEquals($view->EndDate, $item->EndDate());
     $this->assertEquals($view->ResourceId, $item->ResourceId());
     $start = Date::Parse('2011-12-01');
     $end = Date::Parse('2011-12-02');
     $period = new SchedulePeriod($start, $end);
     $display = Date::Parse('2011-12-03');
     $span = 3;
     $expectedSlot = new ReservationSlot($period, $period, $display, $span, $view);
     $actualSlot = $item->BuildSlot($period, $period, $display, $span);
     $this->assertEquals($expectedSlot, $actualSlot);
 }
コード例 #4
0
 private function Collides(ReservationListItem $item, $itemIndex)
 {
     $previousItem = $itemIndex > 0 ? $this->_items[--$itemIndex] : null;
     $nextItem = $itemIndex < count($this->_items) - 1 ? $this->_items[++$itemIndex] : null;
     $itemDateRange = new DateRange($item->StartDate(), $item->EndDate());
     if ($previousItem != null) {
         if ($itemDateRange->Overlaps(new DateRange($previousItem->StartDate(), $previousItem->EndDate()))) {
             return true;
         }
     }
     if ($nextItem != null) {
         if ($itemDateRange->Overlaps(new DateRange($nextItem->StartDate(), $nextItem->EndDate()))) {
             return true;
         }
     }
     return false;
 }
コード例 #5
0
 public function __construct(Date $start, Date $end, $resourceId)
 {
     $this->start = $start;
     $this->end = $end;
     $this->resourceId = $resourceId;
     parent::__construct(new TestReservationItemView(1, $start, $end, $resourceId));
 }