Minor changes

This commit is contained in:
Abhishek Kumar
2023-02-13 12:43:22 +05:30
parent 73a4ebd243
commit eece6b7f0f
9 changed files with 182 additions and 173 deletions

View File

@@ -4,12 +4,16 @@
#customization_list
border: 0px
<<<<<<< HEAD
.booking_occupancy
.booking_occupancy_wrapper
max-height: 250px
overflow-x: auto
#modal-booking-documents
=======
#booking-documents-modal
>>>>>>> Minor changes
.documents-list
table
tbody

View File

@@ -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 <contact@prestashop.com>
* @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)}
<div class="bootstrap">
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{$conf}
</div>
</div>
{/if}
{if isset($errors) && count($errors) && current($errors) != '' && (!isset($disableDefaultErrorOutPut) || $disableDefaultErrorOutPut == false)}
<div class="bootstrap">
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{if count($errors) == 1}
{reset($errors)}
{else }
{l s='%d errors' sprintf=$errors|count}
<br/>
<ol>
{foreach $errors as $error}
<li>{$error}</li>
{/foreach}
</ol>
{/if}
</div>
</div>
{/if}
{if isset($informations) && count($informations) && $informations}
<div class="bootstrap">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<ul id="infos_block" class="list-unstyled">
{foreach $informations as $info}
<li>{$info}</li>
{/foreach}
</ul>
</div>
</div>
{/if}
{if isset($confirmations) && count($confirmations) && $confirmations}
<div class="bootstrap">
<div class="alert alert-success" style="display:block;">
{foreach $confirmations as $conf}
{$conf}
{/foreach}
</div>
</div>
{/if}
{if isset($warnings) && count($warnings)}
<div class="bootstrap">
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{if count($warnings) > 1}
<h4>{l s='There are %d warnings:' sprintf=count($warnings)}</h4>
{/if}
<ul class="list-unstyled">
{foreach $warnings as $warning}
<li>{$warning}</li>
{/foreach}
</ul>
</div>
</div>
{/if}

View File

@@ -20,7 +20,6 @@
{if is_array($booking_documents) && count($booking_documents)}
{foreach from=$booking_documents item=booking_document}
<tr>
<td class="text-left">{$booking_document.title}</td>
<td class="text-center">
<a href="{$link->getAdminLink('AdminBookingDocument')}&action=getDocument&id_document={$booking_document.id_htl_booking_document}&is_preview=1" target="_blank">
{if $booking_document.file_type == HotelBookingDocument::FILE_TYPE_IMAGE}
@@ -30,6 +29,7 @@
{/if}
</a>
</td>
<td class="text-left">{$booking_document.title}</td>
<td class="text-center">{dateFormat date=$booking_document.date_add full=1}</td>
<td class="text-center">
<a class="btn btn-info" href="{$link->getAdminLink('AdminBookingDocument')}&action=getDocument&id_document={$booking_document.id_htl_booking_document}">
@@ -43,6 +43,11 @@
{/foreach}
{else}
<tr>
<td colspan="4" class="text-center">{l s='No documents uploaded yet.'}</td>
<td class="list-empty" colspan="4">
<div class="list-empty-msg">
<i class="icon-warning-sign list-empty-icon"></i>
{l s='No documents uploaded yet.'}
</div>
</td>
</tr>
{/if}

View File

