コード例 #1
0
ファイル: FrontierController.php プロジェクト: arbi/MyCode
 public function chargeAction()
 {
     $detailDao = $this->getServiceLocator()->get('dao_apartment_details');
     $request = $this->getRequest();
     $bookingId = (int) $this->params()->fromRoute('booking_id', 0);
     $hash = $this->params()->fromRoute('hash', '');
     $itemId = $this->params()->fromRoute('item_id', 0);
     if (!$bookingId || Helper::hashForFrontierCharge($bookingId) != $hash) {
         Helper::setFlashMessage(['error' => TextConstants::ERROR_NO_ITEM]);
         return $this->redirect()->toRoute('backoffice/default', ['controller' => 'concierge', 'action' => 'view']);
     }
     /**
      * @var \DDD\Service\Frontier $service
      */
     $service = $this->getServiceLocator()->get('service_frontier');
     $data = $service->getDataForFrontierCharge($bookingId, $itemId);
     if (!$data) {
         Helper::setFlashMessage(['error' => TextConstants::ERROR_NO_ITEM]);
         return $this->redirect()->toRoute('backoffice/default', ['controller' => 'concierge', 'action' => 'view']);
     }
     $creditCards = false;
     if (isset($data['booking_data']['customer_id']) && $data['booking_data']['customer_id'] > 0) {
         /**
          * @var Card $cardService
          */
         $cardService = $this->getServiceLocator()->get('service_card');
         $creditCards = $cardService->getCustomerCreditCardsForFrontier($data['booking_data']['customer_id']);
     }
     $creditCardForm = new CreditCard();
     $currencyDao = $this->getServiceLocator()->get('dao_currency_currency');
     $currencyUtility = new Currency($currencyDao);
     $limitAmount = $currencyUtility->convert(200, 'USD', $data['booking_data']['acc_currency_sign']);
     $apartmentSpotsDao = $this->getServiceLocator()->get('dao_apartment_spots');
     $parkingSpotPriority = $apartmentSpotsDao->getApartmentParkingPrioritySpots($data['booking_data']['apartment_id_assigned']);
     $spotsPriority = [];
     foreach ($parkingSpotPriority as $key => $value) {
         if (!is_null($value)) {
             array_push($spotsPriority, $value);
         }
     }
     return array('data' => $data, 'itemId' => $itemId, 'creditCards' => $creditCards, 'creditCardForm' => $creditCardForm, 'limitAmount' => $limitAmount, 'spotsPriority' => $spotsPriority);
 }
コード例 #2
0
ファイル: Frontier.php プロジェクト: arbi/MyCode
 /**
  * @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;
 }