update in blockcart for handling same date booking dates

This commit is contained in:
Shreesh Arora
2024-10-01 21:09:19 +05:30
parent 527fa2f048
commit 53b6b121c0
6 changed files with 28 additions and 15 deletions

View File

@@ -2161,7 +2161,6 @@ class AdminControllerCore extends Controller
'bootstrap' => $this->bootstrap,
'default_language' => (int)Configuration::get('PS_LANG_DEFAULT'),
'display_addons_connection' => Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController')),
'show_full_date' => $this->show_full_date,
));
$module = Module::getInstanceByName('themeconfigurator');
@@ -2940,7 +2939,8 @@ class AdminControllerCore extends Controller
'token' => $this->token,
'host_mode' => defined('_PS_HOST_MODE_') ? 1 : 0,
'stock_management' => (int)Configuration::get('PS_STOCK_MANAGEMENT'),
'language_is_rtl' => $this->context->language->is_rtl
'language_is_rtl' => $this->context->language->is_rtl,
'show_full_date' => $this->show_full_date,
));
if ($this->display_header) {

View File

@@ -496,6 +496,7 @@ class FrontControllerCore extends Controller
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'show_full_date' => $this->show_full_date
));
// Add the tpl files directory for mobile
@@ -597,7 +598,6 @@ class FrontControllerCore extends Controller
'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),
'HOOK_RIGHT_COLUMN' => ($this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : ''),
'show_breadcrump' => $this->show_breadcrump,
'show_full_date' => $this->show_full_date
));
} else {
$this->context->smarty->assign('HOOK_MOBILE_HEADER', Hook::exec('displayMobileHeader'));
@@ -1192,7 +1192,6 @@ class FrontControllerCore extends Controller
'token' => Tools::getToken(),
'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
'content_only' => (int)Tools::getValue('content_only'),
'show_full_date' => $this->show_full_date,
));
$this->context->smarty->assign($this->initLogoAndFavicon());

View File

@@ -122,7 +122,8 @@ $(document).ready(function() {
//JS Object : update the cart by ajax actions
var ajaxCart = {
dateFormat: 'dd-mm-yy',
dateFormat: 'DD-MM-YYYY',
dateFormatFull: 'DD-MM-YYYY HH:mm:ss',
nb_total_products: 0,
//override every button in the page in relation to the cart
overrideButtonsInThePage: function() {
@@ -928,8 +929,11 @@ var ajaxCart = {
if (this.bookingData.date_diff !== 'undefined') {
$.each(this.bookingData.date_diff, function(date_diff_k, date_diff_v) {
from = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_form));
to = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_to));
let dateFormatToUse = from == to ? ajaxCart.dateFormatFull : ajaxCart.dateFormat;
content += '<tr class="rooms_remove_container">';
content += '<td>' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_form)) + '&nbsp;-&nbsp;' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_to)) + '</td>';
content += '<td>' + moment(new Date(date_diff_v.data_form)).format(dateFormatToUse) + '&nbsp;-&nbsp;' + moment(new Date(date_diff_v.data_to)).format(dateFormatToUse) + '</td>';
content += '<td class="num_rooms_in_date">' + date_diff_v.num_rm + '</td>';
content += '<td>' + formatCurrency(parseFloat(date_diff_v.amount) + parseFloat(date_diff_v.demand_price), currency_format, currency_sign, currency_blank) + '</td>';
content += '<td>';
@@ -965,8 +969,11 @@ var ajaxCart = {
var product_price_float = this.price_float;
if (this.bookingData.date_diff !== 'undefined') {
$.each(this.bookingData.date_diff, function(date_diff_k1, date_diff_v1) {
from = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_form));
to = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_to));
let dateFormatToUse = from == to ? ajaxCart.dateFormatFull : ajaxCart.dateFormat;
booking_dates_content += '<tr class="rooms_remove_container">';
booking_dates_content += '<td>' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_form)) + '&nbsp;-&nbsp;' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_to)) + '</td>';
booking_dates_content += '<td>' + moment(new Date(date_diff_v1.data_form)).format(dateFormatToUse) + '&nbsp;-&nbsp;' + moment(new Date(date_diff_v1.data_to)).format(dateFormatToUse) + '</td>';
booking_dates_content += '<td class="num_rooms_in_date">' + date_diff_v1.num_rm + '</td>';
booking_dates_content += '<td>' + formatCurrency(parseFloat(date_diff_v1.amount) + parseFloat(date_diff_v1.demand_price), currency_format, currency_sign, currency_blank) + '</td>';
booking_dates_content += '<td>';

View File

