Added: No Show and Cancellation as new booking statuses

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
varun kewlani
2026-07-17 18:11:46 +05:30
parent 5b4d65cbb8
commit 92e543fc22
53 changed files with 888 additions and 55 deletions

View File

@@ -104,6 +104,8 @@
<th>{l s='Check-In'}</th>
<th>{l s='Check-Out'}</th>
<th>{l s='Allotment'}</th>
<th>{l s='Room status'}</th>
<th>{l s='Refund'}</th>
<th>{l s='Action'}</th>
</tr>
</thead>
@@ -140,12 +142,26 @@
{l s='Auto'}
{/if}
</td>
<td>
{if isset($htl_booking_statuses[$data.id_status])}
<span class="badge" style="background-color:{$htl_booking_statuses[$data.id_status].color|escape:'html':'UTF-8'}">{$htl_booking_statuses[$data.id_status].name|escape:'html':'UTF-8'}</span>
{/if}
</td>
<td>
{if $data.refund_count}
{displayPrice price=$data.refund_amount currency=$currency->id} ({$data.refund_count})
{else}
--
{/if}
</td>
<td>
<a title="{l s='Upload/Check guest documents'}" class="btn btn-default" href="#" onclick="BookingDocumentsModal.init({$data.id|intval}, this); return false;">
<span class="badge badge-info">{if $data.num_checkin_documents > 0}{$data.num_checkin_documents}{else}0{/if}</span> <i class="icon-file-text"></i>
</a>
{if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded}
{if $data.id_status == $ROOM_STATUS_NO_SHOW || $data.id_status == $ROOM_STATUS_CANCELLED}
<span class="badge badge-danger">{if $data.id_status == $ROOM_STATUS_NO_SHOW}{l s='No-show'}{else}{l s='Cancelled'}{/if}</span>
{elseif isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded}
<span class="badge badge-danger">{if $data.is_cancelled}{l s='Cancelled'}{else}{l s='Refunded'}{/if}</span>
{elseif $can_edit}
<a class="open_room_status_form btn btn-default" href="#" data-id_hotel_booking_detail="{$data['id']}" data-id_order="{$data['id_order']}" data-id_status="{$data['id_status']}" data-id_room="{$data['id_room']}" data-date_from="{$data['date_from']|date_format:"%Y-%m-%d"}" data-date_to="{$data['date_to']|date_format:"%Y-%m-%d"}" data-check_in_time="{$data['check_in_time']}" data-check_out_time="{$data['check_out_time']}" data-check_in="{$data['check_in']}" data-check_out="{$data['check_out']}">
@@ -1367,9 +1383,12 @@
{addJsDefL name='no_children_allowed_txt'}{l s='Only adults can be accommodated' js=1}{/addJsDefL}
{addJsDefL name='invalid_occupancy_txt'}{l s='Invalid occupancy(adults/children) found.' js=1}{/addJsDefL}
{addJsDefL name='select_room_txt'}{l s='Select room' js=1}{/addJsDefL}
{addJsDefL name='room_status_sealed_warning_txt'}{l s='Are you sure? You cannot change the booking status after this.' js=1}{/addJsDefL}
{addJsDef max_child_age=$max_child_age|escape:'quotes':'UTF-8'}
{addJsDef ROOM_STATUS_CHECKED_IN=$ROOM_STATUS_CHECKED_IN|escape:'quotes':'UTF-8'}
{addJsDef ROOM_STATUS_CHECKED_OUT=$ROOM_STATUS_CHECKED_OUT|escape:'quotes':'UTF-8'}
{addJsDef ROOM_STATUS_NO_SHOW=$ROOM_STATUS_NO_SHOW|escape:'quotes':'UTF-8'}
{addJsDef ROOM_STATUS_CANCELLED=$ROOM_STATUS_CANCELLED|escape:'quotes':'UTF-8'}
{addJsDef ALLOTMENT_MANUAL=$ALLOTMENT_MANUAL|escape:'quotes':'UTF-8'}
{addJsDef PS_OS_CANCELED=Configuration::get('PS_OS_CANCELED')|escape:'quotes':'UTF-8'}
{addJsDef PS_OS_REFUND=Configuration::get('PS_OS_REFUND')|escape:'quotes':'UTF-8'}

View File

@@ -31,7 +31,7 @@
<input type="hidden" name="product_price_tax_excl" value="{Tools::ps_round($data.original_unit_price_tax_excl, _PS_PRICE_COMPUTE_PRECISION_)}" />
<input type="hidden" name="product_price_tax_incl" value="{Tools::ps_round($data.original_unit_price_tax_incl, _PS_PRICE_COMPUTE_PRECISION_)}" />
{if isset($data.id_status) && ($data.id_status != HotelBookingDetail::STATUS_ALLOTED)}
{if isset($data.id_status) && ($data.id_status != HotelBookingDetail::STATUS_ASSIGNED)}
<div class="alert alert-info">
{if $data.id_status == HotelBookingDetail::STATUS_CHECKED_IN}
{l s='The check-in date cannot be changed as the booking has already been checked in.'}
@@ -49,7 +49,7 @@
{if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded}
{dateFormat date=$data.date_from}
{else}
<input type="text" class="form-control edit_product_date_from" readonly {if isset($data.id_status) && ($data.id_status != HotelBookingDetail::STATUS_ALLOTED)}disabled{/if}/>
<input type="text" class="form-control edit_product_date_from" readonly {if isset($data.id_status) && ($data.id_status != HotelBookingDetail::STATUS_ASSIGNED)}disabled{/if}/>
<div class="input-group-addon"><i class="icon-calendar"></i></div>
{/if}
</div>

View File

@@ -30,7 +30,7 @@
{/foreach}
</select>
</div>
<div class="form-group" {if $current_room_status == $ROOM_STATUS_ALLOTED}style="display:none;"{/if}>
<div class="form-group" {if $current_room_status == $ROOM_STATUS_ASSIGNED}style="display:none;"{/if}>
<label class="control-label">{l s='Date'}</label>
<div class="input-group">
<input type="text" name="status_date" class="room_status_date wk-input-date" value="" />
@@ -46,6 +46,11 @@
<input type="hidden" id="room_status_id_order" name="id_order" />
</div>
<div class="form-group">
<label class="control-label">{l s='Note'}</label>
<textarea name="status_remark" class="form-control" rows="2" required="required"></textarea>
</div>
<button class="btn btn-primary" type="submit" name="submitbookingOrderStatus" style="display:none" id="submitbookingOrderStatus"></button>
</form>

View File

