From d4074aaf92ede687b16cc78b5cad249c8d8a39ea Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 6 Feb 2023 14:43:20 +0530 Subject: [PATCH] Allow admin to upload check-in documents --- .../default/sass/controllers/_order.sass | 8 + .../controllers/orders/_booking_documents.tpl | 46 ++++ .../template/controllers/orders/_errors.tpl | 33 +++ .../controllers/orders/helpers/view/view.tpl | 10 +- .../orders/modal_booking_documents.tpl | 51 ++++ controllers/admin/AdminOrdersController.php | 118 +++++++++ js/admin/orders.js | 151 ++++++++++++ .../classes/HotelBookingDocument.php | 223 ++++++++++++++++++ .../classes/HotelReservationSystemDb.php | 11 + .../admin/AdminBookingDocumentController.php | 60 +++++ modules/hotelreservationsystem/define.php | 1 + .../documents/.htaccess | 1 + .../documents/booking_guests/index.php | 29 +++ .../documents/index.php | 29 +++ .../hotelreservationsystem.php | 1 + 15 files changed, 768 insertions(+), 4 deletions(-) create mode 100644 admin/themes/default/template/controllers/orders/_booking_documents.tpl create mode 100644 admin/themes/default/template/controllers/orders/_errors.tpl create mode 100644 admin/themes/default/template/controllers/orders/modal_booking_documents.tpl create mode 100644 modules/hotelreservationsystem/classes/HotelBookingDocument.php create mode 100644 modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php create mode 100644 modules/hotelreservationsystem/documents/.htaccess create mode 100644 modules/hotelreservationsystem/documents/booking_guests/index.php create mode 100644 modules/hotelreservationsystem/documents/index.php diff --git a/admin/themes/default/sass/controllers/_order.sass b/admin/themes/default/sass/controllers/_order.sass index a516c46c3..40cefd140 100644 --- a/admin/themes/default/sass/controllers/_order.sass +++ b/admin/themes/default/sass/controllers/_order.sass @@ -3,3 +3,11 @@ #customization_list border: 0px + +#modal-booking-documents + .booking-documents + table + tbody + img + max-height: 55px + max-width: 55px diff --git a/admin/themes/default/template/controllers/orders/_booking_documents.tpl b/admin/themes/default/template/controllers/orders/_booking_documents.tpl new file mode 100644 index 000000000..0305d0532 --- /dev/null +++ b/admin/themes/default/template/controllers/orders/_booking_documents.tpl @@ -0,0 +1,46 @@ +{** + * 2010-2023 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this module to newer + * versions in the future. If you wish to customize this module for your + * needs please refer to CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2023 Webkul IN + * @license LICENSE.txt + *} + +{if is_array($booking_documents) && count($booking_documents)} + {foreach from=$booking_documents item=booking_document} + + {$booking_document.id_htl_booking_document} + + {if $booking_document.file_type == HotelBookingDocument::FILE_TYPE_IMAGE} + + + + {elseif $booking_document.file_type == HotelBookingDocument::FILE_TYPE_PDF} + + {l s='Download PDF'} + + {/if} + + + + + + + + {/foreach} +{else} + + {l s='No documents.'} + +{/if} diff --git a/admin/themes/default/template/controllers/orders/_errors.tpl b/admin/themes/default/template/controllers/orders/_errors.tpl new file mode 100644 index 000000000..9aaa10cae --- /dev/null +++ b/admin/themes/default/template/controllers/orders/_errors.tpl @@ -0,0 +1,33 @@ +{** + * 2010-2023 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this module to newer + * versions in the future. If you wish to customize this module for your + * needs please refer to CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2023 Webkul IN + * @license LICENSE.txt + *} + +{if isset($errors)} +

+ {if count($errors) > 1} + {l s='There are %d errors:' sprintf=[count($errors)]} + {else} + {l s='There is 1 error:'} + {/if} +

+
    + {foreach from=$errors item=error} +
  1. {$error}
  2. + {/foreach} +