@@ -133,9 +133,9 @@
</tr>
{foreach from=$product.bookingData['date_diff'] key=data_k1 item=data_v}
<tr class="rooms_remove_container">
{assign var="is_full_date" value=($show_full_date && ($data_v['data_form']|date_format:'%D' == $data_v['data_to']|date_format:'%D'))}
<td>
{assign var="is_full_date" value=($show_full_date && ($data_v['data_form']|date_format:'%D' == $data_v['data_to']|date_format:'%D'))}
{dateFormat date=$data_v['data_form'] full=$is_full_date}&nbsp;-&nbsp;{dateFormat date=$data_v['data_to'] full=$show_full_date}
{dateFormat date=$data_v['data_form'] full=$is_full_date}&nbsp;-&nbsp;{dateFormat date=$data_v['data_to'] full=$is_full_date}
</td>
<td class="num_rooms_in_date">{$data_v['num_rm']}</td>
<td>{convertPrice price=($data_v['amount'] + $data_v['demand_price'])}</td>

View File

@@ -124,7 +124,8 @@ $(document).ready(function() {
//JS Object : update the cart by ajax actions
var ajaxCart = {
dateFormat: 'dd-mm-yy',
dateFormat: 'DD-MM-YYYY',
dateFormatFull: 'DD-MM-YYYY HH:mm:ss',
nb_total_products: 0,
//override every button in the page in relation to the cart
overrideButtonsInThePage: function() {
@@ -930,8 +931,11 @@ var ajaxCart = {
if (this.bookingData.date_diff !== 'undefined') {
$.each(this.bookingData.date_diff, function(date_diff_k, date_diff_v) {
from = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_form));
to = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_to));
let dateFormatToUse = from == to ? ajaxCart.dateFormatFull : ajaxCart.dateFormat;
content += '<tr class="rooms_remove_container">';
content += '<td>' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_form)) + '&nbsp;-&nbsp;' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v.data_to)) + '</td>';
content += '<td>' + moment(new Date(date_diff_v.data_form)).format(dateFormatToUse) + '&nbsp;-&nbsp;' + moment(new Date(date_diff_v.data_to)).format(dateFormatToUse) + '</td>';
content += '<td class="num_rooms_in_date">' + date_diff_v.num_rm + '</td>';
content += '<td>' + formatCurrency(parseFloat(date_diff_v.amount) + parseFloat(date_diff_v.demand_price), currency_format, currency_sign, currency_blank) + '</td>';
content += '<td>';
@@ -967,8 +971,11 @@ var ajaxCart = {
var product_price_float = this.price_float;
if (this.bookingData.date_diff !== 'undefined') {
$.each(this.bookingData.date_diff, function(date_diff_k1, date_diff_v1) {
from = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_form));
to = $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_to));
let dateFormatToUse = from == to ? ajaxCart.dateFormatFull : ajaxCart.dateFormat;
booking_dates_content += '<tr class="rooms_remove_container">';
booking_dates_content += '<td>' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_form)) + '&nbsp;-&nbsp;' + $.datepicker.formatDate(ajaxCart.dateFormat, new Date(date_diff_v1.data_to)) + '</td>';
booking_dates_content += '<td>' + moment(new Date(date_diff_v1.data_form)).format(dateFormatToUse) + '&nbsp;-&nbsp;' + moment(new Date(date_diff_v1.data_to)).format(dateFormatToUse) + '</td>';
booking_dates_content += '<td class="num_rooms_in_date">' + date_diff_v1.num_rm + '</td>';
booking_dates_content += '<td>' + formatCurrency(parseFloat(date_diff_v1.amount) + parseFloat(date_diff_v1.demand_price), currency_format, currency_sign, currency_blank) + '</td>';
booking_dates_content += '<td>';
@@ -1282,10 +1289,10 @@ function disableRoomTypeDemands(show) {
function disableRoomTypeServices(disable) {
if (disable) {
$('#service_products_cont').find('button.select_room_service').attr('disabled', 'disabled');
$('#service_products_cont').find('button.add_roomtype_product').attr('disabled', 'disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').attr('disabled', 'disabled');
} else {
$('#service_products_cont').find('button.select_room_service').removeAttr('disabled');
$('#service_products_cont').find('button.add_roomtype_product').removeAttr('disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').removeAttr('disabled');
}
}

View File

@@ -135,7 +135,7 @@
<tr class="rooms_remove_container">
{assign var="is_full_date" value=($show_full_date && ($data_v['data_form']|date_format:'%D' == $data_v['data_to']|date_format:'%D'))}
<td>
{dateFormat date=$data_v['data_form'] full=$is_full_date}&nbsp;-&nbsp;{dateFormat date=$data_v['data_to'] full=$show_full_date}
{dateFormat date=$data_v['data_form'] full=$is_full_date}&nbsp;-&nbsp;{dateFormat date=$data_v['data_to'] full=$is_full_date}
</td>
<td class="num_rooms_in_date">{$data_v['num_rm']}</td>
<td>{convertPrice price=($data_v['amount'] + $data_v['demand_price'])}</td>