Skip to content

Commit

Permalink
Merge pull request #1271 from shreesh-webkul/patch-booking
Browse files Browse the repository at this point in the history
Updated: New hook and date format changes
  • Loading branch information
rohit053 authored Oct 4, 2024
2 parents a764304 + bf71e89 commit 6fb5871
Show file tree
Hide file tree
Showing 27 changed files with 91 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
</a>
</td>
<td><a href="{$link->getAdminLink('AdminAddHotel')|escape:'html':'UTF-8'}&amp;id={$room['id_hotel']}&amp;updatehtl_branch_info">{$room['room_type_info'].hotel_name}</a></td>
<td>{dateFormat date=$room['date_from']} - {dateFormat date=$room['date_to']}</td>
{assign var="is_full_date" value=($show_full_date && ($room['date_from']|date_format:'%D' == $room['date_to']|date_format:'%D'))}
<td>{dateFormat date=$room['date_from'] full=$is_full_date} - {dateFormat date=$room['date_to'] full=$is_full_date}</td>
<td>
<span>
{if $room['adults']}{$room['adults']}{/if} {if $room['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$room['children']}}, {$room['children']} {if $room['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
<td>
<p>{$data.room_type|escape:'html':'UTF-8'}</p>
</td>
<td>{dateFormat date=$data.date_from} - {dateFormat date=$data.date_to}</td>
{assign var="is_full_date" value=($show_full_date && ($data['date_from']|date_format:'%D' == $data['date_to']|date_format:'%D'))}
<td>{dateFormat date=$data.date_from full=$is_full_date} - {dateFormat date=$data.date_to full=$is_full_date}</td>
{if $occupancy_required_for_booking}
<td>
<div class="dropdown">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
<tr>
<td>{$data['room_num']}</td>
<td>{$data['room_type_name']}</td>
<td>{dateFormat date=$data['date_from']} {l s='To'} {dateFormat date=$data['date_to']}</td>
{assign var="is_full_date" value=($show_full_date && ($data['date_from']|date_format:'%D' == $data['date_to']|date_format:'%D'))}
<td>{dateFormat date=$data['date_from'] full=$is_full_date} {l s='To'} {dateFormat date=$data['date_to'] full=$is_full_date}</td>
<td>
{if $order->with_occupancy && $data['children']}
<div class="dropdown">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<p><a href="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}&amp;id_product={$data.id_product}&amp;updateproduct" target="_blank"><span>{$data.room_type}</span></a></p>
</td>
<td>
{dateFormat date=$data.date_from} - {dateFormat date=$data.date_to}
{assign var="is_full_date" value=($show_full_date && ($data['date_from']|date_format:'%D' == $data['date_to']|date_format:'%D'))}
{dateFormat date=$data.date_from full=$is_full_date} - {dateFormat date=$data.date_to full=$is_full_date}
</td>
<td>
{if $data['children']}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
<td>
<a href="{$link->getAdminLink('AdminAddHotel')}&amp;id={$data['id_hotel']|escape:'html':'UTF-8'}&amp;updatehtl_branch_info" target="_blank"><span>{$data['hotel_name']}</span></a>
</td>
<td>{dateFormat date=$data['date_from']|escape:'html':'UTF-8'} {l s='To'} {dateFormat date=$data['date_to']|escape:'html':'UTF-8'}</td>
{assign var="is_full_date" value=($show_full_date && ($data['date_from']|date_format:'%D' == $data['date_to']|date_format:'%D'))}
<td>{dateFormat date=$data['date_from']|escape:'html':'UTF-8' full=$is_full_date} {l s='To'} {dateFormat date=$data['date_to']|escape:'html':'UTF-8' full=$is_full_date}</td>
<td>
<a href="{$link->getAdminLink('AdminOrders')|escape:'html':'UTF-8'}&amp;vieworder&amp;id_order={$data['id_order']|escape:'html':'UTF-8'}">#{$data['id_order']|escape:'html':'UTF-8'}</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
<a href="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}&amp;id_product={$data['id_product']}&amp;updateproduct" target="_blank">{$data['room_type_name']|escape:'html':'UTF-8'}</a>
</td>
<td>
{dateFormat date=$data['date_from']} - {dateFormat date=$data['date_to']}
{assign var="is_full_date" value=($show_full_date && ($data['date_from']|date_format:'%D' == $data['date_to']|date_format:'%D'))}
{dateFormat date=$data['date_from'] full=$is_full_date} - {dateFormat date=$data['date_to'] full=$is_full_date}
</td>
<td>
{if ($data['id_status'] == $hotel_order_status['STATUS_CHECKED_IN']['id_status']) || ($data['id_status'] == $hotel_order_status['STATUS_CHECKED_OUT']['id_status'])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
<td><b>{$bookingInfo.room_num|escape:'html':'UTF-8'}</b></td>
<td>{$bookingInfo.room_type_name|escape:'html':'UTF-8'}</td>
<td>{$bookingInfo.hotel_name|escape:'html':'UTF-8'}</td>
<td>{dateFormat date=$bookingInfo.date_from} - {dateFormat date=$bookingInfo.date_to}</span></td>
{assign var="is_full_date" value=($show_full_date && ($bookingInfo['date_from']|date_format:'%D' == $bookingInfo['date_to']|date_format:'%D'))}
<td>{dateFormat date=$bookingInfo.date_from full=$is_full_date} - {dateFormat date=$bookingInfo.date_to full=$is_full_date}</span></td>
<td>{convertPriceWithCurrency price=$bookingInfo.total_price_tax_incl currency=$currency->id}</td>
</tr>
{/foreach}
Expand Down
5 changes: 3 additions & 2 deletions classes/controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ public function initHeader()
'currentIndex' => self::$currentIndex,
'bootstrap' => $this->bootstrap,
'default_language' => (int)Configuration::get('PS_LANG_DEFAULT'),
'display_addons_connection' => Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController'))
'display_addons_connection' => Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController')),
));

$module = Module::getInstanceByName('themeconfigurator');
Expand Down Expand Up @@ -2951,7 +2951,8 @@ public function init()
'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) {
Expand Down
2 changes: 2 additions & 0 deletions classes/controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ abstract class ControllerCore
/** @var string Controller name */
public $php_self;

public $show_full_date = false;

/**
* Check if the controller is available for the current user/visitor
*/
Expand Down
3 changes: 2 additions & 1 deletion classes/controller/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ public function init()
'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
Expand Down Expand Up @@ -596,7 +597,7 @@ public function initContent()
'HOOK_TOP' => Hook::exec('displayTop'),
'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, // By webkul
'show_breadcrump' => $this->show_breadcrump,
));
} else {
$this->context->smarty->assign('HOOK_MOBILE_HEADER', Hook::exec('displayMobileHeader'));
Expand Down
8 changes: 5 additions & 3 deletions classes/module/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2880,9 +2880,11 @@ public function getOverrides()
} elseif (Module::getModuleIdByName($class)) {
$classInfo['type'] = self::OVERRIDE_TYPE_MODULE;
} elseif (preg_match('#^modules/([a-zA-Z0-9_-]+)/controllers/(admin|front)/([0-9a-zA-Z-_]+).php#', $file, $matches)) {
$classInfo['type'] = self::OVERRIDE_TYPE_MODULE_CONTROLLER;
$classInfo['module'] = $matches[1];
$classInfo['controller_type'] = $matches[2];
if ($class != 'index') {
$classInfo['type'] = self::OVERRIDE_TYPE_MODULE_CONTROLLER;
$classInfo['module'] = $matches[1];
$classInfo['controller_type'] = $matches[2];
}
}

