Exemple #1
0
 public function downloadCsvAction()
 {
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $currency = $apartmentGeneralService->getCurrencySymbol($this->apartmentId);
     $expenseDao = new ExpenseCost($this->getServiceLocator(), '\\ArrayObject');
     $costs = $expenseDao->getApartmentCosts($this->apartmentId);
     $costArray = [];
     foreach ($costs as $cost) {
         $costArray[] = ["ID" => $cost['id'], "Category" => $cost['category'], "Date" => date(Constants::GLOBAL_DATE_FORMAT, strtotime($cost['date'])), "Amount ({$currency})" => $cost['amount'], "Purpose" => $cost['purpose']];
     }
     if (!empty($costArray)) {
         $response = $this->getResponse();
         $headers = $response->getHeaders();
         $utilityCsvGenerator = new CsvGenerator();
         $filename = 'costs_apartment_' . str_replace(' ', '_', date('Y-m-d')) . '.csv';
         $utilityCsvGenerator->setDownloadHeaders($headers, $filename);
         $csv = $utilityCsvGenerator->generateCsv($costArray);
         $response->setContent($csv);
         return $response;
     } else {
         $flash_session = Helper::getSessionContainer('use_zf2');
         $flash_session->flash = ['notice' => 'There are empty data, nothing to download.'];
         $url = $this->getRequest()->getHeader('Referer')->getUri();
         $this->redirect()->toUrl($url);
     }
 }
Exemple #2
0
 public function __invoke($data = [])
 {
     /**
      * @var UserManager $userDao
      */
     $userId = false;
     $result = ['boUser' => 'no'];
     if (isset($_COOKIE['backoffice_user'])) {
         $userId = (int) $_COOKIE['backoffice_user'];
     }
     if ($userId) {
         $userDao = $this->serviceLocator->get('dao_user_user_manager');
         $userInfo = $userDao->getUserTrackingInfo($userId);
         if ($userInfo) {
             $result = ['boUser' => 'yes', 'uid' => strval($userId), 'userCity' => $userInfo['city'], 'userDept' => $userInfo['department']];
         }
     }
     $router = $this->getServiceLocator()->get('application')->getMvcEvent()->getRouteMatch();
     if ($router) {
         $action = $router->getParam('action', 'index');
         $controller = $router->getParam('controller', 'index');
         $controllerArray = explode("\\", $controller);
         $controller = strtolower(array_pop($controllerArray));
         if ($controller == 'booking' && $action == 'thank-you') {
             $session_booking = Helper::getSessionContainer('booking');
             if ($session_booking->offsetExists('reservation') && $session_booking->offsetExists('tankyou') && isset($_SERVER['HTTPS'])) {
                 $reservation = $session_booking->reservation;
                 $thankYou = $session_booking->tankyou;
                 $variant = $reservation['bedroom_count'] > 0 ? $reservation['bedroom_count'] . ' ' . $this->getTextline(1446) : $this->getTextline(1190);
                 $cityName = $this->getServiceLocator()->get('service_textline')->getCityName($reservation['city_id']);
                 $result['page_httpResponseCode'] = "200";
                 $result['transactionAffiliation'] = $thankYou['partner'];
                 $result['transaction_currency'] = "USD";
                 $result['transaction_subtotal_include_tax'] = "no";
                 $result['transactionId'] = $thankYou['res_number'];
                 $result['transactionTotal'] = $thankYou['totalWithoutTax'];
                 $result['transactionProducts'] = ['sku' => $reservation['prod_id'], 'name' => $reservation['prod_name'], 'category' => $cityName, 'variant' => $variant, 'price' => $thankYou['totalWithoutTax'], 'quantity' => "1"];
                 $result['ticketID'] = $thankYou['res_number'];
                 $result['PartnerID'] = $data['partner_id'];
             }
         } elseif ($controller == 'key' && $action == 'index' || $controller == 'booking' && $action == 'update-cc-details' || $controller == 'review' && $action == 'index' || $controller == 'chargeauthorization' && $action == 'index') {
             $result['ticketID'] = $data['res_number'];
             $result['PartnerID'] = $data['partner_id'];
         }
     }
     return '<script>dataLayer = [' . json_encode($result) . '];</script>';
 }
 public function downloadCsvAction()
 {
     /**
      * @var ExpenseTicket $expenseService
      */
     $expenseService = $this->getServiceLocator()->get('service_finance_expense_expense_ticket');
     try {
         $data = $expenseService->getCsvArrayForDownload($this->params()->fromQuery());
     } catch (\Exception $ex) {
         $flash = Helper::getSessionContainer('use_zf2');
         $flash->flash = ['error' => $ex->getMessage()];
         return $this->redirect()->toRoute('finance/purchase-order');
     }
     $response = $this->getResponse();
     $headers = $response->getHeaders();
     $filename = 'Purchase Order Items ' . date('Y-m-d') . '.csv';
     $utilityCsvGenerator = new CsvGenerator();
     $utilityCsvGenerator->setDownloadHeaders($headers, $filename);
     $csv = $utilityCsvGenerator->generateCsv($data);
     $response->setContent($csv);
     return $response;
 }
