Merge branch 'develop' into gli-2567

This commit is contained in:
vishalsingh.qlo325
2025-05-07 17:04:41 +05:30
17 changed files with 297 additions and 88 deletions

View File

@@ -1158,19 +1158,80 @@ class AdminCartsControllerCore extends AdminController
// Process when admin changes extra demands of any room while order creation process form.tpl
public function ajaxProcessChangeRoomDemands()
{
$response = array('status' => false);
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
$roomDemands = Tools::getValue('room_demands');
$roomDemands = json_decode($roomDemands, true);
$roomDemands = json_encode($roomDemands);
$objCartbookingCata->extra_demands = $roomDemands;
if ($objCartbookingCata->save()) {
$response['status'] = true;
if ($this->tabAccess['edit'] === '1') {
$response = array('status' => false);
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
$roomDemands = Tools::getValue('room_demands');
$roomDemands = json_decode($roomDemands, true);
$roomDemands = json_encode($roomDemands);
$objCartbookingCata->extra_demands = $roomDemands;
if ($objCartbookingCata->save()) {
$response['status'] = true;
}
}
}
$this->ajaxDie(json_encode($response));
}
}
public function ajaxProcessUpdateServiceProduct()
{
if ($this->tabAccess['edit'] === '1') {
$operator = Tools::getValue('operator', 'up');
$idServiceProduct = Tools::getValue('id_product');
$idCartBooking = Tools::getValue('id_cart_booking');
$qty = Tools::getValue('qty');
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
if ($operator == 'up') {
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) {
// validate quanitity
if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) {
if ($objProduct->allow_multiple_quantity) {
if (!Validate::isUnsignedInt($qty)) {
$this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.');
// } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) {
// $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity));
}
} else {
$qty = 1;
}
} else {
$this->errors[] = Tools::displayError('This Service is not available.');
}
} else {
$this->errors[] = Tools::displayError('This Service is not available with selected room.');
}
}
if (empty($this->errors)) {
if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct(
$idCartBooking,
$idServiceProduct,
$qty,
$objHotelCartBookingData->id_cart,
$operator
)) {
$this->ajaxDie(json_encode(array(
'hasError' => false
)));
} else {
$this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.');
}
}
} else {
$this->errors[] = Tools::displayError('Room not found. Please try reloading the page.');
}
$this->ajaxDie(json_encode(array(
'hasError' => true,
'errors' => $this->errors
)));
}
$this->ajaxDie(json_encode($response));
}
public static function getOrderTotalUsingTaxCalculationMethod($id_cart)

View File

@@ -1674,7 +1674,7 @@ class AdminOrdersControllerCore extends AdminController
$this->errors[] = Tools::displayError('The invoice for edit note was unable to load. ');
}
} elseif (Tools::isSubmit('submitAddOrder') && ($id_cart = Tools::getValue('id_cart'))) {
if ($this->tabAccess['edit'] === '1') {
if ($this->tabAccess['add'] === '1') {
$objCart = new Cart($id_cart);
if (Validate::isLoadedObject($objCart)) {
$this->context->cart = $objCart;
@@ -2592,11 +2592,11 @@ class AdminOrdersControllerCore extends AdminController
$helper->id = 'box-today-stay-over';
$helper->icon = 'icon-user';
$helper->color = 'color4';
$helper->title = $this->l('Stay Overs', null, null, false);
$helper->title = $this->l('Occupied Rooms', 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_CHECKED_IN.'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d', strtotime('+ 1 days'))).'&orderFilter_hbd!date_to[]=';
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_stay_over';
$helper->tooltip = $this->l('Total number of stay overs for today.', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=occupied_rooms';
$helper->tooltip = $this->l('The count of rooms that are currently occupied by guests.', null, null, false);
$this->kpis[] = $helper;
$helper = new HelperKpi();
@@ -7102,63 +7102,6 @@ class AdminOrdersControllerCore extends AdminController
die(json_encode($response));
}
public function ajaxProcessUpdateServiceProduct()
{
$operator = Tools::getValue('operator', 'up');
$idServiceProduct = Tools::getValue('id_product');
$idCartBooking = Tools::getValue('id_cart_booking');
$qty = Tools::getValue('qty');
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
if ($operator == 'up') {
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) {
// validate quanitity
if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) {
if ($objProduct->allow_multiple_quantity) {
if (!Validate::isUnsignedInt($qty)) {
$this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.');
// } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) {
// $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity));
}
} else {
$qty = 1;
}
} else {
$this->errors[] = Tools::displayError('This Service is not available.');
}
} else {
$this->errors[] = Tools::displayError('This Service is not available with selected room.');
}
}
if (empty($this->errors)) {
if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct(
$idCartBooking,
$idServiceProduct,
$qty,
$objHotelCartBookingData->id_cart,
$operator
)) {
$this->ajaxDie(json_encode(array(
'hasError' => false
)));
} else {
$this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.');
}
}
} else {
$this->errors[] = Tools::displayError('Room not found. Please try reloading the page.');
}
$this->ajaxDie(json_encode(array(
'hasError' => true,
'errors' => $this->errors
)));
}
// To change the status of the room
public function changeRoomStatus()
{