@@ -20,13 +20,13 @@
<div class="modal-body text-center">
<div class="row">
<div class="col-lg-12">
<div class="alert alert-danger text-left errors-wrap" style="display: none;"></div>
<div class="text-left errors-wrap"></div>
<div class="documents-list">
<table class="table table-striped">
<table class="table table-bordered">
<thead>
<tr>
<th class="text-left">{l s='Title'}</th>
<th class="text-center">{l s='Preview'}</th>
<th class="text-left">{l s='Title'}</th>
<th class="text-center">{l s='Upload Date'}</th>
<th class="text-center">{l s='Actions'}</th>
</tr>
@@ -34,10 +34,9 @@
<tbody></tbody>
</table>
</div>
<div class="add-new-document-form">
<div class="add-new-document-form" style="margin-top: 10px;">
<div class="text-left add-new-wrap">
<a class="btn btn-default btn-add-new-document">
<i class="icon icon-cloud-upload"></i>
<a class="btn btn-primary btn-add-new-document">
{l s='Upload new document'}
</a>
<span></span>
@@ -48,18 +47,26 @@
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2">{l s='Title'}</label>
<label class="control-label col-sm-2">
<span class="label-tooltip" data-toggle="tooltip" title="" data-original-title="{l s='Write the title for the document. Invalid characters <>;=#{}'}">
{l s='Title'}
</span>
</label>
<div class="col-sm-10">
<div class="input-group fixed-width-xxl">
<input type="text" name="title" value="" placeholder="{l s='Eg. Passport, Driver\'s license'}" />
<input type="text" name="title" value="" placeholder="{l s='Eg. Passport, Driving license'}" />
</div>
</div>
</div>
<div class="form-group">
<label class="control-label required col-sm-2">{l s='File'}</label>
<label class="control-label required col-sm-2">
<span class="label-tooltip" data-toggle="tooltip" title="" data-original-title="{l s='Choose the document file to be uploaded.'}">
{l s='File'}
</span>
</label>
<div class="col-sm-10">
<div class="input-file-wrap"></div>
<div class="dummyfile input-group fixed-width-xxl">
<div class="input-group fixed-width-xxl">
<span class="input-group-addon"><i class="icon-file"></i></span>
<input type="text" class="file-name" readonly="">
<span class="input-group-btn">
@@ -69,6 +76,9 @@
</button>
</span>
</div>
<p class="text-left" style="margin-top: 4px; font-style: italic;">
{l s='Upload a PDF or an image file. Allowed image formats: .gif, .jpg, .jpeg and .png'}
</p>
</div>
</div>
<div class="clearfix btn-group-add-new">
@@ -87,4 +97,5 @@
</div>
{addJsDefL name=txt_booking_document_upload_success}{l s='Document uploaded successfully.' js=1}{/addJsDefL}
{addJsDefL name=txt_booking_document_delete_confirm}{l s='Are you sure?' js=1}{/addJsDefL}
{addJsDefL name=txt_booking_document_delete_success}{l s='Document deleted successfully.' js=1}{/addJsDefL}

View File

@@ -1,33 +0,0 @@
{**
* 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)}
<p>
{if count($errors) > 1}
{l s='There are %d errors:' sprintf=[count($errors)]}
{else}
{l s='There is 1 error:'}
{/if}
</p>
<ol>
{foreach from=$errors item=error}
<li>{$error}</li>
{/foreach}
</ol>
{/if}

View File

@@ -23,68 +23,6 @@
* International Registered Trademark & Property of PrestaShop SA
*}
{$header}
{if isset($conf)}
<div class="bootstrap">
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{$conf}
</div>
</div>
{/if}
{if count($errors) && current($errors) != '' && (!isset($disableDefaultErrorOutPut) || $disableDefaultErrorOutPut == false)}
<div class="bootstrap">
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{if count($errors) == 1}
{reset($errors)}
{else }
{l s='%d errors' sprintf=$errors|count}
<br/>
<ol>
{foreach $errors as $error}
<li>{$error}</li>
{/foreach}
</ol>
{/if}
</div>
</div>
{/if}
{if isset($informations) && count($informations) && $informations}
<div class="bootstrap">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<ul id="infos_block" class="list-unstyled">
{foreach $informations as $info}
<li>{$info}</li>
{/foreach}
</ul>
</div>
</div>
{/if}
{if isset($confirmations) && count($confirmations) && $confirmations}
<div class="bootstrap">
<div class="alert alert-success" style="display:block;">
{foreach $confirmations as $conf}
{$conf}
{/foreach}
</div>
</div>
{/if}
{if count($warnings)}
<div class="bootstrap">
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{if count($warnings) > 1}
<h4>{l s='There are %d warnings:' sprintf=count($warnings)}</h4>
{/if}
<ul class="list-unstyled">
{foreach $warnings as $warning}
<li>{$warning}</li>
{/foreach}
</ul>
</div>
</div>
{/if}
{include file='./alerts.tpl'}
{$page}
{$footer}

View File