Exemple #4
0
 /**
  * @return \Zend\Http\Response|ViewModel
  */
 public function thankYouAction()
 {
     try {
         $reservationSession = Helper::getSessionContainer('booking');
         if (!$reservationSession->offsetExists('reservation') || !$reservationSession->offsetExists('tankyou') || !isset($_SERVER['HTTPS'])) {
             return $this->redirect()->toRoute('home');
         }
         /**
          * @var \DDD\Service\Website\Booking $bookingService
          */
         $bookingService = $this->getServiceLocator()->get('service_website_booking');
         $paymentDetails = $bookingService->changePaymentDetailsByGuestCurrency($reservationSession->tankyou['reservation_id']);
         $reservationSession->reservation['payments'] = $paymentDetails;
         $this->layout()->userTrackingInfo = ['partner_id' => $reservationSession->tankyou['partner_id']];
         return new ViewModel(['thankYouPageData' => $reservationSession->tankyou, 'reservation' => $reservationSession->reservation]);
     } catch (\Exception $e) {
         return $this->redirect()->toRoute('home');
     }
 }
 public function saveItemAction()
 {
     /**
      * @var ExpenseTicket $expenseService
      */
     $expenseService = $this->getServiceLocator()->get('service_finance_expense_expense_ticket');
     $request = $this->getRequest();
     $id = $this->params()->fromRoute('id');
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     if ($request->isPost() && $request->isXmlHttpRequest()) {
         try {
             if ($expenseService->saveItem($request->getPost()->data, $request->getFiles(), $extra)) {
                 $result = ['status' => 'success'];
                 if ($extra['poId']) {
                     $message = TextConstants::SUCCESS_UPDATE;
                     $result['redirect-url'] = $this->url()->fromRoute('finance/purchase-order/edit', ['id' => $extra['poId']]);
                 } else {
                     $message = $id ? TextConstants::SUCCESS_UPDATE : TextConstants::SUCCESS_ADD;
                     $result['redirect-url'] = $this->url()->fromRoute('finance/item/edit', ['id' => $extra['itemId']]);
                 }
                 $result['msg'] = $message;
                 $flash = Helper::getSessionContainer('use_zf2');
                 $flash->flash = ['success' => $message];
             }
         } catch (\Exception $ex) {
             $result['msg'] = $ex->getMessage();
             // do nothing
         }
     }
     return new JsonModel($result);
 }
Exemple #6
0
 public function ajaxDownloadOfficeCostsCsvAction()
 {
     try {
         /**
          * @var \DDD\Dao\Finance\Expense\ExpenseCost $expenseCostDao
          */
         $expenseCostDao = $this->getServiceLocator()->get('dao_finance_expense_expense_cost');
         $officeId = $this->params()->fromRoute('id');
         $filter = $this->params()->fromQuery('filter');
         $officeCostsFiltered = $expenseCostDao->getOfficeCosts($officeId, ['sSearch' => $filter, 'iSortCol_0' => 2, 'sSortDir_0' => 'desc']);
         $costArray = [];
         foreach ($officeCostsFiltered as $cost) {
             $costArray[] = ["ID" => $cost['id'], "Category" => $cost['category'], "Date" => date(Constants::GLOBAL_DATE_FORMAT, strtotime($cost['date'])), "Currency" => $cost['currency_code'], "Amount" => $cost['amount'], "Purpose" => $cost['purpose']];
         }
         if (!empty($costArray)) {
             $response = $this->getResponse();
             $headers = $response->getHeaders();
             $utilityCsvGenerator = new CsvGenerator();
             $filename = 'costs_office_' . $officeId . '_' . str_replace(' ', '_', date('Y-m-d')) . '.csv';
             $utilityCsvGenerator->setDownloadHeaders($headers, $filename);
             $csv = $utilityCsvGenerator->generateCsv($costArray);
             $response->setContent($csv);
             return $response;
         } else {
             $flash_session = Helper::getSessionContainer('use_zf2');
             $flash_session->flash = ['notice' => 'There are empty data, nothing to download.'];
             $url = $this->getRequest()->getHeader('Referer')->getUri();
             $this->redirect()->toUrl($url);
         }
     } catch (\Exception $e) {
         $this->gr2logException($e, 'Cannot Download Office Costs Csv');
     }
     return $this->redirect()->toUrl('/');
 }