if ($classInfo['type']) {
Expand Down
5 changes: 3 additions & 2 deletions classes/pdf/HTMLTemplateInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,9 @@ public function getContent()
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);

$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = Tools::displayDate($data_v['date_from']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = Tools::displayDate($data_v['date_to']);
$fullDate = ($this->context->controller->show_full_date && (date('Y-m-d', strtotime($data_v['date_from'])) == date('Y-m-d', strtotime($data_v['date_to']))) ? true : false);
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = Tools::displayDate($data_v['date_from'], null, $fullDate);
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = Tools::displayDate($data_v['date_to'], null, $fullDate);
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['children'] = $data_v['children'];
Expand Down
13 changes: 10 additions & 3 deletions modules/blockcart/ajax-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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>';
Expand Down Expand Up @@ -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>';
Expand Down
5 changes: 3 additions & 2 deletions modules/blockcart/blockcart.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ public function getContentVars($params)
} else {
$addedProduct['price'] = Tools::displayPrice($price['total_price_tax_incl']);
}
$addedProduct['date_from'] = Tools::displayDate($addedProduct['date_from']);
$addedProduct['date_to'] = Tools::displayDate($addedProduct['date_to']);
$fullDate = ($this->context->controller->show_full_date && (date('Y-m-d', strtotime($addedProduct['date_from'])) == date('Y-m-d', strtotime($addedProduct['date_to']))) ? true : false);
$addedProduct['date_from'] = Tools::displayDate($addedProduct['date_from'], null, $fullDate);
$addedProduct['date_to'] = Tools::displayDate($addedProduct['date_to'], null, $fullDate);
} else {
// @todo get price of added product from front
$addedProduct['price'] = ProductCore::getPriceStatic(
Expand Down
3 changes: 2 additions & 1 deletion modules/blockcart/blockcart.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +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>
{$data_v['data_form']|date_format:"%d-%m-%Y"}&nbsp;-&nbsp;{$data_v['data_to']|date_format:"%d-%m-%Y"}
{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>
Expand Down
7 changes: 7 additions & 0 deletions modules/hotelreservationsystem/classes/HotelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,13 @@ public static function validateDateRangeForHotel($dateFrom, $dateTo, $idHotel)
$isValid = false;
}

Hook::exec('actionValidateDateRangeForHotel', array(
'is_valid' => &$isValid,
'date_from' => $dateFrom,
'date_to' => $dateTo,
'id_hotel' => $idHotel
));

return $isValid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<tr>
<td class="text-center">{$cart_data['room_num']|escape:'htmlall':'UTF-8'}</td>
<td class="text-center">{$cart_data['room_type']|escape:'htmlall':'UTF-8'}</td>
<td class="text-center">{dateFormat date=$cart_data['date_from']} - {dateFormat date=$cart_data['date_to']}</td>
{assign var="is_full_date" value=($show_full_date && ($cart_data['date_from']|date_format:'%D' == $cart_data['date_to']|date_format:'%D'))}
<td class="text-center">{dateFormat date=$cart_data['date_from'] full=$is_full_date} - {dateFormat date=$cart_data['date_to'] full=$is_full_date}</td>
<td class="text-center">{convertPrice price=($cart_data['amt_with_qty'] + $cart_data['additional_services_auto_add_with_room_price'] + $cart_data['additional_service_price'] + $cart_data['demand_price'])}</td>
<td class="text-center"><button class="btn btn-default ajax_cart_delete_data" data-id-product="{$cart_data['id_product']|escape:'htmlall':'UTF-8'}" data-id-hotel="{$cart_data['id_hotel']|escape:'htmlall':'UTF-8'}" data-id-cart="{$cart_data['id_cart']|escape:'htmlall':'UTF-8'}" data-id-cart-book-data="{$cart_data['id']|escape:'htmlall':'UTF-8'}" data-date-from="{$cart_data['date_from']|escape:'htmlall':'UTF-8'}" data-date-to="{$cart_data['date_to']|escape:'htmlall':'UTF-8'}"><i class='icon-trash'></i></button></td>
</tr>
Expand Down
Loading

0 comments on commit 6fb5871

Please sign in to comment.