本文整理汇总了PHP中Library\Utility\Helper::getCurrenctDateByTimezone方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::getCurrenctDateByTimezone方法的具体用法?PHP Helper::getCurrenctDateByTimezone怎么用?PHP Helper::getCurrenctDateByTimezone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library\Utility\Helper
的用法示例。
在下文中一共展示了Helper::getCurrenctDateByTimezone方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: itemAction
public function itemAction()
{
/**
* @var $auth \Library\Authentication\BackofficeAuthenticationService
*/
$id = (int) $this->params()->fromRoute('id', 0);
$service = $this->getConcierge();
if (!$id || !($rowObj = $service->getConciergeByGroupId($id))) {
Helper::setFlashMessage(['error' => TextConstants::ERROR_NO_ITEM]);
return $this->redirect()->toRoute('backoffice/default', ['controller' => 'concierge', 'action' => 'view']);
}
$auth = $this->getServiceLocator()->get('library_backoffice_auth');
$authId = (int) $auth->getIdentity()->id;
$external = (int) $auth->getIdentity()->external;
$usermanagerDao = $this->getServiceLocator()->get('dao_user_user_manager');
$userInfo = $usermanagerDao->fetchOne(['id' => $authId]);
$currentDate = time();
if (!is_null($userInfo->getTimezone())) {
$currentDate = Helper::getCurrenctDateByTimezone($userInfo->getTimezone());
}
if ($auth->hasRole(Roles::ROLE_GLOBAL_APARTMENT_GROUP_MANAGER)) {
$userId = false;
} elseif ($auth->hasRole(Roles::ROLE_CONCIERGE_DASHBOARD) || $auth->hasRole(Roles::ROLE_APARTMENT_GROUP_MANAGEMENT)) {
$userId = $authId;
} else {
return ['errorPage' => 'error'];
}
$isBookingManager = false;
if ($auth->hasRole(Roles::ROLE_BOOKING_MANAGEMENT)) {
$isBookingManager = true;
}
$hasFronterCharg = false;
if ($auth->hasRole(Roles::ROLE_FRONTIER_CHARGE)) {
$hasFronterCharg = true;
}
$hasFrontierCard = false;
if ($auth->hasRole(Roles::ROLE_FRONTIER_MANAGEMENT)) {
$hasFrontierCard = true;
}
$hasCurrentStayView = false;
if ($auth->hasRole(Roles::ROLE_CONCIERGE_CURRENT_STAYS)) {
$hasCurrentStayView = true;
}
$checkID = $service->checkGroupForUser($id, $userId);
if (!$checkID) {
return ['errorPage' => 'error'];
}
$timezone = 'UTC';
$group_name = '';
$accommodationList = $service->getApartmentGroupItems($id);
if (is_object($rowObj)) {
$timezone = $rowObj->getTimezone();
$group_name = $rowObj->getName();
}
$conciergeView = $service->getConciergeView($accommodationList, $timezone);
// get bad email list
$getBadEmail = BookingTicket::getBadEmail();
return ['currentStays' => $conciergeView['currentStays'], 'arrivalsYesterday' => $conciergeView['arrivalsYesterday'], 'arrivalsToday' => $conciergeView['arrivalsToday'], 'arrivalsTomorrow' => $conciergeView['arrivalsTomorrow'], 'checkoutsToday' => $conciergeView['checkoutsToday'], 'checkoutsTomorrow' => $conciergeView['checkoutsTomorrow'], 'checkoutsYesterday' => $conciergeView['checkoutsYesterday'], 'dateInTimezone' => $conciergeView['dateInTimezone'], 'groupId' => $id, 'groupName' => $group_name, 'isBookingManager' => $isBookingManager, 'hasFronterCharg' => $hasFronterCharg, 'hasCurrentStayView' => $hasCurrentStayView, 'currentDate' => $currentDate, 'hasFrontierCard' => $hasFrontierCard, 'getBadEmail' => json_encode($getBadEmail), 'userIsExternal' => $external];
}
示例2: testFilterReservationData
/**
* Test filter reservation data action
*/
public function testFilterReservationData()
{
// check services and dao`s
$websiteSearchService = $this->getApplicationServiceLocator()->get('service_website_search');
$this->assertInstanceOf('\\DDD\\Service\\Website\\Search', $websiteSearchService);
$cityDao = new City($this->getApplicationServiceLocator(), 'ArrayObject');
$this->assertInstanceOf('\\DDD\\Dao\\Location\\City', $cityDao);
$cityName = 'Yerevan';
$apartmentTitle = 'hollywood-al-pacino';
$cityResponse = $cityDao->getCityByName($cityName);
$this->assertTrue(ClassicValidator::checkCityName($cityName), "City Name Validator haven't correct regex");
$this->assertTrue(ClassicValidator::checkApartmentTitle($apartmentTitle), "Apartment Name Validator haven't correct regex");
$this->assertArrayHasKey('timezone', $cityResponse);
// check current date
$diffHours = 0;
$boDiffHours = -24;
$currentDate = Helper::getCurrenctDateByTimezone($cityResponse['timezone'], 'd-m-Y', $diffHours);
$currentDateForBo = Helper::getCurrenctDateByTimezone($cityResponse['timezone'], 'd-m-Y', $boDiffHours);
$dateCurrent = new \DateTime("now");
$dateBoCurrent = new \DateTime("yesterday");
$this->assertEquals($currentDate, $dateCurrent->format('d-m-Y'), 'Guest timezone logic is not correct');
$this->assertEquals($currentDateForBo, $dateBoCurrent->format('d-m-Y'), 'Bo User timezone logic is not correct');
}
示例3: changeDateForModification
/**
* @param $ratesData
* @param $reservationId
* @param bool $isGetInfo
* @param bool $isOverbooking
* @param bool $apartel
* @return array
*/
public function changeDateForModification($ratesData, $reservationId, $isGetInfo = false, $apartel = false, $isOverbooking = false)
{
/**
* @var Booking $bookingDao
* @var BookingTicket $reservationTicketService
* @var ReservationNightly $reservationNightlyDao
* @var WorstCXLPolicySelector $policyService
* @var PenaltyCalculation $penaltyService
* @var Logger $logger
* @var \DDD\Service\Booking\Charge $chargeService
* @var \DDD\Service\Availability $availabilityService
*/
if (empty($ratesData) || !$reservationId) {
$this->gr2err("Bad situation while modifying date part: Bad Data for modification date", ['cron' => 'ChannelManager', 'reservation_id' => $reservationId]);
return ['status' => 'error'];
}
$bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
$reservationNightlyDao = $this->getServiceLocator()->get('dao_booking_reservation_nightly');
$policyService = $this->getServiceLocator()->get('service_reservation_worst_cxl_policy_selector');
$logger = $this->getServiceLocator()->get('ActionLogger');
$chargeService = $this->getServiceLocator()->get('service_booking_charge');
$reservationTicketService = $this->getServiceLocator()->get('service_booking_booking_ticket');
$availabilityService = $this->getServiceLocator()->get('service_availability');
$update = $insert = $delete = $rateIds = [];
// Reservation Data
$reservationData = $bookingDao->getReservationPolicyData($reservationId);
$resNightlyData = $reservationNightlyDao->fetchAll(['reservation_id' => $reservationId, 'status' => self::STATUS_BOOKED]);
$isFlexible = $reservationData['penalty_hours'] > $reservationData['refundable_before_hours'] ? true : false;
$today = Helper::getCurrenctDateByTimezone($reservationData['timezone']);
$reservationSetParams = [];
$ratesDateKey = array_keys($ratesData);
sort($ratesDateKey);
$newReservationNightCount = count($ratesDateKey);
$priceAllRefundable = 0;
foreach ($resNightlyData as $row) {
if (in_array($row['date'], $ratesDateKey) || strtotime($today) > strtotime($row['date'])) {
unset($ratesData[$row['date']]);
} else {
if ($reservationData['is_refundable'] == Rate::APARTMENT_RATE_REFUNDABLE && $isFlexible) {
// Refundable flexible period, Nothing change, apply what has
$delete[$row['date']] = ['id' => $row['id'], 'price' => $row['price'], 'apartment_id' => $row['apartment_id'], 'room_id' => $row['room_id'], 'rate_id' => $row['rate_id'], 'date' => $row['date'], 'capacity' => $row['capacity'], 'rate_name' => $row['rate_name'], 'is_refundable' => Rate::APARTMENT_RATE_REFUNDABLE, 'revers' => true, 'update_price' => false];
} elseif ($reservationData['is_refundable'] == Rate::APARTMENT_RATE_REFUNDABLE) {
// Refundable penalty period
$priceAllRefundable += $row['price'];
$update[$row['date']] = ['id' => $row['id'], 'price' => $row['price'], 'apartment_id' => $row['apartment_id'], 'room_id' => $row['room_id'], 'rate_id' => $row['rate_id'], 'date' => $row['date'], 'capacity' => $row['capacity'], 'rate_name' => $row['rate_name'], 'is_refundable' => Rate::APARTMENT_RATE_REFUNDABLE, 'revers' => false, 'update_price' => false];
} elseif ($reservationData['is_refundable'] == Rate::APARTMENT_RATE_NON_REFUNDABLE) {
// Non Refundable
$update[$row['date']] = ['id' => $row['id'], 'price' => $row['price'], 'apartment_id' => $row['apartment_id'], 'room_id' => $row['room_id'], 'rate_id' => $row['rate_id'], 'date' => $row['date'], 'capacity' => $row['capacity'], 'rate_name' => $row['rate_name'], 'is_refundable' => Rate::APARTMENT_RATE_NON_REFUNDABLE, 'revers' => false, 'update_price' => false];
}
//open parking spot availability
$chargeService->openParkingSpotAvailability($row['id']);
}
}
// calculate refundable and penalty period price
$updateDayCount = count($update);
foreach ($update as $key => $row) {
if ($row['is_refundable'] == Rate::APARTMENT_RATE_REFUNDABLE) {
if ($reservationData['penalty'] == Rate::PENALTY_TYPE_PERCENT) {
$update[$key]['revers'] = true;
$update[$key]['update_price'] = true;
$update[$key]['price'] = $row['price'] * $reservationData['penalty_val'] / 100;
} elseif ($reservationData['penalty'] == Rate::PENALTY_TYPE_FIXED_AMOUNT || $reservationData['penalty'] == Rate::PENALTY_TYPE_NIGHTS) {
if ($priceAllRefundable >= $reservationData['penalty_fixed_amount']) {
$penaltyPricePerNight = $reservationData['penalty_fixed_amount'] / $updateDayCount;
$update[$key]['price'] = $penaltyPricePerNight;
$update[$key]['revers'] = true;
$update[$key]['update_price'] = true;
} else {
$update[$key]['revers'] = false;
$update[$key]['update_price'] = false;
}
}
}
}
$insert = $ratesData;
$addedNightCount = count($insert);
// Save and sync Nightly Data
$nightlyData = ['insert' => ['data' => $insert, 'availability' => 0], 'update' => ['data' => $update, 'availability' => 1], 'delete' => ['data' => $delete, 'availability' => 1]];
if ($isGetInfo) {
return $chargeService->chargeForModifyDate($nightlyData, $reservationId, true);
}
// if became overbooking change overbooking status
if ($isOverbooking && $reservationData['overbooking_status'] != BookingTicket::OVERBOOKING_STATUS_OVERBOOKED) {
$updateAvailabilityBit = strtotime($today) < strtotime($reservationData['date_from']);
$changeStatus = $reservationTicketService->changeOverbookingStatus($reservationId, BookingTicket::OVERBOOKING_STATUS_OVERBOOKED, $updateAvailabilityBit);
if (!$changeStatus) {
return ['status' => 'error'];
}
}
$modifyDateLog = $availabilitySyncDays = [];
$addedPrice = 0;
foreach ($nightlyData as $keyType => $data) {
//.........这里部分代码省略.........
示例4: createExtraAutoTaskForKeyChange
/**
* checks if last reservation keys are set right, if not,
* creates an extra task for next reservation's checkin
* @param $lastReservation
* @param $nextReservation
* @return bool
*/
public function createExtraAutoTaskForKeyChange($lastReservation, $nextReservation)
{
if ($nextReservation['no_refresh'] == 1) {
return false;
}
$taskDao = $this->getTaskDao();
$lastReservationTask = $this->getReservationAutoCreatedTask($lastReservation['id'], self::TYPE_CLEANING, $lastReservation['apartment_id_assigned']);
if (is_null($lastReservationTask) || !$lastReservationTask) {
return false;
}
$taskType = self::TYPE_APT_SERVICE;
$nextReservationExtraTask = $this->getReservationAutoCreatedTask($lastReservation['id'], $taskType);
if (!is_null($nextReservationExtraTask) && $nextReservationExtraTask) {
//extra task is already created
return false;
}
$taskSubtaskDao = $this->getTaskSubtasksDao();
$setCodeToSubtask = $taskSubtaskDao->getSubtaskLike($lastReservationTask['id'], $nextReservation['pin'] . ' for next check-in');
$occupancySubtask = $taskSubtaskDao->getSubtaskLike($lastReservationTask['id'], 'Occupancy: ' . $nextReservation['occupancy']);
if (!$setCodeToSubtask && !in_array($nextReservation['lock_type'], LockGeneral::$typeWithoutCode) || !$occupancySubtask) {
//it means that originally the task was been created for another reservation and we have got a new reservation in a middle
$taskName = 'Inspect the apartment for new occupants';
$bookingTicketService = $this->getServiceLocator()->get('service_booking_booking_ticket');
$bookingTicket = $bookingTicketService->getBookingThicketByReservationId($nextReservation['id']);
$apartmentId = $bookingTicket->getApartmentIdAssigned();
$buildingId = $bookingTicket->getApartmentAssignedBuildingId();
$checkInDate = $bookingTicket->getDate_from();
$checkInTime = is_null($bookingTicket->getApartmentCheckInTime()) ? '13:00:00' : $bookingTicket->getApartmentCheckInTime();
$checkInDateTime = $checkInDate . ' ' . $checkInTime;
$checkinDateTimeMinus1Hour = date('Y-m-d H:i:s', strtotime($checkInDateTime) - 3600);
$teamId = $this->getTeamBasedOnType($taskType, $apartmentId, $buildingId);
$actionsSet = [self::ACTION_CHANGE_DETAILS => 1, self::ACTION_CHANGE_STATUS => 1, self::ACTION_MANAGE_STAFF => 1, self::ACTION_MANAGE_SUBTASKS => 1];
$occupancySubtaskOfLastReservation = $taskSubtaskDao->getSubtaskLike($lastReservationTask['id'], 'Occupancy: ');
if (is_null($occupancySubtaskOfLastReservation['description']) || strpos(false === $occupancySubtaskOfLastReservation['description'], 'Occupancy: ')) {
return false;
}
$alreadySetOccupancy = substr($occupancySubtaskOfLastReservation['description'], strlen('Occupancy: '));
$subtaskDescription = [];
if (in_array($nextReservation['lock_type'], LockGeneral::$typeWithoutCode) && $alreadySetOccupancy == $nextReservation['occupancy']) {
return false;
}
$occupancySubtaskOfCreatingTask = 'Occupancy: ' . $nextReservation['occupancy'];
if ($alreadySetOccupancy != $nextReservation['occupancy']) {
$occupancySubtaskOfCreatingTask .= ' (old occupancy: ' . $alreadySetOccupancy . ')';
}
array_push($subtaskDescription, $occupancySubtaskOfCreatingTask);
if ($lastReservation['outside_door_code']) {
array_push($subtaskDescription, 'Enter to building with ' . $lastReservation['outside_door_code']);
}
$setCodeToSubtaskSet = $taskSubtaskDao->getSubtaskLike($lastReservationTask['id'], ' for next check-in');
if ($setCodeToSubtaskSet) {
$SubTaskArray = explode(' for next check-in', $setCodeToSubtaskSet['description']);
$subTaskFirstPart = $SubTaskArray[0];
$subTaskFirstPartArray = explode('Set', $subTaskFirstPart);
$EnterCode = $subTaskFirstPartArray[1];
} else {
$EnterCode = 'Mechanical Key';
}
array_push($subtaskDescription, 'Enter to apartment with ' . $EnterCode);
if ($nextReservation['next_pin']) {
array_push($subtaskDescription, 'Set ' . $nextReservation['next_pin'] . ' for next check-in');
}
/* @var $apartmentDao \DDD\Dao\Apartment\General */
$apartmentDao = $this->getServiceLocator()->get('dao_apartment_general');
$apartmentData = $apartmentDao->getApartmentGeneralInfo($apartmentId);
$apartmentToday = Helper::getCurrenctDateByTimezone($apartmentData['timezone']);
$taskPriority = self::TASK_PRIORITY_NORMAL;
if ($nextReservation['date_from'] <= $apartmentToday) {
$taskPriority = self::TASK_PRIORITY_CRITICAL;
}
$startDateTime = $checkinDateTimeMinus1Hour;
$endDateTime = $checkInDateTime;
$deleteDate = date("Y-m-d", strtotime($endDateTime));
$taskData = ['title' => $taskName, 'task_type' => $taskType, 'team_id' => $teamId, 'following_team_id' => TeamService::TEAM_CONTACT_CENTER, 'start_date' => $startDateTime, 'end_date' => $endDateTime, 'task_status' => self::STATUS_NEW, 'creator_id' => UserMain::SYSTEM_USER_ID, 'task_priority' => $taskPriority, 'description' => 'Prepare For The Next Guest', 'res_id' => $lastReservation['id'], 'property_id' => $apartmentId, 'building_id' => $buildingId, 'verifier_id' => UserService::AUTO_VERIFY_USER_ID, 'is_hk' => self::TASK_IS_HOUSEKEEPING, 'subtask_description' => $subtaskDescription];
$id = $this->taskSave($taskData, $actionsSet, true);
//delete All other extra Key Fob tasks for today on this apartment
$taskDao->deleteAllSameDayAutoGeneratedTasks($id, $deleteDate, $apartmentId, $taskType);
echo 'extra task created, id = ' . $id . "[0m\n\r";
}
}
示例5: filterReservationData
/**
* @param array $data
* @return string
*/
private function filterReservationData($data)
{
$currentDate = date('Y-m-d');
$cityDao = new City($this->getServiceLocator(), 'ArrayObject');
if (isset($data['city']) && ClassicValidator::checkCityName($data['city'])) {
$cityResp = $cityDao->getCityByName(Helper::urlForSearch($data['city']));
if ($cityResp) {
/* @var $websiteSearchService \DDD\Service\Website\Search */
$websiteSearchService = $this->getServiceLocator()->get('service_website_search');
$diffHours = $websiteSearchService->getDiffHoursForDate();
$currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHours);
}
}
if (!isset($data['city']) || !ClassicValidator::checkCityName($data['city']) || !isset($data['apartment']) || !ClassicValidator::checkApartmentTitle($data['apartment']) || !isset($data['guest']) || !is_numeric($data['guest']) || !isset($data['apartment_id']) || !is_numeric($data['apartment_id']) || !isset($data['arrival']) || !ClassicValidator::validateDate($data['arrival'], 'd M Y') || !isset($data['departure']) || !ClassicValidator::validateDate($data['departure'], 'd M Y') || strtotime($data['arrival']) >= strtotime($data['departure']) || strtotime($currentDate) - strtotime($data['arrival']) > 129600 || !isset($data['rate-for-booking']) || !is_numeric($data['rate-for-booking']) || isset($data['apartel_id']) && !is_numeric($data['apartel_id'])) {
return false;
}
return true;
}
示例6: changeReservationDate
/**
* @param $reservationId
* @param $dateFrom
* @param $dateTo
* @param bool $isGetInfo
* @return array
*/
public function changeReservationDate($reservationId, $dateFrom, $dateTo, $isGetInfo = false)
{
/**
* @var ReservationNightly $reservationNightlyDao
* @var \DDD\Service\Reservation\Main $reservationService
* @var \DDD\Service\Reservation\RateSelector $rateSelector
* @var \DDD\Dao\Apartment\Inventory $inventoryDao
* @var \DDD\Dao\Booking\Booking $bookingDao
*/
$inventoryDao = $this->getServiceLocator()->get('dao_apartment_inventory');
$reservationNightlyDao = $this->getServiceLocator()->get('dao_booking_reservation_nightly');
$reservationService = $this->getServiceLocator()->get('service_reservation_main');
$rateSelector = $this->getServiceLocator()->get('service_reservation_rate_selector');
$bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
$reservationData = $bookingDao->getReservationDataForChangeDate($reservationId);
$today = Helper::getCurrenctDateByTimezone($reservationData['timezone']);
$bookingDao->setEntity(new \ArrayObject());
// Data check
if (!$reservationData || !$dateFrom || !ClassicValidator::validateDate($dateFrom, 'Y-m-d') || !$dateTo || !ClassicValidator::validateDate($dateTo, 'Y-m-d') || strtotime($dateFrom) >= strtotime($dateTo)) {
return ['status' => 'error', 'msg' => TextConstants::MODIFICATION_BAD_DATA_FOR_CHANGE];
}
$error = '';
if ($reservationData['date_from'] != $dateFrom && strtotime($today) > strtotime($dateFrom)) {
$error .= TextConstants::MODIFICATION_DATE_NOT_PAST;
}
if ($reservationData['status'] != BookingService::BOOKING_STATUS_BOOKED) {
$error .= TextConstants::MODIFICATION_STATUS_BOOKED;
}
if ($reservationData['date_from'] == $dateFrom && $reservationData['date_to'] == $dateTo) {
$error .= TextConstants::MODIFICATION_NO_INDICATED;
}
if (strtotime($today) > strtotime($dateTo)) {
$error .= TextConstants::MODIFICATION_DATE_SHOULD_FUTURE;
}
if ($error) {
return ['status' => 'error', 'msg' => $error];
}
// check is apartel
$apartel = $reservationData['apartel_id'] && $reservationData['channel_res_id'] > 0 ? $reservationData['apartel_id'] : false;
// New Date generation
$resNightlyData = $reservationNightlyDao->fetchAll(['reservation_id' => $reservationId, 'status' => ReservationMainService::STATUS_BOOKED], [], 'date ASC');
$existingNightlyData = $startRateApartment = $lastRateApartment = $existingDate = $newNightlyData = [];
$existingNightCount = $resNightlyData->count();
if (!$existingNightCount) {
return ['status' => 'error', 'msg' => TextConstants::MODIFICATION_BAD_DATA_FOR_CHANGE];
}
foreach ($resNightlyData as $key => $night) {
$existingNightlyData[$night['date']] = $night;
}
// existing date array
$existingDate = array_keys($existingNightlyData);
$startRateApartment = $existingNightlyData[current($existingDate)];
$lastRateApartment = $existingNightlyData[end($existingDate)];
$dateFromTime = strtotime($dateFrom);
$dateToTime = strtotime($dateTo);
while ($dateFromTime < $dateToTime) {
$date = date('Y-m-d', $dateFromTime);
if (in_array($date, $existingDate)) {
// existing date
$newFromData = $existingNightlyData[$date];
} else {
if (strtotime($date) < strtotime($reservationData['date_from'])) {
// get rate data from start date
$newFromData = $startRateApartment;
$rateIdForChangeDate = $startRateApartment['rate_id'];
} else {
// get rate data from last date
$rateIdForChangeDate = $lastRateApartment['rate_id'];
$newFromData = $lastRateApartment;
}
if ($apartel) {
/**
* @var \DDD\Dao\Apartel\Rate $apartelRateDao
* @var \DDD\Dao\Apartel\Inventory $apartelInventoryDao
*/
$apartelRateDao = $this->getServiceLocator()->get('dao_apartel_rate');
$apartelInventoryDao = $this->getServiceLocator()->get('dao_apartel_inventory');
// rate exist and active if not use fuzzy logic
if (!$apartelRateDao->checkRateExistAndActive($rateIdForChangeDate)) {
$newFromData = $rateSelector->getSelectorRate($reservationId, $date, $isGetInfo, $apartel);
$rateIdForChangeDate = $newFromData['rate_id'];
}
// check apartment availability
if (!$inventoryDao->checkApartmentAvailabilityApartmentDateList($newFromData['apartment_id'], [$date])) {
return ['status' => 'error', 'msg' => TextConstants::ERROR_NO_AVAILABILITY];
}
// check apartel availability and get price
$priceApartel = $apartelInventoryDao->getPriceByRateIdDate($rateIdForChangeDate, $date);
$newPrice = $priceApartel['price'];
} else {
/** @var \DDD\Dao\Apartment\Rate $rateDao */
$rateDao = $this->getServiceLocator()->get('dao_apartment_rate');
// rate exist and active if not use fuzzy logic
//.........这里部分代码省略.........
示例7: getFixedDate
/**
*
* @param array $data
* @return array
*/
public function getFixedDate($data)
{
$currentDate = date('Y-m-d');
$cityDao = new City($this->getServiceLocator(), 'ArrayObject');
if (isset($data['city']) && ClassicValidator::checkCityName($data['city'])) {
$cityResp = $cityDao->getCityBySlug($data['city']);
if ($cityResp) {
$diffHousr = $this->getDiffHoursForDate();
$currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHousr);
}
}
$arrival = isset($data['arrival']) && $data['arrival'] && ClassicValidator::validateDate($data['arrival']) ? date('Y-m-d', strtotime($data['arrival'])) : '';
$departure = isset($data['departure']) && $data['departure'] && ClassicValidator::validateDate($data['departure']) ? date('Y-m-d', strtotime($data['departure'])) : '';
if ($arrival && $departure && strtotime($arrival) > strtotime($departure)) {
$arrival = $departure = '';
} elseif ($arrival && strtotime($currentDate) > strtotime($arrival) || $departure && strtotime($currentDate) > strtotime($departure)) {
$arrival = $departure = '';
} elseif (!$arrival && $departure) {
$departure = '';
} elseif ($arrival && !$departure) {
$departure = date('Y-m-d', strtotime($arrival . '+1 day'));
}
return ['arrival' => $arrival, 'departure' => $departure];
}
示例8: getOptions
/**
*
* @return array
*/
public function getOptions($data)
{
/* @var $websiteSearchService \DDD\Service\Website\Search */
$websiteSearchService = $this->getServiceLocator()->get('service_website_search');
$diffHours = $websiteSearchService->getDiffHoursForDate();
$options['current_date'] = Helper::getCurrenctDateByTimezone($data['city_data']['timezone'], 'd-m-Y', $diffHours);
$router = $this->getServiceLocator()->get('router');
$url = $router->assemble([], ['name' => 'search']);
$options['url'] = $url;
$guest = Objects::getGuestList(['guest' => $this->getTextLineSite(1455), 'guests' => $this->getTextLineSite(1456)]);
$options['guest'] = $guest;
return $options;
}
示例9: getCurrentDateCity
public function getCurrentDateCity($cityId)
{
$cityDao = new \DDD\Dao\Geolocation\Cities($this->getServiceLocator(), 'ArrayObject');
$city = $cityDao->fetchOne(['id' => $cityId], ['timezone']);
if ($city && $city['timezone']) {
return Helper::getCurrenctDateByTimezone($city['timezone'], 'Y-m-d H:i:s');
}
return date('Y-m-d H:i:s');
}
示例10: getReservationCard
/**
* @param int $id
* @param ControllerBase $controller
* @return array | bool
*/
public function getReservationCard($id, ControllerBase $controller)
{
/**
* @var \DDD\Dao\Booking\Booking $reservationDao
*/
$card = false;
/**
* @var $reservationDao \DDD\Dao\Booking\Booking
* @var $cccaDao \DDD\Dao\Finance\Ccca
*/
$reservationDao = $this->getServiceLocator()->get('dao_booking_booking');
$cccaDao = $this->getServiceLocator()->get('dao_finance_ccca');
$result = $reservationDao->getTheCard($id);
// check has frontier charge permission
$auth = $this->getServiceLocator()->get('library_backoffice_auth');
$router = $controller->getEvent()->getRouter();
if ($result) {
$card = ['id' => $result->getId(), 'bookingStatus' => $result->getBookingStatus(), 'resNumber' => $result->getResNumber(), 'name' => $result->getResNumber(), 'guest' => $result->getGuest(), 'apartmentAssignedId' => $result->getApartmentAssignedId(), 'apartmentAssigned' => $result->getApartmentAssigned(), 'building' => $result->getBuilding(), 'buildingId' => $result->getBuildingId(), 'unitNumber' => $result->getUnitNumber(), 'guest_phone' => $result->getGuestPhone(), 'travelPhone' => $result->getGuestTravelPhone(), 'dateFrom' => $result->getDateFrom() ? date(Constants::GLOBAL_DATE_FORMAT, strtotime($result->getDateFrom())) : '', 'dateTo' => $result->getDateTo() ? date(Constants::GLOBAL_DATE_FORMAT, strtotime($result->getDateTo())) : '', 'arrivalDate' => $result->getArrivalDate() ? date(Constants::GLOBAL_DATE_FORMAT . ' H:i', strtotime($result->getArrivalDate())) : '', 'departureDate' => $result->getDepartureDate() ? date(Constants::GLOBAL_DATE_FORMAT . ' H:i', strtotime($result->getDepartureDate())) : '', 'now' => Helper::getCurrenctDateByTimezone($result->getTimezone()), 'arrivalStatus' => $result->getArrivalStatus(), 'occupancy' => $result->getOccupancy(), 'guestBalance' => $result->getGuestBalance(), 'housekeepingComments' => $result->getHousekeepingComments(), 'cccaVerified' => $result->getCccaVerified(), 'parking' => $result->getParking(), 'parking_url' => $router->assemble(['res_num' => $result->getResNumber()], ['name' => 'frontier/print-parking-permits']), 'key_task' => $result->getKeyTask(), 'keyTask' => $result->getKeyTask(), 'guestEmail' => $result->getGuestEmail(), 'cccaPageStatus' => $result->getCccaPageStatus(), 'cccaPageToken' => $result->getCccaPageToken(), 'apartmentCurrencyCode' => $result->getApartmentCurrencyCode(), 'cccaPageLink' => ''];
if (strtotime($card['now']) <= strtotime($card['dateTo']) && $result->getKiPageStatus() == ReservationTicketService::SEND_KI_PAGE_STATUS && $result->getKiPageHash()) {
$card['keyUrl'] = 'https://' . DomainConstants::WS_SECURE_DOMAIN_NAME . '/key?code=' . $result->getKiPageHash() . '&view=0' . '&bo=' . $result->getKiPageGodModeCode();
}
if ($auth->hasRole(Roles::ROLE_FRONTIER_CHARGE)) {
$card['frontierCharge'] = '/frontier/charge/' . $result->getId() . '/0/' . Helper::hashForFrontierCharge($result->getId());
}
if (is_null($result->getArrivalTime())) {
$card['arrivalTime'] = date('H:i', strtotime($result->getApartmentCheckInTime()));
} else {
$card['arrivalTime'] = date('H:i', strtotime($result->getArrivalTime()));
}
/* @var $chargeAuthorizationService \DDD\Service\Reservation\ChargeAuthorization */
$chargeAuthorizationService = $this->getServiceLocator()->get('service_reservation_charge_authorization');
$card['creditCardsForAuthorization'] = $chargeAuthorizationService->getCreditCardsForAuthorization($id);
// CCCA page link
$cccaData = $cccaDao->getAllSentCcca($id);
if ($cccaData) {
foreach ($cccaData as $index => $row) {
$lastDigit = 0;
foreach ($card['creditCardsForAuthorization'] as $cardInfo) {
if ($cardInfo->getId() == $row->getCcId()) {
$lastDigit = $cardInfo->getLast4Digits();
break;
}
}
$card['cccaPageLink'][$index] = ['link' => 'https://' . DomainConstants::WS_SECURE_DOMAIN_NAME . '/ccca-page?token=' . $row->getPageToken(), 'lastDigit' => $lastDigit];
}
}
$card['hasMoreCards'] = false;
if (count($card['creditCardsForAuthorization']) > $cccaData->count()) {
$card['hasMoreCards'] = true;
}
}
return $card;
}
示例11: filterQueryData
/**
* @param array $data
* @return string
*/
public function filterQueryData($data)
{
$currentDate = date('Y-m-d');
$cityDao = new City($this->getServiceLocator(), 'ArrayObject');
if (!isset($data['city'])) {
$pageSlugExp = explode('--', $data['slug']);
$citySlug = $pageSlugExp[1];
} else {
$citySlug = $data['city'];
}
if (isset($citySlug) && ClassicValidator::checkCityName($citySlug)) {
$cityResp = $cityDao->getCityBySlug(Helper::urlForSearch($citySlug, TRUE));
if ($cityResp) {
/* @var $websiteSearchService \DDD\Service\Website\Search */
$websiteSearchService = $this->getServiceLocator()->get('service_website_search');
$diffHours = $websiteSearchService->getDiffHoursForDate();
$currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHours);
}
}
if (!isset($data['arrival']) || !ClassicValidator::validateDate($data['arrival']) || !isset($data['departure']) || !ClassicValidator::validateDate($data['departure']) || strtotime($data['arrival']) < strtotime($currentDate) || strtotime($data['arrival']) >= strtotime($data['departure'])) {
return false;
}
return true;
}
示例12: ajaxReportIncidentAction
public function ajaxReportIncidentAction()
{
/**
* @var \DDD\Dao\Booking\Booking $reservationDao
* @var \DDD\Service\Task $taskService
*/
$user = $this->getServiceLocator()->get('library_backoffice_auth');
$taskService = $this->getServiceLocator()->get('service_task');
$request = $this->getRequest();
$result = ['status' => 'success', 'msg' => 'Incident report has been created.', 'title' => '', 'taskId' => 0];
$taskId = (int) $request->getPost('task_id', 0);
try {
if ($request->isXmlHttpRequest() && $taskId) {
$task = $taskService->getTaskDao()->getTaskById($taskId);
$apartmentId = $task->getProperty_id();
$buildingId = $task->getBuildingId();
$resId = $task->getResId();
$timezone = $task->getTimezone();
$currentDateCity = Helper::getCurrenctDateByTimezone($timezone, 'Y-m-d H:i:s');
$ninetySixHoursLaterDateCity = Helper::incrementDateByTimezone($timezone, 96, 'Y-m-d H:i:s');
$userId = $user->getIdentity()->id;
$creator = $user->getIdentity()->id;
switch ((int) $request->getPost('incident_type', 0)) {
case HouseKeeping::INCIDENT_REPORT_EVIDENCE_OF_SMOKING:
$damageType = 'There was evidence of smoking';
break;
case HouseKeeping::INCIDENT_REPORT_KEYS_WERE_NOT_RETURNED:
$damageType = 'The keys were not returned';
break;
case HouseKeeping::INCIDENT_REPORT_DIRTY_HOUSE:
$damageType = 'The house was left in a unusually dirty condition';
break;
case HouseKeeping::INCIDENT_REPORT_BROKEN_FURNITURE:
$damageType = 'There was broken furniture';
break;
case HouseKeeping::INCIDENT_REPORT_OTHER:
$damageType = $request->getPost('description', 'Incident Report');
break;
}
$title = $damageType;
$description = '';
$incidentTaskId = $taskService->createReportIncidentTask($resId, $apartmentId, $buildingId, $currentDateCity, $ninetySixHoursLaterDateCity, $title, $creator, $description, $userId, $taskId);
$result['title'] = $title;
$result['taskId'] = $incidentTaskId;
}
} catch (\Exception $e) {
$result['status'] = 'error';
$result['msg'] = TextConstants::SERVER_ERROR;
}
return new JsonModel($result);
}
示例13: getMoveStartDate
/**
* @param $resDateFrom
* @param $apartmentId
* @return bool|string
*/
public function getMoveStartDate($resDateFrom, $apartmentId)
{
/**
* @var \DDD\Dao\Apartment\General $apartmentDao
*/
$apartmentDao = $this->getServiceLocator()->get('dao_apartment_general');
$apartmentData = $apartmentDao->getApartmentDataForReservationMove($apartmentId);
$today = Helper::getCurrenctDateByTimezone($apartmentData['timezone']);
// $time = Helper::getCurrenctDateByTimezone($apartmentData['timezone'], 'H:i:s');
// if ($resDateFrom > $today) {
// return $resDateFrom;
// } else if ($time >= $apartmentData['check_in']) {
// return $today;
// } else {
// return Helper::getDateByTimeZone('-1 days', $apartmentData['timezone']);
// }
if ($resDateFrom >= $today) {
return $resDateFrom;
} else {
return $today;
}
}