Skip to content

Commit 6fb0b0d

Browse files
committed
Fixed: Unable to update check-in/check-out time without changing the room status
1 parent a27e55c commit 6fb0b0d

4 files changed

Lines changed: 22 additions & 9 deletions

File tree

admin/themes/default/template/controllers/orders/helpers/view/view.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
{if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded}
149149
<span class="badge badge-danger">{if $data.is_cancelled}{l s='Cancelled'}{else}{l s='Refunded'}{/if}</span>
150150
{elseif $can_edit}
151-
<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']}">
151+
<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']}">
152152
<i class="icon-pencil"></i> {l s='Edit'}
153153
</a>
154154
{/if}

admin/themes/default/template/controllers/orders/modals/_room_status_form.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{/foreach}
3131
</select>
3232
</div>
33-
<div class="form-group" style="display:none;">
33+
<div class="form-group" {if $current_room_status == $ROOM_STATUS_ALLOTED}style="display:none;"{/if}>
3434
<label class="control-label">{l s='Date'}</label>
3535
<div class="input-group">
3636
<input type="text" name="status_date" class="room_status_date wk-input-date" value="" />

controllers/admin/AdminOrdersController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ public function ajaxProcessInitRoomStatusModal()
786786
'order' => $objOrder,
787787
'current_index' => self::$currentIndex,
788788
'hotel_order_status' => $htlOrderStatus,
789+
'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED,
790+
'current_room_status' => Tools::getValue('current_room_status')
789791
)
790792
);
791793
$modal = array(

js/admin/orders.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,13 +2231,14 @@ const RoomStatusModal = {
22312231
url: admin_order_tab_link,
22322232
dataType: 'JSON',
22332233
cache: false,
2234-
data: 'ajax=true&id_order='+id_order+'&action=InitRoomStatusModal',
2234+
data: 'ajax=true&id_order='+id_order+'&action=InitRoomStatusModal&current_room_status='+roomObj.data('id_status'),
22352235
beforeSend: function() {
22362236
$("#page-loader").show();
22372237
},
22382238
success: function(result) {
22392239
if (result.hasError == 0 && result.modalHtml) {
22402240
$('#footer').next('.bootstrap').append(result.modalHtml);
2241+
var currentStatus = roomObj.data('id_status');
22412242

22422243
$('#room-status-modal #room_status_id_hotel_booking_detail').val(roomObj.data('id_hotel_booking_detail'));
22432244
$('#room-status-modal #room_status_date_from').val(roomObj.data('date_from'));
@@ -2246,14 +2247,24 @@ const RoomStatusModal = {
22462247
$('#room-status-modal #room_status_id_order').val(roomObj.data('id_order'));
22472248
$('#room-status-modal .booking_order_status').val(roomObj.data('id_status'));
22482249

2249-
if (roomObj.data('id_status') == result.STATUS_CHECKED_IN) {
2250-
$('.room_status_info_form .room_status_date').val(roomObj.data('date_to') + ' ' + roomObj.data('check_out_time'));
2251-
} else {
2252-
$('.room_status_info_form .room_status_date').val(roomObj.data('date_from') + ' ' + roomObj.data('check_in_time'));
2250+
if (currentStatus != result.STATUS_ALLOTED) {
2251+
$('.room_date_field_container').show();
22532252
}
22542253

2255-
$('#room-status-modal .booking_order_status option:selected').attr('disabled', 'disabled');
2256-
2254+
if (currentStatus == result.STATUS_CHECKED_OUT) {
2255+
if (roomObj.data('check_out') && roomObj.data('check_out') !== "0000-00-00 00:00:00") {
2256+
$('.room_status_info_form .room_status_date').val(roomObj.data('check_out'));
2257+
} else {
2258+
$('.room_status_info_form .room_status_date').val(roomObj.data('date_to') + ' ' + roomObj.data('check_out_time'));
2259+
}
2260+
} else {
2261+
if (roomObj.data('check_in') && roomObj.data('check_in') !== "0000-00-00 00:00:00") {
2262+
$('.room_status_info_form .room_status_date').val(roomObj.data('check_in'));
2263+
} else {
2264+
$('.room_status_info_form .room_status_date').val(roomObj.data('date_from') + ' ' + roomObj.data('check_in_time'));
2265+
}
2266+
}
2267+
22572268
$('#room-status-modal').modal('show');
22582269
} else if (result.errors) {
22592270
showErrorMessage();

0 commit comments

Comments
 (0)