updated occupancy booking for api

This commit is contained in:
Shreesh Arora
2022-12-21 13:11:49 +05:30
parent a70beda4a8
commit cc45397c7e
24 changed files with 51 additions and 45 deletions

View File

@@ -31,7 +31,7 @@
<th><span class="title_box">{l s='Room Image'}</th>
<th><span class="title_box">{l s='Room Type'}</span></th>
<th><span class="title_box">{l s='Duration'}</span></th>
{if $occupancy_wise_booking}
{if $occupancy_required_for_booking}
<th><span class="fixed-width-lg title_box">{l s='Occupancy'}</span></th>
{/if}
<th><span class="title_box">{l s='Unit Price (tax excl)'}</span></th>
@@ -61,7 +61,7 @@
{/if}
</td>
<td>{dateFormat date=$data.date_from} - {dateFormat date=$data.date_to}</td>
{if $occupancy_wise_booking}
{if $occupancy_required_for_booking}
<td>
<div class="dropdown">
<button class="booking_guest_occupancy btn btn-default btn-left btn-block input-occupancy" type="button">

View File

@@ -85,7 +85,7 @@
</td>
<td style="display:none;" class="productQuantity text-center" colspan="2">
{if $order->occupnacy_wise_booking}
{if $order->is_occupnacy_provided}
<div class="booking_occupancy">
<div class="dropdown">
<button class="booking_guest_occupancy btn btn-default btn-left btn-block input-occupancy disabled" type="button">

View File

@@ -79,7 +79,7 @@
{/if}
</td>
<td class="text-center">
{if $order->occupnacy_wise_booking && $data['children']}
{if $order->is_occupnacy_provided && $data['children']}
<div class="dropdown booking_occupancy_show">
<button class="btn btn-default btn-left btn-block" data-toggle="dropdown" type="button">
<span>{if $data['adult']}{$data['adult']}{/if} {if $data['adult'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$data['children']}}, {$data['children']} {if $data['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}</span>
@@ -98,7 +98,7 @@
{else}
<span class="booking_occupancy_show">{if $data['adult']}{$data['adult']}{/if} {if $data['adult'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$data['children']}}, {$data['children']} {if $data['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}</span>
{/if}
{if $order->occupnacy_wise_booking}
{if $order->is_occupnacy_provided}
<div class="booking_occupancy_edit" style="display:none;">
<div class="dropdown">
<button class="booking_guest_occupancy btn btn-default btn-left btn-block input-occupancy" type="button">

View File

@@ -354,12 +354,18 @@ abstract class PaymentModuleCore extends Module
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int)$id_cart, true);
}
if (isset($this->context->employee->id)) {
if (Configuration::get('PS_BACKOFFICE_OCCUPANCY_WISE_BOOKING'))
$order->occupnacy_wise_booking = 1;
if ($this->name == 'wsorder') {
$order->is_occupnacy_provided = 0;
} else {
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING'))
$order->occupnacy_wise_booking = 1;
if (defined('_PS_ADMIN_DIR_')) {
if (Configuration::get('PS_BACKOFFICE_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$order->is_occupnacy_provided = 1;
}
} else {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$order->is_occupnacy_provided = 1;
}
}
}
// advance payment information

View File

@@ -487,7 +487,7 @@ class FrontControllerCore extends Controller
'currencyFormat' => $currency->format, // backward compat
'currencyBlank' => $currency->blank, // backward compat
'occupancy_wise_search' => $occupancyWiseSearch,
'occupancy_wise_booking' => Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING'),
'occupancy_required_for_booking' => Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING'),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
));

View File

