Skip to content

Commit

Permalink
updated occupancy vars name
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreesh Arora committed Jan 19, 2023
1 parent 72943a5 commit 1920b0f
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</td>

<td style="display:none;" class="productQuantity text-center" colspan="2">
{if $order->is_occupnacy_provided}
{if $order->with_occupancy}
<div class="booking_occupancy">
<div class="dropdown">
<button class="booking_guest_occupancy btn btn-default btn-left btn-block input-occupancy disabled" type="button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
{/if}
</td>
<td class="text-center">
{if $order->is_occupnacy_provided && $data['children']}
{if $order->with_occupancy && $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['adults']}{$data['adults']}{/if} {if $data['adults'] > 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>
Expand All @@ -98,7 +98,7 @@
{else}
<span class="booking_occupancy_show">{if $data['adults']}{$data['adults']}{/if} {if $data['adults'] > 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->is_occupnacy_provided}
{if $order->with_occupancy}
<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">
Expand Down
10 changes: 5 additions & 5 deletions classes/PaymentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,15 @@ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_
}

if ($this->name == 'wsorder') {
$order->is_occupnacy_provided = 0;
$order->with_occupancy = 0;
} else {
if (defined('_PS_ADMIN_DIR_')) {
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
$order->is_occupnacy_provided = 1;
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$order->with_occupancy = 1;
}
} else {
if (Configuration::get('PS_FRONT_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
$order->is_occupnacy_provided = 1;
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$order->with_occupancy = 1;
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions classes/controller/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,14 @@ public function init()
$compared_products = CompareProduct::getCompareProducts($this->context->cookie->id_compare);
}

$occupancyWiseSearch = false;
$isOccupancyWiseSearch = false;
if (Configuration::get('PS_FRONT_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
$occupancyWiseSearch = true;
$isOccupancyWiseSearch = true;
}

$bookingTypeOccupancy = false;
if (Configuration::get('PS_FRONT_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
$bookingTypeOccupancy = true;
$occupancyRequiredForBooking = false;
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$occupancyRequiredForBooking = true;
}
$this->context->smarty->assign(array(
// Useful for layout.tpl
Expand Down Expand Up @@ -491,8 +491,8 @@ public function init()
'currencySign' => $currency->sign, // backward compat, see global.tpl
'currencyFormat' => $currency->format, // backward compat
'currencyBlank' => $currency->blank, // backward compat
'occupancy_wise_search' => $occupancyWiseSearch,
'occupancy_required_for_booking' => $bookingTypeOccupancy,
'is_occupancy_wise_search' => $isOccupancyWiseSearch,
'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'),
));
Expand Down
4 changes: 2 additions & 2 deletions classes/order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class OrderCore extends ObjectModel
/**
* @var int is occupancy provided in this order
*/
public $is_occupnacy_provided;
public $with_occupancy;

/**
* @see ObjectModel::$definition
Expand Down Expand Up @@ -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'),
'is_occupnacy_provided' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'default' => 0),
'with_occupancy' => 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'),
),
Expand Down
16 changes: 8 additions & 8 deletions controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ public function renderForm()
$payment_modules[] = Module::getInstanceById((int)$p_module['id_module']);
}

$bookingTypeOccupancy = false;
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
$bookingTypeOccupancy = true;
$occupancyRequiredForBooking = false;
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$occupancyRequiredForBooking = true;
}

$this->context->smarty->assign(array(
Expand All @@ -267,7 +267,7 @@ public function renderForm()
'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_required_for_booking' => $bookingTypeOccupancy,
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
));
$this->content .= $this->createTemplate('form.tpl')->fetch();
}
Expand Down Expand Up @@ -1856,7 +1856,7 @@ public function ajaxProcessAddProductOnOrder()
'error' => Tools::displayError('Check out Date Should be after Check In date.'),
)));
}
if ($order->is_occupnacy_provided) {
if ($order->with_occupancy) {
if ($occupancy) {
foreach($occupancy as $key =>$roomOccupancy) {
if (!$roomOccupancy['adults'] || !Validate::isUnsignedInt($roomOccupancy['adults'])) {
Expand Down Expand Up @@ -1902,7 +1902,7 @@ public function ajaxProcessAddProductOnOrder()
}


if ($order->is_occupnacy_provided) {
if ($order->with_occupancy) {
$req_rm = count($occupancy);
} else {
$req_rm = $product_informations['product_quantity'];
Expand Down Expand Up @@ -1999,7 +1999,7 @@ public function ajaxProcessAddProductOnOrder()
$this->context->cart = $cart;
$this->context->customer = new Customer($order->id_customer);

if ($order->is_occupnacy_provided) {
if ($order->with_occupancy) {
$objRoomType = new HotelRoomType();
$roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($id_product);
}
Expand All @@ -2022,7 +2022,7 @@ public function ajaxProcessAddProductOnOrder()
$objCartBookingData->date_from = $date_from;
$objCartBookingData->date_to = $date_to;

if ($order->is_occupnacy_provided) {
if ($order->with_occupancy) {
$room_occupancy = array_shift($occupancy);
$objCartBookingData->adults = $room_occupancy['adults'];
$objCartBookingData->children = $room_occupancy['children'];
Expand Down
14 changes: 7 additions & 7 deletions controllers/admin/AdminPPreferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ public function __construct()
'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_FRONT_ROOM_BOOKING_TYPE' => array(
'PS_FRONT_ROOM_UNIT_SELECTION_TYPE' => array(
'title' => $this->l('In front-end, add rooms to cart with'),
'hint' => $this->l('In Room occupancy, while adding rooms in cart customer has to select per room occupancy and in room quantity customer only has to select number of rooms.'),
'cast' => 'intval',
'type' => 'select',
'list' => array(
array('id' => HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE, 'name' => $this->l('Room Occupancy')),
array('id' => HotelBookingDetail::ROOM_BOOKING_QUANTITY_WISE, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')),
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
),
'identifier' => 'id',
),
Expand Down Expand Up @@ -181,8 +181,8 @@ public function __construct()
'cast' => 'intval',
'type' => 'select',
'list' => array(
array('id' => HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE, 'name' => $this->l('Room Occupancy')),
array('id' => HotelBookingDetail::ROOM_BOOKING_QUANTITY_WISE, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')),
array('id' => HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)'))
),
'identifier' => 'id',
),
Expand Down Expand Up @@ -433,11 +433,11 @@ public function beforeUpdateOptions()
}

if (Tools::getValue('PS_FRONT_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
$_POST['PS_FRONT_ROOM_BOOKING_TYPE'] = HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE;
$_POST['PS_FRONT_ROOM_UNIT_SELECTION_TYPE'] = HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY;
}

if (Tools::getValue('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
$_POST['PS_BACKOFFICE_ROOM_BOOKING_TYPE'] = HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE;
$_POST['PS_BACKOFFICE_ROOM_BOOKING_TYPE'] = HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY;
}

if (Tools::getIsset('PS_CATALOG_MODE')) {
Expand Down
12 changes: 6 additions & 6 deletions controllers/front/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ protected function processChangeProductInCart()
$date_to = date("Y-m-d", strtotime($date_to));
$operator = Tools::getValue('op', 'up');

$bookingTypeOccupancy = false;
if (Configuration::get('PS_FRONT_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
$bookingTypeOccupancy = true;
$occupancyRequiredForBooking = false;
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$occupancyRequiredForBooking = true;
}

if ($bookingTypeOccupancy) {
if ($occupancyRequiredForBooking) {
if ($occupancy = json_decode(Tools::getValue('occupancy'), true)) {
$this->qty = count($occupancy);
} else {
Expand Down Expand Up @@ -303,7 +303,7 @@ protected function processChangeProductInCart()

// valdiate occupancy if providede
if ($operator == 'up') {
if ($bookingTypeOccupancy) {
if ($occupancyRequiredForBooking) {
foreach($occupancy as $key => $roomOccupancy) {
if (!isset($roomOccupancy['adults']) || !$roomOccupancy['adults'] || !Validate::isUnsignedInt($roomOccupancy['adults'])) {
$this->errors[] = sprintf(Tools::displayError('Invalid number of adults for Room %s.'), ($key + 1));
Expand Down Expand Up @@ -348,7 +348,7 @@ protected function processChangeProductInCart()
$this->errors[] = Tools::displayError('You can\'t book room after date '.$maxOrdDate);
}
}
if ($bookingTypeOccupancy) {
if ($occupancyRequiredForBooking) {
foreach($occupancy as $key => $roomOccupancy) {
if ($roomOccupancy['adults'] > $roomTypeInfo['max_adults']) {
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have adults more than %s'), $key + 1, $roomTypeInfo['max_adults']);
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public function assignBookingFormVars(
'id_cart' => $idCart,
'id_guest' => $idGuest,
);
if (Configuration::get('PS_FRONT_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$bookingParams['occupancy'] = $occupancy;
$quantity = count($occupancy);
} else {
Expand Down
2 changes: 1 addition & 1 deletion install/data/db_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,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',
`is_occupnacy_provided` tinyint(1) NOT NULL DEFAULT '0',
`with_occupancy` tinyint(1) NOT NULL DEFAULT '0',
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_order`),
Expand Down
4 changes: 2 additions & 2 deletions js/admin/ppreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ $(document).ready(function() {
{
if ($('#PS_FRONT_SEARCH_TYPE').val() == SEARCH_TYPE_OWS) {
$('#PS_FRONT_OWS_SEARCH_ALGO_TYPE').closest('.form-group').show('fast');
$('#PS_FRONT_ROOM_BOOKING_TYPE').closest('.form-group').hide('fast');
$('#PS_FRONT_ROOM_UNIT_SELECTION_TYPE').closest('.form-group').hide('fast');
} else {
$('#PS_FRONT_OWS_SEARCH_ALGO_TYPE').closest('.form-group').hide('fast');
$('#PS_FRONT_ROOM_BOOKING_TYPE').closest('.form-group').show('fast');
$('#PS_FRONT_ROOM_UNIT_SELECTION_TYPE').closest('.form-group').show('fast');
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/hotelreservationsystem/classes/HotelBookingDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class HotelBookingDetail extends ObjectModel
const SEARCH_TYPE_NORMAL = 2;

//
const ROOM_BOOKING_OCCUPANCY_WISE = 1;
const ROOM_BOOKING_QUANTITY_WISE = 2;
const PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY = 1;
const PS_FRONT_ROOM_UNIT_SELECTION_TYPE_QUANTITY = 2;

public static $definition = array(
'table' => 'htl_booking_detail',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public function addCartBookingData(
) {
$chkQty = 0;
$num_days = HotelHelper::getNumberOfDays($date_from, $date_to);
if (Configuration::get('PS_FRONT_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$roomsRequired = count($occupancy);
} else {
$objRoomType = new HotelRoomType();
Expand All @@ -468,7 +468,7 @@ public function addCartBookingData(
$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_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$room_occupancy = array_shift($occupancy);
$obj_htl_cart_booking_data->adults = $room_occupancy['adults'];
$obj_htl_cart_booking_data->children = $room_occupancy['children'];
Expand Down Expand Up @@ -533,7 +533,7 @@ public function updateRoomCartBookingData(
'id_guest' => $id_guest,
);

if (Configuration::get('PS_FRONT_ROOM_BOOKING_TYPE') == HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE) {
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
$roomsRequired = count($occupancy);
} else {
$roomsRequired = $occupancy;
Expand Down
4 changes: 2 additions & 2 deletions modules/hotelreservationsystem/classes/HotelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ public function insertDefaultHotelEntries()
// 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_ROOM_BOOKING_TYPE', HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE);
Configuration::updateValue('PS_FRONT_ROOM_UNIT_SELECTION_TYPE', HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY);
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_ROOM_BOOKING_TYPE', HotelBookingDetail::ROOM_BOOKING_OCCUPANCY_WISE);
Configuration::updateValue('PS_BACKOFFICE_ROOM_BOOKING_TYPE', HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY);

return true;
}
Expand Down
Loading

0 comments on commit 1920b0f

Please sign in to comment.