/** * @param ReservationListItem $item * @return SchedulePeriod which has the closest starting time to $endingTime without going prior to it */ private function FindClosestLayoutIndexBeforeStartingTime(ReservationListItem $item) { for ($i = count($this->_layoutItems) - 1; $i >= 0; $i--) { $currentItem = $this->_layoutItems[$i]; if ($currentItem->BeginDate()->LessThan($item->StartDate())) { return $currentItem; } } Log::Error('Could not find a fitting starting slot for reservation. Id %s, ResourceId: %s, Start: %s, End: %s', $item->Id(), $item->ResourceId(), $item->StartDate()->ToString(), $item->EndDate()->ToString()); return null; }
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; }
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); }