Exemplo n.º 1
0
 public function getBookingOptions($data)
 {
     /**
      * @var \DDD\Service\Booking\BookingAddon $bookingAddonService
      * @var \DDD\Dao\Partners\Partners $partnerDao
      * @var \DDD\Dao\Booking\Charge $chargeDao
      * @var \DDD\Dao\Booking\ChargeTransaction $bankTransactionDao
      * @var \DDD\Dao\ApartmentGroup\ApartmentGroup $apartmentGroupDao
      * @var ChargeAuthorizationService $chargeAuthorizationService
      * @var Psp $pspDao
      */
     $bookingAddonService = $this->getServiceLocator()->get('service_booking_booking_addon');
     $partnerDao = $this->getServiceLocator()->get('dao_partners_partners');
     $apartmentGroupDao = $this->getServiceLocator()->get('dao_apartment_group_apartment_group');
     $chargeDao = $this->getServiceLocator()->get('dao_booking_charge');
     $bankTransactionDao = $this->getServiceLocator()->get('dao_booking_change_transaction');
     $apartmentDao = $this->getServiceLocator()->get('dao_accommodation_accommodations');
     $curencyRateDao = new \DDD\Dao\Currency\Currency($this->getServiceLocator(), 'DDD\\Domain\\Booking\\Currency');
     $countryDao = new \DDD\Dao\Geolocation\Countries($this->getServiceLocator());
     $teamsDao = new \DDD\Dao\Team\Team($this->getServiceLocator());
     $statusDao = new \DDD\Dao\Booking\Statuses($this->getServiceLocator());
     $accDeailsDao = new \DDD\Dao\Apartment\Details($this->getServiceLocator(), 'ArrayObject');
     $apartmentDescriptionDao = new \DDD\Dao\Apartment\Description($this->getServiceLocator(), 'ArrayObject');
     $chargeAuthorizationService = $this->getServiceLocator()->get('service_reservation_charge_authorization');
     $detailsRow = $accDeailsDao->fetchOne(['apartment_id' => $data['apartmentIdAssigned']]);
     $accInfo = $apartmentDao->fetchOne(['id' => $data['apartmentIdAssigned']]);
     $apartmentDescription = $apartmentDescriptionDao->fetchOne(['apartment_id' => $data['apartmentIdAssigned']]);
     $result = [];
     $result['apartment']['check_in'] = $apartmentDescription['check_in'];
     $status = $data['status'];
     $countries = $countryDao->getAllActiveCountries();
     $result['countries'] = $countries;
     /**
      * @todo do not fetchAll
      * Fetch using usage service
      */
     $result['teams'] = $teamsDao->fetchAll(['usage_notifiable' => 1]);
     $affiliateID = $data['aff_id'];
     $partner = $partnerDao->getPartners($affiliateID);
     $result['partners'] = iterator_to_array($partner);
     $result['partner_data'] = $partnerDao->getPartnerModel($affiliateID);
     $statuses = $statusDao->getAllList($status);
     $result['statuses'] = iterator_to_array($statuses);
     $pspDao = $this->getServiceLocator()->get('dao_psp_psp');
     $pspList = $pspDao->getPspListForTransaction();
     $result['psp'] = iterator_to_array($pspList);
     $addonsList = $bookingAddonService->getAddons();
     $addonsArray = $bookingAddonService->getAddonsArray();
     $creditCardsForAuthorization = $chargeAuthorizationService->getCreditCardsForAuthorization($data['id']);
     $result['credit_cards_for_authorization'] = $creditCardsForAuthorization;
     if ($status == BookingService::BOOKING_STATUS_BOOKED) {
         unset($addonsArray[BookingAddon::ADDON_TYPE_PENALTY]);
     } else {
         unset($addonsArray[BookingAddon::ADDON_TYPE_ACC]);
         unset($addonsArray[BookingAddon::ADDON_TYPE_NIGHT]);
     }
     $result['addons'] = $addonsList;
     $result['addons_array'] = $addonsArray;
     $result['apartels'] = $apartmentGroupDao->getApartelsByApartmentId($data['apartmentIdAssigned']);
     $curencyRate = $curencyRateDao->fetchAll();
     $curencyRateArray = [];
     foreach ($curencyRate as $row) {
         if ($detailsRow) {
             if ((int) $detailsRow['cleaning_fee']) {
                 if ($row->getId() == $accInfo->getCurrencyId()) {
                     $cleaningFeeData = ['currency_id' => $row->getId(), 'cname' => $row->getCode(), 'currency_rate' => $row->getValue()];
                 }
             }
         }
         $curencyRateArray[] = ['code' => $row->getCode(), 'value' => $row->getValue()];
     }
     if ($detailsRow) {
         if ((int) $detailsRow['cleaning_fee']) {
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['value'] = $detailsRow['cleaning_fee'];
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['currency_id'] = $cleaningFeeData['currency_id'];
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['cname'] = $cleaningFeeData['cname'];
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['currency_rate'] = $cleaningFeeData['currency_rate'];
         }
     }
     $result['curencyRate'] = json_encode($curencyRateArray);
     $chargeType = Objects::getChargeType();
     $result['chargeType'] = $chargeType;
     $charges = $chargeDao->getChargesByReservationId($data['id'], 1);
     $result['charges'] = iterator_to_array($charges);
     $charged = $chargeDao->getChargesByReservationId($data['id'], 0);
     $result['charged'] = iterator_to_array($charged);
     $getSumAndBalance = $this->getSumAndBalanc($data['id']);
     $result['balances_and_summaries'] = $getSumAndBalance;
     $transactions = $bankTransactionDao->getReservationTransactions($data['id']);
     $result['transactions'] = $transactions->count() ? iterator_to_array($transactions) : false;
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $hasFinanceRole = $auth->hasRole(Roles::ROLE_RESERVATION_FINANCE);
     $hasPayableRole = $auth->hasRole(Roles::ROLE_BILLPAY);
     $hasTransactionVerifierRole = $auth->hasRole(Roles::ROLE_BOOKING_TRANSACTION_VERIFIER);
     $result['hasFinanceRole'] = $hasFinanceRole;
     $result['hasFinanceRole'] = $hasFinanceRole;
     $result['hasPayableRole'] = $hasPayableRole;
     $result['hasTransactionVerifierRole'] = $hasTransactionVerifierRole;
     if ($auth->hasRole(Roles::ROLE_CREDIT_CARD)) {
         $result['hasCreditCardViewer'] = true;
     }
     return $result;
 }
Exemplo n.º 2
0
 public function getPhoneByCountryId($countryId)
 {
     $countryDao = new \DDD\Dao\Geolocation\Countries($this->getServiceLocator(), 'ArrayObject');
     $phone = $countryDao->getPhoneByCountryId($countryId);
     return $phone;
 }