@@ -330,7 +330,7 @@ class AdminOrdersControllerCore extends AdminController
public function initModal()
{
parent::initModal();
$this->modals[] = $this->getModalBookingDocuments();
$this->modals[] = $this->getBookingDocumentsModal();
}
public function setMedia()
@@ -1646,13 +1646,13 @@ class AdminOrdersControllerCore extends AdminController
return parent::renderView();
}
public function getModalBookingDocuments()
public function getBookingDocumentsModal()
{
$modalContent = $this->context->smarty->fetch('controllers/orders/modal_booking_documents.tpl');
$modalContent = $this->context->smarty->fetch('controllers/orders/_booking_documents_modal.tpl');
// set modal details
$modal = array(
'modal_id' => 'modal-booking-documents',
'modal_id' => 'booking-documents-modal',
'modal_class' => 'modal-md',
'modal_title' => $this->l('Documents'),
'modal_content' => $modalContent,
@@ -1692,7 +1692,7 @@ class AdminOrdersControllerCore extends AdminController
if (!$title) {
$title = '--';
} else {
if (!Validate::isString($title)) {
if (!Validate::isCatalogName($title)) {
$this->errors[] = $this->l('Please enter a valid Title.');
}
}
@@ -1700,7 +1700,7 @@ class AdminOrdersControllerCore extends AdminController
$objHotelBookingDocument = new HotelBookingDocument();
$objHotelBookingDocument->setFileInfoForUploadedDocument('booking_document');
if (!count($objHotelBookingDocument->fileInfo)) {
$this->errors[] = $this->l('Please upload a document.');
$this->errors[] = $this->l('Please select a file to upload.');
} elseif ($objHotelBookingDocument->fileInfo['size'] > Tools::getMaxUploadSize()) {
$this->errors[] = $this->l('Uploaded file size is too large.');
} elseif(!(ImageManager::isRealImage($objHotelBookingDocument->fileInfo['tmp_name'])
@@ -1729,7 +1729,7 @@ class AdminOrdersControllerCore extends AdminController
'errors' => $this->errors,
));
$response['errors'] = $this->context->smarty->fetch('controllers/orders/_errors.tpl');
$response['errors'] = $this->context->smarty->fetch('alerts.tpl');
$response['status'] = false;
}
@@ -1808,7 +1808,7 @@ class AdminOrdersControllerCore extends AdminController
'pdf_icon_link' => $this->context->link->getBaseLink().'modules/hotelreservationsystem/views/img/pdf-icon.jpg',
));
return $this->context->smarty->fetch('controllers/orders/_booking_documents.tpl');
return $this->context->smarty->fetch('controllers/orders/_booking_document_line.tpl');
}
public function ajaxProcessSearchProducts()

View File

