コード例 #1
0
ファイル: BookingUserSelection.php プロジェクト: blab2015/seh
 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);
 }
コード例 #2
0
ファイル: BookingManager.php プロジェクト: blab2015/seh
 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))));
 }