@@ -45,6 +45,7 @@ class OrderCore extends ObjectModel
const ORDER_COMPLETE_REFUND_FLAG = 1;
const ORDER_COMPLETE_CANCELLATION_FLAG = 2;
const ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG = 3;
const ORDER_COMPLETE_NOSHOW_FLAG = 4;
/** @var int Delivery address id */
public $id_address_delivery;
@@ -2924,6 +2925,28 @@ class OrderCore extends ObjectModel
if (count($uniqueRefunded) == 1 && $uniqueRefunded[0] == 1) {
return true;
}
// If action is Order::ORDER_COMPLETE_NOSHOW_FLAG then we check every room is
// No-show — no mixing with Cancelled. A mixed order (some No-show, some
// Cancelled) matches neither this flag nor ORDER_COMPLETE_CANCELLATION_FLAG,
// same all-or-nothing strictness that flag already uses.
} elseif ($action == Order::ORDER_COMPLETE_NOSHOW_FLAG) {
if (empty($list)) {
return false;
}
foreach ($list as $product) {
if (isset($product['id_status'])) {
// room booking row
if ($product['id_status'] != HotelBookingDetail::STATUS_NO_SHOW) {
return false;
}
} elseif (!$product['is_cancelled']) {
// service products can't be "no-show" — just require them to
// already be resolved, same bar as ORDER_COMPLETE_CANCELLATION_FLAG
return false;
}
}
return true;
// If action is Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG (for cancelled and refund requests) then we will check that all rooms are either cancelled or requested for refund
} elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG) {
foreach ($list as $product) {
@@ -2956,7 +2979,7 @@ class OrderCore extends ObjectModel
foreach ($list as $product) {
if ($product['is_refunded'] == 0
&& !OrderReturn::getOrdersReturnDetail($this->id, 0, isset($product['id']) ? $product['id'] : 0)
&& $product['id_status'] == HotelBookingDetail::STATUS_ALLOTED
&& $product['id_status'] == HotelBookingDetail::STATUS_ASSIGNED
) {
return false;
}
@@ -2971,7 +2994,12 @@ class OrderCore extends ObjectModel
public function getOrderCompleteRefundStatus()
{
$idOrderState = 0;
if ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) {
// checked first, on purpose: a paid No-show room that's been approved ends up with
// is_refunded=1 and is_cancelled=0 (same shape ORDER_COMPLETE_REFUND_FLAG looks for),
// so No-show has to win the race or a fully no-show order would wrongly become "Refunded"
if ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_NOSHOW_FLAG)) {
$idOrderState = Configuration::get('PS_OS_NO_SHOW');
} elseif ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) {
$idOrderState = Configuration::get('PS_OS_REFUND');
} elseif ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) {
$idOrderState = Configuration::get('PS_OS_CANCELED');

View File

@@ -57,6 +57,9 @@ class OrderReturnCore extends ObjectModel
/** @var int whether $id_return_type is cart_rule or order_slip */
public $return_type;
/** @var int why this refund request exists: EVENT_TYPE_CANCELLATION/_NO_SHOW/_REFUND */
public $event_type;
/** @var string Object creation date */
public $date_add;
@@ -67,6 +70,11 @@ class OrderReturnCore extends ObjectModel
const RETURN_TYPE_CART_RULE = 1;
const RETURN_TYPE_ORDER_SLIP = 2;
/** possible values for $event_type */
const EVENT_TYPE_CANCELLATION = 1;
const EVENT_TYPE_NO_SHOW = 2;
const EVENT_TYPE_REFUND = 3;
/**
* @see ObjectModel::$definition
*/
@@ -84,6 +92,7 @@ class OrderReturnCore extends ObjectModel
'by_admin' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_return_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'return_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'event_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
),
@@ -771,20 +780,36 @@ class OrderReturnCore extends ObjectModel
return false;
}
public function getRefundedAmount($idOrder, $idOrderReturn = 0, $idHtlBooking = 0)
/**
* @param int $idOrder
* @param int $idOrderReturn
* @param int $idHtlBooking
* @param bool $detailedInfo when true, also returns the number of refund
* requests (not just the refunded amount) — e.g. for the order
* detail page's per-room "Refund" column
* @return float|array plain refunded amount by default; array('amount', 'count') when $detailedInfo
*/
public function getRefundedAmount($idOrder, $idOrderReturn = 0, $idHtlBooking = 0, $detailedInfo = false)
{
$sql = 'SELECT SUM(ord.`refunded_amount`) FROM `'._DB_PREFIX_.'order_return_detail` ord';
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (orr.`id_order_return` = ord.`id_order_return`)';
$sql .= ' WHERE orr.`id_order` = '.(int)$idOrder;
$where = ' WHERE orr.`id_order` = '.(int) $idOrder;
if ($idOrderReturn) {
$sql .= ' AND ord.`id_order_return` = '.(int)$idOrderReturn;
$where .= ' AND ord.`id_order_return` = '.(int) $idOrderReturn;
}
if ($idHtlBooking) {
$sql .= ' AND ord.`id_htl_booking` = '.(int)$idHtlBooking;
$where .= ' AND ord.`id_htl_booking` = '.(int) $idHtlBooking;
}
$from = ' FROM `'._DB_PREFIX_.'order_return_detail` ord
LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (orr.`id_order_return` = ord.`id_order_return`)';
if ($detailedInfo) {
$sql = 'SELECT COUNT(ord.`id_order_return_detail`) AS count, SUM(ord.`refunded_amount`) AS amount'.$from.$where;
return Db::getInstance()->getRow($sql);
}
$sql = 'SELECT SUM(ord.`refunded_amount`) AS amount'.$from.$where;
return Db::getInstance()->getValue($sql);
}
}

View File

@@ -26,7 +26,7 @@
/* Debug only */
if (!defined('_PS_MODE_DEV_')) {
define('_PS_MODE_DEV_', false);
define('_PS_MODE_DEV_', true);
}
/* Compatibility warning */
define('_PS_DISPLAY_COMPATIBILITY_WARNING_', false);

View File

