From d4074aaf92ede687b16cc78b5cad249c8d8a39ea Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 6 Feb 2023 14:43:20 +0530 Subject: [PATCH 01/11] 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 @@ public function initToolbar() return $res; } + public function initModal() + { + parent::initModal(); + $this->modals[] = $this->getModalBookingDocuments(); + } + public function setMedia() { parent::setMedia(); @@ -1637,6 +1643,99 @@ public function renderView() 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 @@ public function ajaxProcessUpdateGuestDetails() $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 @@ public function getModuleSql() 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 @@ public function dropTables() `'._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/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; } From 272c61ea640ce13037ea5ff1115bf27cf5ad80de Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 9 Feb 2023 13:35:47 +0530 Subject: [PATCH 02/11] Document upload flow changes --- .../default/sass/controllers/_order.sass | 2 +- .../controllers/orders/_booking_documents.tpl | 26 ++--- .../controllers/orders/helpers/view/view.tpl | 5 +- .../orders/modal_booking_documents.tpl | 57 +++++++++-- controllers/admin/AdminOrdersController.php | 23 +++-- js/admin/orders.js | 94 +++++++++++++------ .../classes/HotelBookingDocument.php | 13 ++- .../classes/HotelReservationSystemDb.php | 2 +- .../admin/AdminBookingDocumentController.php | 3 +- 9 files changed, 159 insertions(+), 66 deletions(-) diff --git a/admin/themes/default/sass/controllers/_order.sass b/admin/themes/default/sass/controllers/_order.sass index 40cefd140..10fdd0f6b 100644 --- a/admin/themes/default/sass/controllers/_order.sass +++ b/admin/themes/default/sass/controllers/_order.sass @@ -5,7 +5,7 @@ border: 0px #modal-booking-documents - .booking-documents + .documents-list table tbody img diff --git a/admin/themes/default/template/controllers/orders/_booking_documents.tpl b/admin/themes/default/template/controllers/orders/_booking_documents.tpl index 0305d0532..676cd44e6 100644 --- a/admin/themes/default/template/controllers/orders/_booking_documents.tpl +++ b/admin/themes/default/template/controllers/orders/_booking_documents.tpl @@ -20,20 +20,22 @@ {if is_array($booking_documents) && count($booking_documents)} {foreach from=$booking_documents item=booking_document} - {$booking_document.id_htl_booking_document} + {$booking_document.title} - {if $booking_document.file_type == HotelBookingDocument::FILE_TYPE_IMAGE} - - - - {elseif $booking_document.file_type == HotelBookingDocument::FILE_TYPE_PDF} - - {l s='Download PDF'} - - {/if} + + {if $booking_document.file_type == HotelBookingDocument::FILE_TYPE_IMAGE} + + {elseif $booking_document.file_type == HotelBookingDocument::FILE_TYPE_PDF} + + {/if} + + {dateFormat date=$booking_document.date_add full=1} - + + + + @@ -41,6 +43,6 @@ {/foreach} {else} - {l s='No documents.'} + {l s='No documents.'} {/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 7fe7d33b7..16e0859ed 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -294,8 +294,9 @@ {dateFormat date=$data['date_from']} - {dateFormat date=$data['date_to']} - - {l s='Documents'} + + + {l s='Documents'} {$data.num_checkin_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 index af69758ae..95866e83d 100644 --- a/admin/themes/default/template/controllers/orders/modal_booking_documents.tpl +++ b/admin/themes/default/template/controllers/orders/modal_booking_documents.tpl @@ -21,28 +21,67 @@
-
- +
- - + + +
{l s='ID'}{l s='Download/Preview'}{l s='Title'}{l s='Preview'}{l s='Upload Date'} {l s='Actions'}
- +
+
-
- + +
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index f4d7f4347..11a728cad 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1546,6 +1546,9 @@ public function renderView() // get booking information by order $bookingOrderInfo = $objBookingDetail->getBookingDataByOrderId($order->id); + foreach ($bookingOrderInfo as &$bookingOrderRoomInfo) { + $bookingOrderRoomInfo['num_checkin_documents'] = HotelBookingDocument::getCountByIdHtlBooking($bookingOrderRoomInfo['id']); + } // hotel booking statuses $htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus(); @@ -1678,6 +1681,7 @@ public function ajaxProcessUploadBookingDocument() $response = array('status' => false); $idHtlBooking = (int) Tools::getValue('id_htl_booking'); + $title = Tools::getValue('title'); // validations $objHotelBookingDetail = new HotelBookingDetail($idHtlBooking); @@ -1685,6 +1689,14 @@ public function ajaxProcessUploadBookingDocument() $this->errors[] = $this->l('Booking detail not found.'); } + if (!$title) { + $title = '--'; + } else { + if (!Validate::isString($title)) { + $this->errors[] = $this->l('Please enter a valid Title.'); + } + } + $objHotelBookingDocument = new HotelBookingDocument(); $objHotelBookingDocument->setFileInfoForUploadedDocument('booking_document'); if (!count($objHotelBookingDocument->fileInfo)) { @@ -1697,11 +1709,13 @@ public function ajaxProcessUploadBookingDocument() $objHotelBookingDocument = new HotelBookingDocument(); $objHotelBookingDocument->setFileInfoForUploadedDocument('booking_document'); $objHotelBookingDocument->id_htl_booking = $idHtlBooking; + $objHotelBookingDocument->title = $title; $objHotelBookingDocument->setFileType(); if ($objHotelBookingDocument->save()) { $objHotelBookingDocument->saveDocumentFile(); $response['html'] = $this->getRenderedBookingDocuments($idHtlBooking); + $response['num_checkin_documents'] = HotelBookingDocument::getCountByIdHtlBooking($idHtlBooking); $response['status'] = true; } else { $this->errors[] = $this->l('Document upload failed.'); @@ -1729,6 +1743,7 @@ public function ajaxProcessDeleteBookingDocument() $idHtlBooking = $objHotelBookingDocument->id_htl_booking; if ($objHotelBookingDocument->delete()) { $response['html'] = $this->getRenderedBookingDocuments($idHtlBooking); + $response['num_checkin_documents'] = HotelBookingDocument::getCountByIdHtlBooking($idHtlBooking); $response['status'] = true; } } @@ -1783,16 +1798,10 @@ 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, + 'pdf_icon_link' => $this->context->link->getBaseLink().'modules/hotelreservationsystem/views/img/pdf-icon.jpg', )); return $this->context->smarty->fetch('controllers/orders/_booking_documents.tpl'); diff --git a/js/admin/orders.js b/js/admin/orders.js index 284bf8bf6..15bfb663b 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1309,41 +1309,61 @@ function checkTotalRefundProductQuantity(it) actualizeTotalRefundVoucher(); } -$(document).on('click', '#modal-booking-documents .booking-documents .btn-add-new-document', function() { +$(document).on('click', '#modal-booking-documents .btn-add-new-document', function() { BookingDocumentsModal.addNew(); - BookingDocumentsFile.addNew(); + BookingDocumentsForm.addNew(); }); $(document).on('change', '.input-booking-document', function(e) { e.preventDefault(); + if (!this.files.length) { $(this).remove(); return; } - BookingDocumentsFile.updatePreview(); + BookingDocumentsForm.updatePreview(); +}); + +$(document).on('click', '#form-add-new-document .btn-add-file', function(e) { + e.preventDefault(); + + BookingDocumentsForm.openFileChooser(); +}); + +$(document).on('click', '#form-add-new-document .btn-group-add-new .cancel', function(e) { + e.preventDefault(); + + BookingDocumentsForm.close(); + BookingDocumentsModal.enableAddNewButton(); +}); + +$(document).on('click', '#form-add-new-document .btn-group-add-new .upload', function(e) { + e.preventDefault(); + BookingDocumentsModal.uploadDocument(); }); -$(document).on('click', '#modal-booking-documents .booking-documents .btn-delete-document', function(e) { +$(document).on('click', '#modal-booking-documents .documents-list .btn-delete-document', function(e) { + e.preventDefault(); + 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(); + init: function(idHtlBooking, $this) { + BookingDocumentsModal.currentTr = $this; + $('#modal-booking-documents .documents-list').find('[name="id_hotel_booking"]').val(idHtlBooking); + BookingDocumentsForm.init(); BookingDocumentsModal.reset(); BookingDocumentsModal.show(idHtlBooking); }, reset: function() { - $('#modal-booking-documents .booking-documents table tbody').html(''); + $('#modal-booking-documents .documents-list table tbody').html(''); }, show: function(idHtlBooking) { $('#modal-booking-documents').modal('show'); - $('#modal-booking-documents #booking-document-id-htl-booking').attr('value', idHtlBooking); + $('#form-add-new-document').find('[name="id_htl_booking"]').attr('value', idHtlBooking); let data = { ajax: true, action: 'getBookingDocuments', @@ -1363,22 +1383,21 @@ const BookingDocumentsModal = { }); }, setBodyHtml: function(html) { - $('#modal-booking-documents .booking-documents table tbody').html(html); + $('#modal-booking-documents .documents-list table tbody').html(html); }, close: function() { $('#modal-booking-documents').modal('hide'); }, addNew: function() { BookingDocumentsModal.hideErrors(); - BookingDocumentsModal.disableAddNewButton(); + BookingDocumentsModal.hideAddNewButton(); }, beforeSubmit: function() { BookingDocumentsModal.hideErrors(); - BookingDocumentsModal.disableAddNewButton(); }, uploadDocument: function() { BookingDocumentsModal.beforeSubmit(); - let formData = new FormData($('#modal-booking-documents form.booking-documents').get(0)); + let formData = new FormData($('form#form-add-new-document').get(0)); formData.append('ajax', true); formData.append('action', 'uploadBookingDocument'); $.ajax({ @@ -1392,15 +1411,14 @@ const BookingDocumentsModal = { if (jsonResponse.status) { showSuccessMessage(txt_booking_document_upload_success); BookingDocumentsModal.reset(); - BookingDocumentsFile.resetPreview(); + BookingDocumentsForm.reset(); + BookingDocumentsForm.resetPreview(); BookingDocumentsModal.setBodyHtml(jsonResponse.html); + BookingDocumentsModal.setDocumentsCount(jsonResponse.num_checkin_documents); } else { BookingDocumentsModal.showErrors(jsonResponse.errors); } }, - complete: function() { - BookingDocumentsModal.enableAddNewButton(); - }, }); }, deleteDocument: function($this) { @@ -1419,13 +1437,14 @@ const BookingDocumentsModal = { success: function(response) { if (response.status) { BookingDocumentsModal.setBodyHtml(response.html); + BookingDocumentsModal.setDocumentsCount(response.num_checkin_documents); showSuccessMessage(txt_booking_document_delete_success); } }, }); }, showErrors: function(errors) { - $('#modal-booking-documents .errors-wrap').html(errors); + $('#modal-booking-documents .errors-wrap').stop().html(errors); $('#modal-booking-documents .errors-wrap').show('slow'); }, hideErrors: function() { @@ -1434,28 +1453,41 @@ const BookingDocumentsModal = { }); }, enableAddNewButton: function() { - $('#modal-booking-documents .booking-documents .btn-add-new-document').removeClass('disabled'); + $('#modal-booking-documents .btn-add-new-document').show(200); + }, + hideAddNewButton: function() { + $('#modal-booking-documents .btn-add-new-document').hide(200); }, - disableAddNewButton: function() { - $('#modal-booking-documents .booking-documents .btn-add-new-document').addClass('disabled'); + setDocumentsCount: function(count) { + $(BookingDocumentsModal.currentTr).find('.count-documents').html(count); }, } -const BookingDocumentsFile = { +const BookingDocumentsForm = { init: function() { - BookingDocumentsFile.inputHtml = ''; + BookingDocumentsForm.inputHtml = ''; + }, + reset: function() { + $('#form-add-new-document').get(0).reset(); }, resetPreview: function() { - $('#modal-booking-documents .booking-documents .add-new-wrap span').html(''); + $('#form-add-new-document .file-name').val(''); }, updatePreview: function() { - BookingDocumentsFile.resetPreview(); - let input = $('#modal-booking-documents .booking-documents').find('.input-file-wrap input'); + BookingDocumentsForm.resetPreview(); + let input = $('#form-add-new-document').find('.input-file-wrap input'); let file = $(input).get(0).files[0]; - $('#modal-booking-documents .booking-documents .add-new-wrap span').html(file.name); + $('#form-add-new-document .file-name').val(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(); + $('#modal-booking-documents #form-add-new-document').show(200); + $('#form-add-new-document').find('.input-file-wrap').html(BookingDocumentsForm.inputHtml); + }, + openFileChooser: function() { + $('#form-add-new-document').find('.input-file-wrap').html(BookingDocumentsForm.inputHtml); + $('#form-add-new-document').find('.input-file-wrap input').click(); + }, + close: function() { + $('#modal-booking-documents #form-add-new-document').hide(200); }, } diff --git a/modules/hotelreservationsystem/classes/HotelBookingDocument.php b/modules/hotelreservationsystem/classes/HotelBookingDocument.php index 26c497994..3f1024c47 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDocument.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDocument.php @@ -22,10 +22,10 @@ class HotelBookingDocument extends ObjectModel { public $id_htl_booking_document; public $id_htl_booking; + public $title; public $file_type; public $file_name; public $date_add; - public $date_upd; const FILE_TYPE_IMAGE = 1; const FILE_TYPE_PDF = 2; @@ -39,10 +39,10 @@ class HotelBookingDocument extends ObjectModel 'primary' => 'id_htl_booking_document', 'fields' => array( 'id_htl_booking' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'title' => array('type' => self::TYPE_STRING, 'validate' => 'isString'), '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'), ), ); @@ -79,6 +79,15 @@ public static function getDocumentsByIdHtlBooking($idHtlBooking) ); } + public static function getCountByIdHtlBooking($idHtlBooking) + { + return (int) Db::getInstance()->getValue( + 'SELECT COUNT(*) + FROM `'._DB_PREFIX_.'htl_booking_document` + WHERE `id_htl_booking` = '.(int) $idHtlBooking + ); + } + public static function getDocumentsByIdOrder($idOrder) { return Db::getInstance()->executeS( diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 11c6ba326..c4da5d106 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -183,10 +183,10 @@ public function getModuleSql() "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, + `title` varchar(32) NOT NULL DEFAULT '', `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;", diff --git a/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php b/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php index ae0b0be47..977babeb2 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminBookingDocumentController.php @@ -31,6 +31,7 @@ public function processGetDocument() $contentLength = $objHotelBookingDocument->getContentLength(); $filePath = $objHotelBookingDocument->getPhysicalPath(); $downloadFileName = $objHotelBookingDocument->getDownloadFileName(); + $contentDisposition = Tools::getValue('is_preview') ? 'inline' : 'attachment'; if (Tools::file_exists_cache($filePath)) { if (ob_get_level() && ob_get_length() > 0) { @@ -40,7 +41,7 @@ public function processGetDocument() header('Content-Transfer-Encoding: binary'); header('Content-Type: '.$contentType); header('Content-Length: '.$contentLength); - header('Content-Disposition: attachment; filename="'.$downloadFileName.'"'); + header('Content-Disposition: '.$contentDisposition.'; filename="'.$downloadFileName.'"'); @set_time_limit(0); readfile($filePath); } From 50a83676e42958170fcc2e89ff7ac350a4283690 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 9 Feb 2023 15:18:51 +0530 Subject: [PATCH 03/11] Add file type validation --- controllers/admin/AdminOrdersController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 11a728cad..c0fb43ba0 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1703,6 +1703,10 @@ public function ajaxProcessUploadBookingDocument() $this->errors[] = $this->l('Please upload a document.'); } elseif ($objHotelBookingDocument->fileInfo['size'] > Tools::getMaxUploadSize()) { $this->errors[] = $this->l('Uploaded file size is too large.'); + } elseif(!ImageManager::isRealImage($objHotelBookingDocument->fileInfo['tmp_name']) + || $objHotelBookingDocument->fileInfo['mime'] != 'application/pdf' + ) { + $this->errors[] = $this->l('Please upload an image or a PDF file only.'); } if (!count($this->errors)) { From a11570dfa0de182e4c4acb9294cb84e5f3fc7da3 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 9 Feb 2023 17:17:53 +0530 Subject: [PATCH 04/11] Fix file upload issue --- .../template/controllers/orders/_booking_documents.tpl | 2 +- controllers/admin/AdminOrdersController.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_booking_documents.tpl b/admin/themes/default/template/controllers/orders/_booking_documents.tpl index 676cd44e6..c3121ad42 100644 --- a/admin/themes/default/template/controllers/orders/_booking_documents.tpl +++ b/admin/themes/default/template/controllers/orders/_booking_documents.tpl @@ -43,6 +43,6 @@ {/foreach} {else} - {l s='No documents.'} + {l s='No documents uploaded yet.'} {/if} diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index c0fb43ba0..28b2e61d0 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1703,10 +1703,10 @@ public function ajaxProcessUploadBookingDocument() $this->errors[] = $this->l('Please upload a document.'); } elseif ($objHotelBookingDocument->fileInfo['size'] > Tools::getMaxUploadSize()) { $this->errors[] = $this->l('Uploaded file size is too large.'); - } elseif(!ImageManager::isRealImage($objHotelBookingDocument->fileInfo['tmp_name']) - || $objHotelBookingDocument->fileInfo['mime'] != 'application/pdf' + } elseif(!(ImageManager::isRealImage($objHotelBookingDocument->fileInfo['tmp_name']) + || $objHotelBookingDocument->fileInfo['mime'] == 'application/pdf') ) { - $this->errors[] = $this->l('Please upload an image or a PDF file only.'); + $this->errors[] = $this->l('Please upload an image or a PDF file only. Allowed image formats: .gif, .jpg, .jpeg and .png'); } if (!count($this->errors)) { From 70cb208b231014a3dd48f0c23e1bdb692dbb72c7 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 13 Feb 2023 12:43:22 +0530 Subject: [PATCH 05/11] Minor changes --- .../default/sass/controllers/_order.sass | 2 +- admin/themes/default/template/alerts.tpl | 87 +++++++++++++++++ ...cuments.tpl => _booking_document_line.tpl} | 9 +- ...ments.tpl => _booking_documents_modal.tpl} | 31 ++++-- .../template/controllers/orders/_errors.tpl | 33 ------- admin/themes/default/template/layout.tpl | 64 +------------ controllers/admin/AdminOrdersController.php | 16 ++-- js/admin/orders.js | 95 +++++++++++-------- .../classes/HotelBookingDocument.php | 16 +--- 9 files changed, 179 insertions(+), 174 deletions(-) create mode 100644 admin/themes/default/template/alerts.tpl rename admin/themes/default/template/controllers/orders/{_booking_documents.tpl => _booking_document_line.tpl} (90%) rename admin/themes/default/template/controllers/orders/{modal_booking_documents.tpl => _booking_documents_modal.tpl} (73%) delete mode 100644 admin/themes/default/template/controllers/orders/_errors.tpl diff --git a/admin/themes/default/sass/controllers/_order.sass b/admin/themes/default/sass/controllers/_order.sass index 10fdd0f6b..3fdc166b0 100644 --- a/admin/themes/default/sass/controllers/_order.sass +++ b/admin/themes/default/sass/controllers/_order.sass @@ -4,7 +4,7 @@ #customization_list border: 0px -#modal-booking-documents +#booking-documents-modal .documents-list table tbody diff --git a/admin/themes/default/template/alerts.tpl b/admin/themes/default/template/alerts.tpl new file mode 100644 index 000000000..2d4e3973e --- /dev/null +++ b/admin/themes/default/template/alerts.tpl @@ -0,0 +1,87 @@ +{* +* 2007-2017 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2017 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{if isset($conf)} +
+
+ + {$conf} +
+
+{/if} +{if isset($errors) && count($errors) && current($errors) != '' && (!isset($disableDefaultErrorOutPut) || $disableDefaultErrorOutPut == false)} +
+
+ + {if count($errors) == 1} + {reset($errors)} + {else } + {l s='%d errors' sprintf=$errors|count} +
+
    + {foreach $errors as $error} +
  1. {$error}
  2. + {/foreach} +
+ {/if} +
+
+{/if} +{if isset($informations) && count($informations) && $informations} +
+
+ +
    + {foreach $informations as $info} +
  • {$info}
  • + {/foreach} +
+
+
+{/if} +{if isset($confirmations) && count($confirmations) && $confirmations} +
+
+ {foreach $confirmations as $conf} + {$conf} + {/foreach} +
+
+{/if} +{if isset($warnings) && count($warnings)} +
+
+ + {if count($warnings) > 1} +

{l s='There are %d warnings:' sprintf=count($warnings)}

+ {/if} +
    + {foreach $warnings as $warning} +
  • {$warning}
  • + {/foreach} +
+
+
+{/if} diff --git a/admin/themes/default/template/controllers/orders/_booking_documents.tpl b/admin/themes/default/template/controllers/orders/_booking_document_line.tpl similarity index 90% rename from admin/themes/default/template/controllers/orders/_booking_documents.tpl rename to admin/themes/default/template/controllers/orders/_booking_document_line.tpl index c3121ad42..9411ae1b8 100644 --- a/admin/themes/default/template/controllers/orders/_booking_documents.tpl +++ b/admin/themes/default/template/controllers/orders/_booking_document_line.tpl @@ -20,7 +20,6 @@ {if is_array($booking_documents) && count($booking_documents)} {foreach from=$booking_documents item=booking_document} - {$booking_document.title} {if $booking_document.file_type == HotelBookingDocument::FILE_TYPE_IMAGE} @@ -30,6 +29,7 @@ {/if} + {$booking_document.title} {dateFormat date=$booking_document.date_add full=1} @@ -43,6 +43,11 @@ {/foreach} {else} - {l s='No documents uploaded yet.'} + +
+ + {l s='No documents uploaded yet.'} +
+ {/if} diff --git a/admin/themes/default/template/controllers/orders/modal_booking_documents.tpl b/admin/themes/default/template/controllers/orders/_booking_documents_modal.tpl similarity index 73% rename from admin/themes/default/template/controllers/orders/modal_booking_documents.tpl rename to admin/themes/default/template/controllers/orders/_booking_documents_modal.tpl index 95866e83d..d62524b3f 100644 --- a/admin/themes/default/template/controllers/orders/modal_booking_documents.tpl +++ b/admin/themes/default/template/controllers/orders/_booking_documents_modal.tpl @@ -20,13 +20,13 @@