Exemple #7
0
 public static function getUserCountry()
 {
     $sessionNamespase = Helper::getSessionContainer('visitor');
     $country_name = $sessionNamespase->country_name;
     $country_id = $sessionNamespase->country_id;
     $country_iso = $sessionNamespase->country_iso;
     return ['country_name' => $country_name, 'country_id' => $country_id, 'country_iso' => $country_iso];
 }
Exemple #8
0
 public function onViewHelper(MvcEvent $e)
 {
     /**
      * @var ViewModel|\ArrayObject $viewModel
      */
     $viewModel = $e->getViewModel();
     $base_url = Constants::BASE_PATH_VIEW;
     $viewModel->basePathView = $base_url;
     $viewModel->globalVersion = Constants::VERSION;
     $viewModel->globalImgDomainName = DomainConstants::IMG_DOMAIN_NAME;
     $viewModel->flashMessenger = Helper::getSessionContainer('use_zf2')->flash;
     $home_url = '/home';
     $session_home_url = Helper::getSessionContainer('default_home_url');
     if (isset($session_home_url->home_url)) {
         $home_url = $session_home_url->home_url;
     }
     $viewModel->default_home_url = $base_url . $home_url;
 }
Exemple #9
0
 /**
  * @param array $userAndPayData
  * @return array
  */
 public function bookingProcess($userAndPayData)
 {
     /**
      * @var BookingTicket $bookingTicketService
      * @var ChannelManager $channelManagerService
      * @var PenaltyCalculation $penaltyService
      * @var ApartmentGroup $apartmentGroupService
      * @var \DDD\Service\Finance\Customer $customerFinanceService
      * @var Logger $logger
      * @var \DDD\Service\Reservation\Main $reservationService
      * @var \DDD\Service\Partners $partnerService
      * @var \DDD\Service\Queue\InventorySynchronizationQueue $syncService
      */
     $bookingTicketService = $this->getServiceLocator()->get('service_booking_booking_ticket');
     $channelManagerService = $this->getServiceLocator()->get('service_channel_manager');
     $apartmentGroupService = $this->getServiceLocator()->get('service_apartment_group');
     $reservationService = $this->getServiceLocator()->get('service_reservation_main');
     $partnerService = $this->getServiceLocator()->get('service_partners');
     $syncService = $this->getServiceLocator()->get('service_queue_inventory_synchronization_queue');
     $session_booking = Helper::getSessionContainer('booking');
     if (empty($userAndPayData) || !$session_booking->offsetExists('reservation')) {
         return ['status' => 'error'];
     }
     $reservationData = $session_booking->reservation;
     //bookingProcess
     $data = $tankYou = [];
     $data['apartment_id_assigned'] = $reservationData['prod_id'];
     $data['apartment_id_origin'] = $reservationData['prod_id'];
     $data['room_id'] = $reservationData['room_id'];
     $data['acc_name'] = $reservationData['prod_name'];
     $data['acc_country_id'] = $reservationData['country_id'];
     $data['acc_province_id'] = $reservationData['province_id'];
     $data['acc_city_id'] = $reservationData['city_id'];
     $data['acc_province_name'] = $reservationData['province_name'];
     $data['acc_city_name'] = $reservationData['city_name'];
     $data['acc_address'] = $reservationData['address'];
     $data['building_name'] = $apartmentGroupService->getBuildingName($reservationData['prod_id']);
     $data['date_from'] = $reservationData['date_from'];
     $data['date_to'] = $reservationData['date_to'];
     // Currency Rate
     /** @var \DDD\Service\Currency\Currency $currencyService */
     $currencyService = $this->getServiceLocator()->get('service_currency_currency');
     $data['currency_rate'] = $currencyService->getCurrencyConversionRate($this->getCurrencySite(), $reservationData['code']);
     $data['currency_rate_usd'] = $currencyService->getCurrencyConversionRate('USD', $reservationData['code']);
     $data['booker_price'] = $reservationData['amount_price'];
     $data['guest_currency_code'] = $this->getCurrencySite();
     $data['occupancy'] = $reservationData['guest'];
     $resNumber = $tankYou['res_number'] = $bookingTicketService->generateResNumber();
     $data['res_number'] = $resNumber;
     $data['timestamp'] = date('Y-m-d H:i:s');
     $data['apartment_currency_code'] = $reservationData['code'];
     $data['ki_page_status'] = BookingTicket::NOT_SEND_KI_PAGE_STATUS;
     $data['ki_page_hash'] = $bookingTicketService->generatePageHash($data['res_number'], $data['timestamp']);
     $data['review_page_hash'] = $bookingTicketService->generatePageHash($data['res_number'], $data['apartment_id_origin']);
     $data['remarks'] = isset($userAndPayData['remarks']) ? $userAndPayData['remarks'] : '';
     if (isset($reservationData['arrival_time']) && !empty($reservationData['arrival_time'])) {
         $data['guest_arrival_time'] = $reservationData['arrival_time'];
     }
     // Affiliate Data
     $webSiteAff = WebSite::WEB_SITE_PARTNER;
     $visitor = new Container('visitor');
     if (isset($userAndPayData['aff-id']) && (int) $userAndPayData['aff-id'] > 0 && $userAndPayData['aff-id'] != WebSite::WEB_SITE_PARTNER && Helper::isBackofficeUser()) {
         $webSiteAff = $userAndPayData['aff-id'];
     } elseif (!is_null($visitor->partnerId) && (int) $visitor->partnerId) {
         $webSiteAff = (int) $visitor->partnerId;
     }
     $partnerData = $partnerService->getPartnerDataForReservation($webSiteAff, $reservationData['prod_id'], true);
     $data['partner_ref'] = isset($userAndPayData['aff-ref']) ? $userAndPayData['aff-ref'] : '';
     $data['partner_id'] = $webSiteAff;
     $data['partner_name'] = $partnerData->getPartnerName();
     $data['partner_commission'] = $partnerData->getCommission();
     $data['model'] = $partnerData->getBusinessModel();
     // Is backoffice user
     if (Helper::isBackofficeUser()) {
         if (isset($userAndPayData['not_send_mail']) && $userAndPayData['not_send_mail'] > 0) {
             $otherInfo['no_send_guest_mail'] = true;
         }
     }
     // check apartel
     if (isset($userAndPayData['apartel']) && $userAndPayData['apartel'] > 0) {
         /** @var $apartelGeneralDao \DDD\Dao\Apartel\General */
         $apartelGeneralDao = $this->getServiceLocator()->get('dao_apartel_general');
         if ($apartelGeneralDao->checkApartmentFromThisApartel($userAndPayData['apartel'], $reservationData['prod_id'])) {
             $data['apartel_id'] = $userAndPayData['apartel'];
         }
     }
     $userAndPayData['phone'] = $this->clearPhone($userAndPayData['phone']);
     // Personal Data
     $data['guest_first_name'] = $tankYou['first_name'] = $userAndPayData['first-name'];
     $data['guest_last_name'] = $tankYou['last_name'] = $userAndPayData['last-name'];
     $data['guest_email'] = $tankYou['email'] = $userAndPayData['email'];
     $data['guest_address'] = $tankYou['address'] = $userAndPayData['address'];
     $data['guest_city_name'] = $tankYou['city'] = $userAndPayData['city'];
     $data['guest_country_id'] = $tankYou['country'] = $userAndPayData['country'];
     $data['guest_language_iso'] = 'en';
     $data['guest_zip_code'] = $userAndPayData['zip'];
     $data['guest_phone'] = $tankYou['phone'] = $userAndPayData['phone'] ? $userAndPayData['phone'] : '';
     $tankYou['partner'] = $partnerData->getPartnerName();
     $tankYou['partner_id'] = $webSiteAff;
     $tankYou['totalTax'] = isset($tankYou['totalTax']) ? number_format($tankYou['totalTax'], 2, '.', '') : '';
     $tankYou['totalWithoutTax'] = number_format($reservationData['acc_price'] * $data['currency_rate_usd'], 2, '.', '');
     /** @var \DDD\Dao\Booking\Booking $bookingDao */
     $bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
     $bookingDao->setEntity(new \ArrayObject());
     $customerData['email'] = $data['guest_email'];
     // Credit Card Data
     $ccNotProvided = Helper::isBackofficeUser() && isset($userAndPayData['noCreditCard']);
     if ($ccNotProvided) {
         $customerData['cc_provided'] = false;
     } else {
         $customerData['cc_provided'] = true;
         $customerData['number'] = $cr_number = $userAndPayData['number'];
         $customerData['holder'] = $userAndPayData['holder'];
         $customerData['month'] = $userAndPayData['month'];
         $customerData['year'] = $userAndPayData['year'];
         $customerData['cvc'] = isset($userAndPayData['cvc']) ? $userAndPayData['cvc'] : false;
     }
     if (Helper::isBackofficeUser()) {
         $customerData['source'] = Card::CC_SOURCE_WEBSITE_RESERVATION_EMPLOYEE;
     } else {
         $customerData['source'] = Card::CC_SOURCE_WEBSITE_RESERVATION_GUEST;
     }
     try {
         $bookingDao->beginTransaction();
         $newAvailability = 0;
         $otherInfo['cc_provided'] = $customerData['cc_provided'];
         $otherInfo['availability'] = $newAvailability;
         $data['customer_data'] = $customerData;
         $ratesData = $reservationService->getRateDataByRateIdDates($reservationData['rateId'], $reservationData['date_from'], $reservationData['date_to']);
         $otherInfo['ratesData'] = $ratesData;
         $reservationId = $reservationService->registerReservation($data, $otherInfo, true);
         $tankYou['reservation_id'] = $reservationId;
         $session_booking->tankyou = $tankYou;
         // discount for Ginosiks
         $discountValidator = $bookingTicketService->validateAndCheckDiscountData(['email' => $data['guest_email'], 'aff_id' => $data['partner_id']]);
         if ($discountValidator['valid'] && ceil($discountValidator['discount_value']) && $discountValidator['aff_id'] == BookingTicket::SECRET_DISCOUNT_AFFILIATE_ID) {
             $discountSave['is_refundable'] = ApartmentRate::APARTMENT_RATE_NON_REFUNDABLE;
             $discountSave['penalty'] = ApartmentRate::PENALTY_TYPE_PERCENT;
             $discountSave['penalty_val'] = 100;
             $discountSave['funds_confirmed'] = BookingTicket::CC_STATUS_VALID;
             $bookingDao->save($discountSave, ['id' => $reservationId]);
             $logger = $this->getServiceLocator()->get('ActionLogger');
             $logger->save(Logger::MODULE_BOOKING, $reservationId, Logger::ACTION_BOOKING_CC_STATUS, BookingTicket::CC_STATUS_VALID + 1);
         }
         // Push into synchronization queue
         $syncService->push($reservationData['prod_id'], $reservationData['date_from'], $reservationData['date_to']);
         $bookingDao->commitTransaction();
         return ['status' => 'success'];
     } catch (\Exception $e) {
         $this->gr2logException($e, 'Cannot booking from Website', ['apartment_id' => $data['apartment_id_origin'], 'room_id' => $data['room_id'], 'rate_id' => isset($data['rate_id']) ? $data['rate_id'] : '', 'date_from' => $data['date_from'], 'date_to' => $data['date_to'], 'partner_id' => $data['partner_id'], 'partner_reference' => $data['partner_ref']]);
         $bookingDao->rollbackTransaction();
         return ['status' => 'error'];
     }
 }
 public function getUrlForRedirect()
 {
     $last_visit = Helper::getSessionContainer('last_visit');
     $last_visit_url = $last_visit->last_visit_url;
     $homeUrl = $this->getHomeUrl();
     $homeNamespase = Helper::getSessionContainer('default_home_url');
     $homeNamespase->home_url = $homeUrl;
     if (!$last_visit_url) {
         $last_visit_url = $homeUrl;
     }
     return $last_visit_url;
 }
 public function loginAction()
 {
     /**
      * @var BackofficeAuthenticationService $backofficeAuthenticationService
      */
     $this->layout('layout/login');
     $session = new Container('authFailed');
     $router = $this->getEvent()->getRouter();
     $request = $this->getRequest();
     $lastRequestUrl = $request->getQuery()->request_url;
     $loginUrl = $router->assemble([], ['name' => 'backoffice_user_login']);
     if ($session->authFailed) {
         $form = new LoginForm();
         $form->setInputFilter(new LoginFilter());
         $error = $session->authFailed === self::CONNECTION_TIMEDOUT ? 'Connection Timed Out.' : 'Authentication failed.';
         $session->getManager()->getStorage()->clear('authFailed');
         return new ViewModel(['form' => $form, 'error' => $error, 'backofficeVersion' => Constants::APP_VERSION]);
     }
     $serviceLocator = $this->getServiceLocator();
     $backofficeAuthenticationService = $serviceLocator->get('library_backoffice_auth');
     if ($backofficeAuthenticationService->hasIdentity()) {
         $redirectHome = $backofficeAuthenticationService->getHomeUrl();
         if (!empty($lastRequestUrl) && $lastRequestUrl != $loginUrl) {
             $redirectUrl = $lastRequestUrl;
         } else {
             $redirectUrl = $redirectHome;
         }
         return $this->redirect()->toUrl($redirectUrl);
     }
     $failure = '';
     $request = $this->getRequest();
     $form = new LoginForm();
     if ($request->isPost()) {
         $postData = $request->getPost();
         $form->setInputFilter(new LoginFilter());
         $form->setData($postData);
         if ($form->isValid()) {
             $formData = $form->getData();
             $result = $backofficeAuthenticationService->authenticate(null, $formData['identity'], $formData['credential']);
             if ($result->isValid()) {
                 $auth = $this->getServiceLocator()->get('library_backoffice_auth');
                 $userIdentity = $auth->getIdentity();
                 // update user last login date and time
                 $userManagerService = $serviceLocator->get('service_user');
                 $userManagerService->updateLastLogin($userIdentity->id);
                 $appConfig = $serviceLocator->get('config');
                 $backofficeAuthenticationService->setAsBackofficeUser($appConfig['session']['config']['options']['cookie_domain']);
                 $backofficeAuthenticationService->setRememberMyEmail($formData['identity'], $appConfig['session']['config']['options']['cookie_domain']);
                 $redirect = $backofficeAuthenticationService->getUrlForRedirect();
                 if (!empty($lastRequestUrl) && $lastRequestUrl != $loginUrl) {
                     $redirect = $lastRequestUrl;
                 } else {
                     $redirect = $redirect;
                 }
                 return $this->redirect()->toUrl($redirect);
             } else {
                 $failure = 'Authentication failed.';
             }
         } else {
             $failure = 'Authentication failed.';
         }
     }
     $session1 = Helper::getSessionContainer('logout');
     if ($session1->offsetExists('loggedOut') && $session1->offsetGet('loggedOut')) {
         $session1->getManager()->getStorage()->clear();
     }
     return new ViewModel(['form' => $form, 'error' => $failure, 'lastRequestUrl' => $lastRequestUrl, 'backofficeVersion' => Constants::APP_VERSION]);
 }