@@ -313,9 +313,11 @@ class AdminOrdersControllerCore extends AdminController
'displayed' => false,
'type' => 'select',
'list' => array(
HotelBookingDetail::STATUS_ALLOTED => $this->l('Alloted'),
HotelBookingDetail::STATUS_ASSIGNED => $this->l('Assigned'),
HotelBookingDetail::STATUS_CHECKED_IN => $this->l('Checked in'),
HotelBookingDetail::STATUS_CHECKED_OUT => $this->l('Checked out'),
HotelBookingDetail::STATUS_NO_SHOW => $this->l('No-show'),
HotelBookingDetail::STATUS_CANCELLED => $this->l('Cancelled'),
),
)
));
@@ -402,9 +404,7 @@ class AdminOrdersControllerCore extends AdminController
}
if ($this->tabAccess['edit'] === 1) {
if (((int) $order->isReturnable())
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0)
) {
if ((int) $order->isReturnable()) {
$orderTotalPaid = $order->getTotalPaid();
$orderDiscounts = $order->getCartRules();
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
@@ -784,13 +784,17 @@ class AdminOrdersControllerCore extends AdminController
// set modal details
$response['hasError'] = 1;
if (Validate::isLoadedObject($objOrder = new Order(Tools::getValue('id_order')))) {
$htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus();
$objHotelBookingStatus = new HotelBookingStatus();
$htlOrderStatus = $objHotelBookingStatus->getAllStatuses(
$this->context->language->id,
(int) Tools::getValue('current_room_status')
);
$this->context->smarty->assign(
array(
'order' => $objOrder,
'current_index' => self::$currentIndex,
'hotel_order_status' => $htlOrderStatus,
'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED,
'ROOM_STATUS_ASSIGNED' => HotelBookingDetail::STATUS_ASSIGNED,
'current_room_status' => Tools::getValue('current_room_status')
)
);
@@ -812,7 +816,7 @@ class AdminOrdersControllerCore extends AdminController
$this->context->smarty->assign($modal);
$response['hasError'] = 0;
$response['STATUS_ALLOTED'] = HotelBookingDetail::STATUS_ALLOTED;
$response['STATUS_ASSIGNED'] = HotelBookingDetail::STATUS_ASSIGNED;
$response['STATUS_CHECKED_IN'] = HotelBookingDetail::STATUS_CHECKED_IN;
$response['STATUS_CHECKED_OUT'] = HotelBookingDetail::STATUS_CHECKED_OUT;
$response['modalHtml'] = $this->context->smarty->fetch('modal.tpl');
@@ -1063,11 +1067,12 @@ class AdminOrdersControllerCore extends AdminController
$objBookingDetail = new HotelBookingDetail();
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
$objOrderReturn = new OrderReturn();
$refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1, 0, 1);
if ($bookingOrderInfo = $objBookingDetail->getBookingDataByOrderId($objOrder->id)) {
$objBookingDemand = new HotelBookingDemands();
foreach($bookingOrderInfo as $key => $booking) {
if ((in_array($booking['id'], $refundReqBookings)) || $booking['is_refunded']) {
// multiple refund requests are now allowed per booking — only still
// exclude a booking that's already fully refunded, not a re-request
if ($booking['is_refunded']) {
unset($bookingOrderInfo[$key]);
} else {
$bookingOrderInfo[$key]['total_price_tax_incl'] += $objBookingDemand->getRoomTypeBookingExtraDemands(
@@ -1495,7 +1500,7 @@ class AdminOrdersControllerCore extends AdminController
LEFT JOIN (
SELECT GROUP_CONCAT(
CASE
WHEN `id_status`='.HotelBookingDetail::STATUS_ALLOTED.' THEN \''.$this->l('Alloted').'\'
WHEN `id_status`='.HotelBookingDetail::STATUS_ASSIGNED.' THEN \''.$this->l('Assigned').'\'
WHEN `id_status`='.HotelBookingDetail::STATUS_CHECKED_IN.' THEN \''.$this->l('Checked in').'\'
WHEN `id_status`='.HotelBookingDetail::STATUS_CHECKED_OUT.' THEN \''.$this->l('Checked out').'\'
ELSE \''.$this->l('Invalid status').'\'
@@ -1916,10 +1921,11 @@ class AdminOrdersControllerCore extends AdminController
$objOrderReturn = new OrderReturn();
$bookings = Tools::getValue('id_htl_booking');
if ($bookings && count($bookings)) {
$refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($order->id, 0, 1, 0, 1);
// multiple refund requests are now allowed per booking — only still
// block a booking that's already fully refunded, not a re-request
foreach ($bookings as $idHtlBooking) {
$objBookingDetail = new HotelBookingDetail($idHtlBooking);
if ((in_array($idHtlBooking, $refundReqBookings)) || $objBookingDetail->is_refunded) {
if ($objBookingDetail->is_refunded) {
$this->errors[] = Tools::displayError('Wrong bookings found for cancelation.');
break;
}
@@ -1955,6 +1961,7 @@ class AdminOrdersControllerCore extends AdminController
$objOrderReturn->by_admin = 1;
$objOrderReturn->question = $refundReason;
$objOrderReturn->refunded_amount = 0;
$objOrderReturn->event_type = OrderReturn::EVENT_TYPE_REFUND;
$objOrderReturn->save();
if ($objOrderReturn->id) {
if ($bookings) {
@@ -3119,7 +3126,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->color = 'color1';
$helper->title = $this->l('Arrivals', null, null, false);
$helper->subtitle = $this->l('Today', null, null, false);
$helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_ALLOTED.'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d'));
$helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_ASSIGNED.'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d'));
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_arrivals';
$helper->tooltip = $this->l('Total number of arrivals for today.', null, null, false);
$this->kpis[] = $helper;
@@ -3642,6 +3649,18 @@ class AdminOrdersControllerCore extends AdminController
}
}
$bookingOrderRoomInfo['num_checkin_documents'] = HotelBookingDocument::getCountByIdHtlBooking($bookingOrderRoomInfo['id']);
$roomRefundInfo = $objOrderReturn->getRefundedAmount($bookingOrderRoomInfo['id_order'], 0, $bookingOrderRoomInfo['id'], true);
$bookingOrderRoomInfo['refund_amount'] = $roomRefundInfo['amount'];
$bookingOrderRoomInfo['refund_count'] = (int) $roomRefundInfo['count'];
}
unset($bookingOrderRoomInfo);
// catalog of the 5 booking statuses (id_booking_status => color/name), for the
// Rooms Booking Detail table's status badge
$htlBookingStatuses = array();
foreach ((new HotelBookingStatus())->getAllStatuses($this->context->language->id) as $htlBookingStatus) {
$htlBookingStatuses[$htlBookingStatus['id_status']] = $htlBookingStatus;
}
$objHotelBookingDetail = new HotelBookingDetail();
@@ -3724,6 +3743,7 @@ class AdminOrdersControllerCore extends AdminController
'totalRoomsCostTE' => $totalRoomsCostTE,
'total_room_tax' => $total_room_tax,
'htl_booking_order_data' => $bookingOrderInfo,
'htl_booking_statuses' => $htlBookingStatuses,
'hotel_order_status' => $htlOrderStatus,
'order_detail_data' => $order_detail_data,
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
@@ -3808,6 +3828,8 @@ class AdminOrdersControllerCore extends AdminController
'orderDocuments' => $order->getDocuments(),
'ROOM_STATUS_CHECKED_IN' => HotelBookingDetail::STATUS_CHECKED_IN,
'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT,
'ROOM_STATUS_NO_SHOW' => HotelBookingDetail::STATUS_NO_SHOW,
'ROOM_STATUS_CANCELLED' => HotelBookingDetail::STATUS_CANCELLED,
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
'order_convenience_fee_services' => $orderConvenienceFeeServices,
'page_header_toolbar_btn' => $this->page_header_toolbar_btn,
@@ -7007,7 +7029,7 @@ class AdminOrdersControllerCore extends AdminController
}
}
if ($objBookingDetail->id_status != HotelBookingDetail::STATUS_ALLOTED
if ($objBookingDetail->id_status != HotelBookingDetail::STATUS_ASSIGNED
&& strtotime($old_date_from) != strtotime($new_date_from)
) {
die(json_encode(array(
@@ -8804,6 +8826,7 @@ class AdminOrdersControllerCore extends AdminController
$idHotelBookingDetail = (int) Tools::getValue('id_hotel_booking_detail');
if (Validate::isLoadedObject($objHotelBookingDetail = new HotelBookingDetail($idHotelBookingDetail))) {
$newStatus = (int) Tools::getValue('booking_order_status');
$statusRemark = Tools::getValue('status_remark');
// date choosen for the status change
if ($statusDate = Tools::getValue('status_date')) {
$statusDate = date('Y-m-d H:i:s', strtotime($statusDate));
@@ -8823,6 +8846,12 @@ class AdminOrdersControllerCore extends AdminController
) {
$this->errors[] = Tools::displayError('Date should be between booking from date and to date.');
}
} elseif ($newStatus == HotelBookingDetail::STATUS_NO_SHOW && strtotime($dateFrom) > time()) {
$this->errors[] = Tools::displayError('Room cannot be marked as No-show before the booking\'s check-in date.');
}
if (!$statusRemark) {
$this->errors[] = Tools::displayError('Please enter a note for this status change.');
}
if ($objHotelBookingDetail->id_status == HotelBookingDetail::STATUS_CHECKED_OUT
@@ -8854,7 +8883,7 @@ class AdminOrdersControllerCore extends AdminController
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) {
$orderBookings = $objHotelBookingDetail->getOrderCurrentDataByOrderId(
$id_order,
array(HotelBookingDetail::STATUS_ALLOTED, HotelBookingDetail::STATUS_CHECKED_IN),
array(HotelBookingDetail::STATUS_ASSIGNED, HotelBookingDetail::STATUS_CHECKED_IN),
0,
0
);
@@ -8865,7 +8894,6 @@ class AdminOrdersControllerCore extends AdminController
if ($remainingCheckoutRooms == 1 && $newStatus == HotelBookingDetail::STATUS_CHECKED_OUT && $hasPendingBills) {
$this->errors[] = Tools::displayError('You cannot checkout the last room while there are pending bills for this order.');
} else {
$objHotelBookingDetail->id_status = $newStatus;
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN) {
$objHotelBookingDetail->check_in = $statusDate;
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) {
@@ -8874,17 +8902,91 @@ class AdminOrdersControllerCore extends AdminController
$objHotelBookingDetail->check_in = '';
$objHotelBookingDetail->check_out = '';
}
if ($objHotelBookingDetail->save()) {
Hook::exec(
'actionRoomBookingStatusUpdateAfter',
array(
'id_hotel_booking_detail' => $objHotelBookingDetail->id,
'id_order' => $objHotelBookingDetail->id_order,
'id_room' => $objHotelBookingDetail->id_room,
'date_from' => $objHotelBookingDetail->date_from,
'date_to' => $objHotelBookingDetail->date_to
)
$changeParams = array(
'id_employee' => (int) $this->context->employee->id,
'remark' => $statusRemark,
);
if ($newStatus == HotelBookingDetail::STATUS_CANCELLED || $newStatus == HotelBookingDetail::STATUS_NO_SHOW) {
// picking Cancelled/No-show also creates the matching refund
// request — unpaid: everything resolves immediately together;
// paid: room status stays as-is until the request is approved
// in Manage Order Refund Requests
$eventType = ($newStatus == HotelBookingDetail::STATUS_CANCELLED)
? OrderReturn::EVENT_TYPE_CANCELLATION
: OrderReturn::EVENT_TYPE_NO_SHOW;
$hasOrderDiscountOrPayment = ((float) $order->getTotalPaid() > 0 || $order->getCartRules()) ? true : false;
$objOrderReturn = new OrderReturn();
$objOrderReturn->id_customer = $order->id_customer;
$objOrderReturn->id_order = $order->id;
$objOrderReturn->state = 0;
$objOrderReturn->by_admin = 1;
$objOrderReturn->question = $statusRemark;
$objOrderReturn->refunded_amount = 0;
$objOrderReturn->event_type = $eventType;
$objOrderReturn->save();
$objOrderReturnDetail = new OrderReturnDetail();
$objOrderReturnDetail->id_order_return = $objOrderReturn->id;
$objOrderReturnDetail->id_order_detail = $objHotelBookingDetail->id_order_detail;
$objOrderReturnDetail->product_quantity = HotelHelper::getNumberOfDays(
$objHotelBookingDetail->date_from,
$objHotelBookingDetail->date_to
);
$objOrderReturnDetail->id_htl_booking = $objHotelBookingDetail->id;
$objOrderReturnDetail->refunded_amount = 0;
if (!$hasOrderDiscountOrPayment) {
$objOrderReturnDetail->id_customization = 1;
}
$objOrderReturnDetail->save();
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING'));
$statusChanged = false;
if (!$hasOrderDiscountOrPayment) {
$statusChanged = $objHotelBookingDetail->changeStatus($newStatus, $changeParams);
if ($statusChanged) {
$objHotelBookingDetail->processRefundInBookingTables();
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_REFUNDED'));
// if every room in the order is now No-show (or fully
// cancelled/refunded), bump the order's own status —
// same pattern already used by the initiateRefund handler
$order = new Order($order->id);
if ($idOrderState = $order->getOrderCompleteRefundStatus()) {
$objOrderHistory = new OrderHistory();
$objOrderHistory->id_order = (int) $order->id;
$useExistingPayment = !$order->hasInvoice();
$objOrderHistory->changeIdOrderState($idOrderState, $order, $useExistingPayment);
$objOrderHistory->addWithemail();
}
}
$success = $statusChanged;
} else {
// paid: request is Pending, room status doesn't change yet —
// nothing to announce via the room-status-update hook below
$success = true;
}
} else {
$statusChanged = $objHotelBookingDetail->changeStatus($newStatus, $changeParams);
$success = $statusChanged;
}
if ($success) {
if ($statusChanged) {
Hook::exec(
'actionRoomBookingStatusUpdateAfter',
array(
'id_hotel_booking_detail' => $objHotelBookingDetail->id,
'id_order' => $objHotelBookingDetail->id_order,
'id_room' => $objHotelBookingDetail->id_room,
'date_from' => $objHotelBookingDetail->date_from,
'date_to' => $objHotelBookingDetail->date_to
)
);
}
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . (int) $objHotelBookingDetail->id_order . '&vieworder&token=' . $this->token . '&conf=4');
} else {

View File

@@ -1118,7 +1118,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
date('Y-m-d'),
date('Y-m-d', strtotime('+1 day')),
$idHotels,
HotelBookingDetail::STATUS_ALLOTED
HotelBookingDetail::STATUS_ASSIGNED
);
break;

View File

@@ -497,7 +497,7 @@ class OrderDetailControllerCore extends FrontController
'use_tax' => Configuration::get('PS_TAX'),
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED,
'ROOM_STATUS_ASSIGNED' => HotelBookingDetail::STATUS_ASSIGNED,
'ROOM_STATUS_CHECKED_IN' => HotelBookingDetail::STATUS_CHECKED_IN,
'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT,
)
@@ -610,12 +610,14 @@ class OrderDetailControllerCore extends FrontController
}
// the room has already been checked in/checked out, room will not be able to be cancelled by the customer
if ($objHotelBookingDetail->id_status != HotelBookingDetail::STATUS_ALLOTED) {
if ($objHotelBookingDetail->id_status != HotelBookingDetail::STATUS_ASSIGNED) {
$this->errors[] = Tools::displayError('Some selected rooms have already been checked-in/checked-out.');
break;
}
if (OrderReturn::getOrdersReturnDetail($objOrder->id, 0, $idHtlBooking)) {
// multiple refund requests are now allowed per booking — only still
// block a booking that's already fully refunded, not a re-request
if ($objHotelBookingDetail->is_refunded) {
$this->errors[] = Tools::displayError('Some selected rooms have already been requested for cancellation.');
break;
}
@@ -640,6 +642,7 @@ class OrderDetailControllerCore extends FrontController
$objOrderReturn->by_admin = 0;
$objOrderReturn->question = $cancellationReason;
$objOrderReturn->refunded_amount = 0;
$objOrderReturn->event_type = OrderReturn::EVENT_TYPE_REFUND;
$objOrderReturn->save();
if ($objOrderReturn->id) {
if ($idsHtlBooking) {

View File

@@ -1350,6 +1350,7 @@ CREATE TABLE `PREFIX_order_return` (
`by_admin` tinyint(1) unsigned NOT NULL DEFAULT '0',
`id_return_type` tinyint(1) unsigned NOT NULL DEFAULT '0',
`return_type` tinyint(1) unsigned NOT NULL DEFAULT '0',
`event_type` tinyint(1) unsigned NOT NULL DEFAULT '0',
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_order_return`),

View File

@@ -461,6 +461,9 @@
<configuration id="PS_OS_OVERBOOKING_PARTIAL_PAID" name="PS_OS_OVERBOOKING_PARTIAL_PAID">
<value>12</value>
</configuration>
<configuration id="PS_OS_NO_SHOW" name="PS_OS_NO_SHOW">
<value>13</value>
</configuration>
<!-- <configuration id="PS_OS_AWAITING_PARTIAL_PAYMENT" name="PS_OS_AWAITING_PARTIAL_PAYMENT">
<value>13</value>
</configuration> -->

View File

@@ -38,5 +38,7 @@
</order_state>
<order_state id="Overbooking_partial_paid" invoice="0" send_email="0" color="#FF69B4" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0" pdf_delivery="0" pdf_invoice="0">
</order_state>
<order_state id="No_show" invoice="0" send_email="1" color="#DC143C" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0" pdf_delivery="0" pdf_invoice="0">
</order_state>
</entities>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Получено частично плащане</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Неявяване</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>আংশিক পেমেন্ট প্রাপ্ত</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>অনুপস্থিত</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Pagamento parcial recebido</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Não comparecimento</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Částečná platba přijata</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Nedostavení se</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Teilzahlung erhalten</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Nichterscheinen</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Partial payment received</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>No-show</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Pago parcial recibido</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>No presentado</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>پرداخت جزئی دریافت شد</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>عدم حضور</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Paiement partiel reçu</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Non présentation</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>תשלום חלקי התקבל</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>אי-הגעה</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Primljena djelomična uplata</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Nedolazak</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Részleges kifizetés megérkezett</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Meg nem jelenés</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Pembayaran sebagian diterima</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Ketidakhadiran</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Pagamento parziale ricevuto</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Mancata presentazione</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Gautas dalinis apmokėjimas</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Neatvykimas</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Примено е делумно плаќање</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Непојавување</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Gedeeltelijke betaling ontvangen</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Niet verschenen</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Partial payment received</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Ikke-møtt</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Otrzymano częściową płatność</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Niepojawienie się</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Pagamento parcial recebido</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Não comparência</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Paiement partiel reçu</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Non présentation</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Plata parțială primită</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Neprezentare</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Частичная оплата получена</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Неявка</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>අර්ධ ගෙවීමක් ලැබී ඇත</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>නොපැමිණි</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Делимична уплата примљена</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Непојављивање</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Delbetalning mottagen</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Utebliven ankomst</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>已收到部分付款</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>未入住</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>Đã nhận được một phần thanh toán</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>Khách không đến</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -48,4 +48,8 @@
<name>已收到部分付款</name>
<template>partial_payment_accepted</template>
</order_state>
<order_state id="No_show">
<name>未入住</name>
<template/>
</order_state>
</entity_order_state>

View File

@@ -1605,6 +1605,10 @@ $(document).ready(function() {
} else {
$form.find('.room_status_date').closest('.form-group').hide();
}
if (status == ROOM_STATUS_NO_SHOW || status == ROOM_STATUS_CANCELLED) {
showErrorMessage(room_status_sealed_warning_txt);
}
});
// open date picker for the date input of check-in checkout dates

View File

@@ -70,9 +70,11 @@ class HotelBookingDetail extends ObjectModel
public $date_add;
public $date_upd;
protected $moduleInstance;
const STATUS_ALLOTED = 1;
const STATUS_ASSIGNED = 1;
const STATUS_CHECKED_IN = 2;
const STATUS_CHECKED_OUT = 3;
const STATUS_NO_SHOW = 4;
const STATUS_CANCELLED = 5;
// booking allotment types
const ALLOTMENT_AUTO = 1;
@@ -1614,6 +1616,67 @@ class HotelBookingDetail extends ObjectModel
return $idHotel;
}
/**
* The only place `id_status` is allowed to change on an already-existing booking row.
* Validates the transition against HotelBookingStatus::getAllowedTransitions(), saves,
* logs the change to HotelBookingStatusHistory, and fires actionBookingStatusBefore/After.
*
* Not for setting the initial status when a brand-new booking row is first created —
* that's plain field initialization, not a transition, and is unaffected by this method.
*
* @param int $newStatus one of HotelBookingDetail::STATUS_*
* @param array $params optional: 'remark' (string), 'id_employee' (int), 'id_customer' (int)
* @return bool
*/
public function changeStatus($newStatus, $params = array())
{
if (!Validate::isLoadedObject($this)) {
return false;
}
$idStatusFrom = (int) $this->id_status;
if ($idStatusFrom == $newStatus) {
return false;
}
if (!in_array($newStatus, HotelBookingStatus::getAllowedTransitions($idStatusFrom))) {
return false;
}
Hook::exec('actionBookingStatusBefore', array(
'object' => $this,
'id_status_from' => $idStatusFrom,
'id_status_to' => $newStatus,
));
$this->id_status = $newStatus;
if (!$this->save()) {
return false;
}
$objHistory = new HotelBookingStatusHistory();
$objHistory->id_htl_booking = $this->id;
$objHistory->id_status_from = $idStatusFrom;
$objHistory->id_status_to = $newStatus;
$objHistory->id_employee = isset($params['id_employee']) ? (int) $params['id_employee'] : null;
$objHistory->id_customer = isset($params['id_customer']) ? (int) $params['id_customer'] : null;
$remark = isset($params['remark']) ? $params['remark'] : '';
foreach (Language::getLanguages(true) as $lang) {
$objHistory->remark[$lang['id_lang']] = $remark;
}
$objHistory->save();
Hook::exec('actionBookingStatusAfter', array(
'object' => $this,
'id_status_from' => $idStatusFrom,
'id_status_to' => $newStatus,
));
return true;
}
/**
* [updateBookingOrderStatusBYOrderId :: To update the order status of a room in the booking].
* @param [int] $order_id [Id of the order]
@@ -1640,18 +1703,15 @@ class HotelBookingDetail extends ObjectModel
}
if ($newStatus == self::STATUS_CHECKED_IN) {
$objHotelBookingDetail->id_status = $newStatus;
$objHotelBookingDetail->check_in = ($statusDate > $dateTo ? $dateTo : $statusDate);
} elseif ($newStatus == self::STATUS_CHECKED_OUT) {
$objHotelBookingDetail->id_status = $newStatus;
$objHotelBookingDetail->check_out = ($statusDate > $dateTo ? $dateTo : $statusDate);
} else {
$objHotelBookingDetail->id_status = $newStatus;
$objHotelBookingDetail->check_in = '';
$objHotelBookingDetail->check_out = '';
}
return $objHotelBookingDetail->save();
return $objHotelBookingDetail->changeStatus($newStatus);
}
return false;
@@ -3241,7 +3301,7 @@ class HotelBookingDetail extends ObjectModel
$objHtlBooking->id_hotel = $objCartBooking->id_hotel;
$objHtlBooking->id_customer = $cart->id_customer;
$objHtlBooking->booking_type = $objCartBooking->booking_type;
$objHtlBooking->id_status = self::STATUS_ALLOTED;
$objHtlBooking->id_status = self::STATUS_ASSIGNED;
$objHtlBooking->comment = $objCartBooking->comment;
// For Back Order(Because of cart lock)
@@ -3359,9 +3419,9 @@ class HotelBookingDetail extends ObjectModel
$moduleInstance = Module::getInstanceByName('hotelreservationsystem');
$pages = array(
'STATUS_ALLOTED' => array(
'id_status' => self::STATUS_ALLOTED,
'name' => $moduleInstance->l('Alloted', 'hotelreservationsystem')
'STATUS_ASSIGNED' => array(
'id_status' => self::STATUS_ASSIGNED,
'name' => $moduleInstance->l('Assigned', 'hotelreservationsystem')
),
'STATUS_CHECKED_IN' => array(
'id_status' => self::STATUS_CHECKED_IN,

View File

@@ -0,0 +1,101 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-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 support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
/**
* Catalog of room-booking statuses (Assigned, Checked-in, Checked-out, No-show, Cancelled).
*/
class HotelBookingStatus extends ObjectModel
{
public $color;
public $is_terminal;
public $name;
public static $definition = array(
'table' => 'htl_booking_status',
'primary' => 'id_booking_status',
'multilang' => true,
'fields' => array(
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor', 'required' => true),
'is_terminal' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
// lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
),
);
/**
* Which statuses a booking is allowed to move to from its current status.
*
* @param int $currentStatus one of HotelBookingDetail::STATUS_*
* @return array list of HotelBookingDetail::STATUS_* values allowed as the next status
*/
public static function getAllowedTransitions($currentStatus)
{
$transitions = array(
HotelBookingDetail::STATUS_ASSIGNED => array(
HotelBookingDetail::STATUS_CHECKED_IN,
HotelBookingDetail::STATUS_NO_SHOW,
HotelBookingDetail::STATUS_CANCELLED,
),
HotelBookingDetail::STATUS_CHECKED_IN => array(
HotelBookingDetail::STATUS_CHECKED_OUT,
// revert: undo an accidental check-in
HotelBookingDetail::STATUS_ASSIGNED,
),
HotelBookingDetail::STATUS_CHECKED_OUT => array(
// revert: undo an accidental check-out
HotelBookingDetail::STATUS_ASSIGNED,
),
);
return isset($transitions[$currentStatus]) ? $transitions[$currentStatus] : array();
}
/**
* @param int $idLang
* @param int|null $allowedFromStatus when given, only returns statuses reachable from this
* one (per getAllowedTransitions()) instead of the full catalog — e.g. to build the
* room-status dropdown for a booking currently at this status.
* @return array catalog rows (id_status = id_booking_status, color, is_terminal, name), ordered by id
*/
public function getAllStatuses($idLang = 0, $allowedFromStatus = null)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$sql = 'SELECT hbs.*, hbs.`id_booking_status` AS id_status, hbsl.`name` FROM `'._DB_PREFIX_.$this->table.'` hbs
LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` hbsl ON hbs.`id_booking_status` = hbsl.`id_booking_status` AND hbsl.`id_lang` = '.(int) $idLang;
if ($allowedFromStatus !== null) {
$allowed = self::getAllowedTransitions((int) $allowedFromStatus);
if (!$allowed) {
return array();
}
$sql .= ' WHERE hbs.`id_booking_status` IN ('.implode(',', array_map('intval', $allowed)).')';
}
$sql .= ' ORDER BY hbs.`id_booking_status` ASC';
return Db::getInstance()->executeS($sql);
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-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 support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
/**
* Audit log: one row per room-booking status change (htl_booking_detail.id_status).
*/
class HotelBookingStatusHistory extends ObjectModel
{
public $id_htl_booking;
public $id_status_from;
public $id_status_to;
public $id_employee;
public $id_customer;
public $remark;
public $date_add;
public static $definition = array(
'table' => 'htl_booking_status_history',
'primary' => 'id_booking_status_history',
'multilang' => true,
'fields' => array(
'id_htl_booking' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_status_from' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true),
'id_status_to' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true),
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
// lang fields
'remark' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'),
),
);
/**
* @param int $idHtlBooking
* @param int $idLang
* @return array history rows for one booking, oldest first
*/
public function getHistoryByBooking($idHtlBooking, $idLang = 0)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$sql = 'SELECT hbsh.*, hbshl.`remark` FROM `'._DB_PREFIX_.$this->table.'` hbsh
LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` hbshl ON hbsh.`id_booking_status_history` = hbshl.`id_booking_status_history` AND hbshl.`id_lang` = '.(int) $idLang.'
WHERE hbsh.`id_htl_booking` = '.(int) $idHtlBooking.'
ORDER BY hbsh.`id_booking_status_history` ASC';
return Db::getInstance()->executeS($sql);
}
}

View File

@@ -1368,6 +1368,101 @@ class HotelHelper
return true;
}
public function createDefaultBookingStatuses()
{
$htlBookingStatuses = array(
array(
'id' => HotelBookingDetail::STATUS_ASSIGNED,
'color' => '#4169E1',
'is_terminal' => 0,
'name' => array(
'en' => 'Assigned',
'nl' => 'Toegewezen',
'fr' => 'Assignée',
'de' => 'Zugewiesen',
'ru' => 'Назначено',
'es' => 'Asignada',
),
),
array(
'id' => HotelBookingDetail::STATUS_CHECKED_IN,
'color' => '#17A2B8',
'is_terminal' => 0,
'name' => array(
'en' => 'Checked-in',
'nl' => 'Ingecheckt',
'fr' => 'Enregistrée',
'de' => 'Eingecheckt',
'ru' => 'Заселено',
'es' => 'Registrada',
),
),
array(
'id' => HotelBookingDetail::STATUS_CHECKED_OUT,
'color' => '#108510',
'is_terminal' => 0,
'name' => array(
'en' => 'Checked-out',
'nl' => 'Uitgecheckt',
'fr' => 'Départ effectué',
'de' => 'Ausgecheckt',
'ru' => 'Выселено',
'es' => 'Salida realizada',
),
),
array(
'id' => HotelBookingDetail::STATUS_NO_SHOW,
'color' => '#DC143C',
'is_terminal' => 1,
'name' => array(
'en' => 'No-show',
'nl' => 'Niet verschenen',
'fr' => 'Non présentée',
'de' => 'Nicht erschienen',
'ru' => 'Неявка',
'es' => 'No presentada',
),
),
array(
'id' => HotelBookingDetail::STATUS_CANCELLED,
'color' => '#FF8C00',
'is_terminal' => 1,
'name' => array(
'en' => 'Cancelled',
'nl' => 'Geannuleerd',
'fr' => 'Annulée',
'de' => 'Storniert',
'ru' => 'Отменено',
'es' => 'Cancelada',
),
),
);
$languages = Language::getLanguages(true);
foreach ($htlBookingStatuses as $htlBookingStatus) {
$objBookingStatus = new HotelBookingStatus();
// fixed id: this catalog's rows are referenced by the HotelBookingDetail::STATUS_* constants
$objBookingStatus->id = $htlBookingStatus['id'];
$objBookingStatus->force_id = true;
$objBookingStatus->color = $htlBookingStatus['color'];
$objBookingStatus->is_terminal = $htlBookingStatus['is_terminal'];
foreach ($languages as $lang) {
if (isset($htlBookingStatus['name'][$lang['iso_code']])) {
$objBookingStatus->name[$lang['id_lang']] = $htlBookingStatus['name'][$lang['iso_code']];
} else {
$objBookingStatus->name[$lang['id_lang']] = $htlBookingStatus['name']['en'];
}
}
if (!$objBookingStatus->add()) {
return false;
}
}
return true;
}
public static function getPsProducts($id_lang, $start = 0, $limit = 0, $booking_product = null)
{
$sql = 'SELECT p.`id_product`, pl.`name`, p.`booking_product`

View File

@@ -186,6 +186,38 @@ class HotelReservationSystemDb
PRIMARY KEY (`id`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_status` (
`id_booking_status` int(11) NOT NULL AUTO_INCREMENT,
`color` varchar(32) NOT NULL,
`is_terminal` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_booking_status`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_status_lang` (
`id_booking_status` int(11) NOT NULL,
`id_lang` int(11) NOT NULL,
`name` varchar(64) NOT NULL,
PRIMARY KEY (`id_booking_status`, `id_lang`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_status_history` (
`id_booking_status_history` int(11) NOT NULL AUTO_INCREMENT,
`id_htl_booking` int(11) NOT NULL,
`id_status_from` int(11) DEFAULT NULL,
`id_status_to` int(11) NOT NULL,
`id_employee` int(11) DEFAULT NULL,
`id_customer` int(11) DEFAULT NULL,
`date_add` datetime NOT NULL,
PRIMARY KEY (`id_booking_status_history`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_status_history_lang` (
`id_booking_status_history` int(11) NOT NULL,
`id_lang` int(11) NOT NULL,
`remark` text,
PRIMARY KEY (`id_booking_status_history`, `id_lang`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_booking_document` (
`id_htl_booking_document` int(11) NOT NULL AUTO_INCREMENT,
`id_htl_booking` int(11) NOT NULL,
@@ -594,6 +626,10 @@ class HotelReservationSystemDb
`'._DB_PREFIX_.'htl_features_lang`,
`'._DB_PREFIX_.'htl_cart_booking_data`,
`'._DB_PREFIX_.'htl_booking_detail`,
`'._DB_PREFIX_.'htl_booking_status`,
`'._DB_PREFIX_.'htl_booking_status_lang`,
`'._DB_PREFIX_.'htl_booking_status_history`,
`'._DB_PREFIX_.'htl_booking_status_history_lang`,
`'._DB_PREFIX_.'htl_booking_document`,
`'._DB_PREFIX_.'htl_booking_demands`,
`'._DB_PREFIX_.'htl_booking_demands_tax`,

View File

@@ -0,0 +1,132 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-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 support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class AdminBookingStatusesController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'htl_booking_status';
$this->className = 'HotelBookingStatus';
$this->identifier = 'id_booking_status';
$this->context = Context::getContext();
$this->lang = true;
parent::__construct();
// edit only — the 5 statuses are fixed (their IDs are the
// HotelBookingDetail::STATUS_* constants used everywhere), no add/delete
$this->addRowAction('edit');
$this->fields_list = array(
'id_booking_status' => array(
'title' => $this->l('ID'),
'align' => 'center',
'class' => 'fixed-width-xs',
),
'name' => array(
'title' => $this->l('Name'),
'align' => 'center',
'color' => 'color',
),
'is_terminal' => array(
'title' => $this->l('Terminal (final) status'),
'align' => 'text-center',
'type' => 'bool',
'orderby' => false,
'search' => false,
'class' => 'fixed-width-sm',
),
);
}
public function initToolbar()
{
// no "Add new" toolbar button — statuses are fixed
$this->toolbar_btn = array();
}
public function postProcess()
{
// server-side guard, not just hidden buttons: this table's 5 rows are fixed
if (Tools::isSubmit('add'.$this->table)
|| Tools::isSubmit('delete'.$this->table)
|| Tools::isSubmit('submitBulkdelete'.$this->table)
) {
$this->errors[] = $this->l('Booking statuses cannot be added or deleted.');
return;
}
parent::postProcess();
}
public function renderForm()
{
if (!$this->loadObject(true)) {
return;
}
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Booking Status'),
'icon' => 'icon-bookmark',
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name'),
'name' => 'name',
'lang' => true,
'required' => true,
'col' => 4,
),
array(
'type' => 'color',
'label' => $this->l('Color'),
'name' => 'color',
'required' => true,
),
),
'submit' => array(
'title' => $this->l('Save'),
),
);
return parent::renderForm();
}
public function processSave()
{
if (!$this->loadObject(true)) {
return;
}
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
$objDefaultLanguage = Language::getLanguage((int) $defaultLangId);
if (!trim(Tools::getValue('name_'.$defaultLangId))) {
$this->errors[] = $this->l('Status name is required at least in ').$objDefaultLanguage['name'];
}
return parent::processSave();
}
}

View File

@@ -466,6 +466,20 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
// perform booking refund processes in the booking tables
$objHtlBooking->processRefundInBookingTables();
// paid Cancelled/No-show requests only flip the room's status
// once the refund is actually approved here
if ($objOrderReturn->event_type == OrderReturn::EVENT_TYPE_CANCELLATION) {
$objHtlBooking->changeStatus(HotelBookingDetail::STATUS_CANCELLED, array(
'id_employee' => (int) $this->context->employee->id,
'remark' => $objOrderReturn->question,
));
} elseif ($objOrderReturn->event_type == OrderReturn::EVENT_TYPE_NO_SHOW) {
$objHtlBooking->changeStatus(HotelBookingDetail::STATUS_NO_SHOW, array(
'id_employee' => (int) $this->context->employee->id,
'remark' => $objOrderReturn->question,
));
}
} elseif ($id_service_product_order_detail = $objOrderReturnDetail->id_service_product_order_detail) {
$objServiceProductOrderDetail = new ServiceProductOrderDetail($id_service_product_order_detail);
// perform booking refund processes in the service product order tables

View File

@@ -29,6 +29,8 @@ require_once 'classes/HotelImage.php';
require_once 'classes/HotelFeatures.php';
require_once 'classes/HotelBranchFeatures.php';
require_once 'classes/HotelBookingDetail.php';
require_once 'classes/HotelBookingStatus.php';
require_once 'classes/HotelBookingStatusHistory.php';
require_once 'classes/HotelCartBookingData.php';
require_once 'classes/HotelAdvancedPayment.php';
require_once 'classes/HotelOrderRefundRules.php';

View File

@@ -526,6 +526,8 @@ class HotelReservationSystem extends Module
$this->installTab('AdminHotelConfigurationSetting', 'General Settings', 'AdminHotelReservationSystemManagement');
$this->installTab('AdminHotelBedTypes', 'Bed Types', 'AdminCatalog');
// parented under core Orders, next to the existing "Statuses" tab — same idea, for booking statuses
$this->installTab('AdminBookingStatuses', 'Booking Statuses', 'AdminParentOrders');
// Controllers without tabs
$this->installTab('AdminHotelGeneralSettings', 'Hotel General Configuration', 'AdminHotelConfigurationSetting', false);
$this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false);
@@ -577,6 +579,7 @@ class HotelReservationSystem extends Module
|| !$objHtlHelper->createHotelRoomDefaultFeatures()
|| !$objHtlHelper->createHotelDefaultBedTypes()
|| !$objHtlHelper->insertHotelCommonFeatures()
|| !$objHtlHelper->createDefaultBookingStatuses()
) {
return false;
}

View File

@@ -125,6 +125,17 @@
<span class="badge" style="background-color:{$currentStateInfo['color']|escape:'html':'UTF-8'}">{$currentStateInfo['name']|escape:'html':'UTF-8'}</span>
</div>
</div>
<div class="form-group row">
<div class="col-sm-3">
<strong>{l s='Request type' mod='hotelreservationsystem'} :</strong>
</div>
<div class="col-sm-9">
{if $orderReturnInfo['event_type'] == OrderReturn::EVENT_TYPE_CANCELLATION}{l s='Cancellation' mod='hotelreservationsystem'}
{elseif $orderReturnInfo['event_type'] == OrderReturn::EVENT_TYPE_NO_SHOW}{l s='No-show' mod='hotelreservationsystem'}
{elseif $orderReturnInfo['event_type'] == OrderReturn::EVENT_TYPE_REFUND}{l s='Refund' mod='hotelreservationsystem'}
{else}--{/if}
</div>
</div>
{* list of booking requested for refund by the customer *}
{if isset($refundReqBookings) && $refundReqBookings}

View File

@@ -990,16 +990,16 @@
<div class="rooms-summary">
{foreach from=$rm_v['hotel_booking_details'] item=$hotel_booking_detail name=foreachRefundRooms}
{assign var=is_room_cancelled value=(isset($refundReqBookings) && in_array($hotel_booking_detail.id_htl_booking, $refundReqBookings))}
<div class="refund_element_details {if $is_room_cancelled || ($hotel_booking_detail.id_status != $ROOM_STATUS_ALLOTED)}cancelled{/if} clearfix">
<div class="refund_element_details {if $is_room_cancelled || ($hotel_booking_detail.id_status != $ROOM_STATUS_ASSIGNED)}cancelled{/if} clearfix">
<div class="occupancy-wrap">
<div class="checkbox">
<label for="bookings_to_refund_{$hotel_booking_detail.id_htl_booking}">
<input type="checkbox" class="bookings_to_refund" id="bookings_to_refund_{$hotel_booking_detail.id_htl_booking}" name="bookings_to_refund[]" value="{$hotel_booking_detail.id_htl_booking|escape:'html':'UTF-8'}" {if $is_room_cancelled || ($hotel_booking_detail.id_status != $ROOM_STATUS_ALLOTED)}disabled{/if}/>
<input type="checkbox" class="bookings_to_refund" id="bookings_to_refund_{$hotel_booking_detail.id_htl_booking}" name="bookings_to_refund[]" value="{$hotel_booking_detail.id_htl_booking|escape:'html':'UTF-8'}" {if $is_room_cancelled || ($hotel_booking_detail.id_status != $ROOM_STATUS_ASSIGNED)}disabled{/if}/>
{l s='Room'} - {$smarty.foreach.foreachRefundRooms.iteration|string_format:'%02d'}
</label>
<span>({$hotel_booking_detail.adults|string_format:'%02d'} {if $hotel_booking_detail.adults > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $hotel_booking_detail.children > 0}{l s=', '}{$hotel_booking_detail.children|string_format:'%02d'} {if $hotel_booking_detail.children > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if})</span>
{if $hotel_booking_detail.is_cancelled}<span class="badge badge-danger badge-cancelled">{l s='Cancelled'}</span>{else if $hotel_booking_detail.is_refunded}<span class="badge badge-danger badge-cancelled">{l s='Refunded'}</span>{else if $hotel_booking_detail.refund_denied}<span class="badge badge-danger badge-cancelled">{l s='Refund denied'}</span> <i class="icon-info-circle refund-denied-info" data-refund_denied_info="{l s='Refund for this booking is denied. Please contact admin for more detail.'}"></i>{else if $hotel_booking_detail.id_status != $ROOM_STATUS_ALLOTED}<span class="badge badge-danger badge-cancelled">{if $hotel_booking_detail.id_status == $ROOM_STATUS_CHECKED_OUT}{l s='Checked-Out'}{else}{l s='Checked-In'}{/if}</span>{/if}
{if $hotel_booking_detail.is_cancelled}<span class="badge badge-danger badge-cancelled">{l s='Cancelled'}</span>{else if $hotel_booking_detail.is_refunded}<span class="badge badge-danger badge-cancelled">{l s='Refunded'}</span>{else if $hotel_booking_detail.refund_denied}<span class="badge badge-danger badge-cancelled">{l s='Refund denied'}</span> <i class="icon-info-circle refund-denied-info" data-refund_denied_info="{l s='Refund for this booking is denied. Please contact admin for more detail.'}"></i>{else if $hotel_booking_detail.id_status != $ROOM_STATUS_ASSIGNED}<span class="badge badge-danger badge-cancelled">{if $hotel_booking_detail.id_status == $ROOM_STATUS_CHECKED_OUT}{l s='Checked-Out'}{else}{l s='Checked-In'}{/if}</span>{/if}
</div>
</div>