update adminorders page min date and updated configuration

This commit is contained in:
Shreesh Arora
2024-03-13 16:05:24 +05:30
parent 263ba57ac5
commit 0a1651d6ca
5 changed files with 37 additions and 18 deletions

View File

@@ -62,7 +62,7 @@
<div class="fixed-width-xl room_check_in_div">
<div class="input-group">
<div class="input-group-addon">{l s='Check In'}</div>
<input type="text" class="form-control edit_product_date_from" name="edit_product[date_from]" value="{$data.date_from|date_format:"%d-%m-%Y"}"/>
<input type="text" class="form-control edit_product_date_from" name="edit_product[date_from]" value="{$data.date_from|date_format:"%d-%m-%Y"}" data-min_date="{$data.date_from|date_format:"%d-%m-%Y"}"/>
<div class="input-group-addon"><i class="icon-calendar"></i></div>
</div>
</div>
@@ -70,7 +70,7 @@
<div class="fixed-width-xl room_check_out_div">
<div class="input-group">
<div class="input-group-addon">{l s='Check Out'}</div>
<input type="text" class="form-control edit_product_date_to" name="edit_product[date_to]" value="{$data.date_to|date_format:"%d-%m-%Y"}"/>
<input type="text" class="form-control edit_product_date_to" name="edit_product[date_to]" value="{$data.date_to|date_format:"%d-%m-%Y"}" data-min_date="{$data.date_from|date_format:"%d-%m-%Y"}"/>
<div class="input-group-addon"><i class="icon-calendar"></i></div>
</div>
</div>

View File

@@ -48,6 +48,7 @@
var txt_confirm = "{l s='Are you sure?' js=1}";
var statesShipped = new Array();
var has_voucher = {if count($discounts)}1{else}0{/if};
var allowBackdateOrder = {if $allowBackdateOrder}{$allowBackdateOrder}{else}false{/if};
{foreach from=$states item=state}
{if (isset($currentState->shipped) && !$currentState->shipped && $state['shipped'])}
statesShipped.push({$state['id_order_state']});

View File

@@ -78,6 +78,16 @@ class AdminOrderPreferencesControllerCore extends AdminController
'class' => 'fixed-width-xl',
'suffix' => $this->l('day(s)'),
),
'PS_BACKDATE_ORDER_SUPERADMIN' => array(
'title' => $this->l('Allow backdate order from Back-office for super-admin'),
'hint' => $this->l('Allow superadmin to create bookings for backdate'),
'type' => 'bool',
),
'PS_BACKDATE_ORDER_EMPLOYEES' => array(
'title' => $this->l('Allow backdate order from Back-office for employees'),
'hint' => $this->l('Allow employees to create bookings for backdate'),
'type' => 'bool',
),
),
'submit' => array(
'title' => $this->l('Save'),
@@ -197,22 +207,6 @@ class AdminOrderPreferencesControllerCore extends AdminController
),
'submit' => array('title' => $this->l('Save'))
),
'back_date_order' => array(
'title' => $this->l('Backdate Order Restrictions'),
'icon' => 'icon-cogs',
'fields' => array(
'PS_BACKDATE_ORDER_SUPERADMIN' => array(
'title' => $this->l('Allow backdate order from Back-office for super-admin'),
'hint' => $this->l('Allow superadmin to create bookings for backdate'),
'type' => 'bool',
),
'PS_BACKDATE_ORDER_EMPLOYEES' => array(
'title' => $this->l('Allow backdate order from Back-office for employees'),
'hint' => $this->l('Allow employees to create bookings for backdate'),
'type' => 'bool',
),
)
)
);
if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) {

View File

@@ -1758,6 +1758,13 @@ class AdminOrdersControllerCore extends AdminController
// hotel booking statuses
$htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus();
if ($this->context->employee->isSuperAdmin()) {
$backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN';
} else {
$backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES';
}
$allowBackdateOrder = Configuration::get($backOrderConfigKey);
// applicable refund policies
$applicableRefundPolicies = HotelOrderRefundRules::getApplicableRefundRules($order->id);
$this->tpl_view_vars = array(
@@ -1784,6 +1791,7 @@ class AdminOrdersControllerCore extends AdminController
'order' => $order,
'cart' => new Cart($order->id_cart),
'customer' => $customer,
'allowBackdateOrder' => $allowBackdateOrder,
'gender' => $gender,
'customerGuestDetail' => $customerGuestDetail,
'genders' => Gender::getGenders(),

View File

@@ -1561,6 +1561,14 @@ function initRoomEvents()
selectedDate.setDate(selectedDate.getDate() + 1);
$(".edit_product_date_to").datepicker("option", "minDate", selectedDate);
},
beforeShow : function () {
if(allowBackdateOrder) {
var minDate = null;
} else {
var minDate = new Date(Math.min($.datepicker.parseDate('dd-mm-yy', $(this).data('min_date')), new Date()));
}
$(this).datepicker("option", "minDate", minDate);
}
});
$(".edit_product_date_to").datepicker(
@@ -1572,6 +1580,14 @@ function initRoomEvents()
var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[2], date_format[1] - 1, date_format[0])));
selectedDate.setDate(selectedDate.getDate() - 1);
$(".edit_product_date_from").datepicker("option", "maxDate", selectedDate);
},
beforeShow : function () {
if(allowBackdateOrder) {
var minDate = null;
} else {
var minDate = new Date(Math.min($.datepicker.parseDate('dd-mm-yy', $(this).data('min_date')), new Date()));
}
$(this).datepicker("option", "minDate", minDate);
}
});
/*End*/