+{/if} diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index b84467ddd..7fe7d33b7 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -275,8 +275,8 @@ {l s='Room No.'} {l s='Hotel Name'} - {l s='Date From'} - {l s='Date To'} + {l s='Duration'} + {l s='Documents'} {l s='Order Status'} {if isset($htl_booking_order_data) && $htl_booking_order_data} @@ -291,10 +291,12 @@ - {dateFormat date=$data['date_from']} + {dateFormat date=$data['date_from']} - {dateFormat date=$data['date_to']} - {dateFormat date=$data['date_to']} + + {l s='Documents'} +
diff --git a/admin/themes/default/template/controllers/orders/modal_booking_documents.tpl b/admin/themes/default/template/controllers/orders/modal_booking_documents.tpl new file mode 100644 index 000000000..af69758ae --- /dev/null +++ b/admin/themes/default/template/controllers/orders/modal_booking_documents.tpl @@ -0,0 +1,51 @@ +{** + * 2010-2023 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this module to newer + * versions in the future. If you wish to customize this module for your + * needs please refer to CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2023 Webkul IN + * @license LICENSE.txt + *} + +
+ +{addJsDefL name=txt_booking_document_upload_success}{l s='Document uploaded successfully.' js=1}{/addJsDefL} +{addJsDefL name=txt_booking_document_delete_success}{l s='Document deleted successfully.' js=1}{/addJsDefL} diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index e261e9ae3..f4d7f4347 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -327,6 +327,12 @@ class AdminOrdersControllerCore extends AdminController return $res; } + public function initModal() + { + parent::initModal(); + $this->modals[] = $this->getModalBookingDocuments(); + } + public function setMedia() { parent::setMedia(); @@ -1637,6 +1643,99 @@ class AdminOrdersControllerCore extends AdminController return parent::renderView(); } + public function getModalBookingDocuments() + { + $modalContent = $this->context->smarty->fetch('controllers/orders/modal_booking_documents.tpl'); + + // set modal details + $modal = array( + 'modal_id' => 'modal-booking-documents', + 'modal_class' => 'modal-md', + 'modal_title' => $this->l('Documents'), + 'modal_content' => $modalContent, + 'modal_actions' => array(), // required to show Close button + ); + + return $modal; + } + + public function ajaxProcessGetBookingDocuments() + { + $response = array('status' => false); + + $idHtlBooking = (int) Tools::getValue('id_htl_booking'); + $objHotelBookingDetail = new HotelBookingDetail($idHtlBooking); + if (Validate::isLoadedObject($objHotelBookingDetail)) { + $response['html'] = $this->getRenderedBookingDocuments($idHtlBooking); + $response['status'] = true; + } + + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessUploadBookingDocument() + { + $response = array('status' => false); + + $idHtlBooking = (int) Tools::getValue('id_htl_booking'); + + // validations + $objHotelBookingDetail = new HotelBookingDetail($idHtlBooking); + if (!Validate::isLoadedObject($objHotelBookingDetail)) { + $this->errors[] = $this->l('Booking detail not found.'); + } + + $objHotelBookingDocument = new HotelBookingDocument(); + $objHotelBookingDocument->setFileInfoForUploadedDocument('booking_document'); + if (!count($objHotelBookingDocument->fileInfo)) { + $this->errors[] = $this->l('Please upload a document.'); + } elseif ($objHotelBookingDocument->fileInfo['size'] > Tools::getMaxUploadSize()) { + $this->errors[] = $this->l('Uploaded file size is too large.'); + } + + if (!count($this->errors)) { + $objHotelBookingDocument = new HotelBookingDocument(); + $objHotelBookingDocument->setFileInfoForUploadedDocument('booking_document'); + $objHotelBookingDocument->id_htl_booking = $idHtlBooking; + $objHotelBookingDocument->setFileType(); + if ($objHotelBookingDocument->save()) { + $objHotelBookingDocument->saveDocumentFile(); + + $response['html'] = $this->getRenderedBookingDocuments($idHtlBooking); + $response['status'] = true; + } else { + $this->errors[] = $this->l('Document upload failed.'); + } + } else { + $this->context->smarty->assign(array( + 'errors' => $this->errors, + )); + + $response['errors'] = $this->context->smarty->fetch('controllers/orders/_errors.tpl'); + $response['status'] = false; + } + + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessDeleteBookingDocument() + { + $response = array('status' => false); + + $idHtlBookingDocument = (int) Tools::getValue('id_htl_booking_document'); + + $objHotelBookingDocument = new HotelBookingDocument($idHtlBookingDocument); + if (Validate::isLoadedObject($objHotelBookingDocument)) { + $idHtlBooking = $objHotelBookingDocument->id_htl_booking; + if ($objHotelBookingDocument->delete()) { + $response['html'] = $this->getRenderedBookingDocuments($idHtlBooking); + $response['status'] = true; + } + } + + $this->ajaxDie(json_encode($response)); + } + public function ajaxProcessUpdateGuestDetails() { $response = array( @@ -1680,6 +1779,25 @@ class AdminOrdersControllerCore extends AdminController $this->ajaxDie(json_encode($response)); } + private function getRenderedBookingDocuments($idHtlBooking) + { + $bookingDocuments = HotelBookingDocument::getDocumentsByIdHtlBooking($idHtlBooking); + + foreach($bookingDocuments as &$bookingDocument) { + if ($bookingDocument['file_type'] == HotelBookingDocument::FILE_TYPE_IMAGE) { + $bookingDocument['file_link'] = $this->context->link->getAdminLink('AdminBookingDocument'). + '&action=getDocument&id_document='.(int) $bookingDocument['id_htl_booking_document']; + } + } + + $this->context->smarty->assign(array( + 'link' => $this->context->link, + 'booking_documents' => $bookingDocuments, + )); + + return $this->context->smarty->fetch('controllers/orders/_booking_documents.tpl'); + } + public function ajaxProcessSearchProducts() { Context::getContext()->customer = new Customer((int)Tools::getValue('id_customer')); diff --git a/js/admin/orders.js b/js/admin/orders.js index 0c8584b0f..284bf8bf6 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1308,3 +1308,154 @@ function checkTotalRefundProductQuantity(it) if (order_discount_price) actualizeTotalRefundVoucher(); } + +$(document).on('click', '#modal-booking-documents .booking-documents .btn-add-new-document', function() { + BookingDocumentsModal.addNew(); + BookingDocumentsFile.addNew(); +}); + +$(document).on('change', '.input-booking-document', function(e) { + e.preventDefault(); + if (!this.files.length) { + $(this).remove(); + return; + } + + BookingDocumentsFile.updatePreview(); + BookingDocumentsModal.uploadDocument(); +}); + +$(document).on('click', '#modal-booking-documents .booking-documents .btn-delete-document', function(e) { + BookingDocumentsModal.deleteDocument(this); +}); + +const BookingDocumentsModal = { + init: function(idHtlBooking) { + BookingDocumentsFile.noDocumentHtml = ''+'a'+''; + + $('#modal-booking-documents .booking-documents').find('[name="id_hotel_booking"]').val(idHtlBooking); + BookingDocumentsFile.init(); + BookingDocumentsModal.reset(); + BookingDocumentsModal.show(idHtlBooking); + }, + reset: function() { + $('#modal-booking-documents .booking-documents table tbody').html(''); + }, + show: function(idHtlBooking) { + $('#modal-booking-documents').modal('show'); + $('#modal-booking-documents #booking-document-id-htl-booking').attr('value', idHtlBooking); + let data = { + ajax: true, + action: 'getBookingDocuments', + id_htl_booking: parseInt(idHtlBooking), + }; + + $.ajax({ + url: admin_order_tab_link, + data: data, + type: 'POST', + dataType: 'JSON', + success: function(response) { + if (response.status) { + BookingDocumentsModal.setBodyHtml(response.html); + } + }, + }); + }, + setBodyHtml: function(html) { + $('#modal-booking-documents .booking-documents table tbody').html(html); + }, + close: function() { + $('#modal-booking-documents').modal('hide'); + }, + addNew: function() { + BookingDocumentsModal.hideErrors(); + BookingDocumentsModal.disableAddNewButton(); + }, + beforeSubmit: function() { + BookingDocumentsModal.hideErrors(); + BookingDocumentsModal.disableAddNewButton(); + }, + uploadDocument: function() { + BookingDocumentsModal.beforeSubmit(); + let formData = new FormData($('#modal-booking-documents form.booking-documents').get(0)); + formData.append('ajax', true); + formData.append('action', 'uploadBookingDocument'); + $.ajax({ + url: admin_order_tab_link, + data: formData, + processData: false, + contentType: false, + type: 'POST', + success: function(response) { + let jsonResponse = JSON.parse(response); + if (jsonResponse.status) { + showSuccessMessage(txt_booking_document_upload_success); + BookingDocumentsModal.reset(); + BookingDocumentsFile.resetPreview(); + BookingDocumentsModal.setBodyHtml(jsonResponse.html); + } else { + BookingDocumentsModal.showErrors(jsonResponse.errors); + } + }, + complete: function() { + BookingDocumentsModal.enableAddNewButton(); + }, + }); + }, + deleteDocument: function($this) { + let idHtlBookingDocument = parseInt($($this).attr('data-id-htl-booking-document')); + let data = { + ajax: true, + action: 'deleteBookingDocument', + id_htl_booking_document: idHtlBookingDocument, + }; + + $.ajax({ + url: admin_order_tab_link, + data: data, + type: 'POST', + dataType: 'JSON', + success: function(response) { + if (response.status) { + BookingDocumentsModal.setBodyHtml(response.html); + showSuccessMessage(txt_booking_document_delete_success); + } + }, + }); + }, + showErrors: function(errors) { + $('#modal-booking-documents .errors-wrap').html(errors); + $('#modal-booking-documents .errors-wrap').show('slow'); + }, + hideErrors: function() { + $('#modal-booking-documents .errors-wrap').hide('slow', function() { + $('#modal-booking-documents .errors-wrap').html(''); + }); + }, + enableAddNewButton: function() { + $('#modal-booking-documents .booking-documents .btn-add-new-document').removeClass('disabled'); + }, + disableAddNewButton: function() { + $('#modal-booking-documents .booking-documents .btn-add-new-document').addClass('disabled'); + }, +} + +const BookingDocumentsFile = { + init: function() { + BookingDocumentsFile.inputHtml = ''; + }, + resetPreview: function() { + $('#modal-booking-documents .booking-documents .add-new-wrap span').html(''); + }, + updatePreview: function() { + BookingDocumentsFile.resetPreview(); + let input = $('#modal-booking-documents .booking-documents').find('.input-file-wrap input'); + let file = $(input).get(0).files[0]; + $('#modal-booking-documents .booking-documents .add-new-wrap span').html(file.name); + }, + addNew: function() { + $('#modal-booking-documents .booking-documents').find('.input-file-wrap').html(BookingDocumentsFile.inputHtml); + $('#modal-booking-documents .booking-documents').find('.input-file-wrap input').click(); + }, +} diff --git a/modules/hotelreservationsystem/classes/HotelBookingDocument.php b/modules/hotelreservationsystem/classes/HotelBookingDocument.php new file mode 100644 index 000000000..26c497994 --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelBookingDocument.php @@ -0,0 +1,223 @@ + 'htl_booking_document', + 'primary' => 'id_htl_booking_document', + 'fields' => array( + 'id_htl_booking' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'file_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'file_name' => array('type' => self::TYPE_STRING, 'validate' => 'isString'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + ), + ); + + public function __construct($id = null) + { + $this->file_name = ''; + parent::__construct($id); + + $this->documentsBaseDir = _PS_MODULE_DIR_.'hotelreservationsystem/documents/booking_guests/'; + $this->sourceIndexFile = $this->documentsBaseDir.'index.php'; + } + + public function save($null_values = false, $auto_date = true) + { + parent::save($null_values, $auto_date); + + $this->documentsBaseDir = _PS_MODULE_DIR_.'hotelreservationsystem/documents/booking_guests/'; + $this->sourceIndexFile = $this->documentsBaseDir.'index.php'; + + if ($this->id) { + $this->setFileName(); + return $this->update(); + } + + return false; + } + + public static function getDocumentsByIdHtlBooking($idHtlBooking) + { + return Db::getInstance()->executeS( + 'SELECT * + FROM `'._DB_PREFIX_.'htl_booking_document` + WHERE `id_htl_booking` = '.(int) $idHtlBooking + ); + } + + public static function getDocumentsByIdOrder($idOrder) + { + return Db::getInstance()->executeS( + 'SELECT hbdo.* + FROM `'._DB_PREFIX_.'htl_booking_document` hbdo + INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbde + ON (hbde.`id` = hbdo.`id_htl_booking`) + WHERE hbde.`id_order` = '.(int) $idOrder + ); + } + + public function setFileInfoForUploadedDocument($fileName) + { + $this->fileInfo = Tools::fileAttachment($fileName, false); + } + + public function saveDocumentFile() + { + if (!$this->id) { + return false; + } + + $this->setDocumentFolder(); + $this->createDocumentFolder(); + + @move_uploaded_file($this->fileInfo['tmp_name'], $this->getDestinationFilePath()); + } + + public function setDocumentFolder() + { + if (!isset($this->documentFolder)) { + $this->documentFolder = $this->documentsBaseDir.Image::getImgFolderStatic($this->id); + } + } + + public function createDocumentFolder() + { + if (!file_exists($this->documentFolder)) { + // Trying both methods for setting access rights + $mkdir = @mkdir($this->documentFolder, self::$accessRights, true); + $chmod = @chmod($this->documentFolder, self::$accessRights); + + // Copy index.php file in the new folder + if (($mkdir || $chmod) + && !file_exists($this->documentFolder.'index.php') + && file_exists($this->sourceIndexFile) + ) { + return @copy($this->sourceIndexFile, $this->documentFolder.'index.php'); + } + } + + return true; + } + + public function getDestinationFilePath() + { + $fileExtension = pathinfo($this->fileInfo['rename'], PATHINFO_EXTENSION); + + return $this->documentFolder.$this->id.'.'.$fileExtension; + } + + public function setFileType() + { + if (ImageManager::isRealImage($this->fileInfo['tmp_name'])) { + $this->file_type = self::FILE_TYPE_IMAGE; + } elseif ($this->fileInfo['mime'] == 'application/pdf') { + $this->file_type = self::FILE_TYPE_PDF; + } else { + $this->file_type = 0; + } + } + + public function setFileName() + { + $fileExtension = pathinfo($this->fileInfo['rename'], PATHINFO_EXTENSION); + $this->file_name = $this->id.'.'.$fileExtension; + } + + public function getContentType() + { + $file = $this->getPhysicalPath(); + + $contentType = 'application/octet-stream'; + if (function_exists('finfo_open')) { + $fileInfo = @finfo_open(FILEINFO_MIME); + $contentType = @finfo_file($fileInfo, $file); + @finfo_close($fileInfo); + } elseif (function_exists('mime_content_type')) { + $contentType = @mime_content_type($file); + } elseif (function_exists('exec')) { + $contentType = trim(@exec('file -b --mime-type '.escapeshellarg($file))); + if (!$contentType) { + $contentType = trim(@exec('file --mime '.escapeshellarg($file))); + } + if (!$contentType) { + $contentType = trim(@exec('file -bi '.escapeshellarg($file))); + } + } + + return $contentType; + } + + public function getContentLength() + { + $file = $this->getPhysicalPath(); + + if (Tools::file_exists_cache($file)) { + return filesize($file); + } + + return 0; + } + + public function getPhysicalPath() + { + $this->setDocumentFolder(); + + return $this->documentFolder.$this->file_name; + } + + public function getDownloadFileName() + { + $objHotelBookingDetail = new HotelBookingDetail($this->id_htl_booking); + $fileExtension = pathinfo($this->file_name, PATHINFO_EXTENSION); + + return self::DOWNLOAD_FILE_PREFIX.$this->id_htl_booking_document.'_'.date('YmdHis').'.'.$fileExtension; + } + + public function deleteDocumentFolder() + { + $this->setDocumentFolder(); + + return Tools::deleteDirectory($this->documentFolder); + } + + public function delete() + { + $this->deleteDocumentFolder(); + + return parent::delete(); + } +} diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 52f6c66f7..11c6ba326 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -180,6 +180,16 @@ class HotelReservationSystemDb PRIMARY KEY (`id`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_document` ( + `id_htl_booking_document` int(11) NOT NULL AUTO_INCREMENT, + `id_htl_booking` int(11) NOT NULL, + `file_type` tinyint(1) NOT NULL DEFAULT '0', + `file_name` varchar(8) NOT NULL DEFAULT '', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_htl_booking_document`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_demands` ( `id_booking_demand` int(11) NOT NULL AUTO_INCREMENT, `id_htl_booking` int(11) NOT NULL, @@ -471,6 +481,7 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_features_lang`, `'._DB_PREFIX_.'htl_cart_booking_data`, `'._DB_PREFIX_.'htl_booking_detail`, + `'._DB_PREFIX_.'htl_booking_document`, `'._DB_PREFIX_.'htl_booking_demands`, `'._DB_PREFIX_.'htl_booking_demands_tax`, `'._DB_PREFIX_.'htl_room_status`, diff --git a/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php b/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php new file mode 100644 index 000000000..ae0b0be47 --- /dev/null +++ b/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php @@ -0,0 +1,60 @@ + &$objHotelBookingDocument)); + + $contentType = $objHotelBookingDocument->getContentType(); + $contentLength = $objHotelBookingDocument->getContentLength(); + $filePath = $objHotelBookingDocument->getPhysicalPath(); + $downloadFileName = $objHotelBookingDocument->getDownloadFileName(); + + if (Tools::file_exists_cache($filePath)) { + if (ob_get_level() && ob_get_length() > 0) { + ob_end_clean(); + } + + header('Content-Transfer-Encoding: binary'); + header('Content-Type: '.$contentType); + header('Content-Length: '.$contentLength); + header('Content-Disposition: attachment; filename="'.$downloadFileName.'"'); + @set_time_limit(0); + readfile($filePath); + } + + exit; + } + + header('HTTP/1.1 404 Not Found'); + header('Status: 404 Not Found'); + } + + public function postProcess() + { + parent::postProcess(); + exit; + } +} diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index 8914bf202..e753332df 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -47,6 +47,7 @@ require_once 'classes/HotelRoomDisableDates.php'; require_once 'classes/HotelBranchRefundRules.php'; require_once 'classes/HotelSettingsLink.php'; +require_once 'classes/HotelBookingDocument.php'; // Web services classes require_once 'classes/WebserviceSpecificManagementQlo.php'; \ No newline at end of file diff --git a/modules/hotelreservationsystem/documents/.htaccess b/modules/hotelreservationsystem/documents/.htaccess new file mode 100644 index 000000000..14249c50b --- /dev/null +++ b/modules/hotelreservationsystem/documents/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/modules/hotelreservationsystem/documents/booking_guests/index.php b/modules/hotelreservationsystem/documents/booking_guests/index.php new file mode 100644 index 000000000..4e62784cb --- /dev/null +++ b/modules/hotelreservationsystem/documents/booking_guests/index.php @@ -0,0 +1,29 @@ +installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', false, false); $this->installTab('AdminRoomTypeGlobalDemand', 'Additional Demand Configuration', false, false); $this->installTab('AdminAssignHotelFeatures', 'Assign Hotel Features', false, false); + $this->installTab('AdminBookingDocument', 'Booking Documents', false, false); return true; }