public function getQuantityAndDurationForService(Service $service, $nbNights, $nbPax, $nbAdults = null, $nbChildren = null)
 {
     if ($nbAdults === null) {
         $nbAdults = $this->datePaxData->getTotalAdults();
     }
     if ($nbChildren === null) {
         $nbChildren = $this->datePaxData->getTotalChildren();
     }
     $quantity = 1;
     $duration = 0;
     if ($service->getDetails()->getPricePerNight() and (!$service->getNightRequested() or $service->getMandatory())) {
         $duration += max(1, $this->datePaxData->getNbNights());
     } elseif (($service->getDetails()->getPricePerNight() or $service->getNightRequested()) and $nbNights) {
         $duration += $nbNights;
     }
     if ($service->getDetails()->getPricePerPax() and (!$service->getPaxRequested() or $service->getMandatory())) {
         $quantity = 1;
         $nbPax = 0;
         if ($service->getDetails()->getChild()) {
             $nbPax += $nbChildren;
         }
         if ($service->getDetails()->getAdult()) {
             $nbPax += $nbAdults;
         }
         $quantity *= $nbPax;
     } elseif ($service->getDetails()->getPricePerPax()) {
         $quantity = (int) $nbPax;
     }
     return array('quantity' => $quantity, 'duration' => $duration);
 }
Exemple #2
0
 public function getNbChildren()
 {
     $nbChildren = 0;
     foreach ($this->datePax->getSelectedRooms() as $room) {
         $nbChildren += $room->getNbChildren();
     }
     return $nbChildren;
 }
Exemple #3
0
 /**
  * @param DatePaxData $searchData
  * @return array
  */
 private function formatRooms(DatePaxData $searchData)
 {
     $formattedRooms = array();
     $rooms = $searchData->getSelectedRooms();
     foreach ($rooms as $room) {
         $roomData = array();
         $roomData[] = array('category' => Container::_AGE_CODE_ADULT, 'count' => $room->nbAdults);
         if ($room->nbChildren > 0) {
             $roomData[] = array('category' => Container::_AGE_CODE_CHILDREN, 'count' => $room->nbChildren);
         }
         $formattedRooms[] = $roomData;
     }
     return $formattedRooms;
 }
Exemple #4
0
 /**
  * @param DatePaxData $searchData
  * @return array
  */
 public function formatRoomsForAvail(DatePaxData $searchData)
 {
     $formattedRooms = array();
     foreach ($searchData->getSelectedRooms() as $room) {
         $guests = array();
         if (($nbAdults = $room->nbAdults) != 0) {
             $guests[] = array('category' => Container::_AGE_CODE_ADULT, 'count' => $nbAdults);
         }
         if (($nbChildren = $room->getNbChildren()) > 0) {
             $guests[] = array('category' => Container::_AGE_CODE_CHILDREN, 'count' => $nbChildren);
         }
         $formattedRooms[] = array('quantity' => 1, 'guests' => $guests);
     }
     return $formattedRooms;
 }
Exemple #5
0
 public function sanitizeDatePaxData(DatePaxData $data)
 {
     $initialLength = $data->getNbNights();
     $now = new \DateTime();
     if ($data->startingDate->format('Y-m-d') < $now->format('Y-m-d')) {
         $data->startingDate = $now;
     }
     $endDate = clone $data->startingDate;
     $data->endingDate = $endDate->add(new \DateInterval(sprintf('P%sD', max($initialLength, 1))));
 }