@@ -193,7 +193,7 @@ class OrderCore extends ObjectModel
/**
* @var int is occupancy provided in this order
*/
public $occupnacy_wise_booking;
public $is_occupnacy_provided;
/**
* @see ObjectModel::$definition
@@ -249,7 +249,7 @@ class OrderCore extends ObjectModel
'reference' => array('type' => self::TYPE_STRING),
'is_advance_payment' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'default' => 0),
'advance_paid_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'occupnacy_wise_booking' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'default' => 0),
'is_occupnacy_provided' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'default' => 0),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
),

View File

@@ -265,7 +265,7 @@ class AdminOrdersControllerCore extends AdminController
'title' => array($this->l('Orders'), $this->l('Create order')),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'occupancy_wise_booking' => Configuration::get('PS_BACKOFFICE_OCCUPANCY_WISE_BOOKING'),
'occupancy_required_for_booking' => Configuration::get('PS_BACKOFFICE_OCCUPANCY_REQUIRED_FOR_BOOKING'),
'occupancy_wise_search' => $occupancyWiseSearch
));
$this->content .= $this->createTemplate('form.tpl')->fetch();
@@ -1792,7 +1792,7 @@ class AdminOrdersControllerCore extends AdminController
'error' => Tools::displayError('Check out Date Should be after Check In date.'),
)));
}
if ($order->occupnacy_wise_booking) {
if ($order->is_occupnacy_provided) {
if ($occupancy) {
foreach($occupancy as $key =>$roomOccupancy) {
if (!Validate::isUnsignedInt($roomOccupancy['adult'])) {
@@ -1952,7 +1952,7 @@ class AdminOrdersControllerCore extends AdminController
$objCartBookingData->date_from = $date_from;
$objCartBookingData->date_to = $date_to;
if ($order->occupnacy_wise_booking) {
if ($order->is_occupnacy_provided) {
$room_occupancy = array_shift($occupancy);
$objCartBookingData->adult = $room_occupancy['adult'];
$objCartBookingData->children = $room_occupancy['children'];

View File

@@ -139,7 +139,7 @@ class AdminPPreferencesControllerCore extends AdminController
),
'identifier' => 'id'
),
'PS_FRONT_OCCUPANCY_WISE_BOOKING' => array(
'PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING' => array(
'title' => $this->l('Front end occupancy required for booking'),
'hint' => $this->l('Select occupancy is required for booking a room for frontend. When enabled occupancy field will be shown in the booking form.'),
'cast' => 'intval',
@@ -169,7 +169,7 @@ class AdminPPreferencesControllerCore extends AdminController
'identifier' => 'id',
'desc' => $this->l('This option is only for fully available rooms. For partially available rooms, always all possible rooms will be displayed.'),
),
'PS_BACKOFFICE_OCCUPANCY_WISE_BOOKING' => array(
'PS_BACKOFFICE_OCCUPANCY_REQUIRED_FOR_BOOKING' => array(
'title' => $this->l('Back-office occupancy required for booking'),
'hint' => $this->l('Select occupancy is required for booking a room for frontend. When enabled occupancy field will be shown in the booking form.'),
'cast' => 'intval',

View File

@@ -270,7 +270,7 @@ class CartControllerCore extends FrontController
$date_to = date("Y-m-d", strtotime($date_to));
if ($occupancy = json_decode(Tools::getValue('occupancy'), true)) {
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$this->qty = count($occupancy);
} else {
$this->qty = $occupancy;
@@ -293,7 +293,7 @@ class CartControllerCore extends FrontController
}
// valdiate occupancy if providede
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
foreach($occupancy as $key =>$roomOccupancy) {
if (!isset($roomOccupancy['adult']) || !$roomOccupancy['adult'] || !Validate::isUnsignedInt($roomOccupancy['adult'])) {
$this->errors[] = sprintf(Tools::displayError('Invalid number of adults for Room %s.'), ($key + 1));
@@ -337,7 +337,7 @@ class CartControllerCore extends FrontController
$this->errors[] = Tools::displayError('You can\'t book room after date '.$maxOrdDate);
}
}
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
foreach($occupancy as $key =>$roomOccupancy) {
if ($roomOccupancy['adult'] > $roomTypeInfo['max_adults']) {
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have adults more than %s'), $key + 1, $roomTypeInfo['max_adults']);

View File

@@ -536,7 +536,7 @@ class ProductControllerCore extends FrontController
'id_cart' => $idCart,
'id_guest' => $idGuest,
);
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$quantity = count($occupancy);
} else {
$quantity = $occupancy;

View File

@@ -1138,7 +1138,7 @@ CREATE TABLE `PREFIX_orders` (
`valid` int(1) unsigned NOT NULL DEFAULT '0',
`is_advance_payment` tinyint(1) NOT NULL DEFAULT '0',
`advance_paid_amount` decimal(20,6) NOT NULL DEFAULT '0.00',
`occupnacy_wise_booking` tinyint(1) NOT NULL DEFAULT '0',
`is_occupnacy_provided` tinyint(1) NOT NULL DEFAULT '0',
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_order`),

View File

@@ -1232,7 +1232,7 @@ function getRoomsExtraDemands()
function getBookingOccupancyDetails(bookingform)
{
let occupancy;
if (occupancy_wise_booking) {
if (occupancy_required_for_booking) {
let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected")
if (selected_occupancy.length) {
occupancy = [];

View File

@@ -266,7 +266,7 @@
<span id="layer_cart_product_time_duration"></span>
</div>
<div>
<strong class="dark">{if isset($occupancy_wise_booking) && $occupancy_wise_booking}{l s='Room occupancy' mod='blockcart'}{else}{l s='Rooms Quantity Added' mod='blockcart'}{/if} &nbsp;-&nbsp;</strong>
<strong class="dark">{if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}{l s='Room occupancy' mod='blockcart'}{else}{l s='Rooms Quantity Added' mod='blockcart'}{/if} &nbsp;-&nbsp;</strong>
<span id="layer_cart_product_quantity"></span>
</div>
<div>

View File

@@ -448,7 +448,7 @@ class HotelCartBookingData extends ObjectModel
) {
$chkQty = 0;
$num_days = HotelHelper::getNumberOfDays($date_from, $date_to);
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$roomsRequired = count($occupancy);
} else {
$objRoomType = new HotelRoomType();
@@ -472,7 +472,7 @@ class HotelCartBookingData extends ObjectModel
$obj_htl_cart_booking_data->extra_demands = $roomDemand;
$obj_htl_cart_booking_data->date_from = $date_from;
$obj_htl_cart_booking_data->date_to = $date_to;
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$room_occupancy = array_shift($occupancy);
$obj_htl_cart_booking_data->adult = $room_occupancy['adult'];
$obj_htl_cart_booking_data->children = $room_occupancy['children'];
@@ -537,7 +537,7 @@ class HotelCartBookingData extends ObjectModel
'id_guest' => $id_guest,
);
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$roomsRequired = count($occupancy);
} else {
$roomsRequired = $occupancy;

View File

@@ -254,10 +254,10 @@ class HotelHelper
// Search Fields
Configuration::updateValue('PS_FRONT_SEARCH_TYPE', HotelBookingDetail::SEARCH_TYPE_OWS);
Configuration::updateValue('PS_FRONT_OWS_SEARCH_ALGO_TYPE', HotelBookingDetail::SEARCH_EXACT_ROOM_TYPE_ALGO);
Configuration::updateValue('PS_FRONT_OCCUPANCY_WISE_BOOKING', true);
Configuration::updateValue('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING', true);
Configuration::updateValue('PS_BACKOFFICE_SEARCH_TYPE', HotelBookingDetail::SEARCH_TYPE_OWS);
Configuration::updateValue('PS_BACKOFFICE_OWS_SEARCH_ALGO_TYPE', HotelBookingDetail::SEARCH_ALL_ROOM_TYPE_ALGO);
Configuration::updateValue('PS_BACKOFFICE_OCCUPANCY_WISE_BOOKING', true);
Configuration::updateValue('PS_BACKOFFICE_OCCUPANCY_REQUIRED_FOR_BOOKING', true);
return true;
}

View File

@@ -295,7 +295,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
);
$this->tpl_view_vars['occupancy_wise_booking'] = Configuration::get('PS_BACKOFFICE_OCCUPANCY_WISE_BOOKING');
$this->tpl_view_vars['occupancy_required_for_booking'] = Configuration::get('PS_BACKOFFICE_OCCUPANCY_REQUIRED_FOR_BOOKING');
if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS ) {
$this->tpl_view_vars['occupancy_adults'] = array_sum(array_column($occupancy, 'adult'));
@@ -375,7 +375,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$obj_cart_book_data = new HotelCartBookingData();
$total_amount = $this->context->cart->getOrderTotal();
if ($opt) {
if (!Configuration::get('PS_BACKOFFICE_OCCUPANCY_WISE_BOOKING')) {
if (!Configuration::get('PS_BACKOFFICE_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$objRoomType = new HotelRoomType();
$roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($id_product);
}
@@ -390,7 +390,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$obj_cart_book_data->comment = $comment;
$obj_cart_book_data->date_from = $date_from;
$obj_cart_book_data->date_to = $date_to;
if (Configuration::get('PS_BACKOFFICE_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_BACKOFFICE_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
$room_occupancy = array_shift($occupancy);
$obj_cart_book_data->adult = $room_occupancy['adult'];
$obj_cart_book_data->children = $room_occupancy['children'];

View File

@@ -664,7 +664,7 @@ $(document).ready(function() {
function getBookingOccupancyDetails(bookingform)
{
let occupancy;
if (occupancy_wise_booking) {
if (occupancy_required_for_booking) {
let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected")
if (selected_occupancy.length) {
occupancy = [];

View File

@@ -312,7 +312,7 @@
<th><span class="title_box">{l s='Duration' mod='hotelreservationsystem'}</span></th>
<th><span class="title_box">{l s='Message' mod='hotelreservationsystem'}</span></th>
<th><span class="title_box">{l s='Allotment Type' mod='hotelreservationsystem'}</span></th>
{if $occupancy_wise_booking}
{if $occupancy_required_for_booking}
<th class="fixed-width-xxl"><span class="title_box">{l s='Guests' mod='hotelreservationsystem'}</span></th>
{/if}
<th class="text-right"><span class="title_box">{l s='Action' mod='hotelreservationsystem'}</span></th>
@@ -333,7 +333,7 @@
{/foreach}
<input type="text" id="comment_{$avai_v['id_room']|escape:'htmlall':'UTF-8'}" class="form-control avai_comment" placeholder="{l s='Allotment message' mod='hotelreservationsystem'}">
</td>
{if $occupancy_wise_booking}
{if $occupancy_required_for_booking}
<td class="booking_occupancy">
<div class="dropdown">
<button class="btn btn-default btn-left btn-block booking_guest_occupancy input-occupancy" type="button">
@@ -395,7 +395,7 @@
<th class="text-center"><span class="title_box">{l s='Duration' mod='hotelreservationsystem'}</span></th>
<th><span class="title_box">{l s='Room No.' mod='hotelreservationsystem'}</span></th>
<th class="text-left"><span class="title_box">{l s='Allotment Type' mod='hotelreservationsystem'}</span></th>
{if $occupancy_wise_booking}
{if $occupancy_required_for_booking}
<th class="fixed-width-xxl"><span class="title_box">{l s='Guests' mod='hotelreservationsystem'}</span></th>
{/if}
<th class="text-center"><span class="title_box">{l s='Action' mod='hotelreservationsystem'}</span></th>
@@ -423,7 +423,7 @@
{/foreach}
<input type="text" id="comment_{$sub_part_v['id_room']|escape:'htmlall':'UTF-8'}_{$sub_part_k|escape:'htmlall':'UTF-8'}" class="form-control par_comment" placeholder="{l s='Allotment message' mod='hotelreservationsystem'}">
</td>
{if $occupancy_wise_booking}
{if $occupancy_required_for_booking}
<td class="booking_occupancy">
<div class="dropdown">
<button class="btn btn-default btn-left btn-block booking_guest_occupancy input-occupancy" type="button">
@@ -733,7 +733,7 @@
{addJsDef max_child_age=$max_child_age}
{addJsDef max_child_in_room=$max_child_in_room}
{addJsDef occupancy_wise_search=$occupancy_wise_search|boolval}
{addJsDef occupancy_wise_booking=$occupancy_wise_booking|boolval}
{addJsDef occupancy_required_for_booking=$occupancy_required_for_booking|boolval}
{addJsDefL name='select_age_txt'}{l s='Select age' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name='under_1_age'}{l s='Under 1' js=1 mod='hotelreservationsystem'}{/addJsDefL}

View File

@@ -163,7 +163,7 @@ class WkRoomSearchBlock extends Module
$maxOrderDate = Tools::getValue('max_order_date');
$maxOrderDate = date('Y-m-d', strtotime($maxOrderDate));
if (Configuration::get('PS_FRONT_OCCUPANCY_WISE_BOOKING')) {
if (Configuration::get('PS_FRONT_OCCUPANCY_REQUIRED_FOR_BOOKING')) {
if ($occupancy = Tools::getValue('occupancy')) {
$urlData['occupancy'] = $occupancy;
}

View File

@@ -35,7 +35,7 @@
{if $total_available_rooms > 0}
<div class="row">
<div class="form-group col-sm-12"{if !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
{if isset($occupancy_wise_booking) && $occupancy_wise_booking}
{if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}
<label class="control-label">{l s='Guests'}</label>
{include file="./occupancy_field.tpl"}
{else}

View File

@@ -56,7 +56,7 @@
<div class="col-sm-12 col-md-8 col-lg-9">
<div class="booking_room_fields">
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
{if isset($occupancy_wise_booking) && $occupancy_wise_booking}
{if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}
<div class="booking_guest_occupancy_conatiner">
{include file="./occupancy_field.tpl" room_type_info=$room_v total_available_rooms=$room_v['room_left']}
</div>

View File

@@ -1232,7 +1232,7 @@ function getRoomsExtraDemands()
function getBookingOccupancyDetails(bookingform)
{
let occupancy;
if (occupancy_wise_booking) {
if (occupancy_required_for_booking) {
let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected")
if (selected_occupancy.length) {
occupancy = [];

View File

@@ -1293,7 +1293,7 @@ function getBookingOccupancy()
{
let bookingform = $("#booking-form");
let occupancy;
if (occupancy_wise_booking) {
if (occupancy_required_for_booking) {
let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected")
if (selected_occupancy.length) {
occupancy = [];

View File

@@ -266,7 +266,7 @@
<span id="layer_cart_product_time_duration"></span>
</div>
<div>
<strong class="dark">{if isset($occupancy_wise_booking) && $occupancy_wise_booking}{l s='Room occupancy' mod='blockcart'}{else}{l s='Rooms Quantity Added' mod='blockcart'}{/if} &nbsp;-&nbsp;</strong>
<strong class="dark">{if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}{l s='Room occupancy' mod='blockcart'}{else}{l s='Rooms Quantity Added' mod='blockcart'}{/if} &nbsp;-&nbsp;</strong>
<span id="layer_cart_product_quantity"></span>
</div>
<div>