Exemple #12
0
 public function downloadCsvAction()
 {
     $requestParams = $this->params()->fromQuery();
     /* @var $documentService \DDD\Service\Document\Document */
     $documentService = $this->getServiceLocator()->get('service_document_document');
     $documents = $documentService->getDocumentSearchResults($requestParams);
     $result = [];
     if (count($documents) > 0) {
         foreach ($documents as $document) {
             $documentDescriptionCleaup = str_replace('&nbsp;', ' ', strip_tags($document->getDescription(), '<br>'));
             $result[] = ['Property' => $document->getEntityName(), 'Security Level' => $document->getTeamName(), 'Document Type' => $document->getTypeName(), 'Supplier' => $document->getSupplierName(), 'Account Number' => $document->getAccountNumber(), 'Account Holder' => $document->getAccountHolder(), 'Description' => $documentDescriptionCleaup, 'Created Date' => $document->getCreatedDate(), 'Has Attachment' => empty($document->getAttachment()) ? '-' : '+', 'Has url' => empty($document->getUrl()) ? '-' : '+', 'Valid From' => $document->getValidFrom(), 'Valid To' => $document->getValidTo(), 'Legal Entity' => $document->getLegalEntityName(), 'Signatory' => $document->getSignatoryFullName()];
         }
         $response = $this->getResponse();
         $headers = $response->getHeaders();
         $filename = 'Apartment Documents ' . date('Y-m-d') . '.csv';
         $utilityCsvGenerator = new CsvGenerator();
         $utilityCsvGenerator->setDownloadHeaders($headers, $filename);
         $csv = $utilityCsvGenerator->generateCsv($result);
         $response->setContent($csv);
         return $response;
     } else {
         $flash_session = Helper::getSessionContainer('use_zf2');
         $flash_session->flash = ['notice' => 'The search results were empty, nothing to download.'];
         $url = $this->getRequest()->getHeader('Referer')->getUri();
         $this->redirect()->toUrl($url);
     }
 }