本文整理汇总了PHP中Library\Utility\Helper::checkDatesByDaysCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::checkDatesByDaysCount方法的具体用法?PHP Helper::checkDatesByDaysCount怎么用?PHP Helper::checkDatesByDaysCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library\Utility\Helper
的用法示例。
在下文中一共展示了Helper::checkDatesByDaysCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareData
/**
* @param \DDD\Domain\Booking\BookingTicket $data
* @param array $formData
*
* @return array
*/
public function prepareData($data, $formData)
{
/**
* @var ReviewBooking $review
* @var \DDD\Service\Reservation\PartnerSpecific $partnerSpecificService
* @var \DDD\Service\Booking\Charge $bookingChargeService
* @var \DDD\Dao\Booking\Booking $bookingDao
*/
$partnerSpecificService = $this->getServiceLocator()->get('service_reservation_partner_specific');
$daoReview = new \DDD\Dao\Accommodation\Review($this->getServiceLocator(), 'DDD\\Domain\\Review\\ReviewBooking');
$bookingChargeService = $this->getServiceLocator()->get('service_booking_charge');
$cityService = $this->getServiceLocator()->get('service_location');
$bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
$bookingDao->setEntity(new \DDD\Domain\Booking\PrepareData());
$dataOther = [];
$reservationId = $data->getId();
$startDate = $data->getDate_from();
$endDate = $data->getDate_to();
$review_res_number = $data->getResNumber();
$review = $daoReview->fetchOne(['res_number' => $review_res_number]);
if ($review) {
$data->setHas_review(true);
} else {
$data->setHas_review(false);
}
$auth = $this->getServiceLocator()->get('library_backoffice_auth');
$dataOther['credit_card_view'] = false;
if ($auth->hasRole(Roles::ROLE_CREDIT_CARD)) {
$dataOther['credit_card_view'] = true;
$dataOther['secure_url'] = "https://" . DomainConstants::WS_SECURE_DOMAIN_NAME . "/booking/update-cc-details?code=" . $formData['data']->getProvideCcPageHash();
}
if ($auth->hasRole(Roles::ROLE_RESERVATIONS)) {
$dataOther['reservation_role'] = true;
} else {
$bookingService = $this->getServiceLocator()->get('service_booking');
$part = $bookingService->getPartnerById($data->getPartnerId());
$dataOther['affiliate'] = $part->getPartnerName();
}
$keyPageStatus = '';
if (!Helper::checkDatesByDaysCount(1, $data->getDate_to())) {
$keyPageStatus = "Expired";
} elseif ($data->getKiPageStatus() == 1) {
$kiPageHash = $data->getKiPageHash();
$keyPageStatus = "<a target='_blank' href='https://" . DomainConstants::WS_SECURE_DOMAIN_NAME . '/key?view=0&code=' . $kiPageHash . "' >Key Entry Link</a>";
} elseif (!$data->getKiPageStatus()) {
$keyPageStatus = "Not set yet";
}
$is_penalty_applied = $this->isPenaltyApplied($data->getDate_from(), $data->getIsRefundable(), $data->getRefundableBeforeHours());
$penalty_period = $this->calculateCancelationPeriod($data->getStatus(), $data->getCancelation_date(), $data->getDate_to(), $is_penalty_applied);
$dataOther['keyPageStatus'] = $keyPageStatus;
$dataOther['penalty_period'] = $penalty_period;
$penalty_val = number_format(str_replace(",", ".", $data->getPenalty_val()), 2, '.', '');
$penalty = number_format(str_replace(",", ".", $data->getPenalty()), 2, '.', '');
if (Rate::APARTMENT_RATE_REFUNDABLE == $data->getIsRefundable()) {
if ($data->getRefundableBeforeHours() > 48) {
$dataOther['cancellation'] = "This deal can be canceled for FREE up to " . $data->getRefundableBeforeHours() / 24 . " days before arrival";
} else {
$dataOther['cancellation'] = "This deal can be canceled for FREE up to " . $data->getRefundableBeforeHours() . " hours before arrival";
}
} else {
$dataOther['cancellation'] = 'Non refundable';
}
$dataOther['panelty_type'] = Helper::getPenalty($penalty, $penalty_val, $data->getApartmentCurrencyCode());
foreach ($formData['options']['statuses'] as $row) {
if ($row->getId() == $data->getStatus()) {
$dataOther['status_name'] = $row->getName();
break;
}
}
foreach ($formData['options']['partners'] as $row) {
if ($row->getGid() == $data->getPartnerId()) {
$dataOther['partner_name'] = $row->getPartnerName();
$dataOther['partner_id'] = $data->getPartnerId();
break;
}
}
$customerReservations = $bookingDao->getCustomerReservationsStatuses($data->getGuestEmail());
$bookedReservationsCount = 0;
$cancelledReservationsCount = 0;
$hasDebtBalance = false;
foreach ($customerReservations as $customerReservation) {
if (!$hasDebtBalance && $customerReservation->getBalance() < 0 && $data->getResNumber() != $customerReservation->getResNumber()) {
$hasDebtBalance = true;
}
if ($customerReservation->getStatus() == BookingService::BOOKING_STATUS_BOOKED) {
$bookedReservationsCount++;
} else {
$cancelledReservationsCount++;
}
}
$dataOther['pendingCreditCardInQueue'] = false;
$pendingCreditCardInQueue = $bookingDao->getPendingInQueueCardsByReservationId($reservationId);
if ($pendingCreditCardInQueue->count()) {
$dataOther['pendingCreditCardInQueue'] = true;
//.........这里部分代码省略.........
示例2: indexAction
/**
* @return ViewModel
*/
public function indexAction()
{
/**
* @var \DDD\Service\Textline $textlineService
* @var \DDD\Service\Lock\General $lockService
*/
$textlineService = $this->getServiceLocator()->get('service_textline');
$lockService = $this->getServiceLocator()->get('service_lock_general');
$keyCode = $this->params()->fromQuery('code');
$view = $this->params()->fromQuery('view');
$godMode = $this->params()->fromQuery('bo', false) ?: false;
if ($keyCode === null || !ClassicValidator::validateAlnum($keyCode)) {
return $this->redirect()->toRoute('home')->setStatusCode('301');
}
/**
* if have not key code in query...
* OR not finded thicket...
* OR "arrival date" NOT MORE than "5"
* OR "depart date" NOT LESS than "-3"
* redirect() -> Home
*/
$bookingData = $this->getBookingData($keyCode);
if (!$bookingData || !Helper::checkDatesByDaysCount(1, $bookingData->getDateTo())) {
return $this->redirect()->toRoute('home')->setStatusCode('301');
}
$session = new SessionContainer('visitor');
$parkingTextline = '';
if ($bookingData->hasParking()) {
$parkingTextline = $textlineService->getUniversalTextline($bookingData->getParkingTextlineId());
}
/**
* @var \DDD\Service\Website\Textline $textlineService
*/
$textlineService = $this->getServiceLocator()->get('service_website_textline');
$keyDirectEntryTextline = Helper::evaluateTextline($textlineService->getApartmentDirectKeyInstructionTextline($bookingData->getApartmentId()), ['{{PARKING_TEXTLINE}}' => $parkingTextline]);
$keyReceptionEntryTextline = Helper::evaluateTextline($textlineService->getApartmentReceptionKeyInstructionTextline($bookingData->getApartmentId()), ['{{PARKING_TEXTLINE}}' => $parkingTextline]);
/* @var $customerService \DDD\Service\Customer */
$customerService = $this->getServiceLocator()->get('service_customer');
/**
* If NOT HAVE flag from BO (view=0)...
* Specify that looked & save the date view
*/
if ($view !== '0' && $bookingData->isKiViewed() !== '1' && !$customerService->isBot($session)) {
/**
* @var \DDD\Service\Website\Booking $bookingService
*/
$bookingService = $this->getServiceLocator()->get('service_website_booking');
$bookingService->updateData($bookingData->getId(), ['ki_viewed' => '1', 'ki_viewed_date' => date('Y-m-d H:i:s')]);
}
$lockDatas = $lockService->getLockByReservationApartmentId($bookingData->getApartmentIdAssigned(), $bookingData->getPin(), [LockService::USAGE_APARTMENT_TYPE, LockService::USAGE_BUILDING_TYPE, LockService::USAGE_PARKING_TYPE], true);
foreach ($lockDatas as $key => $lockData) {
switch ($key) {
case LockService::USAGE_APARTMENT_TYPE:
$bookingData->setPin($lockData['code']);
break;
case LockService::USAGE_BUILDING_TYPE:
$bookingData->setOutsideDoorCode($lockData['code']);
break;
case LockService::USAGE_PARKING_TYPE:
// TODO: to be or not to be, this is the question.
break;
}
}
// get Office Address
$officeAddress = false;
if ($bookingData->getKiPageType() == Building::KI_PAGE_TYPE_RECEPTION) {
/**
* @var \DDD\Service\Office $officeService
*/
$officeService = $this->getServiceLocator()->get('service_office');
$officeManagement = $officeService->getData($bookingData->getOfficeId());
/**
* @var \DDD\Domain\Office\OfficeManager $officeData
*/
$officeData = $officeManagement['office'];
$officeAddress = $officeData->getAddress();
}
if ($view !== '0') {
$this->checkCustomerIdentityData($bookingData);
}
$this->layout()->setTemplate('layout/layout-ki');
$this->layout()->userTrackingInfo = ['res_number' => $bookingData->getResNumber(), 'partner_id' => $bookingData->getPartnerId()];
$this->layout()->godMode = $godMode === substr(md5($keyCode), 12, 5);
$this->layout()->keyData = $bookingData;
$this->layout()->keyCode = $keyCode;
$this->layout()->directEntryTextline = $keyDirectEntryTextline;
$this->layout()->receptionEntryTextline = $keyReceptionEntryTextline;
return new ViewModel(['keyData' => $bookingData, 'keyCode' => $keyCode, 'directEntryTextline' => $keyDirectEntryTextline, 'receptionEntryTextline' => $keyReceptionEntryTextline, 'godMode' => $godMode === substr(md5($keyCode), 12, 5), 'isGuest' => $view !== '0', 'officeAddress' => $officeAddress]);
}