/** * Returns new Appointments chain according to bookingData, user entered * @param array $bookingData * @param $creatorId * @param $roomId * @return AppointmentChain */ public function makeChain(\Application\BookingOrder $bookingOrder, $creatorId, $roomId) { $result = new AppointmentChain(); if ($bookingOrder->isRecurring()) { $event_dates = $this->makeDatesChain($bookingOrder->getStartTime(), $bookingOrder->getRecurring(), $bookingOrder->getDuration()); } else { $event_dates = array($bookingOrder->getStartTime()); } $event_duration = $bookingOrder->getEndTime()->getTimestamp() - $bookingOrder->getStartTime()->getTimestamp(); foreach ($event_dates as $event_date) { $appItem = new \Application\AppointmentItem(array('emp_id' => $bookingOrder->getEmpId(), 'notes' => $bookingOrder->getNotes(), 'creator_id' => $creatorId, 'room_id' => $roomId)); $appItem->setTimeStart($event_date); $appItem->setTimeEnd((new \DateTime())->setTimestamp($event_date->getTimestamp() + $event_duration)); $result->add($appItem); } return $result; }
public function testSetNewTime() { // 'time_start' => '2015-10-15 10:25:00', // 'time_end' => '2015-10-15 11:45:00', $app = new \Application\AppointmentItem(self::$arrayToTest); $app->setNewTime('12:30', '13:05'); $this->assertEquals(new \DateTime('2015-10-15 12:30:00'), $app->getTimeStart()); $this->assertEquals(new \DateTime('2015-10-15 13:05:00'), $app->getTimeEnd()); $app->setNewTime('08:15', '00:00'); $this->assertEquals(new \DateTime('2015-10-15 08:15:00'), $app->getTimeStart()); $this->assertEquals(new \DateTime('2015-10-16 00:00:00'), $app->getTimeEnd()); }