@@ -1309,11 +1309,15 @@ function checkTotalRefundProductQuantity(it)
actualizeTotalRefundVoucher();
}
$(document).on('click', '#modal-booking-documents .btn-add-new-document', function() {
$(document).on('click', '#booking-documents-modal .btn-add-new-document', function() {
BookingDocumentsModal.addNew();
BookingDocumentsForm.addNew();
});
$(document).on('click', '#booking-documents-modal [data-dismiss="alert"]', function() {
BookingDocumentsModal.hideErrors();
});
$(document).on('change', '.input-booking-document', function(e) {
e.preventDefault();
@@ -1344,25 +1348,27 @@ $(document).on('click', '#form-add-new-document .btn-group-add-new .upload', fun
BookingDocumentsModal.uploadDocument();
});
$(document).on('click', '#modal-booking-documents .documents-list .btn-delete-document', function(e) {
$(document).on('click', '#booking-documents-modal .documents-list .btn-delete-document', function(e) {
e.preventDefault();
BookingDocumentsModal.deleteDocument(this);
if (confirm(txt_booking_document_delete_confirm)) {
BookingDocumentsModal.deleteDocument(this);
}
});
const BookingDocumentsModal = {
init: function(idHtlBooking, $this) {
BookingDocumentsModal.currentTr = $this;
$('#modal-booking-documents .documents-list').find('[name="id_hotel_booking"]').val(idHtlBooking);
$('#booking-documents-modal .documents-list').find('[name="id_hotel_booking"]').val(idHtlBooking);
BookingDocumentsForm.init();
BookingDocumentsModal.reset();
BookingDocumentsModal.show(idHtlBooking);
},
reset: function() {
$('#modal-booking-documents .documents-list table tbody').html('');
$('#booking-documents-modal .documents-list table tbody').html('');
},
show: function(idHtlBooking) {
$('#modal-booking-documents').modal('show');
$('#booking-documents-modal').modal('show');
$('#form-add-new-document').find('[name="id_htl_booking"]').attr('value', idHtlBooking);
let data = {
ajax: true,
@@ -1383,45 +1389,47 @@ const BookingDocumentsModal = {
});
},
setBodyHtml: function(html) {
$('#modal-booking-documents .documents-list table tbody').html(html);
$('#booking-documents-modal .documents-list table tbody').html(html);
},
close: function() {
$('#modal-booking-documents').modal('hide');
$('#booking-documents-modal').modal('hide');
},
addNew: function() {
BookingDocumentsModal.hideErrors();
BookingDocumentsModal.hideAddNewButton();
},
beforeSubmit: function() {
BookingDocumentsModal.hideErrors();
beforeSubmit: function(cb) {
BookingDocumentsModal.hideErrors(cb);
},
uploadDocument: function() {
BookingDocumentsModal.beforeSubmit();
let formData = new FormData($('form#form-add-new-document').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();
BookingDocumentsForm.reset();
BookingDocumentsForm.resetPreview();
BookingDocumentsModal.setBodyHtml(jsonResponse.html);
BookingDocumentsModal.setDocumentsCount(jsonResponse.num_checkin_documents);
} else {
BookingDocumentsModal.showErrors(jsonResponse.errors);
}
},
BookingDocumentsModal.beforeSubmit(function() {
let formData = new FormData($('form#form-add-new-document').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();
BookingDocumentsForm.reset();
BookingDocumentsForm.resetPreview();
BookingDocumentsModal.setBodyHtml(jsonResponse.html);
BookingDocumentsModal.setDocumentsCount(jsonResponse.num_checkin_documents);
} else {
BookingDocumentsModal.showErrors(jsonResponse.errors);
}
},
});
});
},
deleteDocument: function($this) {
BookingDocumentsModal.hideErrors();
let idHtlBookingDocument = parseInt($($this).attr('data-id-htl-booking-document'));
let data = {
ajax: true,
@@ -1444,19 +1452,22 @@ const BookingDocumentsModal = {
});
},
showErrors: function(errors) {
$('#modal-booking-documents .errors-wrap').stop().html(errors);
$('#modal-booking-documents .errors-wrap').show('slow');
$('#booking-documents-modal .errors-wrap').stop().html(errors);
$('#booking-documents-modal .errors-wrap').show(200);
},
hideErrors: function() {
$('#modal-booking-documents .errors-wrap').hide('slow', function() {
$('#modal-booking-documents .errors-wrap').html('');
hideErrors: function(cb) {
$('#booking-documents-modal .errors-wrap').hide(200, function() {
$('#booking-documents-modal .errors-wrap').html('');
if (typeof cb === 'function') {
cb();
}
});
},
enableAddNewButton: function() {
$('#modal-booking-documents .btn-add-new-document').show(200);
$('#booking-documents-modal .btn-add-new-document').show(200);
},
hideAddNewButton: function() {
$('#modal-booking-documents .btn-add-new-document').hide(200);
$('#booking-documents-modal .btn-add-new-document').hide();
},
setDocumentsCount: function(count) {
$(BookingDocumentsModal.currentTr).find('.count-documents').html(count);
@@ -1480,7 +1491,7 @@ const BookingDocumentsForm = {
$('#form-add-new-document .file-name').val(file.name);
},
addNew: function() {
$('#modal-booking-documents #form-add-new-document').show(200);
$('#booking-documents-modal #form-add-new-document').show(200);
$('#form-add-new-document').find('.input-file-wrap').html(BookingDocumentsForm.inputHtml);
},
openFileChooser: function() {
@@ -1488,6 +1499,6 @@ const BookingDocumentsForm = {
$('#form-add-new-document').find('.input-file-wrap input').click();
},
close: function() {
$('#modal-booking-documents #form-add-new-document').hide(200);
$('#booking-documents-modal #form-add-new-document').hide(200);
},
}

View File

@@ -39,7 +39,7 @@ 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'),
'title' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName'),
'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'),
@@ -59,9 +59,6 @@ class HotelBookingDocument extends ObjectModel
{
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();
@@ -88,17 +85,6 @@ class HotelBookingDocument extends ObjectModel
);
}
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);