From 4abc908c382829424d80fc348fe0f56b13e313a1 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 16 Feb 2023 11:57:09 +0530 Subject: [PATCH 01/77] Fix IDOR at order detail page --- controllers/front/OrderDetailController.php | 158 ++++++++++---------- 1 file changed, 81 insertions(+), 77 deletions(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index fdb54ae3a..022035839 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -163,93 +163,97 @@ class OrderDetailControllerCore extends FrontController $this->errors[] = Tools::displayError('Order ID required'); } else { $order = new Order($id_order); - // Here handle request from the ajax on order details page i.e refund, additional qty etc - $method = Tools::getValue('method'); - // extra demands popup ajax - if ($method == 'getRoomTypeBookingDemands') { - $extraDemandsTpl = ''; - if (($idProduct = Tools::getValue('id_product')) - && ($idOrder = Tools::getValue('id_order')) - && ($dateFrom = Tools::getValue('date_from')) - && ($dateTo = Tools::getValue('date_to')) - ) { - $objBookingDemand = new HotelBookingDemands(); - $useTax = 0; - $customer = Context::getContext()->customer; - if (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC) { - $useTax = 1; + if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) { + // Here handle request from the ajax on order details page i.e refund, additional qty etc + $method = Tools::getValue('method'); + // extra demands popup ajax + if ($method == 'getRoomTypeBookingDemands') { + $extraDemandsTpl = ''; + if (($idProduct = Tools::getValue('id_product')) + && ($idOrder = Tools::getValue('id_order')) + && ($dateFrom = Tools::getValue('date_from')) + && ($dateTo = Tools::getValue('date_to')) + ) { + $objBookingDemand = new HotelBookingDemands(); + $useTax = 0; + $customer = Context::getContext()->customer; + if (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC) { + $useTax = 1; + } + if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( + $idOrder, + $idProduct, + 0, + $dateFrom, + $dateTo, + 1, + 0, + $useTax + )) { + $this->context->smarty->assign( + array( + 'useTax' => $useTax, + 'extraDemands' => $extraDemands, + ) + ); + $extraDemandsTpl .= $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl'); + } } - if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( - $idOrder, - $idProduct, - 0, - $dateFrom, - $dateTo, - 1, - 0, - $useTax - )) { - $this->context->smarty->assign( - array( - 'useTax' => $useTax, - 'extraDemands' => $extraDemands, - ) - ); - $extraDemandsTpl .= $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl'); - } - } - die($extraDemandsTpl); - } elseif ($method == 'submitRefundRequest') { // room cancellation ajax - $hasError = 0; - if (!$refundReason = Tools::getValue('cancellation_reason')) { - $hasError = 1; - } elseif (!Validate::isCleanHtml($refundReason)) { - $hasError = 1; - } - if ($bookingRefunds = Tools::getValue('bookings_to_refund')) { - if (!count($bookingRefunds = json_decode($bookingRefunds, true))) { + die($extraDemandsTpl); + } elseif ($method == 'submitRefundRequest') { // room cancellation ajax + $hasError = 0; + if (!$refundReason = Tools::getValue('cancellation_reason')) { $hasError = 1; - } else { - foreach ($bookingRefunds as $idHtlBooking) { - if (OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking)) { - $hasError = 1; - break; + } elseif (!Validate::isCleanHtml($refundReason)) { + $hasError = 1; + } + if ($bookingRefunds = Tools::getValue('bookings_to_refund')) { + if (!count($bookingRefunds = json_decode($bookingRefunds, true))) { + $hasError = 1; + } else { + foreach ($bookingRefunds as $idHtlBooking) { + if (OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking)) { + $hasError = 1; + break; + } } } + } else { + $hasError = 1; } - } else { - $hasError = 1; - } - if (!$hasError) { - $objOrderReturn = new OrderReturn(); - $objOrderReturn->id_customer = $order->id_customer; - $objOrderReturn->id_order = $order->id; - $objOrderReturn->state = 0; - $objOrderReturn->by_admin = 0; - $objOrderReturn->question = $refundReason; - $objOrderReturn->save(); - if ($objOrderReturn->id) { - foreach ($bookingRefunds as $idHtlBooking) { - $objHtlBooking = new HotelBookingDetail($idHtlBooking); - $numDays = $objHtlBooking->getNumberOfDays( - $objHtlBooking->date_from, - $objHtlBooking->date_to - ); + if (!$hasError) { + $objOrderReturn = new OrderReturn(); + $objOrderReturn->id_customer = $order->id_customer; + $objOrderReturn->id_order = $order->id; + $objOrderReturn->state = 0; + $objOrderReturn->by_admin = 0; + $objOrderReturn->question = $refundReason; + $objOrderReturn->save(); + if ($objOrderReturn->id) { + foreach ($bookingRefunds as $idHtlBooking) { + $objHtlBooking = new HotelBookingDetail($idHtlBooking); + $numDays = $objHtlBooking->getNumberOfDays( + $objHtlBooking->date_from, + $objHtlBooking->date_to + ); - $objOrderReturnDetail = new OrderReturnDetail(); - $objOrderReturnDetail->id_order_return = $objOrderReturn->id; - $objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail; - $objOrderReturnDetail->product_quantity = $numDays; - $objOrderReturnDetail->id_htl_booking = $idHtlBooking; - $objOrderReturnDetail->save(); + $objOrderReturnDetail = new OrderReturnDetail(); + $objOrderReturnDetail->id_order_return = $objOrderReturn->id; + $objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail; + $objOrderReturnDetail->product_quantity = $numDays; + $objOrderReturnDetail->id_htl_booking = $idHtlBooking; + $objOrderReturnDetail->save(); + } } - } - // Emails to customer, admin on refund request state change - $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING')); + // Emails to customer, admin on refund request state change + $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING')); - die(json_encode(array('status' => 1))); + die(json_encode(array('status' => 1))); + } + die(json_encode(array('status' => 0))); } + } else { die(json_encode(array('status' => 0))); } // END ajax request handle From 278328eea10ef655b7fcab832aa9acc56a901b1f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 17 Feb 2023 17:19:50 +0530 Subject: [PATCH 02/77] Check Booking ID when cancelling booking from front office --- controllers/front/OrderDetailController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 022035839..91c745776 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -213,7 +213,10 @@ class OrderDetailControllerCore extends FrontController $hasError = 1; } else { foreach ($bookingRefunds as $idHtlBooking) { - if (OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking)) { + $objHotelBookingDetail = new HotelBookingDetail($idHtlBooking); + if ($objHotelBookingDetail->id_customer == $order->id_customer + || OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking) + ) { $hasError = 1; break; } From e841cc6d491ffff6b28fff6ba2d56ab16bf6ec5b Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 23 Feb 2023 15:30:03 +0530 Subject: [PATCH 03/77] Resolve merge conflicts --- controllers/front/OrderDetailController.php | 365 ++++++++++++++------ 1 file changed, 252 insertions(+), 113 deletions(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 91c745776..ad57e8ae5 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -168,7 +168,7 @@ class OrderDetailControllerCore extends FrontController $method = Tools::getValue('method'); // extra demands popup ajax if ($method == 'getRoomTypeBookingDemands') { - $extraDemandsTpl = ''; + $response = array('reload' => false); if (($idProduct = Tools::getValue('id_product')) && ($idOrder = Tools::getValue('id_order')) && ($dateFrom = Tools::getValue('date_from')) @@ -196,11 +196,28 @@ class OrderDetailControllerCore extends FrontController 'extraDemands' => $extraDemands, ) ); - $extraDemandsTpl .= $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl'); } + $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); + if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $idOrder, + 0, + 0, + $idProduct, + $dateFrom, + $dateTo, + 0, + 0, + $useTax + )) { + $this->context->smarty->assign(array( + 'useTax' => $useTax, + 'additionalServices' => $additionalServices, + )); + } + $response['extra_demands'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl'); } - die($extraDemandsTpl); + die(json_encode($response)); } elseif ($method == 'submitRefundRequest') { // room cancellation ajax $hasError = 0; if (!$refundReason = Tools::getValue('cancellation_reason')) { @@ -290,150 +307,270 @@ class OrderDetailControllerCore extends FrontController //by webkul to show order details properly on order history page - if (Module::isInstalled('hotelreservationsystem')) { - include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; - $objHtlBranchInfo = new HotelBranchInformation(); + // if (Module::isInstalled('hotelreservationsystem')) { + // include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; + // $objHtlBranchInfo = new HotelBranchInformation(); $objBookingDetail = new HotelBookingDetail(); $objRoomType = new HotelRoomType(); $objBookingDemand = new HotelBookingDemands(); + $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); $nonRequestedRooms = 1; $anyBackOrder = 0; $processedProducts = array(); $cartHotelData = array(); + $cartServiceProducts = array(); $total_demands_price_te = 0; $total_demands_price_ti = 0; - + $total_convenience_fee_te = 0; + $total_convenience_fee_ti = 0; if (!empty($products)) { foreach ($products as $type_key => $type_value) { if (in_array($type_value['product_id'], $processedProducts)) { continue; } - $processedProducts[] = $type_value['product_id']; + if ($type_value['is_booking_product']) { + $processedProducts[] = $type_value['product_id']; - $product = new Product($type_value['product_id'], false, $this->context->language->id); - $cover_image_arr = $product->getCover($type_value['product_id']); + $product = new Product($type_value['product_id'], false, $this->context->language->id); + $cover_image_arr = $product->getCover($type_value['product_id']); - if (!empty($cover_image_arr)) { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); - } else { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); - } - - if (isset($customer->id)) { - $obj_cart = new Cart($order->id_cart); - $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id); - } else { - $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); - } - $rm_dtl = $objRoomType->getRoomTypeInfoByIdProduct($type_value['product_id']); - $cartHotelData[$type_key]['id_product'] = $type_value['product_id']; - $cartHotelData[$type_key]['cover_img'] = $cover_img; - - $objBookingDemand = new HotelBookingDemands(); - foreach ($order_bk_data as $data_k => $data_v) { - $date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']); - - /*Product price when order was created*/ - $order_details_obj = new OrderDetail($data_v['id_order_detail']); - $cartHotelData[$type_key]['name'] = $order_details_obj->product_name; - $cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity; - $cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity; - - if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1; - - $num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; - $cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; - if ($data_v['is_back_order']) { - $anyBackOrder = 1; - } + if (!empty($cover_image_arr)) { + $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); } else { - $num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); - $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1; - $cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; - $cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; - $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults']; - $cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children']; + $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; - if ($data_v['is_back_order']) { - $anyBackOrder = 1; + if (isset($customer->id)) { + $obj_cart = new Cart($order->id_cart); + $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id); + } else { + $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); + } + $cartHotelData[$type_key]['id_product'] = $type_value['product_id']; + $cartHotelData[$type_key]['cover_img'] = $cover_img; + + + $objBookingDemand = new HotelBookingDemands(); + foreach ($order_bk_data as $data_k => $data_v) { + $date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']); + + $cartHotelData[$type_key]['adults'] = $data_v['adults']; + $cartHotelData[$type_key]['children'] = $data_v['children']; + /*Product price when order was created*/ + $order_details_obj = new OrderDetail($data_v['id_order_detail']); + $cartHotelData[$type_key]['name'] = $order_details_obj->product_name; + $cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity; + $cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity; + + if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1; + + $num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days']; + $var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; + $cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; + if ($data_v['is_back_order']) { + $anyBackOrder = 1; + } + } else { + $num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); + $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1; + $cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; + $cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; + $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults']; + $cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; + if ($data_v['is_back_order']) { + $anyBackOrder = 1; + } } + + $cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( + $id_order, + $type_value['product_id'], + 0, + $data_v['date_from'], + $data_v['date_to'] + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands( + $id_order, + $type_value['product_id'], + $data_v['id_room'], + $data_v['date_from'], + $data_v['date_to'], + 0, + 1, + 1 + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands( + $id_order, + $type_value['product_id'], + $data_v['id_room'], + $data_v['date_from'], + $data_v['date_to'], + 0, + 1, + 0 + ); + $total_demands_price_ti += $extraDemandPriceTI; + $total_demands_price_te += $extraDemandPriceTE; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl; + + $feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']); + $cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff; + + $cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name']; + // add additional services products in hotel detail. + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'] + ); + + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1 + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0 + ); } - - $cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( $id_order, - $type_value['product_id'], 0, - $data_v['date_from'], - $data_v['date_to'] - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands( - $id_order, + 0, $type_value['product_id'], - $data_v['id_room'], $data_v['date_from'], $data_v['date_to'], - 0, - 1, - 1 - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands( - $id_order, - $type_value['product_id'], $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], $data_v['date_from'], $data_v['date_to'], + $data_v['id_room'], + 1, 0, 1, - 0 + Product::PRICE_ADDITION_TYPE_WITH_ROOM ); - $total_demands_price_ti += $extraDemandPriceTI; - $total_demands_price_te += $extraDemandPriceTE; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl; + // calculate averages now + foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { + $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); + $value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6); - $feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']); - $cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff; + $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); + $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); + } + } else if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE) { + if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { + $total_convenience_fee_ti += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + $type_value['product_id'], + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ); + $total_convenience_fee_te += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + $type_value['product_id'], + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1 + ); + } + } else { + // get all products that are independent. + if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) { + $product = new Product($type_value['product_id'], false, $this->context->language->id); + $cover_image_arr = $product->getCover($type_value['product_id']); - $cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name']; + if (!empty($cover_image_arr)) { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); + } else { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } + $cartServiceProducts[] = $type_value; + } } - // calculate averages now - foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { - $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); - $value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6); - $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); - $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); - } } $redirectTermsLink = $this->context->link->getCMSLink(new CMS(3, $this->context->language->id), null, $this->context->language->id); @@ -442,6 +579,8 @@ class OrderDetailControllerCore extends FrontController array( 'id_cms_refund_policy' => Configuration::get('WK_GLOBAL_REFUND_POLICY_CMS'), 'THEME_DIR' => _THEME_DIR_, + 'total_convenience_fee_ti' => $total_convenience_fee_ti, + 'total_convenience_fee_te' => $total_convenience_fee_te, 'total_demands_price_ti' => $total_demands_price_ti, 'total_demands_price_te' => $total_demands_price_te, 'any_back_order' => $anyBackOrder, @@ -449,10 +588,11 @@ class OrderDetailControllerCore extends FrontController 'back_ord_msg' => Configuration::get('WK_BO_MESSAGE'), 'order_has_invoice' => $order->hasInvoice(), 'cart_htl_data' => $cartHotelData, + 'cart_service_products' => $cartServiceProducts, 'non_requested_rooms' => $nonRequestedRooms, ) ); - } + // } $objOrderReturn = new OrderReturn(); $refundedAmount = 0; @@ -468,7 +608,6 @@ class OrderDetailControllerCore extends FrontController 'refundReqBookings' => $refundReqBookings, 'hasCompletelyRefunded' => $order->hasCompletelyRefunded(), 'refundedAmount' => $refundedAmount, - 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'guestInformations' => (array)new Customer($order->id_customer), From ddde0e35f777957e8bc4a1b62b1010d8849730bd Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 24 Feb 2023 15:19:30 +0530 Subject: [PATCH 04/77] Fix js minification issue --- js/daterangepicker/moment.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/daterangepicker/moment.min.js b/js/daterangepicker/moment.min.js index 3427886d1..02f30abfd 100644 --- a/js/daterangepicker/moment.min.js +++ b/js/daterangepicker/moment.min.js @@ -1,2 +1,2 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.moment=t()}(this,function(){"use strict";var H;function f(){return H.apply(null,arguments)}function a(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function F(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function c(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function L(e){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(e).length;for(var t in e)if(c(e,t))return;return 1}function o(e){return void 0===e}function u(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function V(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function G(e,t){for(var n=[],s=e.length,i=0;i>>0,s=0;sAe(e)?(r=e+1,t-Ae(e)):(r=e,t);return{year:r,dayOfYear:n}}function qe(e,t,n){var s,i,r=ze(e.year(),t,n),r=Math.floor((e.dayOfYear()-r-1)/7)+1;return r<1?s=r+P(i=e.year()-1,t,n):r>P(e.year(),t,n)?(s=r-P(e.year(),t,n),i=e.year()+1):(i=e.year(),s=r),{week:s,year:i}}function P(e,t,n){var s=ze(e,t,n),t=ze(e+1,t,n);return(Ae(e)-s+t)/7}s("w",["ww",2],"wo","week"),s("W",["WW",2],"Wo","isoWeek"),t("week","w"),t("isoWeek","W"),n("week",5),n("isoWeek",5),v("w",p),v("ww",p,w),v("W",p),v("WW",p,w),Te(["w","ww","W","WW"],function(e,t,n,s){t[s.substr(0,1)]=g(e)});function Be(e,t){return e.slice(t,7).concat(e.slice(0,t))}s("d",0,"do","day"),s("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),s("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),s("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),s("e",0,0,"weekday"),s("E",0,0,"isoWeekday"),t("day","d"),t("weekday","e"),t("isoWeekday","E"),n("day",11),n("weekday",11),n("isoWeekday",11),v("d",p),v("e",p),v("E",p),v("dd",function(e,t){return t.weekdaysMinRegex(e)}),v("ddd",function(e,t){return t.weekdaysShortRegex(e)}),v("dddd",function(e,t){return t.weekdaysRegex(e)}),Te(["dd","ddd","dddd"],function(e,t,n,s){s=n._locale.weekdaysParse(e,s,n._strict);null!=s?t.d=s:m(n).invalidWeekday=e}),Te(["d","e","E"],function(e,t,n,s){t[s]=g(e)});var Je="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Qe="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Xe="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Ke=k,et=k,tt=k;function nt(){function e(e,t){return t.length-e.length}for(var t,n,s,i=[],r=[],a=[],o=[],u=0;u<7;u++)s=l([2e3,1]).day(u),t=M(this.weekdaysMin(s,"")),n=M(this.weekdaysShort(s,"")),s=M(this.weekdays(s,"")),i.push(t),r.push(n),a.push(s),o.push(t),o.push(n),o.push(s);i.sort(e),r.sort(e),a.sort(e),o.sort(e),this._weekdaysRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+r.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+i.join("|")+")","i")}function st(){return this.hours()%12||12}function it(e,t){s(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function rt(e,t){return t._meridiemParse}s("H",["HH",2],0,"hour"),s("h",["hh",2],0,st),s("k",["kk",2],0,function(){return this.hours()||24}),s("hmm",0,0,function(){return""+st.apply(this)+r(this.minutes(),2)}),s("hmmss",0,0,function(){return""+st.apply(this)+r(this.minutes(),2)+r(this.seconds(),2)}),s("Hmm",0,0,function(){return""+this.hours()+r(this.minutes(),2)}),s("Hmmss",0,0,function(){return""+this.hours()+r(this.minutes(),2)+r(this.seconds(),2)}),it("a",!0),it("A",!1),t("hour","h"),n("hour",13),v("a",rt),v("A",rt),v("H",p),v("h",p),v("k",p),v("HH",p,w),v("hh",p,w),v("kk",p,w),v("hmm",ge),v("hmmss",we),v("Hmm",ge),v("Hmmss",we),D(["H","HH"],x),D(["k","kk"],function(e,t,n){e=g(e);t[x]=24===e?0:e}),D(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),D(["h","hh"],function(e,t,n){t[x]=g(e),m(n).bigHour=!0}),D("hmm",function(e,t,n){var s=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s)),m(n).bigHour=!0}),D("hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s,2)),t[N]=g(e.substr(i)),m(n).bigHour=!0}),D("Hmm",function(e,t,n){var s=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s))}),D("Hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s,2)),t[N]=g(e.substr(i))});k=de("Hours",!0);var at,ot={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Ce,monthsShort:Ue,week:{dow:0,doy:6},weekdays:Je,weekdaysMin:Xe,weekdaysShort:Qe,meridiemParse:/[ap]\.?m?\.?/i},R={},ut={};function lt(e){return e&&e.toLowerCase().replace("_","-")}function ht(e){for(var t,n,s,i,r=0;r=t&&function(e,t){for(var n=Math.min(e.length,t.length),s=0;s=t-1)break;t--}r++}return at}function dt(t){var e;if(void 0===R[t]&&"undefined"!=typeof module&&module&&module.exports&&null!=t.match("^[^/\\\\]*$"))try{e=at._abbr,require("./locale/"+t),ct(e)}catch(e){R[t]=null}return R[t]}function ct(e,t){return e&&((t=o(t)?mt(e):ft(e,t))?at=t:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),at._abbr}function ft(e,t){if(null===t)return delete R[e],null;var n,s=ot;if(t.abbr=e,null!=R[e])Q("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=R[e]._config;else if(null!=t.parentLocale)if(null!=R[t.parentLocale])s=R[t.parentLocale]._config;else{if(null==(n=dt(t.parentLocale)))return ut[t.parentLocale]||(ut[t.parentLocale]=[]),ut[t.parentLocale].push({name:e,config:t}),null;s=n._config}return R[e]=new K(X(s,t)),ut[e]&&ut[e].forEach(function(e){ft(e.name,e.config)}),ct(e),R[e]}function mt(e){var t;if(!(e=e&&e._locale&&e._locale._abbr?e._locale._abbr:e))return at;if(!a(e)){if(t=dt(e))return t;e=[e]}return ht(e)}function _t(e){var t=e._a;return t&&-2===m(e).overflow&&(t=t[O]<0||11We(t[Y],t[O])?b:t[x]<0||24P(r,u,l)?m(s)._overflowWeeks=!0:null!=h?m(s)._overflowWeekday=!0:(d=$e(r,a,o,u,l),s._a[Y]=d.year,s._dayOfYear=d.dayOfYear)),null!=e._dayOfYear&&(i=bt(e._a[Y],n[Y]),(e._dayOfYear>Ae(i)||0===e._dayOfYear)&&(m(e)._overflowDayOfYear=!0),h=Ze(i,0,e._dayOfYear),e._a[O]=h.getUTCMonth(),e._a[b]=h.getUTCDate()),t=0;t<3&&null==e._a[t];++t)e._a[t]=c[t]=n[t];for(;t<7;t++)e._a[t]=c[t]=null==e._a[t]?2===t?1:0:e._a[t];24===e._a[x]&&0===e._a[T]&&0===e._a[N]&&0===e._a[Ne]&&(e._nextDay=!0,e._a[x]=0),e._d=(e._useUTC?Ze:je).apply(null,c),r=e._useUTC?e._d.getUTCDay():e._d.getDay(),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[x]=24),e._w&&void 0!==e._w.d&&e._w.d!==r&&(m(e).weekdayMismatch=!0)}}function Tt(e){if(e._f===f.ISO_8601)St(e);else if(e._f===f.RFC_2822)Ot(e);else{e._a=[],m(e).empty=!0;for(var t,n,s,i,r,a=""+e._i,o=a.length,u=0,l=ae(e._f,e._locale).match(te)||[],h=l.length,d=0;de.valueOf():e.valueOf()"}),i.toJSON=function(){return this.isValid()?this.toISOString():null},i.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},i.unix=function(){return Math.floor(this.valueOf()/1e3)},i.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},i.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},i.eraName=function(){for(var e,t=this.localeData().eras(),n=0,s=t.length;nthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},i.isLocal=function(){return!!this.isValid()&&!this._isUTC},i.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},i.isUtc=At,i.isUTC=At,i.zoneAbbr=function(){return this._isUTC?"UTC":""},i.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},i.dates=e("dates accessor is deprecated. Use date instead.",ke),i.months=e("months accessor is deprecated. Use month instead",Ge),i.years=e("years accessor is deprecated. Use year instead",Ie),i.zone=e("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?(this.utcOffset(e="string"!=typeof e?-e:e,t),this):-this.utcOffset()}),i.isDSTShifted=e("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!o(this._isDSTShifted))return this._isDSTShifted;var e,t={};return $(t,this),(t=Nt(t))._a?(e=(t._isUTC?l:W)(t._a),this._isDSTShifted=this.isValid()&&0 Date: Fri, 24 Feb 2023 15:58:34 +0530 Subject: [PATCH 05/77] Fix cancel request issue --- classes/order/OrderReturn.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 41623a56e..10c549b4e 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -219,13 +219,13 @@ class OrderReturnCore extends ObjectModel 0 ); $bookingRow['additional_services_tax_excl'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, + $bookingRow['id_order'], 0, 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], + $bookingRow['id_product'], + $bookingRow['date_from'], + $bookingRow['date_to'], + $bookingRow['id_room'], 1, 0 ); From f22b1dcf527c426b76fb242e468fab6ab1b554eb Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 24 Feb 2023 16:22:18 +0530 Subject: [PATCH 06/77] Fix email --- mails/en/credit_slip.html | 2 +- mails/en/credit_slip.txt | 2 +- .../controllers/admin/AdminOrderRefundRequestsController.php | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mails/en/credit_slip.html b/mails/en/credit_slip.html index 6699fa084..f7a8ded54 100644 --- a/mails/en/credit_slip.html +++ b/mails/en/credit_slip.html @@ -102,7 +102,7 @@ - You can review this credit slip and download your invoice from the "My credit slips" section of your account by clicking "My account" on our shop. + You can review this credit slip and download your invoice from the "My credit slips" section of your account by clicking "My account" on our shop. diff --git a/mails/en/credit_slip.txt b/mails/en/credit_slip.txt index ea3727f85..f0c1422ea 100644 --- a/mails/en/credit_slip.txt +++ b/mails/en/credit_slip.txt @@ -7,7 +7,7 @@ We have generated a credit slip in your name for order with the reference {order_name}. You can review this credit slip and download your invoice from the -"My credit slips" [/{history_url}] section of your account by clicking +"My credit slips" [/{credit_slip_url}] section of your account by clicking "My account" [/{my_account_url}] on our shop. {shop_name} [/{shop_url}] powered by Webkul(tm) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index 9bad576c7..ee2af9910 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -448,6 +448,8 @@ class AdminOrderRefundRequestsController extends ModuleAdminController Hook::exec('actionOrderSlipAdd', array('order' => $objOrder, 'bookingList' => $bookingList)); + $params['{credit_slip_url}'] = $this->context->link->getPageLink('order-slip', true); + @Mail::Send( (int)$objOrder->id_lang, 'credit_slip', From 1bb0e35085bea3da7aaac143d93a1245de53be0b Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 24 Feb 2023 17:31:38 +0530 Subject: [PATCH 07/77] Fix Operations Today --- modules/dashguestcycle/dashguestcycle.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/dashguestcycle/dashguestcycle.php b/modules/dashguestcycle/dashguestcycle.php index a012b2b8b..7eb15b98e 100644 --- a/modules/dashguestcycle/dashguestcycle.php +++ b/modules/dashguestcycle/dashguestcycle.php @@ -170,7 +170,7 @@ class DashGuestCycle extends Module } $tr[] = array( - 'value' => $arrivalInfo['adult'] + $arrivalInfo['children'], + 'value' => $arrivalInfo['adults'] + $arrivalInfo['children'], 'class' => 'text-center', ); $tr[] = array( @@ -230,7 +230,7 @@ class DashGuestCycle extends Module } $tr[] = array( - 'value' => $departureInfo['adult'] + $departureInfo['children'], + 'value' => $departureInfo['adults'] + $departureInfo['children'], 'class' => 'text-center', ); $tr[] = array( @@ -291,7 +291,7 @@ class DashGuestCycle extends Module } $tr[] = array( - 'value' => $inHouseInfo['adult'] + $inHouseInfo['children'], + 'value' => $inHouseInfo['adults'] + $inHouseInfo['children'], 'class' => 'text-center', ); $tr[] = array( From 7a20fd535f85dd02ce061bfbf8753a7123267571 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 24 Feb 2023 17:43:16 +0530 Subject: [PATCH 08/77] Preparation time text change --- controllers/admin/AdminOrderPreferencesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminOrderPreferencesController.php b/controllers/admin/AdminOrderPreferencesController.php index 5d75b728f..e1c53fd2d 100644 --- a/controllers/admin/AdminOrderPreferencesController.php +++ b/controllers/admin/AdminOrderPreferencesController.php @@ -72,7 +72,7 @@ class AdminOrderPreferencesControllerCore extends AdminController ), 'GLOBAL_PREPARATION_TIME' => array( 'title' => $this->l('Preparation time'), - 'hint' => $this->l('Number of days required to prepare a room for stay.'), + 'hint' => $this->l('Number of days required to prepare a room for a guest\'s stay. For example, if you set this value to 3 and someone is booking on 2nd of March he can only book rooms for dates from and after 3 days, i.e, 5th of March.'), 'desc' => $this->l('Set to 0 to disable this feature.'), 'type' => 'text', 'class' => 'fixed-width-xl', From bda0b5d48d1b755e20c0af535dc765bd283ec179 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Fri, 24 Feb 2023 18:59:28 +0530 Subject: [PATCH 09/77] totalAvailableRooms issue resolved on room detail page --- controllers/front/ProductController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..82b8c764f 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -603,6 +603,7 @@ class ProductControllerCore extends FrontController $quantity = 1; } + $totalAvailableRooms = 0; if ($hotelRoomData = $objBookingDetail->DataForFrontSearch($bookingParams)) { $totalAvailableRooms = $hotelRoomData['stats']['num_avail']; $quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity; From cefd2c52c90d05f104d0926d588a9896a0dddb9a Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 24 Feb 2023 19:07:21 +0530 Subject: [PATCH 10/77] Add statsdata module note --- modules/statscatalog/statscatalog.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/statscatalog/statscatalog.php b/modules/statscatalog/statscatalog.php index 199149606..a91052559 100644 --- a/modules/statscatalog/statscatalog.php +++ b/modules/statscatalog/statscatalog.php @@ -282,6 +282,12 @@ class StatsCatalog extends Module

'.$this->l('Defines the average conversion rate for the room type page. It is possible to book a room type without viewing the room type page, so this rate can be greater than 1.').' +

'; + + $link = $this->context->link->getAdminLink('AdminModules').'&configure=statsdata'; + $html .=' +

+ '.$this->l('Note: ').''.$this->l('You must enable the "Save global page views" option from ').'Data mining for statistics'.$this->l(' module for accurate data, or use the QloApps Google Analytics module.').'

'; From c6a98546d0c495651cfce0c0efef3fefa62216a4 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 24 Feb 2023 19:31:07 +0530 Subject: [PATCH 11/77] Change Geolocation file link --- controllers/admin/AdminGeolocationController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/admin/AdminGeolocationController.php b/controllers/admin/AdminGeolocationController.php index 0fbb808a1..4c960a331 100644 --- a/controllers/admin/AdminGeolocationController.php +++ b/controllers/admin/AdminGeolocationController.php @@ -139,9 +139,9 @@ class AdminGeolocationControllerCore extends AdminController { $this->display = 'options'; if (!$this->isGeoLiteCityAvailable()) { - $this->displayWarning($this->l('In order to use Geolocation, please download').' - '.$this->l('this file').' '. - $this->l('and extract it (using Winrar or Gzip) into the /tools/geoip/ directory.')); + $this->displayWarning($this->l('In order to use Geolocation, please download the file').' + GeoLiteCity.dat '. + $this->l('from GitHub and copy into the /tools/geoip/ directory.')); Configuration::updateValue('PS_GEOLOCATION_ENABLED', 0); } From b53706a53e1ded76614849ab7d1ba889b71c5f98 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Mon, 27 Feb 2023 14:49:49 +0530 Subject: [PATCH 12/77] Fixed hotel image issue on room type page --- controllers/front/ProductController.php | 7 +++++-- themes/hotel-reservation-theme/css/product.css | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..83eec473b 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -357,11 +357,12 @@ class ProductControllerCore extends FrontController // booking preparation time $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id); + $objHotelImage = new HotelImage(); $hotelImageLink = null; if ($coverImage = HotelImage::getCover($hotel_id)) { $hotelImagesBaseDir = _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/'; $hotelImageLink = $this->context->link->getMediaLink( - $hotelImagesBaseDir.$coverImage['hotel_image_id'].'.jpg' + $objHotelImage->getImageLink($coverImage['id'], ImageType::getFormatedName('large')) ); } @@ -603,6 +604,7 @@ class ProductControllerCore extends FrontController $quantity = 1; } + $totalAvailableRooms = 0; if ($hotelRoomData = $objBookingDetail->DataForFrontSearch($bookingParams)) { $totalAvailableRooms = $hotelRoomData['stats']['num_avail']; $quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity; @@ -1244,7 +1246,8 @@ class ProductControllerCore extends FrontController $hotelImagesBaseDir = _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/'; foreach ($hotelImages as &$hotelImage) { $hotelImage['link'] = $this->context->link->getMediaLink( - $hotelImagesBaseDir.$hotelImage['hotel_image_id'].'.jpg' + $objHotelImage->getImageLink($hotelImage['id'], + ImageType::getFormatedName('large')) ); } diff --git a/themes/hotel-reservation-theme/css/product.css b/themes/hotel-reservation-theme/css/product.css index 105900873..3ce47bf0f 100644 --- a/themes/hotel-reservation-theme/css/product.css +++ b/themes/hotel-reservation-theme/css/product.css @@ -1689,7 +1689,8 @@ ul.service-product-nav > li:hover { height: 200px; border-radius: 4px; object-fit: cover; - transition: all 0.2s; } + transition: all 0.2s; + box-shadow: #00000029 0px 0px 2px 1px; } #room_info_hotel_images .image-item img:hover { transform: scale(1.05); } From 7801e0469aa18cad8b73d44572de3d236947e990 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 27 Feb 2023 16:20:02 +0530 Subject: [PATCH 13/77] Fix Stats > Stats issues --- modules/statscheckup/statscheckup.php | 11 ----------- modules/statsforecast/statsforecast.php | 2 +- modules/statsproduct/statsproduct.php | 16 ++-------------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php index 132a933bf..5192a3d48 100644 --- a/modules/statscheckup/statscheckup.php +++ b/modules/statscheckup/statscheckup.php @@ -280,17 +280,6 @@ class StatsCheckUp extends Module ); foreach ($result as $row) { - $row['stock'] = 0; - if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($row['id_product'])) { - $bookingParams['hotel_id'] = $roomTypeInfo['id_hotel']; - $bookingParams['id_room_type'] = $row['id_product']; - if ($booking_data = $objBookingDtl->getBookingData($bookingParams)) { - if (isset($booking_data['stats']['num_avail'])) { - $row['stock'] = $booking_data['stats']['num_avail']; - } - } - } - $totals['products']++; $scores = array( 'active' => ($row['active'] ? 2 : 0), diff --git a/modules/statsforecast/statsforecast.php b/modules/statsforecast/statsforecast.php index 426ff4cf9..b4744b6c2 100644 --- a/modules/statsforecast/statsforecast.php +++ b/modules/statsforecast/statsforecast.php @@ -240,7 +240,7 @@ class StatsForecast extends Module $this->html .= ' - '.($this->context->cookie->stats_granularity == 42 ? (Tools::displayDate($row['fix_date']).' - '.Tools::displayDate($row['end_date'])) : Tools::displayDate($row['fix_date'])).' + '.($this->context->cookie->stats_granularity == 42 ? (Tools::displayDate($row['fix_date']).' - '.Tools::displayDate($row['end_date'])) : $row['fix_date']).' '.$visits_today.' '.(int)$row['registrations'].' '.(int)$row['countOrders'].' diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php index 53aff5c72..3c03159e0 100644 --- a/modules/statsproduct/statsproduct.php +++ b/modules/statsproduct/statsproduct.php @@ -302,20 +302,8 @@ class StatsProduct extends ModuleGraph '; - $bookingParams = array(); - $bookingParams['date_from'] = $dateFrom; - $bookingParams['date_to'] = $dateTo; - foreach ($this->getProducts($this->context->language->id) as $product) { - $availRooms = 0; - if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($product['id_product'])) { - $bookingParams['hotel_id'] = $roomTypeInfo['id_hotel']; - $bookingParams['id_room_type'] = $product['id_product']; - if ($booking_data = $objBookingDtl->getBookingData($bookingParams)) { - if (isset($booking_data['stats']['num_avail'])) { - $availRooms = $booking_data['stats']['num_avail']; - } - } - } + // get room types info + foreach ($this->getProducts() as $product) { $this->html .= ' From 420f77bec1c29c95afab1925357a6346d38af962 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 27 Feb 2023 16:41:39 +0530 Subject: [PATCH 14/77] Fix Purchased References --- controllers/admin/AdminStatsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 8a75a6383..8e30ebf28 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -284,7 +284,7 @@ class AdminStatsControllerCore extends AdminStatsTabController if (!$distinct_products) { return '0%'; } - return round(100 * $distinct_products / AdminStatsController::getTotalProducts()).'%'; + return round(100 * $distinct_products / AdminStatsController::getTotalRoomTypes()).'%'; } public static function getOrders($date_from, $date_to, $granularity = false, $id_hotel = false) From 2a51b07b8aa7c15165d0eebd9fa1bc19ac960ecf Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 27 Feb 2023 17:32:49 +0530 Subject: [PATCH 15/77] Fix Unknown customer age --- modules/statspersonalinfos/statspersonalinfos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/statspersonalinfos/statspersonalinfos.php b/modules/statspersonalinfos/statspersonalinfos.php index 1a7513894..6389d2255 100644 --- a/modules/statspersonalinfos/statspersonalinfos.php +++ b/modules/statspersonalinfos/statspersonalinfos.php @@ -324,7 +324,7 @@ class StatsPersonalInfos extends ModuleGraph // Total unknown $sql = 'SELECT COUNT(`id_customer`) as total FROM `'._DB_PREFIX_.'customer` - WHERE `birthday` IS NULL + WHERE `birthday` = "0000-00-00" '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) && $result['total']) { From 75eef294c0e116cc819f955a1a2f9cc3fe679c68 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 27 Feb 2023 19:18:46 +0530 Subject: [PATCH 16/77] Fix DRR on dashboard --- controllers/admin/AdminStatsController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 8a75a6383..75d7a7160 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1665,9 +1665,10 @@ class AdminStatsControllerCore extends AdminStatsTabController $dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo))); } - $sql = 'SELECT SUM(total_paid_tax_excl) + $sql = 'SELECT SUM(total_paid_tax_excl - refunded_amount) FROM ( SELECT o.`id_order`, o.`total_paid_tax_excl` / o.`conversion_rate` AS total_paid_tax_excl, + IFNULL(orr.`refunded_amount`, 0) AS refunded_amount, (SELECT hbd.`id_hotel` FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = o.`id_order` LIMIT 1 @@ -1677,6 +1678,8 @@ class AdminStatsControllerCore extends AdminStatsTabController ON (hbd.`id_order` = o.`id_order`) INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi ON (hbi.`id` = hbd.`id_hotel`) + LEFT JOIN `' ._DB_PREFIX_.'order_return` orr + ON (orr.`id_order` = o.`id_order`) WHERE o.`valid` = 1 AND hbi.`active` = 1 AND hbd.`is_refunded` = 0 AND o.`invoice_date` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59" AND o.`source` = "'.pSQL(Configuration::get('PS_SHOP_DOMAIN')).'"'. From cf2d5d657faf7d83c6675832b459afeb86beaca8 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 27 Feb 2023 19:28:13 +0530 Subject: [PATCH 17/77] updated category quantity field view --- .../hotel-reservation-theme/_partials/quantity_field.tpl | 2 +- themes/hotel-reservation-theme/css/category.css | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/themes/hotel-reservation-theme/_partials/quantity_field.tpl b/themes/hotel-reservation-theme/_partials/quantity_field.tpl index 08cb53f9a..e285af842 100644 --- a/themes/hotel-reservation-theme/_partials/quantity_field.tpl +++ b/themes/hotel-reservation-theme/_partials/quantity_field.tpl @@ -17,7 +17,7 @@ * @license LICENSE.txt *} -
+
diff --git a/themes/hotel-reservation-theme/css/category.css b/themes/hotel-reservation-theme/css/category.css index faaa81fa2..370a352e6 100644 --- a/themes/hotel-reservation-theme/css/category.css +++ b/themes/hotel-reservation-theme/css/category.css @@ -195,13 +195,11 @@ p.capa_txt { { text-align: right; } + .rm_qty_cont { + margin-bottom: 0; + } } -.rm_qty_cont -{ - width: 120px; - margin-right: 15px; -} .qty_txt { color: #333333; From a35999f4387ee61284032062654f4cb27ce77c56 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Mon, 27 Feb 2023 19:37:58 +0530 Subject: [PATCH 18/77] resolved text-issues --- .../controllers/dashboard/helpers/view/view.tpl | 12 ++++++------ .../controllers/products/additionalfacilities.tpl | 4 ++-- .../template/controllers/products/occupancy.tpl | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/admin/themes/default/template/controllers/dashboard/helpers/view/view.tpl b/admin/themes/default/template/controllers/dashboard/helpers/view/view.tpl index 3b54c23d5..593acfed7 100644 --- a/admin/themes/default/template/controllers/dashboard/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/dashboard/helpers/view/view.tpl @@ -129,15 +129,15 @@

{l s="Help Center"}

{l s="Official Documentation"}
-
{l s="Qloapps User Guide"}
+
{l s="QloApps User Guide"}
-
{l s="Qloapps Forum"}
-
{l s="Connect with the Qloapps community"}
+
{l s="QloApps Forum"}
+
{l s="Connect with the QloApps community"}
-
{l s="Qloapps Addons"}
-
{l s="Enhance your store Qloapps modules"}
+
{l s="QloApps Addons"}
+
{l s="Enhance your store QloApps modules"}
{l s="Contact Us!"}
@@ -148,4 +148,4 @@
- + \ No newline at end of file diff --git a/admin/themes/default/template/controllers/products/additionalfacilities.tpl b/admin/themes/default/template/controllers/products/additionalfacilities.tpl index 184db5f77..f3f6ee91f 100644 --- a/admin/themes/default/template/controllers/products/additionalfacilities.tpl +++ b/admin/themes/default/template/controllers/products/additionalfacilities.tpl @@ -24,7 +24,7 @@ {l s='Room Type Additional Facilities'}
- {l s='To create new Additiona facilities '} {l s='click here.'} + {l s='To create new Additional facilities'} {l s='click here.'}
{if isset($allDemands) && $allDemands}
@@ -112,4 +112,4 @@
{/if} -{/if} +{/if} \ No newline at end of file diff --git a/admin/themes/default/template/controllers/products/occupancy.tpl b/admin/themes/default/template/controllers/products/occupancy.tpl index 1605e2818..db17ea06e 100644 --- a/admin/themes/default/template/controllers/products/occupancy.tpl +++ b/admin/themes/default/template/controllers/products/occupancy.tpl @@ -54,7 +54,9 @@
- {l s='Below, enter the maximum of adults or children which can be accommodated in a room of this room type. Also, enter maximum number of guests for this room type.'} + {l s='Below, enter the maximum number of adults and children which can be accommodated in a room of this room type.'} +
+ {l s='For maximum room occupancy, the total number of guests which can be accommodated in a room of this room type.'}
From c55156d79709014d0bdc8e0a03b9009c46c234eb Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 27 Feb 2023 20:13:18 +0530 Subject: [PATCH 19/77] fixed free order and room reallocate issue --- classes/PaymentModule.php | 20 ++++--- .../views/js/HotelReservationAdmin.js | 59 ------------------- .../views/js/admin/hotel_rooms_booking.js | 57 ++++++++++++++++++ .../hotel_rooms_booking/helpers/view/view.tpl | 2 +- 4 files changed, 70 insertions(+), 68 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index c1427a39f..44d4a95f1 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -379,19 +379,23 @@ abstract class PaymentModuleCore extends Module (float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_ ); - $order->amount_paid = (float)Tools::ps_round( - (($order->advance_paid_amount * $amount_paid) / $this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, null, $id_carrier)), - _PS_PRICE_COMPUTE_PRECISION_ - ); + if ($totalOrder = $this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, null, $id_carrier)) { + $order->amount_paid = (float)Tools::ps_round( + (($order->advance_paid_amount * $amount_paid) / $totalOrder), + _PS_PRICE_COMPUTE_PRECISION_ + ); + } } else { $order->advance_paid_amount = (float)Tools::ps_round( (float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_ ); - $order->amount_paid = (float)Tools::ps_round( - (($order->advance_paid_amount * $amount_paid) / $this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)), - _PS_PRICE_COMPUTE_PRECISION_ - ); + if ($orderTotal = $this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)) { + $order->amount_paid = (float)Tools::ps_round( + (($order->advance_paid_amount * $amount_paid) / $orderTotal), + _PS_PRICE_COMPUTE_PRECISION_ + ); + } } // Creating order diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index e67d4faca..0c60a8389 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -411,65 +411,6 @@ $(document).ready(function() { $(this).parents('.child_feature_row').remove(); }); - /*For swaping rooms in the modal*/ - $("#realloc_allocated_rooms").on('click', function(e) { - $(".error_text").text(''); - if ($('#realloc_avail_rooms').val() == 0) { - $("#realloc_sel_rm_err_p").text(slct_rm_err); - return false; - } - }); - $("#swap_allocated_rooms").on('click', function(e) { - $(".error_text").text(''); - if ($('#swap_avail_rooms').val() == 0) { - $("#swap_sel_rm_err_p").text(slct_rm_err); - return false; - } - }); - - $('#mySwappigModal').on('hidden.bs.modal', function(e) { - $(".modal_date_from").val(''); - $(".modal_date_to").val(''); - $(".modal_id_room").val(''); - $(".modal_curr_room_num").val(''); - $(".cust_name").text(''); - $(".cust_email").text(''); - $(".swp_rm_opts").remove(); - $(".realloc_rm_opts").remove(); - }); - - $('#mySwappigModal').on('shown.bs.modal', function(e) { - $(".modal_date_from").val(e.relatedTarget.dataset.date_from); - $(".modal_date_to").val(e.relatedTarget.dataset.date_to); - $(".modal_id_room").val(e.relatedTarget.dataset.id_room); - $(".modal_curr_room_num").val(e.relatedTarget.dataset.room_num); - $(".cust_name").text(e.relatedTarget.dataset.cust_name); - $(".cust_email").text(e.relatedTarget.dataset.cust_email); - html = ''; - if (e.relatedTarget.dataset.avail_rm_realloc) { - var json_arr_rm_swp = JSON.parse(e.relatedTarget.dataset.avail_rm_swap); - $.each(json_arr_rm_swp, function(key, val) { - html += ''; - }); - } - if (html != '') { - $("#swap_avail_rooms").append(html); - } - - html = ''; - if (e.relatedTarget.dataset.avail_rm_realloc) { - var json_arr_rm_realloc = JSON.parse(e.relatedTarget.dataset.avail_rm_realloc); - $.each(json_arr_rm_realloc, function(key, val) { - html += ''; - }); - } - if (html != '') { - $("#realloc_avail_rooms").append(html); - } - }); - - /* ---- Book Now page Admin ---- */ - /* ---- HotelConfigurationSettingController Admin ---- */ if ($('#WK_SHOW_MSG_ON_BO_on').prop('checked') === true) { diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index de5b4a126..233b65b4a 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -954,4 +954,61 @@ $(document).ready(function() { return [true, ""]; } } + + /*For swaping rooms in the modal*/ + $("#realloc_allocated_rooms").on('click', function(e) { + $(".error_text").text(''); + if ($('#realloc_avail_rooms').val() == 0) { + $("#realloc_sel_rm_err_p").text(slct_rm_err); + return false; + } + }); + $("#swap_allocated_rooms").on('click', function(e) { + $(".error_text").text(''); + if ($('#swap_avail_rooms').val() == 0) { + $("#swap_sel_rm_err_p").text(slct_rm_err); + return false; + } + }); + + $('#mySwappigModal').on('hidden.bs.modal', function(e) { + $(".modal_date_from").val(''); + $(".modal_date_to").val(''); + $(".modal_id_room").val(''); + $(".modal_curr_room_num").val(''); + $(".cust_name").text(''); + $(".cust_email").text(''); + $(".swp_rm_opts").remove(); + $(".realloc_rm_opts").remove(); + }); + + $('#mySwappigModal').on('shown.bs.modal', function(e) { + $(".modal_date_from").val(e.relatedTarget.dataset.date_from); + $(".modal_date_to").val(e.relatedTarget.dataset.date_to); + $(".modal_id_room").val(e.relatedTarget.dataset.id_room); + $(".modal_curr_room_num").val(e.relatedTarget.dataset.room_num); + $(".cust_name").text(e.relatedTarget.dataset.cust_name); + $(".cust_email").text(e.relatedTarget.dataset.cust_email); + html = ''; + if (e.relatedTarget.dataset.avail_rm_realloc) { + var json_arr_rm_swp = JSON.parse(e.relatedTarget.dataset.avail_rm_swap); + $.each(json_arr_rm_swp, function(key, val) { + html += ''; + }); + } + if (html != '') { + $("#swap_avail_rooms").append(html); + } + + html = ''; + if (e.relatedTarget.dataset.avail_rm_realloc) { + var json_arr_rm_realloc = JSON.parse(e.relatedTarget.dataset.avail_rm_realloc); + $.each(json_arr_rm_realloc, function(key, val) { + html += ''; + }); + } + if (html != '') { + $("#realloc_avail_rooms").append(html); + } + }); }); \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl index f8454e636..4b23997ad 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl @@ -218,7 +218,7 @@
-
+
- + ({l s='Below'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years'})
@@ -123,7 +123,7 @@
- + ({l s='Below'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years'})
diff --git a/themes/hotel-reservation-theme/_partials/occupancy_field.tpl b/themes/hotel-reservation-theme/_partials/occupancy_field.tpl index e7870f4ab..e793e8618 100644 --- a/themes/hotel-reservation-theme/_partials/occupancy_field.tpl +++ b/themes/hotel-reservation-theme/_partials/occupancy_field.tpl @@ -63,7 +63,7 @@
- +
@@ -134,7 +134,7 @@
- +
From 7472b95ce263b2adb52057388cd2f82763db6250 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Tue, 28 Feb 2023 16:50:24 +0530 Subject: [PATCH 24/77] resolved db exception on qlocleaner integrity check --- modules/qlocleaner/qlocleaner.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/qlocleaner/qlocleaner.php b/modules/qlocleaner/qlocleaner.php index 931802cf2..8f0e96393 100644 --- a/modules/qlocleaner/qlocleaner.php +++ b/modules/qlocleaner/qlocleaner.php @@ -641,7 +641,6 @@ class QloCleaner extends Module array('warehouse_carrier', 'id_carrier', 'carrier', 'id_carrier'), array('warehouse_product_location', 'id_product', 'product', 'id_product'), array('warehouse_product_location', 'id_warehouse', 'warehouse', 'id_warehouse'), - array('product_comment', 'id_product', 'product', 'id_product'), array('specific_price', 'id_product', 'customer', 'id_customer'), array('specific_price', 'id_group', 'group', 'id_group'), array('htl_features_block_data_lang', 'id_features_block', 'htl_features_block_data', 'id_features_block'), From 1d5801b412fe072bd28b43ea44f9801cc6cc31c4 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 28 Feb 2023 18:44:37 +0530 Subject: [PATCH 25/77] update search panel --- .../classes/WkRoomSearchHelper.php | 26 +++++++------------ .../views/css/wk-category-search.css | 4 +++ .../views/css/wk-landing-page-search.css | 16 +++++++++++- .../views/css/wk-roomtype-search.css | 13 ++++++++++ .../views/js/wk-room-search-block.js | 4 ++- .../templates/hook/roomTypePageSearch.tpl | 6 +++-- .../views/templates/hook/searchForm.tpl | 2 +- 7 files changed, 49 insertions(+), 22 deletions(-) diff --git a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php index 67820f156..e0543f189 100644 --- a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php +++ b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php @@ -218,56 +218,48 @@ class WkRoomSearchHelper 'location' => 4, 'hotel' => 5, 'date' => 5, - 'occupancy' => 5, - 'search' => 3 + 'occupancy' => 4, + 'search' => 4 ); if (!$locationEnabled) { unset($search_column_widths['location']); - $search_column_widths['date'] += 1; + $search_column_widths['date'] += 2; $search_column_widths['search'] += 1; if ($occupancyEnabled) { - $search_column_widths['search'] += 1; $search_column_widths['occupancy'] += 1; } elseif ($smartyVars['show_hotel_name'] || count($hotelsInfo) > 1) { $search_column_widths['hotel'] += 1; } else { - $search_column_widths['search'] += 1; $search_column_widths['date'] += 1; } } if (!$smartyVars['show_hotel_name'] && count($hotelsInfo) <= 1) { unset($search_column_widths['hotel']); - $search_column_widths['date'] += 1; + $search_column_widths['date'] += 2; $search_column_widths['search'] += 1; if ($occupancyEnabled) { - $search_column_widths['date'] += 1; $search_column_widths['occupancy'] += 2; } else { - $search_column_widths['date'] += 1; $search_column_widths['date'] += 2; } } if (!$occupancyEnabled) { unset($search_column_widths['occupancy']); + $search_column_widths['date'] += 1; if ($smartyVars['show_hotel_name'] || count($hotelsInfo) > 1) { + $search_column_widths['hotel'] += 1; + $search_column_widths['date'] += 1; if ($locationEnabled) { - $search_column_widths['hotel'] += 1; $search_column_widths['location'] += 1; - $search_column_widths['search'] += 2; - $search_column_widths['date'] += 1; } else { - $search_column_widths['hotel'] += 2; - $search_column_widths['search'] += 2; - $search_column_widths['date'] += 2; - + $search_column_widths['date'] += 1; } } else { - $search_column_widths['date'] += 1; - $search_column_widths['date'] += 4; + $search_column_widths['date'] += 3; } } $smartyVars['column_widths'] = $search_column_widths; diff --git a/modules/wkroomsearchblock/views/css/wk-category-search.css b/modules/wkroomsearchblock/views/css/wk-category-search.css index 4e619cde8..fd3ce4f30 100644 --- a/modules/wkroomsearchblock/views/css/wk-category-search.css +++ b/modules/wkroomsearchblock/views/css/wk-category-search.css @@ -44,6 +44,10 @@ height: unset; min-height: 45px; } + #search_hotel_block_form #search_room_submit { + height: unset; + min-height: 45px; + } /* #search_hotel_block_form #search_room_submit { height: 45px; } */ diff --git a/modules/wkroomsearchblock/views/css/wk-landing-page-search.css b/modules/wkroomsearchblock/views/css/wk-landing-page-search.css index f1f5fcd26..1eb3038d2 100644 --- a/modules/wkroomsearchblock/views/css/wk-landing-page-search.css +++ b/modules/wkroomsearchblock/views/css/wk-landing-page-search.css @@ -24,6 +24,7 @@ left: 0; right: 0; z-index: 10;} + .header-rmsearch-hide-xs { background-image: url("../img/black-opacity-5.png");} .header-rmsearch-show-xs { @@ -50,7 +51,16 @@ #make_booking_btn_div { margin-top: 20px; text-align: center;} - +@media (max-width: 767px) { + .header-rmsearch-wrapper #search_hotel_block_form.grid { + grid-template-columns: 1fr; + column-gap: 0px; + } + .header-rmsearch-wrapper { + height: calc(100vw - 60px); + width: calc(100vw - 60px); + } +} .fancy_search_header_xs { margin-top: 25px; padding-left: 15px; @@ -62,6 +72,10 @@ float: left; margin-top: 5px; width: 125px;} + #search_hotel_block_form #search_room_submit { + height: unset; + min-height: 45px; + } /* .fancybox-inner #search_hotel_block_form { grid-template-columns: 1fr; } */ \ No newline at end of file diff --git a/modules/wkroomsearchblock/views/css/wk-roomtype-search.css b/modules/wkroomsearchblock/views/css/wk-roomtype-search.css index d2976d0f0..414039e20 100644 --- a/modules/wkroomsearchblock/views/css/wk-roomtype-search.css +++ b/modules/wkroomsearchblock/views/css/wk-roomtype-search.css @@ -64,6 +64,19 @@ background-color: #FAFAFA;} .faded-txt { color: #777777;} + #search_hotel_block_form #search_room_submit { + height: unset; + min-height: 45px; + } +@media (max-width: 767px) { + .header-rmsearch-wrapper #search_hotel_block_form.grid { + grid-template-columns: 1fr; + column-gap: 0px; + } + .header-rmsearch-details-wrapper .modify_roomtype_search_btn { + padding: 6px 12px; + } +} @media (max-width: 991px) { .header-rmsearch-wrapper .close_room_serach_wrapper { top: -8px; diff --git a/modules/wkroomsearchblock/views/js/wk-room-search-block.js b/modules/wkroomsearchblock/views/js/wk-room-search-block.js index b60e3a77b..6434ac658 100644 --- a/modules/wkroomsearchblock/views/js/wk-room-search-block.js +++ b/modules/wkroomsearchblock/views/js/wk-room-search-block.js @@ -42,7 +42,9 @@ $(document).ready(function() { padding: 0, autoScale: false, maxWidth: '100%', - 'hideOnContentClick': false, + helpers: { + overlay: { closeClick: false } //Disable click outside event + }, 'afterClose': function() { $('.header-rmsearch-container').show(); $('#xs_room_search_form').show(); diff --git a/modules/wkroomsearchblock/views/templates/hook/roomTypePageSearch.tpl b/modules/wkroomsearchblock/views/templates/hook/roomTypePageSearch.tpl index 95f9783e0..1c3d29e56 100644 --- a/modules/wkroomsearchblock/views/templates/hook/roomTypePageSearch.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/roomTypePageSearch.tpl @@ -26,7 +26,9 @@
-

{l s='Searched results for' mod='wkroomsearchblock'}:

+

{l s='Searched results for' mod='wkroomsearchblock'}: + +

@@ -35,7 +37,7 @@
-
+
diff --git a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl index 6f5dae6c9..b2ee7a61f 100644 --- a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl @@ -195,7 +195,7 @@
{/if}
-
From 2b82020381dcafa1098d57f56744d83cd9dd5192 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 28 Feb 2023 20:01:10 +0530 Subject: [PATCH 26/77] updated best and most viewed rooms stats --- modules/dashproducts/dashproducts.php | 2 +- modules/statsbestproducts/statsbestproducts.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/dashproducts/dashproducts.php b/modules/dashproducts/dashproducts.php index 3cbe6fc69..f3927610c 100644 --- a/modules/dashproducts/dashproducts.php +++ b/modules/dashproducts/dashproducts.php @@ -561,7 +561,7 @@ class DashProducts extends Module LEFT JOIN `'._DB_PREFIX_.'date_range` dr ON pv.`id_date_range` = dr.`id_date_range` LEFT JOIN `'._DB_PREFIX_.'page` p ON pv.`id_page` = p.`id_page` LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = p.`id_page_type` - LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON hrt.`id_product` = p.`id_object` + INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON hrt.`id_product` = p.`id_object` WHERE pt.`name` = \'product\' '.Shop::addSqlRestriction(false, 'pv').' AND dr.`time_start` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" diff --git a/modules/statsbestproducts/statsbestproducts.php b/modules/statsbestproducts/statsbestproducts.php index 04dfe49ff..1d91fd849 100644 --- a/modules/statsbestproducts/statsbestproducts.php +++ b/modules/statsbestproducts/statsbestproducts.php @@ -205,7 +205,8 @@ class StatsBestProducts extends ModuleGrid LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (hrt.`id_product` = p.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil - ON (hbil.`id` = hrt.`id_hotel` AND hbil.`id_lang` = '.(int) $id_lang .')'; + ON (hbil.`id` = hrt.`id_hotel` AND hbil.`id_lang` = '.(int) $id_lang .') + WHERE p.`booking_product` = 1'; if (Validate::IsName($this->_sort)) { $this->query .= ' ORDER BY `'.bqSQL($this->_sort).'`'; From 241e4a85b6775a35753fd6853dfad839609d32b0 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 28 Feb 2023 20:12:06 +0530 Subject: [PATCH 27/77] Text change --- .../dashperformance/views/templates/hook/dashboard_zone_two.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl index 91842bd5b..4ea64cba4 100644 --- a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl +++ b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl @@ -50,7 +50,7 @@
-
+

{l s='Total Revenue Per Available Room' mod='dashperformance'}

From 26023cfbf87af16816faf20dffb994b6c53e3146 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Tue, 28 Feb 2023 20:22:58 +0530 Subject: [PATCH 28/77] resolved guest order detail page issue --- controllers/front/GuestTrackingController.php | 336 ++++++++++++------ modules/statsdata/statsdata.php | 2 +- .../hotel-reservation-theme/order-detail.tpl | 2 +- 3 files changed, 236 insertions(+), 104 deletions(-) diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index e227fe592..0ce9722ea 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -49,16 +49,16 @@ class GuestTrackingControllerCore extends FrontController { if (Tools::isSubmit('submitGuestTracking') || Tools::isSubmit('submitTransformGuestToCustomer')) { // These lines are here for retrocompatibility with old theme - $id_order = Tools::getValue('id_order'); + $idOrder = Tools::getValue('id_order'); $order_collection = array(); - if ($id_order) { - if (is_numeric($id_order)) { - $order = new Order((int)$id_order); + if ($idOrder) { + if (is_numeric($idOrder)) { + $order = new Order((int)$idOrder); if (Validate::isLoadedObject($order)) { $order_collection = Order::getByReference($order->reference); } } else { - $order_collection = Order::getByReference($id_order); + $order_collection = Order::getByReference($idOrder); } } @@ -71,7 +71,7 @@ class GuestTrackingControllerCore extends FrontController $email = Tools::getValue('email'); - if (empty($order_reference) && empty($id_order)) { + if (empty($order_reference) && empty($idOrder)) { $this->errors[] = Tools::displayError('Please provide your order\'s reference number.'); } elseif (empty($email)) { $this->errors[] = Tools::displayError('Please provide a valid email address.'); @@ -185,6 +185,7 @@ class GuestTrackingControllerCore extends FrontController include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; $objHtlBranchInfo = new HotelBranchInformation(); $objBookingDetail = new HotelBookingDetail(); + $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); $objRoomType = new HotelRoomType(); $nonRequestedRooms = 0; @@ -225,130 +226,253 @@ class GuestTrackingControllerCore extends FrontController if ($orderProducts = $order->getProducts()) { $total_demands_price_te = 0; $total_demands_price_ti = 0; + $total_convenience_fee_te = 0; + $total_convenience_fee_ti = 0; + // ddd($orderProducts); foreach ($orderProducts as $type_key => $type_value) { if (in_array($type_value['product_id'], $processedProducts)) { continue; } - $processedProducts[] = $type_value['product_id']; + if ($type_value['is_booking_product']) { + $processedProducts[] = $type_value['product_id']; - $product = new Product($type_value['product_id'], false, $this->context->language->id); - $cover_image_arr = $product->getCover($type_value['product_id']); + $product = new Product($type_value['product_id'], false, $this->context->language->id); + $cover_image_arr = $product->getCover($type_value['product_id']); - if (!empty($cover_image_arr)) { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); - } else { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); - } - - if (isset($customer->id)) { - $obj_cart = new Cart($order->id_cart); - $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id); - } else { - $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); - } - $rm_dtl = $objRoomType->getRoomTypeInfoByIdProduct($type_value['product_id']); - - $cartHotelData[$type_key]['id_product'] = $type_value['product_id']; - $cartHotelData[$type_key]['cover_img'] = $cover_img; - $cartHotelData[$type_key]['adults'] = $rm_dtl['adults']; - $cartHotelData[$type_key]['children'] = $rm_dtl['children']; - - $objBookingDemand = new HotelBookingDemands(); - foreach ($order_bk_data as $data_k => $data_v) { - $date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']); - - /*Product price when order was created*/ - $order_details_obj = new OrderDetail($data_v['id_order_detail']); - $prod_ord_dtl_name = $order_details_obj->product_name; - $cartHotelData[$type_key]['name'] = $prod_ord_dtl_name; - - $cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity; - $cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity; - - if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1; - - $num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days']; - $var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant; - $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; - if ($data_v['is_back_order']) { - $anyBackOrder = 1; - } + if (!empty($cover_image_arr)) { + $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); } else { - $num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); + $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } - $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1; - $cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; - $cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; - $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; + if (isset($customer->id)) { + $obj_cart = new Cart($order->id_cart); + $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id); + } else { + $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); + } + $cartHotelData[$type_key]['id_product'] = $type_value['product_id']; + $cartHotelData[$type_key]['cover_img'] = $cover_img; - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; - if ($data_v['is_back_order']) { - $anyBackOrder = 1; + + $objBookingDemand = new HotelBookingDemands(); + foreach ($order_bk_data as $data_k => $data_v) { + $date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']); + + $cartHotelData[$type_key]['adults'] = $data_v['adults']; + $cartHotelData[$type_key]['children'] = $data_v['children']; + /*Product price when order was created*/ + $order_details_obj = new OrderDetail($data_v['id_order_detail']); + $cartHotelData[$type_key]['name'] = $order_details_obj->product_name; + $cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity; + $cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity; + + if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1; + + $num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days']; + $var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; + $cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; + if ($data_v['is_back_order']) { + $anyBackOrder = 1; + } + } else { + $num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); + $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1; + $cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; + $cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; + $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults']; + $cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; + if ($data_v['is_back_order']) { + $anyBackOrder = 1; + } } + + $cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( + $idOrder, + $type_value['product_id'], + 0, + $data_v['date_from'], + $data_v['date_to'] + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands( + $idOrder, + $type_value['product_id'], + $data_v['id_room'], + $data_v['date_from'], + $data_v['date_to'], + 0, + 1, + 1 + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands( + $idOrder, + $type_value['product_id'], + $data_v['id_room'], + $data_v['date_from'], + $data_v['date_to'], + 0, + 1, + 0 + ); + $total_demands_price_ti += $extraDemandPriceTI; + $total_demands_price_te += $extraDemandPriceTE; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl; + + $feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']); + $cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff; + + $cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name']; + // add additional services products in hotel detail. + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $idOrder, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'] + ); + + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $idOrder, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1 + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $idOrder, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0 + ); } - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - $idOrder, - $type_value['product_id'], - 0, - $data_v['date_from'], - $data_v['date_to'] - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0; + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; } - $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands( + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( $idOrder, - $type_value['product_id'], 0, + 0, + $type_value['product_id'], $data_v['date_from'], $data_v['date_to'], - 0, + $data_v['id_room'], 1, - 1 + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM ); - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI; - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0; + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; } - $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands( + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( $idOrder, - $type_value['product_id'], 0, + 0, + $type_value['product_id'], $data_v['date_from'], $data_v['date_to'], + $data_v['id_room'], + 1, 0, 1, - 0 + Product::PRICE_ADDITION_TYPE_WITH_ROOM ); - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE; - $total_demands_price_ti += $extraDemandPriceTI; - $total_demands_price_te += $extraDemandPriceTE; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl; + // calculate averages now + foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { + $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); + $value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6); - $feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']); - $cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff; + $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); + $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); + } + } else if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE) { + if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { + $total_convenience_fee_ti += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $idOrder, + $type_value['product_id'], + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ); + $total_convenience_fee_te += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $idOrder, + $type_value['product_id'], + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1 + ); + } + } else { + // get all products that are independent. + if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) { + $product = new Product($type_value['product_id'], false, $this->context->language->id); + $cover_image_arr = $product->getCover($type_value['product_id']); - //enter hotel name - $hotelInfo = $objHtlBranchInfo->hotelBranchesInfo( - Configuration::get('PS_LANG_DEFAULT'), - 2, - 0, - $data_v['id_hotel'] - ); - $cartHotelData[$type_key]['hotel_name'] = $hotelInfo['hotel_name']; + if (!empty($cover_image_arr)) { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); + } else { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } + $cartServiceProducts[] = $type_value; + } } } } @@ -359,8 +483,15 @@ class GuestTrackingControllerCore extends FrontController null, $this->context->language->id ); + $customerGuestDetail = false; + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + $customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail); + } + $this->context->smarty->assign( array( + 'total_convenience_fee_ti' => $total_convenience_fee_ti, + 'total_convenience_fee_te' => $total_convenience_fee_te, 'total_demands_price_ti' => $total_demands_price_ti, 'total_demands_price_te' => $total_demands_price_te, 'any_back_order' => $anyBackOrder, @@ -369,6 +500,7 @@ class GuestTrackingControllerCore extends FrontController 'order_has_invoice' => $order->hasInvoice(), 'cart_htl_data' => $cartHotelData, 'non_requested_rooms' => $nonRequestedRooms, + 'customerGuestDetail' => $customerGuestDetail, ) ); //end diff --git a/modules/statsdata/statsdata.php b/modules/statsdata/statsdata.php index 3e36b4216..f0be053a8 100644 --- a/modules/statsdata/statsdata.php +++ b/modules/statsdata/statsdata.php @@ -126,7 +126,7 @@ class StatsData extends Module FROM `'._DB_PREFIX_.'guest` WHERE `id_customer` = '.(int)$params['cookie']->id_customer); - if ((int)$result['id_guest']) { + if (isset($result['id_guest']) && ( int)$result['id_guest']) { // The new guest is merged with the old one when it's connecting to an account $guest->mergeWithCustomer($result['id_guest'], $params['cookie']->id_customer); $params['cookie']->id_guest = $guest->id; diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index 8808b58f0..5e932891b 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -399,7 +399,7 @@ {$data_v['hotel_name']|escape:'html':'UTF-8'}

- {if $rm_v['adults'] <= 9}0{$rm_v['adults']}{else}{$rm_v['adults']}{/if} {if $rm_v['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $rm_v['children']}, {if $rm_v['children'] <= 9}0{$rm_v['children']}{else} {$rm_v['children']}{/if} {if $rm_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}
{if $rm_v['num_rm'] <= 9}0{/if}{$rm_v['num_rm']} {if $rm_v['num_rm'] > 1}{l s='Rooms'}{else}{l s='Room'}{/if} + {if $data_v['adults'] <= 9}0{$data_v['adults']}{else}{$data_v['adults']}{/if} {if $data_v['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $data_v['children']}, {if $data_v['children'] <= 9}0{$data_v['children']}{else} {$data_v['children']}{/if} {if $data_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}
{if $rm_v['num_rm'] <= 9}0{/if}{$rm_v['num_rm']} {if $rm_v['num_rm'] > 1}{l s='Rooms'}{else}{l s='Room'}{/if}

{$rm_v['data_form']|date_format:"%d-%m-%Y"} From c1cc3304c349c664b3af1f3d33ee247a96d3bc00 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Wed, 1 Mar 2023 12:35:25 +0530 Subject: [PATCH 29/77] resolved php warnings on refund request --- classes/order/OrderReturn.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 41623a56e..10c549b4e 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -219,13 +219,13 @@ class OrderReturnCore extends ObjectModel 0 ); $bookingRow['additional_services_tax_excl'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, + $bookingRow['id_order'], 0, 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], + $bookingRow['id_product'], + $bookingRow['date_from'], + $bookingRow['date_to'], + $bookingRow['id_room'], 1, 0 ); From 09434009e80a49e9f9ba17d65f68a6940c9813e8 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 1 Mar 2023 12:52:42 +0530 Subject: [PATCH 30/77] Fix maps on room type detail page --- themes/hotel-reservation-theme/js/product.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 96ae9a806..3359014cf 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1029,7 +1029,9 @@ function checkUrl() { /*#####################################################################*/ $(document).ready(function() { - BookingForm.init(); + if (!PS_CATALOG_MODE) { + BookingForm.init(); + } $(document).on('QloApps:updateRoomOccupancy', function(e) { BookingForm.refresh(); From 1bb06de67fc2067c88856a1afcda2a48ec4a4fe9 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 1 Mar 2023 12:55:11 +0530 Subject: [PATCH 31/77] Remove Order Restrict --- .../classes/HotelReservationSystemDb.php | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 62c56975c..dd5f1c62b 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -471,11 +471,10 @@ class HotelReservationSystemDb "INSERT INTO `"._DB_PREFIX_."htl_settings_link` (`id_settings_link`, `icon`, `link`, `new_window`, `position`, `unremovable`, `active`, `date_add`, `date_upd`) VALUES (1, 'icon-cogs', 'index.php?controller=AdminHotelGeneralSettings', 0, 0, 1, 1, NOW(), NOW()), - (2, 'icon-list-alt', 'index.php?controller=AdminOrderRestrictSettings', 0, 1, 1, 1, NOW(), NOW()), - (3, 'icon-dollar', 'index.php?controller=AdminHotelFeaturePricesSettings', 0, 2, 1, 1, NOW(), NOW()), - (4, 'icon-plus-square', 'index.php?controller=AdminRoomTypeGlobalDemand', 0, 3, 1, 1, NOW(), NOW()), - (5, 'icon-file-text', 'index.php?controller=AdminAboutHotelBlockSetting', 0, 4, 0, 1, NOW(), NOW()), - (6, 'icon-th-list', 'index.php?controller=AdminFeaturesModuleSetting', 0, 5, 0, 1, NOW(), NOW());", + (2, 'icon-dollar', 'index.php?controller=AdminHotelFeaturePricesSettings', 0, 2, 1, 1, NOW(), NOW()), + (3, 'icon-plus-square', 'index.php?controller=AdminRoomTypeGlobalDemand', 0, 3, 1, 1, NOW(), NOW()), + (4, 'icon-file-text', 'index.php?controller=AdminAboutHotelBlockSetting', 0, 4, 0, 1, NOW(), NOW()), + (5, 'icon-th-list', 'index.php?controller=AdminFeaturesModuleSetting', 0, 5, 0, 1, NOW(), NOW());", "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_settings_link_lang` ( `id_settings_link` int(10) unsigned NOT NULL, @@ -491,27 +490,22 @@ class HotelReservationSystemDb ORDER BY `id_lang`;", "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) - SELECT 2, `id_lang`, 'Order Restrict', 'Configure if you want to restrict orders till a specific date for your hotels.' + SELECT 2, `id_lang`, 'Advanced Price Rules', 'Here set Advanced price rules for specific dates.' FROM `"._DB_PREFIX_."lang` ORDER BY `id_lang`;", "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) - SELECT 3, `id_lang`, 'Advanced Price Rules', 'Here set Advanced price rules for specific dates.' + SELECT 3, `id_lang`, 'Additional Facilities', 'Here create Additional facilities and their prices for room types.' FROM `"._DB_PREFIX_."lang` ORDER BY `id_lang`;", "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) - SELECT 4, `id_lang`, 'Additional Facilities', 'Here create Additional facilities and their prices for room types.' + SELECT 4, `id_lang`, 'Hotel Interior Block', 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.' FROM `"._DB_PREFIX_."lang` ORDER BY `id_lang`;", "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) - SELECT 5, `id_lang`, 'Hotel Interior Block', 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.' - FROM `"._DB_PREFIX_."lang` - ORDER BY `id_lang`;", - - "INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) - SELECT 6, `id_lang`, 'Hotel Amenities Block', 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.' + SELECT 5, `id_lang`, 'Hotel Amenities Block', 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.' FROM `"._DB_PREFIX_."lang` ORDER BY `id_lang`;", ); From 84a2e07eb4a1e05e46edb48b1842981eac32d0ca Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Wed, 1 Mar 2023 18:54:09 +0530 Subject: [PATCH 32/77] remove unused category kpis --- .../admin/AdminCategoriesController.php | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index ae49e80d2..20725ae55 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -369,49 +369,49 @@ class AdminCategoriesControllerCore extends AdminController } } - public function renderKpis() - { - $time = time(); - $kpis = array(); + // public function renderKpis() + // { + // $time = time(); + // $kpis = array(); - $helper = new HelperKpi(); - $helper->id = 'box-disabled-categories'; - $helper->icon = 'icon-off'; - $helper->color = 'color1'; - $helper->title = $this->l('Disabled Categories', null, null, false); - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_categories'; - $kpis[] = $helper->generate(); + // $helper = new HelperKpi(); + // $helper->id = 'box-disabled-categories'; + // $helper->icon = 'icon-off'; + // $helper->color = 'color1'; + // $helper->title = $this->l('Disabled Categories', null, null, false); + // $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_categories'; + // $kpis[] = $helper->generate(); - // $helper = new HelperKpi(); - // $helper->id = 'box-empty-categories'; - // $helper->icon = 'icon-bookmark-empty'; - // $helper->color = 'color2'; - // $helper->href = $this->context->link->getAdminLink('AdminTracking'); - // $helper->title = $this->l('Empty Categories', null, null, false); - // $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=empty_categories'; - // $kpis[] = $helper->generate(); + // // $helper = new HelperKpi(); + // // $helper->id = 'box-empty-categories'; + // // $helper->icon = 'icon-bookmark-empty'; + // // $helper->color = 'color2'; + // // $helper->href = $this->context->link->getAdminLink('AdminTracking'); + // // $helper->title = $this->l('Empty Categories', null, null, false); + // // $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=empty_categories'; + // // $kpis[] = $helper->generate(); - $helper = new HelperKpi(); - $helper->id = 'box-top-category'; - $helper->icon = 'icon-money'; - $helper->color = 'color3'; - $helper->title = $this->l('Top Category', null, null, false); - $helper->subtitle = $this->l('30 days', null, null, false); - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=top_category'; - $kpis[] = $helper->generate(); + // $helper = new HelperKpi(); + // $helper->id = 'box-top-category'; + // $helper->icon = 'icon-money'; + // $helper->color = 'color3'; + // $helper->title = $this->l('Top Category', null, null, false); + // $helper->subtitle = $this->l('30 days', null, null, false); + // $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=top_category'; + // $kpis[] = $helper->generate(); - $helper = new HelperKpi(); - $helper->id = 'box-products-per-category'; - $helper->icon = 'icon-search'; - $helper->color = 'color4'; - $helper->title = $this->l('Average number of products per category', null, null, false); - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=products_per_category'; - $kpis[] = $helper->generate(); + // $helper = new HelperKpi(); + // $helper->id = 'box-products-per-category'; + // $helper->icon = 'icon-search'; + // $helper->color = 'color4'; + // $helper->title = $this->l('Average number of products per category', null, null, false); + // $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=products_per_category'; + // $kpis[] = $helper->generate(); - $helper = new HelperKpiRow(); - $helper->kpis = $kpis; - return $helper->generate(); - } + // $helper = new HelperKpiRow(); + // $helper->kpis = $kpis; + // return $helper->generate(); + // } public function renderForm() { From 722e3cbc8c769ed2793ac94abef6d3d45fbb6923 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Wed, 1 Mar 2023 20:42:50 +0530 Subject: [PATCH 33/77] resolved service product url issue --- controllers/front/ProductController.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..6cf7da8b3 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -114,6 +114,10 @@ class ProductControllerCore extends FrontController $this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id); } + if (!$this->product->booking_product) { + Tools::redirect($this->context->link->getPageLink('pagenotfound')); + } + if (!Validate::isLoadedObject($this->product)) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); @@ -192,12 +196,6 @@ class ProductControllerCore extends FrontController $this->context->cookie->last_visited_category = (int)$this->category->id_category; } } - - if (!$this->product->booking_product) { - header('HTTP/1.1 403 Forbidden'); - header('Status: 403 Forbidden'); - $this->errors[] = Tools::displayError('You do not have access to this Product.'); - } } } From de1846ec9f7b98fb9448ba3ecaf541403af69b4f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 2 Mar 2023 15:11:10 +0530 Subject: [PATCH 34/77] Fix stats --- install/data/xml/configuration.xml | 18 + .../statsbestproducts/statsbestproducts.php | 2 +- modules/statscatalog/statscatalog.php | 12 +- modules/statscheckup/statscheckup.php | 402 ++++++++++++++++-- modules/statsproduct/statsproduct.php | 17 +- 5 files changed, 388 insertions(+), 63 deletions(-) diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 6a465c94a..c9babed8d 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -686,6 +686,24 @@ 3 + + 50 + + + 150 + + + 1 + + + 2 + + + 1 + + + 2 + 0_3|0_4 diff --git a/modules/statsbestproducts/statsbestproducts.php b/modules/statsbestproducts/statsbestproducts.php index 04dfe49ff..fcee8f62e 100644 --- a/modules/statsbestproducts/statsbestproducts.php +++ b/modules/statsbestproducts/statsbestproducts.php @@ -202,7 +202,7 @@ class StatsBestProducts extends ModuleGrid FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int) $id_lang .') - LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt + INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (hrt.`id_product` = p.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = hrt.`id_hotel` AND hbil.`id_lang` = '.(int) $id_lang .')'; diff --git a/modules/statscatalog/statscatalog.php b/modules/statscatalog/statscatalog.php index 199149606..8f4ab5af6 100644 --- a/modules/statscatalog/statscatalog.php +++ b/modules/statscatalog/statscatalog.php @@ -46,7 +46,7 @@ class StatsCatalog extends Module parent::__construct(); - $this->displayName = $this->l('Catalog statistics'); + $this->displayName = $this->l('Hotel statistics'); $this->description = $this->l('Adds a tab containing general statistics about your catalog to the Stats dashboard.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.7.0.99'); } @@ -119,7 +119,7 @@ class StatsCatalog extends Module LEFT JOIN `'._DB_PREFIX_.'page` pa ON pv.`id_page` = pa.`id_page` LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = pa.`id_page_type` LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = pa.`id_object` - LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`) + INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`) '.Shop::addSqlAssociation('product', 'p').' '.$this->join.' WHERE pt.`name` IN ("product.php", "product") @@ -149,7 +149,7 @@ class StatsCatalog extends Module FROM `'._DB_PREFIX_.'image` i LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = i.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt + INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (hrt.`id_product` = i.`id_product`) WHERE hrt.`id_hotel` = hbi.`id` ) AS room_type_images @@ -174,7 +174,7 @@ class StatsCatalog extends Module FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.`id_order` = od.`id_order` LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = od.`product_id` - LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`) + INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`) '.Shop::addSqlAssociation('product', 'p').' '.$this->join.' WHERE o.valid = 1 @@ -194,7 +194,7 @@ class StatsCatalog extends Module $sql = 'SELECT p.id_product, pl.name, pl.link_rewrite FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`) + INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').') '.$this->join.' @@ -287,7 +287,7 @@ class StatsCatalog extends Module if (count($products_nb) && count($products_nb) < 50) { $html .= ' -
'.$this->l('Room types never booked').'
+
'.$this->l('Room types never booked').'
diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php index 132a933bf..5ef5451e6 100644 --- a/modules/statscheckup/statscheckup.php +++ b/modules/statscheckup/statscheckup.php @@ -91,6 +91,8 @@ class StatsCheckUp extends Module .$this->displayName.' '; + $activeTab = 'hotels'; + if (Tools::isSubmit('submitCheckupRoomType')) { $confs = array( 'ROOM_TYPE_CHECKUP_DESCRIPTIONS_LT', @@ -129,6 +131,25 @@ class StatsCheckUp extends Module $this->html .= $this->displayConfirmation($this->l('Configuration updated.')); } + if (Tools::isSubmit('submitCheckupService')) { + $confs = array( + 'SERVICE_CHECKUP_DESCRIPTIONS_SHORT_LT', + 'SERVICE_CHECKUP_DESCRIPTIONS_SHORT_GT', + 'SERVICE_CHECKUP_IMAGES_LT', + 'SERVICE_CHECKUP_IMAGES_GT', + 'SERVICE_CHECKUP_ORDERS_LT', + 'SERVICE_CHECKUP_ORDERS_GT', + ); + + foreach ($confs as $confname) { + Configuration::updateValue($confname, (int)Tools::getValue($confname)); + } + + $this->html .= $this->displayConfirmation($this->l('Configuration updated.')); + + $activeTab = 'services'; + } + if (Tools::isSubmit('submitCheckupOrder')) { $this->context->cookie->checkup_order = (int)Tools::getValue('submitCheckupOrder'); $this->html .= $this->displayConfirmation($this->l('Configuration updated.')); @@ -142,6 +163,35 @@ class StatsCheckUp extends Module $this->id_hotel = (int) Tools::getValue('id_hotel'); } + $this->html .= ' + + +
+
+ '.$this->getHotelsTab().' +
+
+ '.$this->getServicesTab().' +
+
+ '; + + return $this->html; + } + + private function getHotelsTab() + { $employee = Context::getContext()->employee; $prop30 = ((strtotime($employee->stats_date_to.' 23:59:59') - strtotime($employee->stats_date_from.' 00:00:00')) / 60 / 60 / 24) / 30; @@ -187,7 +237,7 @@ class StatsCheckUp extends Module 'TOTAL_ROOMS' => array('name' => $this->l('Total rooms'), 'text' => $this->l('rooms')), ); - $this->html .= ' + $hotelsHtml = '
@@ -200,7 +250,7 @@ class StatsCheckUp extends Module foreach ($array_conf as $conf => $translations) { $confKeyLt = ($this->id_hotel ? 'ROOM_TYPE' : 'HOTEL').'_CHECKUP_'.$conf.'_LT'; $confKeyGt = ($this->id_hotel ? 'ROOM_TYPE' : 'HOTEL').'_CHECKUP_'.$conf.'_GT'; - $this->html .= ' + $hotelsHtml .= ' '; } - $this->html .= '
@@ -227,7 +277,7 @@ class StatsCheckUp extends Module
+ $hotelsHtml .= ' @@ -251,12 +301,12 @@ class StatsCheckUp extends Module '.$this->l('ID').' - '.$this->l('Room type').' + '.(!$this->id_hotel ? $this->l('Hotel') : $this->l('Room type')).' '.$this->l('Active').''; foreach ($languages as $language) { - $this->html .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).')'; + $hotelsHtml .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).')'; } - $this->html .= ' + $hotelsHtml .= ' '.$this->l('Images').' '.$this->l('Orders').' '.$this->l('Total rooms').' @@ -280,17 +330,6 @@ class StatsCheckUp extends Module ); foreach ($result as $row) { - $row['stock'] = 0; - if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($row['id_product'])) { - $bookingParams['hotel_id'] = $roomTypeInfo['id_hotel']; - $bookingParams['id_room_type'] = $row['id_product']; - if ($booking_data = $objBookingDtl->getBookingData($bookingParams)) { - if (isset($booking_data['stats']['num_avail'])) { - $row['stock'] = $booking_data['stats']['num_avail']; - } - } - } - $totals['products']++; $scores = array( 'active' => ($row['active'] ? 2 : 0), @@ -302,7 +341,7 @@ class StatsCheckUp extends Module $totals['images'] += (int)$scores['images']; $totals['orders'] += (int)$scores['orders']; $totals['total_rooms'] += (int)$scores['total_rooms']; - $descriptions = $this->getDescriptions($row['id_object']); + $descriptions = $this->getDescriptions($this->id_hotel ? 'room_type' : 'hotel', $row['id_object']); foreach ($descriptions as $description) { if (isset($description['iso_code']) && isset($description['description'])) { $row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description'])); @@ -321,16 +360,16 @@ class StatsCheckUp extends Module } else { $objectLink = $this->context->link->getAdminLink('AdminAddHotel').'&updatehtl_branch_info&id='.$row['id_object']; } - $this->html .= ' + $hotelsHtml .= ' '.$row['id_object'].' '.Tools::substr($row['object_name'], 0, 42).' '.$array_colors[$scores['active']].''; foreach ($languages as $language) { if (isset($row['desclength_'.$language['iso_code']])) { - $this->html .= ''.(int)$row['desclength_'.$language['iso_code']].' '.$array_colors[$scores['description_'.$language['iso_code']]].''; + $hotelsHtml .= ''.(int)$row['desclength_'.$language['iso_code']].' '.$array_colors[$scores['description_'.$language['iso_code']]].''; } else { - $this->html .= '0 '.$array_colors[0].''; + $hotelsHtml .= '0 '.$array_colors[0].''; } } @@ -339,7 +378,7 @@ class StatsCheckUp extends Module $objectViewLink = $this->context->link->getAdminLink('AdminStats').'&module='.$this->name.'&id_hotel='.$row['id_object']; } - $this->html .= ' + $hotelsHtml .= ' '.(int)$row['nbImages'].' '.$array_colors[$scores['images']].' '.(int)$row['nbOrders'].' '.$array_colors[$scores['orders']].' '.(int)$row['totalRooms'].' '.$array_colors[$scores['total_rooms']].' @@ -348,7 +387,7 @@ class StatsCheckUp extends Module '; } - $this->html .= ''; + $hotelsHtml .= ''; $totals['active'] = $totals['active'] / $totals['products']; $totals['active'] = ($totals['active'] < 1 ? 0 : ($totals['active'] > 1.5 ? 2 : 1)); @@ -365,15 +404,15 @@ class StatsCheckUp extends Module $totals['average'] = array_sum($totals) / $divisor; $totals['average'] = ($totals['average'] < 1 ? 0 : ($totals['average'] > 1.5 ? 2 : 1)); - $this->html .= ' + $hotelsHtml .= ' '.$this->l('Active').''; foreach ($languages as $language) { - $this->html .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).')'; + $hotelsHtml .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).')'; } - $this->html .= ' + $hotelsHtml .= ' '.$this->l('Images').' '.$this->l('Orders').' '.$this->l('Total rooms').' @@ -384,19 +423,248 @@ class StatsCheckUp extends Module '.$array_colors[$totals['active']].''; foreach ($languages as $language) { - $this->html .= ''.$array_colors[$totals['description_'.$language['iso_code']]].''; + $hotelsHtml .= ''.$array_colors[$totals['description_'.$language['iso_code']]].''; } - $this->html .= ' + $hotelsHtml .= ' '.$array_colors[$totals['images']].' '.$array_colors[$totals['orders']].' '.$array_colors[$totals['total_rooms']].' '.$array_colors[$totals['average']].' '.(!$this->id_hotel ? '' : '').' + '.($this->id_hotel ? ' + + + + '.$this->l('Back').' + + + ' : '').'
'; - return $this->html; + return $hotelsHtml; + } + + private function getServicesTab() + { + $employee = Context::getContext()->employee; + $prop30 = ((strtotime($employee->stats_date_to.' 23:59:59') - strtotime($employee->stats_date_from.' 00:00:00')) / 60 / 60 / 24) / 30; + + // Get languages + $sql = 'SELECT l.* + FROM '._DB_PREFIX_.'lang l' + .Shop::addSqlAssociation('lang', 'l'); + $languages = Db::getInstance()->executeS($sql); + + $array_colors = array( + 0 => ''.$this->l('Bad').'', + 1 => ''.$this->l('Average').'', + 2 => ''.$this->l('Good').'' + ); + + $divisor = 4; + $totals = array('services' => 0, 'active' => 0, 'images' => 0, 'orders' => 0, 'associated_room_types' => 0); + foreach ($languages as $language) { + $divisor++; + $totals['description_'.$language['iso_code']] = 0; + } + + // set data from here + $result = $this->getServiceStats(); + + if (!$result) { + return $this->l('No service was found.'); + } + + $array_conf = array( + 'DESCRIPTIONS_SHORT' => array('name' => $this->l('Descriptions'), 'text' => $this->l('chars (without HTML)')), + 'IMAGES' => array('name' => $this->l('Images'), 'text' => $this->l('images')), + 'ORDERS' => array('name' => $this->l('Orders'), 'text' => $this->l('orders / month')), + ); + + $servicesHtml = ' + + + + + + + + + '; + foreach ($array_conf as $conf => $translations) { + $confKeyLt = 'SERVICE_CHECKUP_'.$conf.'_LT'; + $confKeyGt = 'SERVICE_CHECKUP_'.$conf.'_GT'; + $servicesHtml .= ' + + + + + + + '; + } + $servicesHtml .= '
'.$array_colors[0].' '.$this->l('Not enough').''.$array_colors[2].' '.$this->l('Alright').'
+ + +
+
+ '.$this->l('Less than').' + + '.$translations['text'].' +
+
+
+
+
+ '.$this->l('Greater than').' + + '.$translations['text'].' +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+ + + + + + + '; + foreach ($languages as $language) { + $servicesHtml .= ''; + } + $servicesHtml .= ' + + + + '.(!$this->id_hotel ? '' : '').' + + + '; + + + $confCheckup = array( + 'IMAGES_LT' => Configuration::get('SERVICE_CHECKUP_IMAGES_LT'), + 'IMAGES_GT' => Configuration::get('SERVICE_CHECKUP_IMAGES_GT'), + 'ORDERS_LT' => Configuration::get('SERVICE_CHECKUP_ORDERS_LT'), + 'ORDERS_GT' => Configuration::get('SERVICE_CHECKUP_ORDERS_GT'), + 'DESCRIPTIONS_SHORT_LT' => Configuration::get('SERVICE_CHECKUP_DESCRIPTIONS_SHORT_LT'), + 'DESCRIPTIONS_SHORT_GT' => Configuration::get('SERVICE_CHECKUP_DESCRIPTIONS_SHORT_GT'), + ); + + foreach ($result as $row) { + $totals['services']++; + $scores = array( + 'active' => ($row['active'] ? 2 : 0), + 'images' => ($row['nbImages'] < $confCheckup['IMAGES_LT'] ? 0 : ($row['nbImages'] > $confCheckup['IMAGES_GT'] ? 2 : 1)), + 'orders' => (($row['nbOrders'] * $prop30 < $confCheckup['ORDERS_LT']) ? 0 : (($row['nbOrders'] * $prop30 > $confCheckup['ORDERS_GT']) ? 2 : 1)), + ); + $totals['active'] += (int)$scores['active']; + $totals['images'] += (int)$scores['images']; + $totals['orders'] += (int)$scores['orders']; + $descriptions = $this->getDescriptions('service', $row['id_object']); + foreach ($descriptions as $description) { + if (isset($description['iso_code']) && isset($description['description_short'])) { + $row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description_short'])); + } + if (isset($description['iso_code'])) { + $scores['description_'.$description['iso_code']] = ($row['desclength_'.$description['iso_code']] < $confCheckup['DESCRIPTIONS_SHORT_LT'] ? 0 : ($row['desclength_'.$description['iso_code']] > $confCheckup['DESCRIPTIONS_SHORT_GT'] ? 2 : 1)); + $totals['description_'.$description['iso_code']] += $scores['description_'.$description['iso_code']]; + } + } + $scores['average'] = array_sum($scores) / $divisor; + $scores['average'] = ($scores['average'] < 1 ? 0 : ($scores['average'] > 1.5 ? 2 : 1)); + + $objectLink = $this->context->link->getAdminLink('AdminNormalProducts').'&updateproduct&id_product='.$row['id_object']; + $servicesHtml .= ' + + + + + '; + foreach ($languages as $language) { + if (isset($row['desclength_'.$language['iso_code']])) { + $servicesHtml .= ''; + } else { + $servicesHtml .= ''; + } + } + + $servicesHtml .= ' + + + + '; + } + + $servicesHtml .= ''; + + $totals['active'] = $totals['active'] / $totals['services']; + $totals['active'] = ($totals['active'] < 1 ? 0 : ($totals['active'] > 1.5 ? 2 : 1)); + $totals['images'] = $totals['images'] / $totals['services']; + $totals['images'] = ($totals['images'] < 1 ? 0 : ($totals['images'] > 1.5 ? 2 : 1)); + $totals['orders'] = $totals['orders'] / $totals['services']; + $totals['orders'] = ($totals['orders'] < 1 ? 0 : ($totals['orders'] > 1.5 ? 2 : 1)); + $totals['associated_room_types'] = $totals['associated_room_types'] / $totals['services']; + $totals['associated_room_types'] = ($totals['associated_room_types'] < 1 ? 0 : ($totals['associated_room_types'] > 1.5 ? 2 : 1)); + foreach ($languages as $language) { + $totals['description_'.$language['iso_code']] = $totals['description_'.$language['iso_code']] / $totals['services']; + $totals['description_'.$language['iso_code']] = ($totals['description_'.$language['iso_code']] < 1 ? 0 : ($totals['description_'.$language['iso_code']] > 1.5 ? 2 : 1)); + } + $totals['average'] = array_sum($totals) / $divisor; + $totals['average'] = ($totals['average'] < 1 ? 0 : ($totals['average'] > 1.5 ? 2 : 1)); + + $servicesHtml .= ' + + + + + '; + foreach ($languages as $language) { + $servicesHtml .= ''; + } + $servicesHtml .= ' + + + + '.(!$this->id_hotel ? '' : '').' + + + + + '; + foreach ($languages as $language) { + $servicesHtml .= ''; + } + $servicesHtml .= ' + + + + + +
'.$this->l('ID').''.$this->l('Service').''.$this->l('Active').''.$this->l('Associated room types').''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).')'.$this->l('Images').''.$this->l('Orders').''.$this->l('Overall status').''.$this->l('Action').'
'.$row['id_object'].''.Tools::substr($row['object_name'], 0, 42).''.$array_colors[$scores['active']].''.$row['nbAssociatedRoomTypes'].''.(int)$row['desclength_'.$language['iso_code']].' '.$array_colors[$scores['description_'.$language['iso_code']]].'0 '.$array_colors[0].''.(int)$row['nbImages'].' '.$array_colors[$scores['images']].''.(int)$row['nbOrders'].' '.$array_colors[$scores['orders']].''.$array_colors[$scores['average']].'
'.$this->l('Active').''.$this->l('Associated room types').''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).')'.$this->l('Images').''.$this->l('Orders').''.$this->l('Overall status').'
'.$array_colors[$totals['active']].'NA'.$array_colors[$totals['description_'.$language['iso_code']]].''.$array_colors[$totals['images']].''.$array_colors[$totals['orders']].''.$array_colors[$totals['average']].'
'; + + return $servicesHtml; } public function getHotelStats() @@ -479,20 +747,49 @@ class StatsCheckUp extends Module return Db::getInstance()->executeS($sql); } - public function getDescriptions($id_object) + public function getServiceStats() { - if ($this->id_hotel) { - return Db::getInstance()->executeS( - 'SELECT l.`iso_code`, pl.`description` - FROM '._DB_PREFIX_.'product_lang pl - LEFT JOIN '._DB_PREFIX_.'lang l - ON pl.`id_lang` = l.`id_lang` - LEFT JOIN '._DB_PREFIX_.'htl_room_type hrt - ON (hrt.`id_product` = pl.`id_product`) - WHERE hrt.`id_hotel` = '.(int) $this->id_hotel.' - AND pl.`id_product` = '.(int) $id_object - ); - } else { + $date_from = date('Y-m-d', strtotime($this->context->employee->stats_date_from)); + $date_to = date('Y-m-d', strtotime($this->context->employee->stats_date_to)); + $id_lang = $this->context->language->id; + + $order_by = 'p.`id_product`'; + if ($this->context->cookie->checkup_order == self::ORDER_BY_NAME) { + $order_by = 'object_name'; + } elseif ($this->context->cookie->checkup_order == self::ORDER_BY_ORDERS) { + $order_by = 'nbOrders DESC'; + } + + $sql = 'SELECT p.`id_product` AS id_object, p.`active`, pl.`name` AS object_name, + ( + SELECT COUNT(*) + FROM '._DB_PREFIX_.'image i + WHERE i.`id_product` = p.`id_product` + ) AS nbImages, + ( + SELECT COUNT(DISTINCT rsod.`id_order`) FROM `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = rsod.`id_order`) + LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id` = rsod.`id_htl_booking_detail`) + WHERE rsod.`id_product` = p.`id_product` AND o.`valid` = 1 + AND hbd.`date_to` > "'.pSQL($date_from).'" AND hbd.`date_from` < "'.pSQL($date_to).'" + ) AS nbOrders, + ( + SELECT COUNT(*) + FROM `'._DB_PREFIX_.'htl_room_type_service_product` rsp + WHERE rsp.`id_product` = p.`id_product` + ) AS nbAssociatedRoomTypes + FROM '._DB_PREFIX_.'product p + LEFT JOIN '._DB_PREFIX_.'product_lang pl + ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int) $id_lang.') + WHERE p.`booking_product` = 0 + ORDER BY '.$order_by; + + return Db::getInstance()->executeS($sql); + } + + public function getDescriptions($object_type, $id_object = null) + { + if ($object_type == 'hotel') { return Db::getInstance()->executeS( 'SELECT l.`iso_code`, hbil.`description` FROM '._DB_PREFIX_.'htl_branch_info_lang hbil @@ -500,6 +797,27 @@ class StatsCheckUp extends Module ON hbil.`id_lang` = l.`id_lang` WHERE hbil.`id` = '.(int) $id_object ); + } elseif ($object_type == 'room_type') { + return Db::getInstance()->executeS( + 'SELECT l.`iso_code`, pl.`description` + FROM '._DB_PREFIX_.'product_lang pl + LEFT JOIN '._DB_PREFIX_.'lang l + ON pl.`id_lang` = l.`id_lang` + INNER JOIN '._DB_PREFIX_.'htl_room_type hrt + ON (hrt.`id_product` = pl.`id_product`) + WHERE hrt.`id_hotel` = '.(int) $this->id_hotel.' + AND pl.`id_product` = '.(int) $id_object + ); + } elseif ($object_type == 'service') { + return Db::getInstance()->executeS( + 'SELECT l.`iso_code`, pl.`description_short` + FROM '._DB_PREFIX_.'product p + LEFT JOIN '._DB_PREFIX_.'product_lang pl + ON (pl.`id_product` = p.`id_product`) + LEFT JOIN '._DB_PREFIX_.'lang l + ON pl.`id_lang` = l.`id_lang` + WHERE p.`booking_product` = 0' + ); } } } diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php index 53aff5c72..40c3ff7fd 100644 --- a/modules/statsproduct/statsproduct.php +++ b/modules/statsproduct/statsproduct.php @@ -119,6 +119,7 @@ class StatsProduct extends ModuleGraph $sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (hrt.`id_product` = p.`id_product` AND hrt.`id_hotel` = '.(int)Tools::getValue('id_hotel').')'; } $sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang`='.(int)$this->context->language->id.') + WHERE p.`booking_product` = 1 ORDER BY pl.`name`'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); @@ -302,20 +303,8 @@ class StatsProduct extends ModuleGraph '; - $bookingParams = array(); - $bookingParams['date_from'] = $dateFrom; - $bookingParams['date_to'] = $dateTo; - foreach ($this->getProducts($this->context->language->id) as $product) { - $availRooms = 0; - if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($product['id_product'])) { - $bookingParams['hotel_id'] = $roomTypeInfo['id_hotel']; - $bookingParams['id_room_type'] = $product['id_product']; - if ($booking_data = $objBookingDtl->getBookingData($bookingParams)) { - if (isset($booking_data['stats']['num_avail'])) { - $availRooms = $booking_data['stats']['num_avail']; - } - } - } + // get room types info + foreach ($this->getProducts() as $product) { $this->html .= ' From 8b2aed362f7908f27474b73be9d793715e6ff253 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 2 Mar 2023 17:36:19 +0530 Subject: [PATCH 35/77] Fix icon issue on checkout page --- themes/hotel-reservation-theme/order-opc.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index 788a01395..3ca3c0046 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -408,7 +408,7 @@ {/if} - {l s='Applied'} + {l s='Applied'}
{/foreach} From 6855ef13b4a3907037aaac91b9b397cdace24b12 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 2 Mar 2023 18:41:12 +0530 Subject: [PATCH 36/77] resolve admin refund page issue --- classes/order/OrderReturn.php | 27 ++++++++++++++----- .../classes/HotelOrderRefundRules.php | 16 ++++++++++- .../helpers/view/view.tpl | 4 +-- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 41623a56e..46c14853d 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -219,15 +219,28 @@ class OrderReturnCore extends ObjectModel 0 ); $bookingRow['additional_services_tax_excl'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, + $bookingRow['id_order'], 0, 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], + $bookingRow['id_product'], + $bookingRow['date_from'], + $bookingRow['date_to'], + $bookingRow['id_room'], 1, - 0 + 0, + null + ); + $bookingRow['additional_services_tax_incl'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $bookingRow['id_order'], + 0, + 0, + $bookingRow['id_product'], + $bookingRow['date_from'], + $bookingRow['date_to'], + $bookingRow['id_room'], + 1, + 1, + null ); if ($customerView) { @@ -238,7 +251,9 @@ class OrderReturnCore extends ObjectModel $returnsCustView[$dateJoin]['total_price_tax_incl'] += $bookingRow['total_price_tax_incl']; $returnsCustView[$dateJoin]['total_paid_amount'] += $bookingRow['total_paid_amount']; $returnsCustView[$dateJoin]['extra_demands_price_tax_incl'] += $bookingRow['extra_demands_price_tax_incl']; + $returnsCustView[$dateJoin]['extra_demands_price_tax_incl'] += $bookingRow['additional_services_tax_incl']; $returnsCustView[$dateJoin]['extra_demands_price_tax_excl'] += $bookingRow['extra_demands_price_tax_excl']; + $returnsCustView[$dateJoin]['extra_demands_price_tax_excl'] += $bookingRow['additional_services_tax_excl']; } else { unset($bookingRow['id_room']); unset($bookingRow['room_num']); diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index d49354299..a952b3aa8 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -132,6 +132,7 @@ class HotelOrderRefundRules extends ObjectModel $objHtlRefundRules = new HotelBranchRefundRules(); $objHotelBookingDemands = new HotelBookingDemands(); + $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); if ($bookingsToRefund = OrderReturn::getOrdersReturnDetail($idOrder, $idOrderReturn, $idHtlBooking)) { foreach ($bookingsToRefund as $booking) { @@ -152,6 +153,19 @@ class HotelOrderRefundRules extends ObjectModel 1 ); + $totalServicesPrice = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $objHtlBooking->id_order, + 0, + 0, + $objHtlBooking->id_product, + $objHtlBooking->date_from, + $objHtlBooking->date_to, + $objHtlBooking->id_room, + 1, + 1, + null + ); + if ($refundRules = $objHtlRefundRules->getHotelRefundRules($objHtlBooking->id_hotel, 0, 1)) { $orderCurrency = $objOrder->id_currency; $defaultCurrency = Configuration::get('PS_CURRENCY_DEFAULT'); @@ -169,7 +183,7 @@ class HotelOrderRefundRules extends ObjectModel $ruleApplied = false; foreach ($refundRules as $refRule) { if ($daysBeforeCancel >= $refRule['days']) { - $paidAmount = $objHtlBooking->total_paid_amount + $totalDemandsPrice; + $paidAmount = $objHtlBooking->total_paid_amount + $totalDemandsPrice + $totalServicesPrice; if ($objOrder->is_advance_payment) { $refundValue = $refRule['deduction_value_adv_pay']; } else { diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index e89b31f63..451282a0f 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -119,7 +119,7 @@ {l s='Hotel' mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Total rooms paid (tax incl.)'} - {l s='Additional facilities price (tax incl.)'} + {l s='Additional services price (tax incl.)'} {if !$isRefundCompleted} {l s='Rooms cancelation charges' mod='hotelreservationsystem'} {/if} @@ -137,7 +137,7 @@ {$booking['hotel_name']|escape:'htmlall':'UTF-8'} {$booking['date_from']|date_format:"%d-%m-%Y"} {l s='To' mod='hotelreservationsystem'} {$booking['date_to']|date_format:"%d-%m-%Y"} {displayPrice price=$booking['total_paid_amount'] currency=$orderCurrency['id']} - {displayPrice price=$booking['extra_demands_price_tax_incl'] currency=$orderCurrency['id']} + {displayPrice price=($booking['extra_demands_price_tax_incl'] + $booking['additional_services_tax_incl']) currency=$orderCurrency['id']} {if !$isRefundCompleted} {displayPrice price=$booking['cancelation_charge'] currency=$orderCurrency['id']} {/if} From f89c0a5f6755afe43c7b0457886777582de843dc Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 2 Mar 2023 19:07:36 +0530 Subject: [PATCH 37/77] resovle issue when room is added in order for deleted customer --- classes/Customer.php | 2 +- controllers/admin/AdminOrdersController.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/Customer.php b/classes/Customer.php index 519b96b23..718c47161 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -585,7 +585,7 @@ class CustomerCore extends ObjectModel WHERE c.`id_customer` = '.(int)$this->id); $result['last_visit'] = $result2['last_visit']; - $result['age'] = ($result3['age'] != date('Y') ? $result3['age'] : '--'); + $result['age'] = (isset($result3['age']) && $result3['age'] != date('Y') ? $result3['age'] : '--'); return $result; } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index df4af2e8d..77f8124f6 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -2708,7 +2708,7 @@ class AdminOrdersControllerCore extends AdminController $objCartBookingData = new HotelCartBookingData(); $objCartBookingData->id_cart = $this->context->cart->id; $objCartBookingData->id_guest = $this->context->cookie->id_guest; - $objCartBookingData->id_customer = $this->context->customer->id; + $objCartBookingData->id_customer = $order->id_customer; $objCartBookingData->id_currency = $order->id_currency; $objCartBookingData->id_product = $room_info['id_product']; $objCartBookingData->id_room = $room_info['id_room']; @@ -3036,7 +3036,7 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail->id_cart = $this->context->cart->id; $objBookingDetail->id_room = $objCartBookingData->id_room; $objBookingDetail->id_hotel = $objCartBookingData->id_hotel; - $objBookingDetail->id_customer = $this->context->customer->id; + $objBookingDetail->id_customer = $order->id_customer; $objBookingDetail->booking_type = $objCartBookingData->booking_type; $objBookingDetail->id_status = 1; $objBookingDetail->comment = $objCartBookingData->comment; From 8cbd2140222f0fe607c247306829ae8bb639a237 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 2 Mar 2023 19:15:30 +0530 Subject: [PATCH 38/77] backoffice ajax loader does notstop after closing dashboard recommendation block --- js/admin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin.js b/js/admin.js index 91075c0f9..2ba357032 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1616,7 +1616,7 @@ function loadRecommendation() token: token }, success: function(res) { - if (res.success && res.content.trim()) { + if (res.success && res.content && res.content.trim()) { $('#recommendation-wrapper-skeleton').fadeIn('slow'); $('#recommendation-wrapper').html(res.content); let images = $('#recommendation-wrapper img'); From 0025b5ce3552b62450993430ff21b72bb2f96062 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 2 Mar 2023 19:57:34 +0530 Subject: [PATCH 39/77] resolve multiple order occupancy issue --- classes/PaymentModule.php | 4 ++-- classes/controller/FrontController.php | 2 +- controllers/admin/AdminOrdersController.php | 2 +- .../admin/AdminPPreferencesController.php | 12 ++++++------ controllers/front/CartController.php | 4 ++-- controllers/front/ProductController.php | 2 +- .../classes/HotelBookingDetail.php | 4 ++-- .../classes/HotelCartBookingData.php | 17 +++++++++++++---- .../classes/HotelHelper.php | 4 ++-- .../admin/AdminHotelRoomsBookingController.php | 4 ++-- .../views/js/admin/hotel_rooms_booking.js | 2 +- modules/wkroomsearchblock/wkroomsearchblock.php | 2 +- 12 files changed, 34 insertions(+), 25 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index c1427a39f..d17d5051a 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -362,11 +362,11 @@ abstract class PaymentModuleCore extends Module $order->with_occupancy = 0; } else { if (defined('_PS_ADMIN_DIR_')) { - if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $order->with_occupancy = 1; } } else { - if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $order->with_occupancy = 1; } } diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index cdd22e7a8..221396a35 100644 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -441,7 +441,7 @@ class FrontControllerCore extends Controller } $occupancyRequiredForBooking = false; - if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $occupancyRequiredForBooking = true; } $this->context->smarty->assign(array( diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index df4af2e8d..77c115f48 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -252,7 +252,7 @@ class AdminOrdersControllerCore extends AdminController } $occupancyRequiredForBooking = false; - if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $occupancyRequiredForBooking = true; } diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 5a0cd05de..1ea8b3f50 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -146,8 +146,8 @@ class AdminPPreferencesControllerCore extends AdminController 'cast' => 'intval', 'type' => 'select', 'list' => array( - 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)')) + array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')), + array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)')) ), 'identifier' => 'id', ), @@ -181,8 +181,8 @@ class AdminPPreferencesControllerCore extends AdminController 'cast' => 'intval', 'type' => 'select', 'list' => array( - 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)')) + array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY, 'name' => $this->l('Room Occupancy')), + array('id' => HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY, 'name' => $this->l('Rooms Quantity (No. of rooms)')) ), 'identifier' => 'id', ), @@ -442,11 +442,11 @@ class AdminPPreferencesControllerCore extends AdminController } if (Tools::getValue('PS_FRONT_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) { - $_POST['PS_FRONT_ROOM_UNIT_SELECTION_TYPE'] = HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY; + $_POST['PS_FRONT_ROOM_UNIT_SELECTION_TYPE'] = HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY; } if (Tools::getValue('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) { - $_POST['PS_BACKOFFICE_ROOM_BOOKING_TYPE'] = HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY; + $_POST['PS_BACKOFFICE_ROOM_BOOKING_TYPE'] = HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY; } if (Tools::getIsset('PS_CATALOG_MODE')) { diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index a2444c921..67aa61dc7 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -285,11 +285,11 @@ class CartControllerCore extends FrontController if ($product->booking_product) { $occupancyRequiredForBooking = false; - if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $occupancyRequiredForBooking = true; } - if ($occupancyRequiredForBooking) { + if ($occupancyRequiredForBooking && $operator == 'up') { if ($occupancy = json_decode(Tools::getValue('occupancy'), true)) { $this->qty = count($occupancy); } else { diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..497db5576 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -591,7 +591,7 @@ class ProductControllerCore extends FrontController 'id_cart' => $idCart, 'id_guest' => $idGuest, ); - if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $bookingParams['occupancy'] = $occupancy; $quantity = count($occupancy); } else { diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 1a459053b..08ee46466 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -82,8 +82,8 @@ class HotelBookingDetail extends ObjectModel const SEARCH_TYPE_NORMAL = 2; // - const PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY = 1; - const PS_FRONT_ROOM_UNIT_SELECTION_TYPE_QUANTITY = 2; + const PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY = 1; + const PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY = 2; public static $definition = array( 'table' => 'htl_booking_detail', diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 3afd75fac..a391ae2dc 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -450,7 +450,12 @@ class HotelCartBookingData extends ObjectModel $chkQty = 0; $num_days = HotelHelper::getNumberOfDays($date_from, $date_to); $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (defined('_PS_ADMIN_DIR_')) { + $PS_ROOM_UNIT_SELECTION_TYPE = Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE'); + } else { + $PS_ROOM_UNIT_SELECTION_TYPE = Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE'); + } + if ($PS_ROOM_UNIT_SELECTION_TYPE == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $roomsRequired = count($occupancy); } else { $objRoomType = new HotelRoomType(); @@ -475,7 +480,7 @@ class HotelCartBookingData extends ObjectModel $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_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if ($PS_ROOM_UNIT_SELECTION_TYPE == HotelBookingDetail::PS_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']; @@ -573,8 +578,12 @@ class HotelCartBookingData extends ObjectModel 'id_cart' => $id_cart, 'id_guest' => $id_guest, ); - - if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (defined('_PS_ADMIN_DIR_')) { + $PS_ROOM_UNIT_SELECTION_TYPE = Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE'); + } else { + $PS_ROOM_UNIT_SELECTION_TYPE = Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE'); + } + if ($PS_ROOM_UNIT_SELECTION_TYPE == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $roomsRequired = count($occupancy); } else { $roomsRequired = $occupancy; diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 7234b8370..114f67b3a 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -256,10 +256,10 @@ class HotelHelper // 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_UNIT_SELECTION_TYPE', HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY); + Configuration::updateValue('PS_FRONT_ROOM_UNIT_SELECTION_TYPE', HotelBookingDetail::PS_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::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY); + Configuration::updateValue('PS_BACKOFFICE_ROOM_BOOKING_TYPE', HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY); return true; } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 3030aadc6..3b14a8e0c 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -300,7 +300,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $allotmentTypes = HotelBookingDetail::getAllAllotmentTypes(); $occupancyRequiredForBooking = false; - if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $occupancyRequiredForBooking = true; } @@ -765,7 +765,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController parent::setMedia(); $currency = new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT')); $occupancyRequiredForBooking = false; - if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $occupancyRequiredForBooking = true; } $jsVars = array( diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index de5b4a126..86aadb67d 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -312,7 +312,7 @@ $(document).ready(function() { occupancy = false; } } else { - return true; + return 1; } return occupancy; diff --git a/modules/wkroomsearchblock/wkroomsearchblock.php b/modules/wkroomsearchblock/wkroomsearchblock.php index 3934b099b..16da3cb60 100644 --- a/modules/wkroomsearchblock/wkroomsearchblock.php +++ b/modules/wkroomsearchblock/wkroomsearchblock.php @@ -168,7 +168,7 @@ class WkRoomSearchBlock extends Module $maxOrderDate = Tools::getValue('max_order_date'); $maxOrderDate = date('Y-m-d', strtotime($maxOrderDate)); - if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_FRONT_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { if ($occupancy = Tools::getValue('occupancy')) { $urlData['occupancy'] = $occupancy; } From 34a0604a4519637672fae0a2d3b3816bd41b345e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 2 Mar 2023 20:31:56 +0530 Subject: [PATCH 40/77] fixed service product issues --- .../controllers/normal_products/prices.tpl | 9 - .../orders/_room_extra_services_modal.tpl | 13 +- .../orders/_room_facilities_block.tpl | 160 +++++++-------- .../orders/_room_services_block.tpl | 194 +++++++++--------- .../controllers/orders/helpers/view/view.tpl | 11 +- classes/Cart.php | 4 - classes/Product.php | 7 +- classes/SpecificPrice.php | 3 +- .../admin/AdminNormalProductsController.php | 27 ++- controllers/admin/AdminOrdersController.php | 1 + controllers/admin/AdminProductsController.php | 1 - controllers/front/OrderOpcController.php | 4 +- controllers/front/ProductController.php | 20 +- install/data/db_structure.sql | 1 - install/data/xml/category_group.xml | 6 +- .../bankwire/controllers/front/payment.php | 3 + .../bankwire/controllers/front/validation.php | 3 + modules/cheque/controllers/front/payment.php | 3 + .../cheque/controllers/front/validation.php | 3 + .../classes/RoomTypeServiceProduct.php | 2 + .../RoomTypeServiceProductCartDetail.php | 16 ++ .../_partials/service-products-list-row.tpl | 35 ++-- .../_partials/service-products.tpl | 2 +- themes/hotel-reservation-theme/js/product.js | 44 ++-- 24 files changed, 319 insertions(+), 253 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/prices.tpl b/admin/themes/default/template/controllers/normal_products/prices.tpl index 5c6e4550b..9296a4701 100644 --- a/admin/themes/default/template/controllers/normal_products/prices.tpl +++ b/admin/themes/default/template/controllers/normal_products/prices.tpl @@ -469,15 +469,6 @@ $(document).ready(function () {
-
- -
-
- {l s='unit'} - -
-
-
@@ -51,8 +46,8 @@ margin: 0px;} #rooms_type_extra_demands .demand_edit_badge { font-size: 14px;} - #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { - font-size: 14px;} + /* #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { */ + /* font-size: 14px;} */ #rooms_extra_demands .demand_header { padding: 10px; color: #333; diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index abc426f8d..1b96dba9b 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -17,91 +17,91 @@ * @license https://store.webkul.com/license.html *} -{if (isset($extraDemands) && $extraDemands) || (isset($roomTypeDemands) && $roomTypeDemands)} -
- - {if isset($orderEdit) && $orderEdit} -

- - -

+
+ + {if isset($orderEdit) && $orderEdit} +

+ + +

- {* Already selected room demands *} -
- - - {if isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} - {foreach $roomDemand['extra_demands'] as $demand} - - - - - - {/foreach} + {* Already selected room demands *} +
+
{$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
+ + {if isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} + {foreach $roomDemand['extra_demands'] as $demand} + + + + + {/foreach} - {else} - - - - {/if} - -
{$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
- {l s='No facilities added yet.'} -
-
+ {/foreach} + {else} + + + {l s='No facilities added yet.'} + + + {/if} + + +
- {* Room demands available for the current editing room*} -
-
- {if isset($roomTypeDemands) && $roomTypeDemands} - {foreach $roomTypeDemands as $idGlobalDemand => $demand} -
-
-
-
- -
-
-

{$demand['name']|escape:'html':'UTF-8'}

- {if isset($demand['adv_option']) && $demand['adv_option']} - - {else} - - {/if} -
+ {* Room demands available for the current editing room*} +
+
+ {if isset($roomTypeDemands) && $roomTypeDemands} + {foreach $roomTypeDemands as $idGlobalDemand => $demand} +
+
+
+
+ +
+
+

{$demand['name']|escape:'html':'UTF-8'}

+ {if isset($demand['adv_option']) && $demand['adv_option']} + + {else} + + {/if}
-
-

{if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

-
- {/foreach} - {/if} -
- -
- {elseif isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} -
- {foreach $roomDemand['extra_demands'] as $demand} -
-

- {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} -

+
+

{if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

+
{/foreach} -
- {/foreach} - {/if} -
-{/if} \ No newline at end of file + {/if} +
+ +
+ {elseif isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} +
+ {foreach $roomDemand['extra_demands'] as $demand} +
+

+ {$demand['name']} + {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} +

+
+ {/foreach} +
+ {/foreach} + {else} + {l s='No facilities available!'} + {/if} +
\ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl index 66c2e5b21..7566f1e5b 100644 --- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl @@ -17,114 +17,114 @@ * @license https://store.webkul.com/license.html *} -{if (isset($additionalServices) && $additionalServices) || (isset($roomTypeServiceProducts) && $roomTypeServiceProducts)} -
- {if isset($orderEdit) && $orderEdit} +
+ {if isset($orderEdit) && $orderEdit} -

- - -

+

+ + +

- {* Already selected room services *} -
- - - {if isset($additionalServices) && $additionalServices} - {foreach $additionalServices['additional_services'] as $service} - - - + + + + {/foreach} + {else} + + + + {/if} + +
-
{$service['name']|escape:'html':'UTF-8'}
- {if $service['allow_multiple_quantity']} -
- -
- {/if} -
- {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} - {l s='Convenience fee'} + {* Already selected room services *} +
+ + + {if isset($additionalServices) && $additionalServices} + {foreach $additionalServices['additional_services'] as $service} + + - - - - {/foreach} - {else} - - - - {/if} - -
+
{$service['name']|escape:'html':'UTF-8'}
+ {if $service['allow_multiple_quantity']} +
+ +
{/if} - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} - {l s='Auto added'} - {/if} -
{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
- {l s='No services added yet.'}
-
-
-
- {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} - {foreach $roomTypeServiceProducts as $product} -
-
-
-
- -
-
-

{$product['name']|escape:'html':'UTF-8'}

- {if $product.allow_multiple_quantity} -
- -
- {/if} -
-
-
-
-

- {convertPrice price=$product.price_tax_incl} -

-
-
- {/foreach} - {else} - {l s='No services available to select, All services already added.'} - {/if} -
- - -
- - {elseif isset($additionalServices) && $additionalServices} -
- {foreach $additionalServices['additional_services'] as $service} -
-
-
- +
{if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} {/if} {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} {l s='Auto added'} {/if} - -
{$service['name']|escape:'html':'UTF-8'}
- {if $service['allow_multiple_quantity']} -
{l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
- {/if} - +
{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
+ {l s='No services added yet.'} +
+
+
+
+ {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} + {foreach $roomTypeServiceProducts as $product} +
+
+
+
+ +
+
+

{$product['name']|escape:'html':'UTF-8'}

+ {if $product.allow_multiple_quantity} +
+ +
+ {/if} +
+
-
- {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
+

+ {convertPrice price=$product.price_tax_incl} +

-
- {/foreach} + {/foreach} + {else} + {l s='No services available to select, All services already added.'} + {/if}
- {/if} -
-{/if} + + + + + {elseif isset($additionalServices) && $additionalServices} +
+ {foreach $additionalServices['additional_services'] as $service} +
+
+
+ + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} + {l s='Convenience fee'} + {/if} + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} + {l s='Auto added'} + {/if} + +
{$service['name']|escape:'html':'UTF-8'}
+ {if $service['allow_multiple_quantity']} +
{l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
+ {/if} + +
+
+ {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
+
+
+ {/foreach} +
+ {else} + {l s='No services available!'} + {/if} +
diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 8a2b5b313..5dd42117e 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1717,14 +1717,21 @@ $('#room_extra_demand_content #back_to_service_btn').hide(); }); - $(document).on('focusout', '#rooms_type_extra_demands .qty', function(e) { + $(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) { var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { $(this).val(1); } updateServiceProducts($(this)); }); + $(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) { + var qty_wntd = $(this).val(); + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { + $(this).val(1); + } + }); + function updateServiceProducts(element) { var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail'); diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..574459920 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -568,10 +568,6 @@ class CartCore extends ObjectModel $sql->where('cp.`id_product` = '.(int)$id_product); } $sql->where('p.`id_product` IS NOT NULL'); - // hide invisible products - // if ($front) { - // $sql->where('p.`is_invisible` = 0'); - // } // Build ORDER BY $sql->orderBy('cp.`date_add`, cp.`id_product`, cp.`id_product_attribute` ASC'); diff --git a/classes/Product.php b/classes/Product.php index 33d169e23..5664c139b 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -240,7 +240,6 @@ class ProductCore extends ObjectModel public $cache_has_attachments; public $is_virtual; public $booking_product; - public $is_invisible; public $id_pack_product_attribute; public $cache_default_attribute; @@ -297,7 +296,6 @@ class ProductCore extends ObjectModel 'cache_has_attachments' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'is_virtual' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'booking_product' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - 'is_invisible' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'service_product_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), /* Shop fields */ @@ -992,7 +990,7 @@ class ProductCore extends ObjectModel public function deleteServiceInfo() { if (!RoomTypeServiceProduct::deleteRoomProductLink($this->id) - ||RoomTypeServiceProductPrice::deleteRoomProductPrices($this->id) + || !RoomTypeServiceProductPrice::deleteRoomProductPrices($this->id) ) { return false; } @@ -1339,7 +1337,6 @@ class ProductCore extends ObjectModel .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') .(!is_null($auto_add_to_cart) ? ' AND product_shop.`auto_add_to_cart` = '.$auto_add_to_cart:'') - .($front ? ' AND p.`is_invisible` = 0':'') .($available_for_order != 2 ? ' AND p.`available_for_order` = '.(int)$available_for_order:'') .($active ? ' AND product_shop.`active` = 1' : ''); return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -1384,7 +1381,6 @@ class ProductCore extends ObjectModel .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') .(!is_null($auto_add_to_cart) ? ' AND product_shop.`auto_add_to_cart` = '.$auto_add_to_cart:'') - .($front ? ' AND p.`is_invisible` = 0':'') .($available_for_order != 2 ? ' AND p.`available_for_order` = '.(int)$available_for_order:'') .($active ? ' AND product_shop.`active` = 1' : ''); @@ -1429,7 +1425,6 @@ class ProductCore extends ObjectModel AND p.`service_product_type` = '.(int)self::SERVICE_PRODUCT_WITH_ROOMTYPE. ' AND product_shop.`id_shop` = '.(int)$context->shop->id .($front ? ' AND product_shop.`auto_add_to_cart` = 0 AND product_shop.`show_at_front` = 1':'') - .($front ? ' AND p.`is_invisible` = 0':'') .($active ? ' AND product_shop.`active` = 1' : ''); diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 139b392ab..2794311ff 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -145,8 +145,7 @@ class SpecificPriceCore extends ObjectModel FROM `'._DB_PREFIX_.'specific_price` WHERE 1 '.self::filterOutField('id_product', $id_product). ($id_product_attribute ? ' AND id_product_attribute = '.(int) $id_product_attribute : '').' - AND id_cart = '.(int) $id_cart.' - GROUP BY `id_specific_price_rule`' + AND id_cart = '.(int) $id_cart ); } diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 17cbc74d1..5210546c9 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -99,7 +99,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->available_tabs_lang = array( 'Informations' => $this->l('Information'), 'Prices' => $this->l('Prices'), - 'Seo' => $this->l('SEO'), + // 'Seo' => $this->l('SEO'), 'Images' => $this->l('Images'), 'Associations' => $this->l('Associations'), ); @@ -108,7 +108,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->available_tabs = array_merge($this->available_tabs, array( 'Informations' => 0, 'Prices' => 1, - 'Seo' => 2, + // 'Seo' => 2, 'Associations' => 3, 'Images' => 4, )); @@ -948,7 +948,7 @@ class AdminNormalProductsControllerCore extends AdminController $id_groups = Tools::getValue('spm_id_group'); $id_customers = Tools::getValue('spm_id_customer'); $prices = Tools::getValue('spm_price'); - $from_quantities = Tools::getValue('spm_from_quantity'); + $from_quantities = 1; $reductions = Tools::getValue('spm_reduction'); $reduction_types = Tools::getValue('spm_reduction_type'); $froms = Tools::getValue('spm_from'); @@ -1939,7 +1939,7 @@ class AdminNormalProductsControllerCore extends AdminController if ($this->isTabSubmitted('Prices')) { // $this->processAdvancedPayment(); $this->processPriceAddition(); - // $this->processSpecificPricePriorities(); + $this->processSpecificPricePriorities(); } if ($this->isTabSubmitted('Images')) { $this->processImageLegends(); @@ -2016,6 +2016,22 @@ class AdminNormalProductsControllerCore extends AdminController $default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); + + // we have removed seo tab as it is currently not required, but in product object requires link_rewrite + // so adding link_rewrite in $_POST + if (Configuration::get('PS_FORCE_FRIENDLY_PRODUCT') || !Validate::isLoadedObject($this->object)) { + $link_rewrite = $_POST['name_'.$default_language->id]; + if (!Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) { + $link_rewrite = Tools::replaceAccentedChars($link_rewrite); + } + $link_rewrite = str_replace(' ', '-', $link_rewrite); + $link_rewrite = preg_replace('/[\/\\"\'|,;%]*/', '', $link_rewrite); + $_POST['link_rewrite_'.$default_language->id] = $link_rewrite; + } else { + $_POST['link_rewrite_'.$default_language->id] = $this->object->link_rewrite[$default_language->id]; + } + // end + // Check required fields foreach ($rules['required'] as $field) { if (!$this->isProductFieldUpdated($field)) { @@ -2855,13 +2871,12 @@ class AdminNormalProductsControllerCore extends AdminController $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setTemplate('tree_associated_categories.tpl') ->setHeaderTemplate('tree_associated_header.tpl') - ->setRootCategory((int)Configuration::get('PS_PRODUCTS_CATEGORY')) + ->setRootCategory((int)Configuration::get('PS_SERVICE_CATEGORY')) ->setUseCheckBox(true) ->setUseSearch(false) ->setFullTree(0) ->setSelectedCategories($categories) ->setUseBulkActions(false); - // ->setDisablAllCategories(true); $data->assign(array('default_category' => $default_category, 'selected_cat_ids' => implode(',', array_keys($selected_cat)), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index df4af2e8d..ca9b99ff1 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4738,6 +4738,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } } + $smartyVars['show_active'] = true; $this->context->smarty->assign($smartyVars); $servicesTpl = $this->context->smarty->fetch( diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index d49a74365..cb73e6fa6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2081,7 +2081,6 @@ class AdminProductsControllerCore extends AdminController } } - // shreesh check if product is virtual, then set categories according to hotel // if (Tools::getValue('is_virtual')) { $id_hotel = Tools::getValue('id_hotel'); if (!$id_hotel || !Validate::isUnsignedInt($id_hotel)) { diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index f5a5bec2b..cc11fa369 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -389,6 +389,9 @@ class OrderOpcControllerCore extends ParentOrderController */ public function initContent() { + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + parent::initContent(); // check ORDER RESTRICT condition before payment by the customer @@ -452,7 +455,6 @@ class OrderOpcControllerCore extends ParentOrderController $this->context->smarty->assign('checkout_process_steps', $this->checkoutProcess->getSteps()); - // @todo shreesh get this checked with sumit sir // set room type demands // $objGlobalDemand = new HotelRoomTypeGlobalDemand(); // $allDemands = $objGlobalDemand->getAllDemands(); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..054555062 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1318,12 +1318,13 @@ class ProductControllerCore extends FrontController public function displayAjaxCheckServiceProductWithRoomType() { $response = array( - 'status' => false + 'success' => false ); if ($this->isTokenValid()) { $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); + $addedServiceProduct = Tools::getValue('added_service_product'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1334,7 +1335,22 @@ class ProductControllerCore extends FrontController if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) { $response['error'] = Tools::displayError('Selected product is not available with current room type'); } else { - $response['status'] = true; + if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { + $response['success'] = true; + if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { + if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } else { + $response['msg'] = 'Service already added.'; + } + } else { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } + } else { + $response['error'] = Tools::displayError('Service not Found'); + } } } else { $response['error'] = Tools::displayError('Room Type not Found'); diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 5bc961640..8d5607c38 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1554,7 +1554,6 @@ CREATE TABLE `PREFIX_product` ( `cache_has_attachments` tinyint(1) NOT NULL DEFAULT '0', `is_virtual` tinyint(1) NOT NULL DEFAULT '0', `booking_product` tinyint(1) NOT NULL DEFAULT '1', - `is_invisible` tinyint(1) NOT NULL DEFAULT '0', `cache_default_attribute` int(10) unsigned DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, diff --git a/install/data/xml/category_group.xml b/install/data/xml/category_group.xml index a0187a2f0..902335903 100644 --- a/install/data/xml/category_group.xml +++ b/install/data/xml/category_group.xml @@ -11,8 +11,8 @@ - - - + + + diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index cee1fe886..59dc5ab17 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -50,6 +50,9 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index c96ff78ec..5df9b7411 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -49,6 +49,9 @@ class BankwireValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + // Check Order restrict condition before Payment by the customer if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index e1415337d..1d5e0f76b 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -50,6 +50,9 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index 6f75120a9..f280abd3f 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -48,6 +48,9 @@ class ChequeValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 199d3a178..6a16c420d 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -182,6 +182,8 @@ class RoomTypeServiceProduct extends ObjectModel 1, $useTax ); + + $serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']); } } diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index eafa043bb..f9446f9f9 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -341,4 +341,20 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } return false; } + + public static function validateServiceProductsInCart() + { + $context = Context::getContext(); + if ($cartProducts = $context->cart->getProducts()) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); + foreach ($cartProducts as $product) { + if (!$product['active'] && !$product['booking_product']) { + $serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']); + foreach ($serviceProducts as $serviceProduct) { + $objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']); + } + } + } + } + } } \ No newline at end of file diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index f700c7720..08e3c1b8e 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -20,9 +20,15 @@ {if isset($product) && $product}
  • - + {if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if} + {foreach $product.images as $image} + {if $image['cover'] == 0} + + {/if} + {/foreach}
    @@ -36,7 +42,7 @@ {/if}
    - {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} @@ -46,20 +52,21 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if $product.available_for_order && !$PS_CATALOG_MODE && !$order_date_restrict && !((isset($restricted_country_mode) && $restricted_country_mode))} + {if $product.allow_multiple_quantity && $product.available_for_order} +
    + +
    + {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} +
    +
    + + +
    +
    + {/if} {/if} {/if} - {if $product.allow_multiple_quantity && $product.available_for_order} -
    - -
    - {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} -
    -
    - - -
    -
    - {/if} +
    diff --git a/themes/hotel-reservation-theme/_partials/service-products.tpl b/themes/hotel-reservation-theme/_partials/service-products.tpl index 2b3565520..370f10de9 100644 --- a/themes/hotel-reservation-theme/_partials/service-products.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products.tpl @@ -45,7 +45,7 @@ {/foreach} {else}
      - {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products group='all' init=true} + {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products init=true}
    {if RoomTypeServiceProduct::WK_NUM_RESULTS < $num_total_service_products}
    diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 96ae9a806..57a0add94 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1201,6 +1201,15 @@ $(document).ready(function() { if (typeof(qty) == 'undefined') { qty = 1; } + var added_service_product = []; + + $('#additional_products input.service_product').each(function () { + added_service_product.push({ + 'id_product': $(this).data('id_product'), + 'quantity':$(this).val(), + }); + }); + $.ajax({ type: 'POST', headers: { @@ -1215,31 +1224,36 @@ $(document).ready(function() { qty: qty, id_product: $('#product_page_product_id').val(), service_product: id_product, + added_service_product: added_service_product, action: 'checkServiceProductWithRoomType', ajax: true, token: static_token }, success: function(result) { - if (result.status) { - if ($('input#service_product_'+ id_product).length) { - var prevQty = $('input#service_product_'+ id_product).val(); - if (parseInt(prevQty) > 0) { - qty = parseInt(qty) + parseInt(prevQty); + if (result.success) { + if (result.add) { + if ($('input#service_product_'+ id_product).length) { + var prevQty = $('input#service_product_'+ id_product).val(); + if (parseInt(prevQty) > 0) { + qty = parseInt(qty) + parseInt(prevQty); + } + $('input#service_product_'+ id_product).val(qty); + } else { + $('').attr({ + id: 'service_product_'+ id_product, + name: 'service_product['+ id_product +'][]', + class: 'service_product', + 'data-id_product': id_product, + value: qty + }).appendTo('#additional_products'); } - $('input#service_product_'+ id_product).val(qty); - } else { - $('').attr({ - id: 'service_product_'+ id_product, - name: 'service_product['+ id_product +'][]', - class: 'service_product', - 'data-id_product': id_product, - value: qty - }).appendTo('#additional_products'); } // reset input $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); - showSuccessMessage(cart_extra_service_add); + if (result.msg) { + showSuccessMessage(result.msg); + } BookingForm.refresh(); } else { if (result.error) { From d95093a8dfa0f86d9c336f8c1ce91b7d24d8dd9e Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 3 Mar 2023 11:42:14 +0530 Subject: [PATCH 41/77] Fix Customers KPI on Customers page --- controllers/admin/AdminStatsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 8a75a6383..8c0096b5f 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -354,7 +354,7 @@ class AdminStatsControllerCore extends AdminStatsTabController public static function getCustomerMainGender() { $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' - SELECT SUM(IF(g.id_gender IS NOT NULL, 1, 0)) as total, SUM(IF(type = 0, 1, 0)) as male, SUM(IF(type = 1, 1, 0)) as female, SUM(IF(type = 2, 1, 0)) as neutral + SELECT SUM(IF(c.id_gender IS NOT NULL, 1, 0)) as total, SUM(IF(type = 0, 1, 0)) as male, SUM(IF(type = 1, 1, 0)) as female, SUM(IF(type = 2, 1, 0)) as neutral FROM `'._DB_PREFIX_.'customer` c LEFT JOIN `'._DB_PREFIX_.'gender` g ON c.id_gender = g.id_gender WHERE c.active = 1 '.Shop::addSqlRestriction()); From e4115edfdf4977c815dea89cbaf5e2dc4fd79937 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:04:43 +0530 Subject: [PATCH 42/77] resovle issue on book now page after clearing cart table --- .../AdminHotelRoomsBookingController.php | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 3030aadc6..5a838ae0a 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -40,27 +40,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController } if (!isset($this->context->cookie->id_cart)) { - // create a new cart - $objCart = new Cart(); - $objCart->recyclable = 0; - $objCart->gift = 0; - $objCart->id_shop = (int) $this->context->shop->id; - $objCart->id_lang = (($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : (int) Configuration::get('PS_LANG_DEFAULT')); - $objCart->id_currency = (($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT')); - $objCart->id_address_delivery = 0; - $objCart->id_address_invoice = 0; - $objCart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT'); - $objCart->id_guest = (int) $this->context->cookie->id_guest; - $objCart->setNoMultishipping(); - - $this->context->cart = $objCart; - $this->context->cart->save(); - + $objCart = $this->createNewCart(); $this->context->cookie->id_cart = (int) $objCart->id; } else { // use previous cart - $this->context->cart = new Cart($this->context->cookie->id_cart); + if (!validate::isLoadedObject($objCart = new Cart($this->context->cookie->id_cart))) { + $objCart = $this->createNewCart(); + } } + $this->context->cart = $objCart; $objCustomer = new Customer(); $objCustomer->id_gender = 0; @@ -77,6 +65,26 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $this->context->customer = $objCustomer; } + protected function createNewCart() + { + // create a new cart + $objCart = new Cart(); + $objCart->recyclable = 0; + $objCart->gift = 0; + $objCart->id_shop = (int) $this->context->shop->id; + $objCart->id_lang = (($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : (int) Configuration::get('PS_LANG_DEFAULT')); + $objCart->id_currency = (($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT')); + $objCart->id_address_delivery = 0; + $objCart->id_address_invoice = 0; + $objCart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT'); + $objCart->id_guest = (int) $this->context->cookie->id_guest; + $objCart->setNoMultishipping(); + + $objCart->save(); + return $objCart; + } + + public function postProcess() { if (Tools::getValue('date_from')) { From c4b9475767167734ea848ac3ab5079eb02c11810 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:33:23 +0530 Subject: [PATCH 43/77] updated category page options --- .../admin/AdminCategoriesController.php | 232 ++++++++++-------- 1 file changed, 128 insertions(+), 104 deletions(-) diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index ae49e80d2..52a97e785 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -81,17 +81,18 @@ class AdminCategoriesControllerCore extends AdminController 'title' => $this->l('Position'), 'filter_key' => 'sa!position', 'position' => 'position', - 'align' => 'center' - ), - 'active' => array( - 'title' => $this->l('Displayed'), - 'active' => 'status', - 'type' => 'bool', - 'class' => 'fixed-width-xs', 'align' => 'center', - 'ajax' => true, - 'orderby' => false - ) + 'class' => 'fixed-width-sm' + ), + // 'active' => array( + // 'title' => $this->l('Displayed'), + // 'active' => 'status', + // 'type' => 'bool', + // 'class' => 'fixed-width-xs', + // 'align' => 'center', + // 'ajax' => true, + // 'orderby' => false + // ) ); $this->bulk_actions = array( @@ -421,7 +422,7 @@ class AdminCategoriesControllerCore extends AdminController $obj = $this->loadObject(true); $context = Context::getContext(); $id_shop = $context->shop->id; - $selected_categories = array((isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop))? (int)$obj->id_parent : (int)Tools::getValue('id_parent', Category::getRootCategory()->id)); + $selected_categories = array((isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop))? (int)$obj->id_parent : (int)Tools::getValue('id_parent', Configuration::get('PS_SERVICE_CATEGORY'))); $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP')); $default = new Group(Configuration::get('PS_CUSTOMER_GROUP')); @@ -479,25 +480,25 @@ class AdminCategoriesControllerCore extends AdminController 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:').' <>;=#{}', ), - array( - 'type' => 'switch', - 'label' => $this->l('Displayed'), - 'name' => 'active', - 'required' => false, - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ) - ), + // array( + // 'type' => 'switch', + // 'label' => $this->l('Displayed'), + // 'name' => 'active', + // 'required' => false, + // 'is_bool' => true, + // 'values' => array( + // array( + // 'id' => 'active_on', + // 'value' => 1, + // 'label' => $this->l('Enabled') + // ), + // array( + // 'id' => 'active_off', + // 'value' => 0, + // 'label' => $this->l('Disabled') + // ) + // ) + // ), array( 'type' => 'categories', 'label' => $this->l('Parent category'), @@ -509,80 +510,80 @@ class AdminCategoriesControllerCore extends AdminController 'root_category' => Configuration::get('PS_SERVICE_CATEGORY') ) ), - array( - 'type' => 'textarea', - 'label' => $this->l('Description'), - 'name' => 'description', - 'autoload_rte' => true, - 'lang' => true, - 'hint' => $this->l('Invalid characters:').' <>;=#{}' - ), - array( - 'type' => 'file', - 'label' => $this->l('Category Cover Image'), - 'name' => 'image', - 'display_image' => true, - 'image' => $image_url ? $image_url : false, - 'size' => $image_size, - 'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->_category->id.'&token='.$this->token.'&deleteImage=1', - 'hint' => $this->l('This is the main image for your category, displayed in the category page. The category description will overlap this image and appear in its top-left corner.'), - 'format' => $format['category'] - ), - array( - 'type' => 'file', - 'label' => $this->l('Category thumbnail'), - 'name' => 'thumb', - 'display_image' => true, - 'image' => $thumb_url ? $thumb_url : false, - 'size' => $thumb_size, - 'format' => $format['medium'] - ), - array( - 'type' => 'text', - 'label' => $this->l('Meta title'), - 'name' => 'meta_title', - 'maxchar' => 70, - 'lang' => true, - 'rows' => 5, - 'cols' => 100, - 'hint' => $this->l('Forbidden characters:').' <>;=#{}' - ), - array( - 'type' => 'textarea', - 'label' => $this->l('Meta description'), - 'name' => 'meta_description', - 'maxchar' => 160, - 'lang' => true, - 'rows' => 5, - 'cols' => 100, - 'hint' => $this->l('Forbidden characters:').' <>;=#{}' - ), - array( - 'type' => 'tags', - 'label' => $this->l('Meta keywords'), - 'name' => 'meta_keywords', - 'lang' => true, - 'hint' => $this->l('To add "tags," click in the field, write something, and then press "Enter."').' '.$this->l('Forbidden characters:').' <>;=#{}' - ), - array( - 'type' => 'text', - 'label' => $this->l('Friendly URL'), - 'name' => 'link_rewrite', - 'lang' => true, - 'required' => true, - 'hint' => $this->l('Only letters, numbers, underscore (_) and the minus (-) character are allowed.') - ), - array( - 'type' => 'group', - 'label' => $this->l('Group access'), - 'name' => 'groupBox', - 'values' => Group::getGroups(Context::getContext()->language->id), - 'info_introduction' => $this->l('You now have three default customer groups.'), - 'unidentified' => $unidentified_group_information, - 'guest' => $guest_group_information, - 'customer' => $default_group_information, - 'hint' => $this->l('Mark all of the customer groups which you would like to have access to this category.') - ) + // array( + // 'type' => 'textarea', + // 'label' => $this->l('Description'), + // 'name' => 'description', + // 'autoload_rte' => true, + // 'lang' => true, + // 'hint' => $this->l('Invalid characters:').' <>;=#{}' + // ), + // array( + // 'type' => 'file', + // 'label' => $this->l('Category Cover Image'), + // 'name' => 'image', + // 'display_image' => true, + // 'image' => $image_url ? $image_url : false, + // 'size' => $image_size, + // 'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->_category->id.'&token='.$this->token.'&deleteImage=1', + // 'hint' => $this->l('This is the main image for your category, displayed in the category page. The category description will overlap this image and appear in its top-left corner.'), + // 'format' => $format['category'] + // ), + // array( + // 'type' => 'file', + // 'label' => $this->l('Category thumbnail'), + // 'name' => 'thumb', + // 'display_image' => true, + // 'image' => $thumb_url ? $thumb_url : false, + // 'size' => $thumb_size, + // 'format' => $format['medium'] + // ), + // array( + // 'type' => 'text', + // 'label' => $this->l('Meta title'), + // 'name' => 'meta_title', + // 'maxchar' => 70, + // 'lang' => true, + // 'rows' => 5, + // 'cols' => 100, + // 'hint' => $this->l('Forbidden characters:').' <>;=#{}' + // ), + // array( + // 'type' => 'textarea', + // 'label' => $this->l('Meta description'), + // 'name' => 'meta_description', + // 'maxchar' => 160, + // 'lang' => true, + // 'rows' => 5, + // 'cols' => 100, + // 'hint' => $this->l('Forbidden characters:').' <>;=#{}' + // ), + // array( + // 'type' => 'tags', + // 'label' => $this->l('Meta keywords'), + // 'name' => 'meta_keywords', + // 'lang' => true, + // 'hint' => $this->l('To add "tags," click in the field, write something, and then press "Enter."').' '.$this->l('Forbidden characters:').' <>;=#{}' + // ), + // array( + // 'type' => 'text', + // 'label' => $this->l('Friendly URL'), + // 'name' => 'link_rewrite', + // 'lang' => true, + // 'required' => true, + // 'hint' => $this->l('Only letters, numbers, underscore (_) and the minus (-) character are allowed.') + // ), + // array( + // 'type' => 'group', + // 'label' => $this->l('Group access'), + // 'name' => 'groupBox', + // 'values' => Group::getGroups(Context::getContext()->language->id), + // 'info_introduction' => $this->l('You now have three default customer groups.'), + // 'unidentified' => $unidentified_group_information, + // 'guest' => $guest_group_information, + // 'customer' => $default_group_information, + // 'hint' => $this->l('Mark all of the customer groups which you would like to have access to this category.') + // ) ), 'submit' => array( 'title' => $this->l('Save'), @@ -736,6 +737,13 @@ class AdminCategoriesControllerCore extends AdminController $this->errors[] = Tools::displayError('The category cannot be a parent of itself.'); } } + // @todo remove this after adding link_rewrite form option + // currently have removed link_rewrite as it is currently not required + // so adding link_rewrite in $_POST + foreach (Language::getLanguages(true) as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang'])); + } + $object = parent::processAdd(); //if we create a you root category you have to associate to a shop before to add sub categories in. So we redirect to AdminCategories listing @@ -745,6 +753,22 @@ class AdminCategoriesControllerCore extends AdminController return $object; } + public function processUpdate() + { + // @todo remove this after adding link_rewrite form option + // currently have removed link_rewrite as it is currently not required + // so adding link_rewrite in $_POST + if (!Validate::isLoadedObject($this->object)) { + foreach (Language::getLanguages(true) as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang'])); + } + } else { + foreach (Language::getLanguages(true) as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']]; + } + } + } + protected function setDeleteMode() { if ($this->delete_mode == 'link' || $this->delete_mode == 'linkanddisable') { From f34b8a4b67c05cf2fae8f6239eb00ba9a9e8c7c2 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:43:40 +0530 Subject: [PATCH 44/77] updated link_rewrite field of service product --- controllers/admin/AdminNormalProductsController.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 5210546c9..1ffa75ae4 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -2020,15 +2020,13 @@ class AdminNormalProductsControllerCore extends AdminController // we have removed seo tab as it is currently not required, but in product object requires link_rewrite // so adding link_rewrite in $_POST if (Configuration::get('PS_FORCE_FRIENDLY_PRODUCT') || !Validate::isLoadedObject($this->object)) { - $link_rewrite = $_POST['name_'.$default_language->id]; - if (!Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) { - $link_rewrite = Tools::replaceAccentedChars($link_rewrite); + foreach ($languages as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang'])); } - $link_rewrite = str_replace(' ', '-', $link_rewrite); - $link_rewrite = preg_replace('/[\/\\"\'|,;%]*/', '', $link_rewrite); - $_POST['link_rewrite_'.$default_language->id] = $link_rewrite; } else { - $_POST['link_rewrite_'.$default_language->id] = $this->object->link_rewrite[$default_language->id]; + foreach ($languages as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']]; + } } // end From 103d2ccfd863eeefad7029471573c4a2156bba5e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:53:45 +0530 Subject: [PATCH 45/77] fixed undefined index issue when booking multiple rooms --- controllers/front/OrderDetailController.php | 66 ++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 2a898f8b6..20ed72474 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -479,40 +479,40 @@ class OrderDetailControllerCore extends FrontController 1, 0 ); + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); } - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); // calculate averages now foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); From 8164208fdb4d5578a8fd6ae223f32f05906e1b2d Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 15:22:24 +0530 Subject: [PATCH 46/77] show selected service in order summary admin order page --- .../orders/_current_cart_details_data.tpl | 9 +++++++++ .../RoomTypeServiceProductCartDetail.php | 20 ++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl index 4a17cd334..12df732af 100644 --- a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl +++ b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl @@ -59,6 +59,15 @@ {/foreach} {/if} + {if isset($data['selected_additional_service'][$data['id']]['selected_products_info']) && $data['selected_additional_service'][$data['id']]['selected_products_info']} +
      + {foreach $data['selected_additional_service'][$data['id']]['selected_products_info'] as $selectedService} +
    • + {$selectedService.name|escape:'html':'UTF-8'} +
    • + {/foreach} +
    + {/if} {dateFormat date=$data.date_from} - {dateFormat date=$data.date_to} {if $occupancy_required_for_booking} diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index eafa043bb..883bd13da 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -107,16 +107,24 @@ class RoomTypeServiceProductCartDetail extends ObjectModel if ($useTax === null) $useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true; + $idLang = Context::getContext()->language->id; + $sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, cbd.`id` as `htl_cart_booking_id` , cbd.`id_product` as `room_type_id_product`, cbd.`adults`, cbd.`children`'; if (!$getTotalPrice) { - $sql .= ', cbd.`id_guest`, cbd.`id_customer`, p.`auto_add_to_cart`, p.`price_addition_type`, + $sql .= ', pl.`name`, cbd.`id_guest`, cbd.`id_customer`, p.`auto_add_to_cart`, p.`price_addition_type`, cbd.`id_hotel`, cbd.`id_room`, cbd.`date_from`, cbd.`date_to`, cbd.`is_refunded`'; } $sql .= ' FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd ON(rscd.`htl_cart_booking_id` = cbd.`id`) - LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rscd.`id_product`) - WHERE 1'; + LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd + ON(rscd.`htl_cart_booking_id` = cbd.`id`) + LEFT JOIN `'._DB_PREFIX_.'product` p + ON (p.`id_product` = rscd.`id_product`)'; + if (!$getTotalPrice) { + $sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl + ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$idLang.')'; + } + $sql .= ' WHERE 1'; if (!is_null($autoAddToCart)) { $sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart; @@ -165,7 +173,6 @@ class RoomTypeServiceProductCartDetail extends ObjectModel ); } else { - $roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($product['room_type_id_product']); $qty = $product['quantity'] ? (int)$product['quantity'] : 1; if (isset($selectedServiceProducts[$product['htl_cart_booking_id']])) { if ($product['id_product']) { @@ -175,6 +182,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } else { $selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'][$product['id_product']] = array( 'id_product' => $product['id_product'], + 'name' => $product['name'], 'auto_add_to_cart' => $product['auto_add_to_cart'], 'price_addition_type' => $product['price_addition_type'], 'quantity' => $product['quantity'], @@ -220,6 +228,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $selectedServiceProducts[$product['htl_cart_booking_id']]['children'] = $product['children']; if ($idProduct) { $selectedServiceProducts[$product['htl_cart_booking_id']]['id_product'] = $product['id_product']; + $selectedServiceProducts[$product['htl_cart_booking_id']]['name'] = $product['name']; $selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] = $product['quantity']; $selectedServiceProducts[$product['htl_cart_booking_id']]['auto_add_to_cart'] = $product['auto_add_to_cart']; $selectedServiceProducts[$product['htl_cart_booking_id']]['price_addition_type'] = $product['price_addition_type']; @@ -243,6 +252,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'] = ($product['id_product']) ? array( $product['id_product'] => array( 'id_product' => $product['id_product'], + 'name' => $product['name'], 'quantity' => $product['quantity'], 'auto_add_to_cart' => $product['auto_add_to_cart'], 'price_addition_type' => $product['price_addition_type'], From 6ad39c6ea94ff8b4734d0eed5f3e52a4fac84272 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 16:21:11 +0530 Subject: [PATCH 47/77] fix inactive service adding in cart --- .../hotelreservationsystem/classes/RoomTypeServiceProduct.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 199d3a178..a88f7feda 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -120,7 +120,7 @@ class RoomTypeServiceProduct extends ObjectModel if (Product::isBookingProduct($idProduct)) { $sql = 'SELECT p.`id_product` FROM `'._DB_PREFIX_.'htl_room_type_service_product` rsp INNER JOIN `'._DB_PREFIX_.'product` p ON (rsp.`id_product` = p.`id_product` AND p.`auto_add_to_cart` = 1) - WHERE `id_element` = '.(int)$idProduct.' AND `element_type` = '.self::WK_ELEMENT_TYPE_ROOM_TYPE; + WHERE p.`active` = 1 AND `id_element` = '.(int)$idProduct.' AND `element_type` = '.self::WK_ELEMENT_TYPE_ROOM_TYPE; if (!is_null($priceAdditionType)) { $sql .= ' AND p.`price_addition_type` = '.$priceAdditionType; } From 993ef2ddf9b6a84f8acda7a5ef11aaa0fea68a8f Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 18:33:58 +0530 Subject: [PATCH 48/77] replaced array_key_exists with property_exists for object --- classes/AdminTab.php | 2 +- classes/Cart.php | 2 +- classes/Theme.php | 6 +++--- classes/controller/AdminController.php | 2 +- classes/controller/Controller.php | 6 +++--- classes/stock/SupplyOrder.php | 2 +- classes/stock/SupplyOrderDetail.php | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 5aeee5083..e40c4affe 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -1174,7 +1174,7 @@ abstract class AdminTabCore { /* Classical fields */ foreach ($_POST as $key => $value) { - if (array_key_exists($key, $object) && $key != 'id_'.$table) { + if (property_exists($object, $key) && $key != 'id_'.$table) { /* Do not take care of password field if empty */ if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) { continue; diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..4e1803fa5 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -3523,7 +3523,7 @@ class CartCore extends ObjectModel $module = Module::getInstanceByName($module_name); if (Validate::isLoadedObject($module)) { - if (array_key_exists('id_carrier', $module)) { + if (property_exists($module, 'id_carrier')) { $module->id_carrier = $carrier->id; } if ($carrier->need_range) { diff --git a/classes/Theme.php b/classes/Theme.php index ef1fedee7..ec6cb09f9 100644 --- a/classes/Theme.php +++ b/classes/Theme.php @@ -345,7 +345,7 @@ class ThemeCore extends ObjectModel public function toggleResponsive() { // Object must have a variable called 'responsive' - if (!array_key_exists('responsive', $this)) { + if (!property_exists($this, 'responsive')) { throw new PrestaShopException('property "responsive" is missing in object '.get_class($this)); } @@ -361,7 +361,7 @@ class ThemeCore extends ObjectModel public function toggleDefaultLeftColumn() { - if (!array_key_exists('default_left_column', $this)) { + if (!property_exists($this, 'default_left_column')) { throw new PrestaShopException('property "default_left_column" is missing in object '.get_class($this)); } @@ -374,7 +374,7 @@ class ThemeCore extends ObjectModel public function toggleDefaultRightColumn() { - if (!array_key_exists('default_right_column', $this)) { + if (!property_exists($this,'default_right_column')) { throw new PrestaShopException('property "default_right_column" is missing in object '.get_class($this)); } diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index f95c48be7..223fbb009 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -3611,7 +3611,7 @@ class AdminControllerCore extends Controller { /* Classical fields */ foreach ($_POST as $key => $value) { - if (array_key_exists($key, $object) && $key != 'id_'.$table) { + if (property_exists($object, $key) && $key != 'id_'.$table) { /* Do not take care of password field if empty */ if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) { continue; diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index a21ca409c..0484f6544 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -93,9 +93,9 @@ abstract class ControllerCore */ public function init() { - if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { - set_error_handler(array(__CLASS__, 'myErrorHandler')); - } + // if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { + // set_error_handler(array(__CLASS__, 'myErrorHandler')); + // } if (!defined('_PS_BASE_URL_')) { define('_PS_BASE_URL_', Tools::getShopDomain(true)); diff --git a/classes/stock/SupplyOrder.php b/classes/stock/SupplyOrder.php index 2a62bd5fd..5df2e506b 100644 --- a/classes/stock/SupplyOrder.php +++ b/classes/stock/SupplyOrder.php @@ -486,7 +486,7 @@ class SupplyOrderCore extends ObjectModel $this->id = $data[$this->def['primary']]; } foreach ($data as $key => $value) { - if (array_key_exists($key, $this)) { + if (property_exists($this, $key)) { // formats prices and floats if ($this->def['fields'][$key]['validate'] == 'isFloat' || $this->def['fields'][$key]['validate'] == 'isPrice') { diff --git a/classes/stock/SupplyOrderDetail.php b/classes/stock/SupplyOrderDetail.php index 517107e62..299aeaadf 100644 --- a/classes/stock/SupplyOrderDetail.php +++ b/classes/stock/SupplyOrderDetail.php @@ -338,7 +338,7 @@ class SupplyOrderDetailCore extends ObjectModel $this->id = $data[$this->def['primary']]; } foreach ($data as $key => $value) { - if (array_key_exists($key, $this)) { + if (property_exists($this, $key)) { // formats prices and floats if ($this->def['fields'][$key]['validate'] == 'isFloat' || $this->def['fields'][$key]['validate'] == 'isPrice') { From 411a3f8b8eb75cf0724bcd2f76d2a2d83fb003c1 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 3 Mar 2023 19:38:40 +0530 Subject: [PATCH 49/77] Update Dashavailability graph --- modules/dashavailability/views/js/dashavailability.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/dashavailability/views/js/dashavailability.js b/modules/dashavailability/views/js/dashavailability.js index 73fdefb14..89b8137de 100644 --- a/modules/dashavailability/views/js/dashavailability.js +++ b/modules/dashavailability/views/js/dashavailability.js @@ -26,6 +26,7 @@ function line_chart_availability(widget_name, chart_details) { .useInteractiveGuideline(true) .x(function(d) { return (d !== undefined ? d[0] : 0); }) .y(function(d) { return (d !== undefined ? parseInt(d[1]) : 0); }) + .forceY(0) .margin({ left: 30, right: 30, From de317fa2ad33df14d9b852db4bac368a399fd269 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 11:32:35 +0530 Subject: [PATCH 50/77] Update guests count in Operations Today --- controllers/admin/AdminStatsController.php | 15 +++++++++------ modules/dashguestcycle/dashguestcycle.php | 10 +++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 8a75a6383..f455123fd 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1176,9 +1176,10 @@ class AdminStatsControllerCore extends AdminStatsTabController public static function getArrivalsInfoByDate($date, $idHotel = null) { - $sql = 'SELECT hbd.*, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, + $sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) WHERE hbd.`is_refunded` = 0 AND hbd.`date_from` = "'.pSQL($date).' 00:00:00" AND hbd.`id_status` != '.(int) HotelBookingDetail::STATUS_CHECKED_IN.' @@ -1191,9 +1192,10 @@ class AdminStatsControllerCore extends AdminStatsTabController public static function getDeparturesInfoByDate($date, $idHotel = null) { - $sql = 'SELECT hbd.*, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, + $sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) WHERE hbd.`is_refunded` = 0 AND hbd.`date_to` = "'.pSQL($date).' 00:00:00" AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN. @@ -1205,9 +1207,10 @@ class AdminStatsControllerCore extends AdminStatsTabController public static function getInHousesInfo($idHotel = null) { - $sql = 'SELECT hbd.*, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, + $sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) WHERE hbd.`is_refunded` = 0 AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN. (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); @@ -1220,7 +1223,7 @@ class AdminStatsControllerCore extends AdminStatsTabController { $sql = 'SELECT hbd.`id_customer`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, COUNT(hbd.`id`) AS total_rooms, SUM(hbd.`adults` + hbd.`children`) AS total_guests, - hbd.`id_hotel`, hbd.`hotel_name`, hbd.`id_order`, o.`total_paid_tax_excl`, o.`id_currency`, osl.`name` AS `state_name` + hbd.`id_hotel`, hbd.`hotel_name`, hbd.`id_order`, o.`with_occupancy`, o.`total_paid_tax_excl`, o.`id_currency`, osl.`name` AS `state_name` FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl @@ -1237,8 +1240,8 @@ class AdminStatsControllerCore extends AdminStatsTabController public static function getCancellationsInfoByDate($date, $idHotel = null) { $sql = 'SELECT orr.`id_order_return`, orr.`id_customer`, hbd.`room_num`, hbd.`id_product`, hbd.`room_type_name`, - CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, - hbd.`id_hotel`, hbd.`hotel_name`, SUM(hbd.`adults` + hbd.`children`) AS total_guests, + o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, hbd.`id_hotel`, + hbd.`hotel_name`, SUM(hbd.`adults` + hbd.`children`) AS total_guests, hbd.`date_from`, hbd.`date_to`, orr.`id_order` FROM `'._DB_PREFIX_.'order_return` orr LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord ON (ord.`id_order_return` = orr.`id_order_return`) diff --git a/modules/dashguestcycle/dashguestcycle.php b/modules/dashguestcycle/dashguestcycle.php index a012b2b8b..783ac20e4 100644 --- a/modules/dashguestcycle/dashguestcycle.php +++ b/modules/dashguestcycle/dashguestcycle.php @@ -170,7 +170,7 @@ class DashGuestCycle extends Module } $tr[] = array( - 'value' => $arrivalInfo['adult'] + $arrivalInfo['children'], + 'value' => $arrivalInfo['with_occupancy'] ? ($arrivalInfo['adults'] + $arrivalInfo['children']) : '--', 'class' => 'text-center', ); $tr[] = array( @@ -230,7 +230,7 @@ class DashGuestCycle extends Module } $tr[] = array( - 'value' => $departureInfo['adult'] + $departureInfo['children'], + 'value' => $departureInfo['with_occupancy'] ? ($departureInfo['adults'] + $departureInfo['children']) : '--', 'class' => 'text-center', ); $tr[] = array( @@ -291,7 +291,7 @@ class DashGuestCycle extends Module } $tr[] = array( - 'value' => $inHouseInfo['adult'] + $inHouseInfo['children'], + 'value' => $inHouseInfo['with_occupancy'] ? ($inHouseInfo['adults'] + $inHouseInfo['children']) : '--', 'class' => 'text-center', ); $tr[] = array( @@ -357,7 +357,7 @@ class DashGuestCycle extends Module 'class' => 'text-center', ); $tr[] = array( - 'value' => $newBookingInfo['total_guests'], + 'value' => $newBookingInfo['with_occupancy'] ? $newBookingInfo['total_guests'] : '--', 'class' => 'text-center', ); $tr[] = array( @@ -425,7 +425,7 @@ class DashGuestCycle extends Module } $tr[] = array( - 'value' => $cancellationInfo['total_guests'], + 'value' => $cancellationInfo['with_occupancy'] ? $cancellationInfo['total_guests'] : '--', 'class' => 'text-center', ); $tr[] = array( From 49da8574d7e1af3ca1ee33cd26fa1dcacbc84b47 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sun, 5 Mar 2023 12:24:35 +0530 Subject: [PATCH 51/77] resolve export issue --- controllers/admin/AdminCartsController.php | 1 + controllers/admin/AdminNormalProductsController.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index db54f518c..fd7802f8b 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -135,6 +135,7 @@ class AdminCartsControllerCore extends AdminController $smartyVars['type'] = 'non_orderd'; } } + $smartyVars['link'] = $this->context->link; $tpl = $this->createTemplate('_orders.tpl'); $tpl->assign($smartyVars); diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 17cbc74d1..e14345a50 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -90,7 +90,7 @@ class AdminNormalProductsControllerCore extends AdminController parent::__construct(); $this->imageType = 'jpg'; - $this->_defaultOrderBy = 'position'; + $this->_defaultOrderBy = 'id_product'; $this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000); $this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'); $this->allow_export = true; From 20256d4115b5d0e502f760fdf91943477f0f6e77 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 13:51:35 +0530 Subject: [PATCH 52/77] Fix can not create order from cart --- .../default/template/controllers/carts/helpers/view/view.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl index 7f8a5e8d1..3a0ab6816 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -74,7 +74,7 @@ {else}

    {l s='No order was created from this cart.'}

    {if $customer->id} - {l s='Create an order from this cart.'} + {l s='Create an order from this cart.'} {/if} {/if}
    From 3645f2d9e8a145d637e889fcd15622c42b8a4ac1 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sun, 5 Mar 2023 13:59:42 +0530 Subject: [PATCH 53/77] added max allowd quantity for service products --- .../controllers/normal_products/informations.tpl | 11 +++++++++++ classes/Product.php | 4 ++++ controllers/admin/AdminOrdersController.php | 2 ++ controllers/front/CartController.php | 2 ++ install/data/db_structure.sql | 2 ++ js/admin/normal_products.js | 8 ++++++++ .../_partials/cart_booking_demands.tpl | 2 +- .../_partials/service-products-list-row.tpl | 2 +- themes/hotel-reservation-theme/js/order-opc.js | 10 ++++++++-- themes/hotel-reservation-theme/js/product.js | 9 ++++++--- 10 files changed, 45 insertions(+), 7 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index f95d974eb..acc85a424 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -412,6 +412,17 @@
  • +
    available_for_order && $product->isAssociatedToShop()) || $product->auto_add_to_cart || !$product->allow_multiple_quantity}style="display:none;"{/if}> + +
    + +
    +
    diff --git a/classes/Product.php b/classes/Product.php index 33d169e23..911610672 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -77,6 +77,9 @@ class ProductCore extends ObjectModel /** @var bool allow order for multiple quantities */ public $allow_multiple_quantity; + /** @var bool max allowed quantities */ + public $max_quantity; + /** @var string available_now */ public $available_now; @@ -308,6 +311,7 @@ class ProductCore extends ObjectModel 'ecotax' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'), 'minimal_quantity' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'), 'allow_multiple_quantity' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'), + 'max_quantity' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'), 'price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice', 'required' => true), 'wholesale_price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'), 'unity' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isString'), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index df4af2e8d..d6dc4524d 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5264,6 +5264,8 @@ class AdminOrdersControllerCore extends AdminController 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; diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index a2444c921..7736cc76f 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -621,6 +621,8 @@ class CartControllerCore extends FrontController if ($objProduct->allow_multiple_quantity) { if (!Validate::isUnsignedInt($qty)) { $this->errors[] = Tools::displayError('The quantity 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; diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 5bc961640..07a2b4097 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1519,6 +1519,7 @@ CREATE TABLE `PREFIX_product` ( `quantity` int(10) NOT NULL DEFAULT '0', `minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1', `allow_multiple_quantity` tinyint(1) unsigned NOT NULL DEFAULT '1', + `max_quantity` int(10) unsigned NOT NULL DEFAULT '1', `price` decimal(20,6) NOT NULL DEFAULT '0.000000', `wholesale_price` decimal(20,6) NOT NULL DEFAULT '0.000000', `unity` varchar(255) DEFAULT NULL, @@ -1578,6 +1579,7 @@ CREATE TABLE IF NOT EXISTS `PREFIX_product_shop` ( `ecotax` decimal(17,6) NOT NULL DEFAULT '0.000000', `minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1', `allow_multiple_quantity` tinyint(1) unsigned NOT NULL DEFAULT '1', + `max_quantity` int(10) unsigned NOT NULL DEFAULT '1', `price` decimal(20,6) NOT NULL DEFAULT '0.000000', `wholesale_price` decimal(20,6) NOT NULL DEFAULT '0.000000', `unity` varchar(255) DEFAULT NULL, diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index abe3db07a..e15945f8b 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -449,6 +449,14 @@ product_tabs['Informations'] = new function(){ } }); + $('input[name=allow_multiple_quantity]').on('change', function(e) { + if ($(this).val() == 1) { + $('#max_quantity_container').show('fast'); + } else { + $('#max_quantity_container').hide('fast'); + } + }); + $('#related_product_autocomplete_input') .autocomplete('ajax_products_list.php?exclude_packs=0&excludeVirtuals=0&excludeIds='+id_product, { minChars: 1, diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index 788ef2cb0..077c3f9fb 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -118,7 +118,7 @@

    {$product['name']|escape:'html':'UTF-8'}

    {if $product.allow_multiple_quantity}
    - +
    diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index f700c7720..e2474c0d6 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -50,7 +50,7 @@ {/if} {if $product.allow_multiple_quantity && $product.available_for_order}
    - +
    {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if}
    diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index 7456edabe..7f59c444e 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -468,8 +468,11 @@ $(document).ready(function() $(document).on('click', '#rooms_extra_services .qty_up', function(e) { e.preventDefault(); qtyfield = $(this).closest('.qty_container').find('input.qty'); - var currentVal = parseInt(qtyfield.val()); - qtyfield.val(currentVal + 1).trigger('focusout'); + var newQuantity = parseInt(qtyfield.val()) + 1; + if (qtyfield.data('max_quantity') < newQuantity) { + newQuantity = qtyfield.data('max_quantity'); + } + qtyfield.val(newQuantity).trigger('focusout'); }); $(document).on('click', '#rooms_extra_services .qty_down', function(e) { @@ -487,6 +490,9 @@ $(document).ready(function() var qty_wntd = $(this).val(); if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { $(this).val(1); + } + if ($(this).data('max_quantity') < qty_wntd) { + $(this).val(qtyfield.data('max_quantity')); } if ($(this).closest('.room_demand_block').find('.change_room_type_service_product').is(':checked')) { updateServiceProducts($(this).closest('.room_demand_block').find('.change_room_type_service_product')); diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 96ae9a806..57a92afa3 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1106,9 +1106,12 @@ $(document).ready(function() { $(document).on('click', '.service_product_qty_up', function(e) { e.preventDefault(); qtyfield = $(this).closest('.qty_container').find('input.service_product_qty'); - var currentVal = parseInt(qtyfield.val()); - $(this).closest('.qty_container').find('.qty_count span').text(currentVal + 1); - qtyfield.val(currentVal + 1); + var newQuantity = parseInt(qtyfield.val()) + 1; + if (qtyfield.data('max_quantity') < newQuantity) { + newQuantity = qtyfield.data('max_quantity'); + } + $(this).closest('.qty_container').find('.qty_count span').text(newQuantity); + qtyfield.val(newQuantity); }); // The button to decrement the product value From ace3ebe197e63253740212fcf4992ce877a94f10 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 15:31:02 +0530 Subject: [PATCH 54/77] Add guest transformation dusring registration at front office --- controllers/front/AuthController.php | 578 +++++++++--------- .../authentication.tpl | 10 +- .../css/authentication.css | 4 +- .../js/authentication.js | 5 +- 4 files changed, 308 insertions(+), 289 deletions(-) diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 33f7c885e..b205b7a97 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -170,6 +170,8 @@ class AuthControllerCore extends FrontController 'informations' => $this->informations, 'hasError' => !empty($this->errors), 'errors' => $this->errors, + 'hasAjaxExtraData' => !empty($this->ajaxExtraData), + 'ajaxExtraData' => $this->ajaxExtraData, 'page' => $this->context->smarty->fetch($this->template), 'token' => Tools::getToken(false) ); @@ -416,309 +418,314 @@ class AuthControllerCore extends FrontController if (Validate::isEmail($email = Tools::getValue('email')) && !empty($email)) { if (Customer::customerExists($email)) { $this->errors[] = Tools::displayError('An account using this email address has already been registered.', false); + } elseif (Customer::customerExists($email, false, false)) { + $this->errors[] = Tools::displayError('You are already registered as a guest with this email address.').' '.Tools::displayError('').' to generate a password for your account.'; } } - // Preparing customer - $customer = new Customer(); - $lastnameAddress = Tools::getValue('lastname'); - $firstnameAddress = Tools::getValue('firstname'); - $_POST['lastname'] = Tools::getValue('customer_lastname', $lastnameAddress); - $_POST['firstname'] = Tools::getValue('customer_firstname', $firstnameAddress); - $addresses_types = array('address'); - - if (!Configuration::get('PS_ORDER_PROCESS_TYPE') && Configuration::get('PS_GUEST_CHECKOUT_ENABLED') && Tools::getValue('invoice_address')) { - $addresses_types[] = 'address_invoice'; - } - - $error_phone = false; - if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) { - if (Tools::isSubmit('submitGuestAccount') || !Tools::getValue('is_new_customer')) { - if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')) { - $error_phone = true; - } - } elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE')) - || (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create')) - || (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Tools::getValue('email_create'))) - && (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))) { - $error_phone = true; - } - } - - if ($error_phone) { - $this->errors[] = Tools::displayError('You must register at least one phone number.'); - } - - // if PS_CUSTOMER_ADDRESS_CREATION is disabled And customer has no addresses then create customer address - // with the details of first hotel which rooms he has in cart - if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION') - && isset($this->context->cart->id) - && $this->context->cart->id - ) { - if (Module::isInstalled('hotelreservationsystem')) { - include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; - $objHtlCart = new HotelCartBookingData(); - if ($htlCartInfo = $objHtlCart->getCartCurrentDataByCartId($this->context->cart->id)) { - if (isset($htlCartInfo[0]['id_hotel']) && ($idHotel = $htlCartInfo[0]['id_hotel'])) { - if ($address_info = HotelBranchInformation::getAddress($idHotel)) { - $_POST['lastname'] = Tools::getValue('customer_lastname'); - $_POST['firstname'] = Tools::getValue('customer_firstname'); - $_POST['address1'] = $address_info['address1']; - $_POST['city'] = $address_info['city']; - $_POST['postcode'] = $address_info['postcode']; - $_POST['alias'] = 'My address'; - $_POST['id_country'] = $address_info['id_country']; - $_POST['id_state'] = $address_info['id_state']; - $_POST['auto_generated'] = true; - // if form is shorter then address name will be customer name - $lastnameAddress = $_POST['lastname']; - $firstnameAddress = $_POST['firstname']; - } - } - } - } - } - // End - $this->errors = array_unique(array_merge($this->errors, $customer->validateController())); - - // Check the requires fields which are settings in the BO - $this->errors = $this->errors + $customer->validateFieldsRequiredDatabase(); - - if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) { - if (!count($this->errors)) { - - $this->processCustomerNewsletter($customer); - - $customer->firstname = Tools::ucwords($customer->firstname); - $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); - if (!Validate::isBirthDate($customer->birthday)) { - $this->errors[] = Tools::displayError('Invalid date of birth.'); - } - - // New Guest customer - $customer->is_guest = (Tools::isSubmit('is_new_customer') ? !Tools::getValue('is_new_customer', 1) : 0); - $customer->active = 1; - - if (!count($this->errors)) { - if ($customer->add()) { - if (!$customer->is_guest) { - if (!$this->sendConfirmationMail($customer)) { - $this->errors[] = Tools::displayError('The email cannot be sent.'); - } - } - - $this->updateContext($customer); - - $this->context->cart->update(); - Hook::exec('actionCustomerAccountAdd', array( - '_POST' => $_POST, - 'newCustomer' => $customer - )); - if ($this->ajax) { - $return = array( - 'hasError' => !empty($this->errors), - 'errors' => $this->errors, - 'isSaved' => true, - 'id_customer' => (int)$this->context->cookie->id_customer, - 'id_address_delivery' => $this->context->cart->id_address_delivery, - 'id_address_invoice' => $this->context->cart->id_address_invoice, - 'token' => Tools::getToken(false) - ); - $this->ajaxDie(json_encode($return)); - } - - if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) { - Tools::redirect(html_entity_decode($back)); - } - - // redirection: if cart is not empty : redirection to the cart - if (count($this->context->cart->getProducts(true)) > 0) { - $multi = (int)Tools::getValue('multi-shipping'); - Tools::redirect('index.php?controller=order'.($multi ? '&multi-shipping='.$multi : '')); - } - // else : redirection to the account - else { - Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); - } - } else { - $this->errors[] = Tools::displayError('An error occurred while creating your account.'); - } - } - } - } else { - // if registration type is in one step, we save the address - - $_POST['lastname'] = $lastnameAddress; - $_POST['firstname'] = $firstnameAddress; - $post_back = $_POST; - // Preparing addresses - foreach ($addresses_types as $addresses_type) { - $$addresses_type = new Address(); - $$addresses_type->id_customer = 1; - - if ($addresses_type == 'address_invoice') { - foreach ($_POST as $key => &$post) { - if ($tmp = Tools::getValue($key.'_invoice')) { - $post = $tmp; - } - } - } - - $this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController())); - if ($addresses_type == 'address_invoice') { - $_POST = $post_back; - } - - if (!($country = new Country($$addresses_type->id_country)) || !Validate::isLoadedObject($country)) { - $this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country'); - } - - if (!$country->active) { - $this->errors[] = Tools::displayError('This country is not active.'); - } - - $postcode = $$addresses_type->postcode; - /* Check zip code format */ - if ($country->zip_code_format && !$country->checkZipCode($postcode)) { - $this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))); - } elseif (empty($postcode) && $country->need_zip_code) { - $this->errors[] = Tools::displayError('A Zip / Postal code is required.'); - } elseif ($postcode && !Validate::isPostCode($postcode)) { - $this->errors[] = Tools::displayError('The Zip / Postal code is invalid.'); - } - - if ($country->need_identification_number) { - if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')) { - $$addresses_type->dni = null; - } elseif (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))) { - $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.'); - } - } elseif (!$country->need_identification_number) { - $$addresses_type->dni = null; - } - - if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) { - if (!($country = new Country($$addresses_type->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country)) { - $this->errors[] = Tools::displayError('Country is invalid'); - } - } - $contains_state = isset($country) && is_object($country) ? (int)$country->contains_states: 0; - $id_state = isset($$addresses_type) && is_object($$addresses_type) ? (int)$$addresses_type->id_state: 0; - if ((Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state) { - $this->errors[] = Tools::displayError('This country requires you to choose a State.'); - } - } - } - - if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) { - $this->errors[] = Tools::displayError('Invalid date of birth'); - } if (!count($this->errors)) { - if (Customer::customerExists(Tools::getValue('email'))) { - $this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false); + // Preparing customer + $customer = new Customer(); + $lastnameAddress = Tools::getValue('lastname'); + $firstnameAddress = Tools::getValue('firstname'); + $_POST['lastname'] = Tools::getValue('customer_lastname', $lastnameAddress); + $_POST['firstname'] = Tools::getValue('customer_firstname', $firstnameAddress); + $addresses_types = array('address'); + + if (!Configuration::get('PS_ORDER_PROCESS_TYPE') && Configuration::get('PS_GUEST_CHECKOUT_ENABLED') && Tools::getValue('invoice_address')) { + $addresses_types[] = 'address_invoice'; } - $this->processCustomerNewsletter($customer); + $error_phone = false; + if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) { + if (Tools::isSubmit('submitGuestAccount') || !Tools::getValue('is_new_customer')) { + if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')) { + $error_phone = true; + } + } elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE')) + || (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create')) + || (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Tools::getValue('email_create'))) + && (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))) { + $error_phone = true; + } + } - $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); - if (!Validate::isBirthDate($customer->birthday)) { + if ($error_phone) { + $this->errors[] = Tools::displayError('You must register at least one phone number.'); + } + + // if PS_CUSTOMER_ADDRESS_CREATION is disabled And customer has no addresses then create customer address + // with the details of first hotel which rooms he has in cart + if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION') + && isset($this->context->cart->id) + && $this->context->cart->id + ) { + if (Module::isInstalled('hotelreservationsystem')) { + include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; + $objHtlCart = new HotelCartBookingData(); + if ($htlCartInfo = $objHtlCart->getCartCurrentDataByCartId($this->context->cart->id)) { + if (isset($htlCartInfo[0]['id_hotel']) && ($idHotel = $htlCartInfo[0]['id_hotel'])) { + if ($address_info = HotelBranchInformation::getAddress($idHotel)) { + $_POST['lastname'] = Tools::getValue('customer_lastname'); + $_POST['firstname'] = Tools::getValue('customer_firstname'); + $_POST['address1'] = $address_info['address1']; + $_POST['city'] = $address_info['city']; + $_POST['postcode'] = $address_info['postcode']; + $_POST['alias'] = 'My address'; + $_POST['id_country'] = $address_info['id_country']; + $_POST['id_state'] = $address_info['id_state']; + $_POST['auto_generated'] = true; + // if form is shorter then address name will be customer name + $lastnameAddress = $_POST['lastname']; + $firstnameAddress = $_POST['firstname']; + } + } + } + } + } + // End + $this->errors = array_unique(array_merge($this->errors, $customer->validateController())); + + // Check the requires fields which are settings in the BO + $this->errors = $this->errors + $customer->validateFieldsRequiredDatabase(); + + if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) { + if (!count($this->errors)) { + + $this->processCustomerNewsletter($customer); + + $customer->firstname = Tools::ucwords($customer->firstname); + $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); + if (!Validate::isBirthDate($customer->birthday)) { + $this->errors[] = Tools::displayError('Invalid date of birth.'); + } + + // New Guest customer + $customer->is_guest = (Tools::isSubmit('is_new_customer') ? !Tools::getValue('is_new_customer', 1) : 0); + $customer->active = 1; + + if (!count($this->errors)) { + if ($customer->add()) { + if (!$customer->is_guest) { + if (!$this->sendConfirmationMail($customer)) { + $this->errors[] = Tools::displayError('The email cannot be sent.'); + } + } + + $this->updateContext($customer); + + $this->context->cart->update(); + Hook::exec('actionCustomerAccountAdd', array( + '_POST' => $_POST, + 'newCustomer' => $customer + )); + if ($this->ajax) { + $return = array( + 'hasError' => !empty($this->errors), + 'errors' => $this->errors, + 'isSaved' => true, + 'id_customer' => (int)$this->context->cookie->id_customer, + 'id_address_delivery' => $this->context->cart->id_address_delivery, + 'id_address_invoice' => $this->context->cart->id_address_invoice, + 'token' => Tools::getToken(false) + ); + $this->ajaxDie(json_encode($return)); + } + + if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) { + Tools::redirect(html_entity_decode($back)); + } + + // redirection: if cart is not empty : redirection to the cart + if (count($this->context->cart->getProducts(true)) > 0) { + $multi = (int)Tools::getValue('multi-shipping'); + Tools::redirect('index.php?controller=order'.($multi ? '&multi-shipping='.$multi : '')); + } + // else : redirection to the account + else { + Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); + } + } else { + $this->errors[] = Tools::displayError('An error occurred while creating your account.'); + } + } + } + } else { + // if registration type is in one step, we save the address + + $_POST['lastname'] = $lastnameAddress; + $_POST['firstname'] = $firstnameAddress; + $post_back = $_POST; + // Preparing addresses + foreach ($addresses_types as $addresses_type) { + $$addresses_type = new Address(); + $$addresses_type->id_customer = 1; + + if ($addresses_type == 'address_invoice') { + foreach ($_POST as $key => &$post) { + if ($tmp = Tools::getValue($key.'_invoice')) { + $post = $tmp; + } + } + } + + $this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController())); + if ($addresses_type == 'address_invoice') { + $_POST = $post_back; + } + + if (!($country = new Country($$addresses_type->id_country)) || !Validate::isLoadedObject($country)) { + $this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country'); + } + + if (!$country->active) { + $this->errors[] = Tools::displayError('This country is not active.'); + } + + $postcode = $$addresses_type->postcode; + /* Check zip code format */ + if ($country->zip_code_format && !$country->checkZipCode($postcode)) { + $this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))); + } elseif (empty($postcode) && $country->need_zip_code) { + $this->errors[] = Tools::displayError('A Zip / Postal code is required.'); + } elseif ($postcode && !Validate::isPostCode($postcode)) { + $this->errors[] = Tools::displayError('The Zip / Postal code is invalid.'); + } + + if ($country->need_identification_number) { + if (!Configuration::get('PS_CUSTOMER_ADDRESS_CREATION')) { + $$addresses_type->dni = null; + } elseif (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))) { + $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.'); + } + } elseif (!$country->need_identification_number) { + $$addresses_type->dni = null; + } + + if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) { + if (!($country = new Country($$addresses_type->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country)) { + $this->errors[] = Tools::displayError('Country is invalid'); + } + } + $contains_state = isset($country) && is_object($country) ? (int)$country->contains_states: 0; + $id_state = isset($$addresses_type) && is_object($$addresses_type) ? (int)$$addresses_type->id_state: 0; + if ((Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state) { + $this->errors[] = Tools::displayError('This country requires you to choose a State.'); + } + } + } + + if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) { $this->errors[] = Tools::displayError('Invalid date of birth'); } if (!count($this->errors)) { - $customer->active = 1; - // New Guest customer - if (Tools::isSubmit('is_new_customer')) { - $customer->is_guest = !Tools::getValue('is_new_customer', 1); - } else { - $customer->is_guest = 0; + if (Customer::customerExists(Tools::getValue('email'))) { + $this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false); } - if (!$customer->add()) { - $this->errors[] = Tools::displayError('An error occurred while creating your account.'); - } else { - foreach ($addresses_types as $addresses_type) { - $$addresses_type->id_customer = (int)$customer->id; - if ($addresses_type == 'address_invoice') { - foreach ($_POST as $key => &$post) { - if ($tmp = Tools::getValue($key.'_invoice')) { - $post = $tmp; + + $this->processCustomerNewsletter($customer); + + $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); + if (!Validate::isBirthDate($customer->birthday)) { + $this->errors[] = Tools::displayError('Invalid date of birth'); + } + + if (!count($this->errors)) { + $customer->active = 1; + // New Guest customer + if (Tools::isSubmit('is_new_customer')) { + $customer->is_guest = !Tools::getValue('is_new_customer', 1); + } else { + $customer->is_guest = 0; + } + if (!$customer->add()) { + $this->errors[] = Tools::displayError('An error occurred while creating your account.'); + } else { + foreach ($addresses_types as $addresses_type) { + $$addresses_type->id_customer = (int)$customer->id; + if ($addresses_type == 'address_invoice') { + foreach ($_POST as $key => &$post) { + if ($tmp = Tools::getValue($key.'_invoice')) { + $post = $tmp; + } } } - } - $this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController())); - if ($addresses_type == 'address_invoice') { - $_POST = $post_back; - } - if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->add()) { - $this->errors[] = Tools::displayError('An error occurred while creating your address.'); - } - } - if (!count($this->errors)) { - if (!$customer->is_guest) { - $this->context->customer = $customer; - $customer->cleanGroups(); - // we add the guest customer in the default customer group - $customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP'))); - if (!$this->sendConfirmationMail($customer)) { - // webkul - we will not stop process on email delivery fails - //$this->errors[] = Tools::displayError('The email cannot be sent.'); + $this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController())); + if ($addresses_type == 'address_invoice') { + $_POST = $post_back; + } + if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->add()) { + $this->errors[] = Tools::displayError('An error occurred while creating your address.'); } - } else { - $customer->cleanGroups(); - // we add the guest customer in the guest customer group - $customer->addGroups(array((int)Configuration::get('PS_GUEST_GROUP'))); - } - $this->updateContext($customer); - $this->context->cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$customer->id); - $this->context->cart->id_address_invoice = (int)Address::getFirstCustomerAddressId((int)$customer->id); - if (isset($address_invoice) && Validate::isLoadedObject($address_invoice)) { - $this->context->cart->id_address_invoice = (int)$address_invoice->id; } + if (!count($this->errors)) { + if (!$customer->is_guest) { + $this->context->customer = $customer; + $customer->cleanGroups(); + // we add the guest customer in the default customer group + $customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP'))); + if (!$this->sendConfirmationMail($customer)) { + // webkul - we will not stop process on email delivery fails + //$this->errors[] = Tools::displayError('The email cannot be sent.'); + } + } else { + $customer->cleanGroups(); + // we add the guest customer in the guest customer group + $customer->addGroups(array((int)Configuration::get('PS_GUEST_GROUP'))); + } + $this->updateContext($customer); + $this->context->cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$customer->id); + $this->context->cart->id_address_invoice = (int)Address::getFirstCustomerAddressId((int)$customer->id); + if (isset($address_invoice) && Validate::isLoadedObject($address_invoice)) { + $this->context->cart->id_address_invoice = (int)$address_invoice->id; + } - if ($this->ajax && Configuration::get('PS_ORDER_PROCESS_TYPE')) { - $delivery_option = array((int)$this->context->cart->id_address_delivery => (int)$this->context->cart->id_carrier.','); - $this->context->cart->setDeliveryOption($delivery_option); - } + if ($this->ajax && Configuration::get('PS_ORDER_PROCESS_TYPE')) { + $delivery_option = array((int)$this->context->cart->id_address_delivery => (int)$this->context->cart->id_carrier.','); + $this->context->cart->setDeliveryOption($delivery_option); + } - // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated - $this->context->cart->update(); + // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated + $this->context->cart->update(); - // Avoid articles without delivery address on the cart - $this->context->cart->autosetProductAddress(); + // Avoid articles without delivery address on the cart + $this->context->cart->autosetProductAddress(); - Hook::exec('actionCustomerAccountAdd', array( - '_POST' => $_POST, - 'newCustomer' => $customer - )); - if ($this->ajax) { - $return = array( - 'hasError' => !empty($this->errors), - 'errors' => $this->errors, - 'isSaved' => true, - 'id_customer' => (int)$this->context->cookie->id_customer, - 'id_address_delivery' => $this->context->cart->id_address_delivery, - 'id_address_invoice' => $this->context->cart->id_address_invoice, - 'token' => Tools::getToken(false) - ); - $this->ajaxDie(json_encode($return)); - } - // if registration type is in two steps, we redirect to register address - if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) { - Tools::redirect('index.php?controller=address'); - } + Hook::exec('actionCustomerAccountAdd', array( + '_POST' => $_POST, + 'newCustomer' => $customer + )); + if ($this->ajax) { + $return = array( + 'hasError' => !empty($this->errors), + 'errors' => $this->errors, + 'isSaved' => true, + 'id_customer' => (int)$this->context->cookie->id_customer, + 'id_address_delivery' => $this->context->cart->id_address_delivery, + 'id_address_invoice' => $this->context->cart->id_address_invoice, + 'token' => Tools::getToken(false) + ); + $this->ajaxDie(json_encode($return)); + } + // if registration type is in two steps, we redirect to register address + if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) { + Tools::redirect('index.php?controller=address'); + } - if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) { - Tools::redirect(html_entity_decode($back)); - } + if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) { + Tools::redirect(html_entity_decode($back)); + } - // redirection: if cart is not empty : redirection to the cart - if (count($this->context->cart->getProducts(true)) > 0) { - Tools::redirect('index.php?controller=order'.($multi = (int)Tools::getValue('multi-shipping') ? '&multi-shipping='.$multi : '')); - } - // else : redirection to the account - else { - Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); + // redirection: if cart is not empty : redirection to the cart + if (count($this->context->cart->getProducts(true)) > 0) { + Tools::redirect('index.php?controller=order'.($multi = (int)Tools::getValue('multi-shipping') ? '&multi-shipping='.$multi : '')); + } + // else : redirection to the account + else { + Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); + } } } } @@ -772,12 +779,21 @@ class AuthControllerCore extends FrontController */ protected function processTransformAccount() { - if (!Validate::isEmail($email = trim(Tools::getValue('email_create'))) || empty($email)) { + if (!Validate::isEmail($email = trim(Tools::getValue('email_create', Tools::getValue('email')))) || empty($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } elseif ($id_customer = Customer::customerExists($email, true, false)) { $customer = new Customer($id_customer); if ($customer->transformToCustomer($this->context->language->id)) { $this->confirmations[] = 'TRANSFORM_OK'; + + $back = ''; + if ($back == Tools::secureReferrer(Tools::getValue('back'))) { + $back = html_entity_decode($back); + } else { + $back = Tools::safeOutput($back); + } + $this->ajaxExtraData['redirect_link'] = $this->context->link->getPageLink('authentication'). + ($back ? '?back='.$back.'&' : '?').'guest_transform_success=1'; } else { $this->errors[] = Tools::displayError('Your guest account could not be transformed to a customer account.'); } diff --git a/themes/hotel-reservation-theme/authentication.tpl b/themes/hotel-reservation-theme/authentication.tpl index e267cdf05..62f9df117 100644 --- a/themes/hotel-reservation-theme/authentication.tpl +++ b/themes/hotel-reservation-theme/authentication.tpl @@ -50,11 +50,13 @@
    {/if}-->
    -
    - + {/if}

    {l s='Create an account'}

    diff --git a/themes/hotel-reservation-theme/css/authentication.css b/themes/hotel-reservation-theme/css/authentication.css index d89e3b596..de39d3d01 100644 --- a/themes/hotel-reservation-theme/css/authentication.css +++ b/themes/hotel-reservation-theme/css/authentication.css @@ -12,9 +12,9 @@ margin-bottom: 8px; } #create-account_form .form-group { margin: 0 0 20px 0; } - #create-account_form .btn-transform { + #authentication .btn-transform { padding: 0; - font-size: 16px; + font-size: 1em; cursor: pointer; vertical-align: initial; text-decoration: underline; } diff --git a/themes/hotel-reservation-theme/js/authentication.js b/themes/hotel-reservation-theme/js/authentication.js index 78c3cc503..dfee8c4a1 100644 --- a/themes/hotel-reservation-theme/js/authentication.js +++ b/themes/hotel-reservation-theme/js/authentication.js @@ -41,7 +41,8 @@ function submitFunction(submitAction) { var data = { controller: 'authentication', ajax: true, - email_create: $('#email_create').val(), + email_create: $('#email_create').val(), // for login page + email: $('#email').val(), // for personal info page back: $('input[name=back]').val(), token: token }; @@ -59,7 +60,7 @@ function submitFunction(submitAction) { // display confirmations if (jsonData.hasConfirmation) { if (in_array('TRANSFORM_OK', jsonData.confirmations)) { - $('#guest_transform_success').show('slow'); + window.location = jsonData.ajaxExtraData.redirect_link } return; } From 63013bf60ea79f94c220c70b60c2fcbba428db1f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 15:37:55 +0530 Subject: [PATCH 55/77] Remove unused fields from Catalog Price rule --- .../specific_price_rule/helpers/form/form.tpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/admin/themes/default/template/controllers/specific_price_rule/helpers/form/form.tpl b/admin/themes/default/template/controllers/specific_price_rule/helpers/form/form.tpl index 9ad52f538..6f7ee30f4 100644 --- a/admin/themes/default/template/controllers/specific_price_rule/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/specific_price_rule/helpers/form/form.tpl @@ -52,7 +52,7 @@
    -
    + {*
    @@ -68,8 +68,8 @@
    -
    -
    +
    *} + {*
    @@ -85,8 +85,8 @@
    -
    -
    +
    *} + {*
    @@ -111,7 +111,7 @@
    -
    +
    *}
    From 2a81cc028ca4f613f8df65f6d328824badd8a563 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 15:43:10 +0530 Subject: [PATCH 56/77] text change on order refund request view --- .../controllers/admin/AdminOrderRefundRequestsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index 9bad576c7..ba1b5d9cd 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -164,7 +164,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController } $this->fields_list = array( 'id_order_return' => array( - 'title' => $this->l('ID'), + 'title' => $this->l('Refund ID'), 'align' => 'center', 'class' => 'fixed-width-xs', ), From 54127b5de661960bd7deddbb216806ea9a6eee6d Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 16:19:32 +0530 Subject: [PATCH 57/77] Text change on refund detail view page at front officer --- themes/hotel-reservation-theme/order-return.tpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/themes/hotel-reservation-theme/order-return.tpl b/themes/hotel-reservation-theme/order-return.tpl index 8a53d8b49..f34eb786f 100644 --- a/themes/hotel-reservation-theme/order-return.tpl +++ b/themes/hotel-reservation-theme/order-return.tpl @@ -96,7 +96,7 @@
    - {l s='Total Order Amount'} + {l s='Total order amount'}
    {displayPrice price=$orderInfo['total_paid_tax_incl'] currency=$orderInfo['id_currency']} @@ -104,7 +104,7 @@
    - {l s='Refund initiated on'} + {l s='Request date'}
    {$orderReturnInfo['date_add']|date_format:"%d-%m-%Y %I:%M %p"} @@ -114,7 +114,7 @@ {if $currentStateInfo['refunded']}
    - {l s='Refunded Amount' mod='hotelreservationsystem'} + {l s='Refunded amount' mod='hotelreservationsystem'}
    {displayPrice price=$orderReturnInfo['refunded_amount'] currency=$orderInfo['id_currency']} @@ -122,7 +122,7 @@
    - {l s='Payment Mode' mod='hotelreservationsystem'} + {l s='Payment mode' mod='hotelreservationsystem'}
    {$orderReturnInfo['payment_mode']|escape:'html':'UTF-8'} @@ -130,7 +130,7 @@
    - {l s='Transaction Id' mod='hotelreservationsystem'} + {l s='Transaction ID' mod='hotelreservationsystem'}
    {$orderReturnInfo['id_transaction']|escape:'html':'UTF-8'} From 7405418aaf848036d2b525a23de6e9093ddc3af8 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 17:11:27 +0530 Subject: [PATCH 58/77] Fix filter issues on Assign Hotel Features --- .../controllers/admin/AdminAssignHotelFeatures.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAssignHotelFeatures.php b/modules/hotelreservationsystem/controllers/admin/AdminAssignHotelFeatures.php index 3530cd844..11a6e5c01 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAssignHotelFeatures.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAssignHotelFeatures.php @@ -40,11 +40,12 @@ class AdminAssignHotelFeaturesController extends ModuleAdminController $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hi ON (hi.`id` = a.`id_hotel`)'; $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hil ON (hi.`id` = hil.`id` AND hil.id_lang = '.(int)$this->context->language->id.')'; - $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = hi.`state_id`)'; - $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = hi.`country_id` + $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'address` addr ON (addr.`id_hotel` = hi.`id`)'; + $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = addr.`id_state`)'; + $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = addr.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')'; - $this->_select .= 'hi.`city` as htl_city, hi.`id` as htl_id, hil.`hotel_name` as htl_name, + $this->_select .= 'addr.`city` as htl_city, hi.`id` as htl_id, hil.`hotel_name` as htl_name, s.`name` as `state_name`, cl.`name`'; $this->_group = 'GROUP BY a.`id_hotel`'; @@ -57,12 +58,12 @@ class AdminAssignHotelFeaturesController extends ModuleAdminController 'htl_name' => array( 'title' => $this->l('Hotel Name'), 'align' => 'center', - 'filter_key' => 'hi!hotel_name', + 'filter_key' => 'hil!hotel_name', ), 'htl_city' => array( 'title' => $this->l('City'), 'align' => 'center', - 'filter_key' => 'hi!city', + 'filter_key' => 'addr!city', ), 'state_name' => array( From 40b2bb590dfe8843f1a135c986e0527a40a3bdcd Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 17:17:06 +0530 Subject: [PATCH 59/77] Fix PHP issue on front pages --- classes/Page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Page.php b/classes/Page.php index d2c26df76..f63641032 100644 --- a/classes/Page.php +++ b/classes/Page.php @@ -75,7 +75,7 @@ class PageCore extends ObjectModel FROM `'._DB_PREFIX_.'page` WHERE `id_page_type` = '.(int)$page_type_id.$where; $result = Db::getInstance()->getRow($sql); - if ($result['id_page']) { + if (isset($result['id_page']) && $result['id_page']) { return $result['id_page']; } From 8e7566d3199afa15571d143850109dc934f4d2b5 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 6 Mar 2023 11:35:24 +0530 Subject: [PATCH 60/77] Fix js errors on admin book now page --- js/fullcalendar/main.js | 1 - .../admin/AdminHotelRoomsBookingController.php | 13 +++++++++++++ .../views/js/admin/hotel_rooms_booking.js | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/js/fullcalendar/main.js b/js/fullcalendar/main.js index 2ad9d49a2..b3a60643c 100644 --- a/js/fullcalendar/main.js +++ b/js/fullcalendar/main.js @@ -9501,7 +9501,6 @@ var FullCalendar = (function (exports) { }); return (createElement(ContentHook, { hookProps: hookProps, content: options.dayCellContent, defaultContent: props.defaultContent }, props.children)); }; - console.log(DayCellContent); return DayCellContent; }(BaseComponent)); function refineDayCellHookProps(raw) { diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 3030aadc6..340c92cca 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -466,6 +466,19 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $bookingParams['date_from'] = $cal_date_from; $bookingParams['date_to'] = $cal_date_to; $eventData = $objBookingDetail->getBookingData($bookingParams); + if (!$eventData) { + $eventData['stats'] = array( + 'total_room_type' => 0, + 'total_rooms' => 0, + 'max_avail_occupancy' => 0, + 'num_unavail' => 0, + 'num_cart' => 0, + 'num_booked' => 0, + 'num_avail' => 0, + 'num_part_avai' => 0, + ); + } + $eventData['date_format'] = Tools::displayDate($cal_date_from); $events[strtotime($bookingParams['date_from'])] = array( 'is_notification' => 1, diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index de5b4a126..111bc776a 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -49,7 +49,7 @@ $(document).ready(function() { $(info.el).closest('td').find('.day-info svg circle').attr('fill', '#7EC77B'); } else if (info.event.extendedProps.data.stats.num_part_avai > 0) { $(info.el).closest('td').find('.day-info svg circle').attr('fill', '#FFC224'); - } else if (info.event.extendedProps.data.stats.num_booked == info.event.extendedProps.data.stats.total_rooms) { + } else if ((info.event.extendedProps.data.stats.num_booked == info.event.extendedProps.data.stats.total_rooms) && info.event.extendedProps.data.stats.total_rooms != 0) { $(info.el).closest('td').find('.day-info svg circle').attr('fill', '#00AFF0'); } else { $(info.el).closest('td').find('.day-info svg circle').attr('fill', '#FF3838'); From 3d2e5422c89d039784bdece4a7f648130ea0ba7d Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 6 Mar 2023 14:51:07 +0530 Subject: [PATCH 61/77] Fix Add new buttons --- controllers/admin/AdminEmployeesController.php | 4 ++-- controllers/admin/AdminThemesController.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/admin/AdminEmployeesController.php b/controllers/admin/AdminEmployeesController.php index ab1a12d45..64308b5a7 100644 --- a/controllers/admin/AdminEmployeesController.php +++ b/controllers/admin/AdminEmployeesController.php @@ -175,8 +175,6 @@ class AdminEmployeesControllerCore extends AdminController public function initPageHeaderToolbar() { - parent::initPageHeaderToolbar(); - if (empty($this->display)) { $this->page_header_toolbar_btn['new_employee'] = array( 'href' => self::$currentIndex.'&addemployee&token='.$this->token, @@ -195,6 +193,8 @@ class AdminEmployeesControllerCore extends AdminController $this->toolbar_title); } } + + parent::initPageHeaderToolbar(); } public function renderList() diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index eaf7f4c8a..53c8b11c1 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -716,8 +716,6 @@ class AdminThemesControllerCore extends AdminController public function initPageHeaderToolbar() { - parent::initPageHeaderToolbar(); - if (empty($this->display)) { $this->page_header_toolbar_btn['import_theme'] = array( 'href' => self::$currentIndex.'&action=importtheme&token='.$this->token, @@ -746,6 +744,8 @@ class AdminThemesControllerCore extends AdminController $title = implode(' '.Configuration::get('PS_NAVIGATION_PIPE').' ', $this->toolbar_title); $this->page_header_toolbar_title = $title; + + parent::initPageHeaderToolbar(); } private function checkParentClass($name) From 3ee3b84b83af378112bd917e015d57ec526f05c0 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 11:14:37 +0530 Subject: [PATCH 62/77] removed extra services list from current cart row --- .../orders/_current_cart_details_data.tpl | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl index 12df732af..c56112c34 100644 --- a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl +++ b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl @@ -50,24 +50,6 @@

    {$data.room_type|escape:'html':'UTF-8'}

    - {if isset($data.selected_demands) && $data.selected_demands} -
      - {foreach $data.selected_demands as $selDemand} -
    • - {$selDemand.name|escape:'html':'UTF-8'} -
    • - {/foreach} -
    - {/if} - {if isset($data['selected_additional_service'][$data['id']]['selected_products_info']) && $data['selected_additional_service'][$data['id']]['selected_products_info']} -
      - {foreach $data['selected_additional_service'][$data['id']]['selected_products_info'] as $selectedService} -
    • - {$selectedService.name|escape:'html':'UTF-8'} -
    • - {/foreach} -
    - {/if} {dateFormat date=$data.date_from} - {dateFormat date=$data.date_to} {if $occupancy_required_for_booking} @@ -162,7 +144,7 @@ {if (isset($data.extra_demands) && $data.extra_demands) || isset($data.additional_service) && $data.additional_service}
    -  {l s='Services'} +  {l s='Services'} {/if} From 1af18389dbee599b18fbe1ad6bc2ecbe9354da84 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 11:17:15 +0000 Subject: [PATCH 63/77] prevent adding service multiple times --- controllers/front/ProductController.php | 20 +++++++++- themes/hotel-reservation-theme/js/product.js | 42 +++++++++++++------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 03b88c709..73808d9c9 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1319,12 +1319,13 @@ class ProductControllerCore extends FrontController public function displayAjaxCheckServiceProductWithRoomType() { $response = array( - 'status' => false + 'success' => false ); if ($this->isTokenValid()) { $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); + $addedServiceProduct = Tools::getValue('added_service_product'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1335,7 +1336,22 @@ class ProductControllerCore extends FrontController if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) { $response['error'] = Tools::displayError('Selected product is not available with current room type'); } else { - $response['status'] = true; + if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { + $response['success'] = true; + if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { + if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } else { + $response['msg'] = 'Service already added.'; + } + } else { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } + } else { + $response['error'] = Tools::displayError('Service not Found'); + } } } else { $response['error'] = Tools::displayError('Room Type not Found'); diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 96ae9a806..0fd9c3409 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1201,6 +1201,13 @@ $(document).ready(function() { if (typeof(qty) == 'undefined') { qty = 1; } + var added_service_product = []; + $('#additional_products input.service_product').each(function () { + added_service_product.push({ + 'id_product': $(this).data('id_product'), + 'quantity':$(this).val(), + }); + }); $.ajax({ type: 'POST', headers: { @@ -1215,31 +1222,36 @@ $(document).ready(function() { qty: qty, id_product: $('#product_page_product_id').val(), service_product: id_product, + added_service_product: added_service_product, action: 'checkServiceProductWithRoomType', ajax: true, token: static_token }, success: function(result) { - if (result.status) { - if ($('input#service_product_'+ id_product).length) { - var prevQty = $('input#service_product_'+ id_product).val(); - if (parseInt(prevQty) > 0) { - qty = parseInt(qty) + parseInt(prevQty); + if (result.success) { + if (result.add) { + if ($('input#service_product_'+ id_product).length) { + var prevQty = $('input#service_product_'+ id_product).val(); + if (parseInt(prevQty) > 0) { + qty = parseInt(qty) + parseInt(prevQty); + } + $('input#service_product_'+ id_product).val(qty); + } else { + $('').attr({ + id: 'service_product_'+ id_product, + name: 'service_product['+ id_product +'][]', + class: 'service_product', + 'data-id_product': id_product, + value: qty + }).appendTo('#additional_products'); } - $('input#service_product_'+ id_product).val(qty); - } else { - $('').attr({ - id: 'service_product_'+ id_product, - name: 'service_product['+ id_product +'][]', - class: 'service_product', - 'data-id_product': id_product, - value: qty - }).appendTo('#additional_products'); } // reset input $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); - showSuccessMessage(cart_extra_service_add); + if (result.msg) { + showSuccessMessage(result.msg); + } BookingForm.refresh(); } else { if (result.error) { From 0f17dec89e2a0a7c925953f4dda8737d98f112da Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 11:58:37 +0000 Subject: [PATCH 64/77] remove disbale services from cart' --- controllers/front/OrderOpcController.php | 3 +++ modules/bankwire/controllers/front/payment.php | 3 +++ .../bankwire/controllers/front/validation.php | 3 +++ modules/cheque/controllers/front/payment.php | 3 +++ modules/cheque/controllers/front/validation.php | 3 +++ .../classes/RoomTypeServiceProductCartDetail.php | 16 ++++++++++++++++ 6 files changed, 31 insertions(+) diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index f5a5bec2b..f787834b5 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -389,6 +389,9 @@ class OrderOpcControllerCore extends ParentOrderController */ public function initContent() { + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + parent::initContent(); // check ORDER RESTRICT condition before payment by the customer diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index cee1fe886..59dc5ab17 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -50,6 +50,9 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index c96ff78ec..5df9b7411 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -49,6 +49,9 @@ class BankwireValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + // Check Order restrict condition before Payment by the customer if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index e1415337d..1d5e0f76b 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -50,6 +50,9 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index 6f75120a9..f280abd3f 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -48,6 +48,9 @@ class ChequeValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index eafa043bb..f9446f9f9 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -341,4 +341,20 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } return false; } + + public static function validateServiceProductsInCart() + { + $context = Context::getContext(); + if ($cartProducts = $context->cart->getProducts()) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); + foreach ($cartProducts as $product) { + if (!$product['active'] && !$product['booking_product']) { + $serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']); + foreach ($serviceProducts as $serviceProduct) { + $objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']); + } + } + } + } + } } \ No newline at end of file From 3ceefe2c11aeab8ee74be5d54fba3db98ed5854d Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 12:08:50 +0000 Subject: [PATCH 65/77] fix order detail service price not defined --- controllers/front/OrderDetailController.php | 66 ++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 2a898f8b6..20ed72474 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -479,40 +479,40 @@ class OrderDetailControllerCore extends FrontController 1, 0 ); + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); } - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); // calculate averages now foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); From b5b1022bf89bca3c14e7118b1fa8bd86b38fb3ae Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 18:12:58 +0530 Subject: [PATCH 66/77] removed addition changes --- .../orders/_room_extra_services_modal.tpl | 13 +- .../orders/_room_facilities_block.tpl | 160 +++++++++--------- .../orders/_room_services_block.tpl | 10 +- .../controllers/orders/helpers/view/view.tpl | 11 +- controllers/admin/AdminOrdersController.php | 1 - controllers/front/OrderDetailController.php | 66 ++++---- controllers/front/OrderOpcController.php | 3 - controllers/front/ProductController.php | 20 +-- install/data/xml/category_group.xml | 6 +- .../bankwire/controllers/front/payment.php | 3 - .../bankwire/controllers/front/validation.php | 3 - modules/cheque/controllers/front/payment.php | 3 - .../cheque/controllers/front/validation.php | 3 - .../classes/RoomTypeServiceProduct.php | 2 - .../RoomTypeServiceProductCartDetail.php | 16 -- .../_partials/service-products-list-row.tpl | 35 ++-- .../_partials/service-products.tpl | 2 +- themes/hotel-reservation-theme/js/product.js | 44 ++--- 18 files changed, 164 insertions(+), 237 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl index 4714a077b..2e0cd1415 100644 --- a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl +++ b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl @@ -22,8 +22,12 @@
    @@ -46,8 +51,8 @@ margin: 0px;} #rooms_type_extra_demands .demand_edit_badge { font-size: 14px;} - /* #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { */ - /* font-size: 14px;} */ + #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { + font-size: 14px;} #rooms_extra_demands .demand_header { padding: 10px; color: #333; diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index 1b96dba9b..abc426f8d 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -17,91 +17,91 @@ * @license https://store.webkul.com/license.html *} -
    - - {if isset($orderEdit) && $orderEdit} -

    - - -

    +{if (isset($extraDemands) && $extraDemands) || (isset($roomTypeDemands) && $roomTypeDemands)} +
    + + {if isset($orderEdit) && $orderEdit} +

    + + +

    - {* Already selected room demands *} -
    - - - {if isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} - {foreach $roomDemand['extra_demands'] as $demand} - - - - - + {* Already selected room demands *} +
    +
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    + + {if isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} + {foreach $roomDemand['extra_demands'] as $demand} + + + + + + {/foreach} {/foreach} - {/foreach} - {else} - - - - {/if} - -
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    - {l s='No facilities added yet.'} -
    -
    + {else} + + + {l s='No facilities added yet.'} + + + {/if} + + +
    - {* Room demands available for the current editing room*} -
    -
    - {if isset($roomTypeDemands) && $roomTypeDemands} - {foreach $roomTypeDemands as $idGlobalDemand => $demand} -
    -
    -
    -
    - -
    -
    -

    {$demand['name']|escape:'html':'UTF-8'}

    - {if isset($demand['adv_option']) && $demand['adv_option']} - - {else} - - {/if} + {* Room demands available for the current editing room*} +
    +
    + {if isset($roomTypeDemands) && $roomTypeDemands} + {foreach $roomTypeDemands as $idGlobalDemand => $demand} +
    +
    +
    +
    + +
    +
    +

    {$demand['name']|escape:'html':'UTF-8'}

    + {if isset($demand['adv_option']) && $demand['adv_option']} + + {else} + + {/if} +
    +
    +

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    +
    -
    -

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    -
    + {/foreach} + {/if} +
    + +
    + {elseif isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} +
    + {foreach $roomDemand['extra_demands'] as $demand} +
    +

    + {$demand['name']} + {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} +

    {/foreach} - {/if} -
    - -
    - {elseif isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} -
    - {foreach $roomDemand['extra_demands'] as $demand} -
    -

    - {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} -

    -
    - {/foreach} -
    - {/foreach} - {else} - {l s='No facilities available!'} - {/if} -
    \ No newline at end of file +
    + {/foreach} + {/if} +
    +{/if} \ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl index 7566f1e5b..1bbf2ad64 100644 --- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl @@ -17,7 +17,8 @@ * @license https://store.webkul.com/license.html *} -
    +{if (isset($additionalServices) && $additionalServices) || (isset($roomTypeServiceProducts) && $roomTypeServiceProducts)} +
    {if isset($orderEdit) && $orderEdit}

    @@ -36,7 +37,7 @@

    {$service['name']|escape:'html':'UTF-8'}
    {if $service['allow_multiple_quantity']}
    - +
    {/if} @@ -76,7 +77,7 @@

    {$product['name']|escape:'html':'UTF-8'}

    {if $product.allow_multiple_quantity}
    - +
    {/if}
    @@ -124,7 +125,6 @@
    {/foreach}
    - {else} - {l s='No services available!'} {/if}
    +{/if} diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 5dd42117e..8a2b5b313 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1717,21 +1717,14 @@ $('#room_extra_demand_content #back_to_service_btn').hide(); }); - $(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) { + $(document).on('focusout', '#rooms_type_extra_demands .qty', function(e) { var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { + if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { $(this).val(1); } updateServiceProducts($(this)); }); - $(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) { - var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { - $(this).val(1); - } - }); - function updateServiceProducts(element) { var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail'); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index ca9b99ff1..df4af2e8d 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4738,7 +4738,6 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } } - $smartyVars['show_active'] = true; $this->context->smarty->assign($smartyVars); $servicesTpl = $this->context->smarty->fetch( diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 20ed72474..2a898f8b6 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -479,40 +479,40 @@ class OrderDetailControllerCore extends FrontController 1, 0 ); - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); } + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); // calculate averages now foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index cc11fa369..347e82f96 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -389,9 +389,6 @@ class OrderOpcControllerCore extends ParentOrderController */ public function initContent() { - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - parent::initContent(); // check ORDER RESTRICT condition before payment by the customer diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 054555062..a97a90577 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1318,13 +1318,12 @@ class ProductControllerCore extends FrontController public function displayAjaxCheckServiceProductWithRoomType() { $response = array( - 'success' => false + 'status' => false ); if ($this->isTokenValid()) { $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); - $addedServiceProduct = Tools::getValue('added_service_product'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1335,22 +1334,7 @@ class ProductControllerCore extends FrontController if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) { $response['error'] = Tools::displayError('Selected product is not available with current room type'); } else { - if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { - $response['success'] = true; - if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { - if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { - $response['add'] = true; - $response['msg'] = 'Service is added to cart.'; - } else { - $response['msg'] = 'Service already added.'; - } - } else { - $response['add'] = true; - $response['msg'] = 'Service is added to cart.'; - } - } else { - $response['error'] = Tools::displayError('Service not Found'); - } + $response['status'] = true; } } else { $response['error'] = Tools::displayError('Room Type not Found'); diff --git a/install/data/xml/category_group.xml b/install/data/xml/category_group.xml index 902335903..a0187a2f0 100644 --- a/install/data/xml/category_group.xml +++ b/install/data/xml/category_group.xml @@ -11,8 +11,8 @@ - - - + + + diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index 59dc5ab17..cee1fe886 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -50,9 +50,6 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index 5df9b7411..c96ff78ec 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -49,9 +49,6 @@ class BankwireValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - // Check Order restrict condition before Payment by the customer if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index 1d5e0f76b..e1415337d 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -50,9 +50,6 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index f280abd3f..6f75120a9 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -48,9 +48,6 @@ class ChequeValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 6a16c420d..199d3a178 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -182,8 +182,6 @@ class RoomTypeServiceProduct extends ObjectModel 1, $useTax ); - - $serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']); } } diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index f9446f9f9..eafa043bb 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -341,20 +341,4 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } return false; } - - public static function validateServiceProductsInCart() - { - $context = Context::getContext(); - if ($cartProducts = $context->cart->getProducts()) { - $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - foreach ($cartProducts as $product) { - if (!$product['active'] && !$product['booking_product']) { - $serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']); - foreach ($serviceProducts as $serviceProduct) { - $objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']); - } - } - } - } - } } \ No newline at end of file diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 08e3c1b8e..f700c7720 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -20,15 +20,9 @@ {if isset($product) && $product}
  • - + {if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if} - {foreach $product.images as $image} - {if $image['cover'] == 0} - - {/if} - {/foreach}
    @@ -42,7 +36,7 @@ {/if}
    - {if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} @@ -52,21 +46,20 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if $product.available_for_order && !$PS_CATALOG_MODE && !$order_date_restrict && !((isset($restricted_country_mode) && $restricted_country_mode))} - {if $product.allow_multiple_quantity && $product.available_for_order} -
    - -
    - {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} -
    -
    - - -
    -
    - {/if} {/if} {/if} - + {if $product.allow_multiple_quantity && $product.available_for_order} +
    + +
    + {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} +
    +
    + + +
    +
    + {/if}
    diff --git a/themes/hotel-reservation-theme/_partials/service-products.tpl b/themes/hotel-reservation-theme/_partials/service-products.tpl index 370f10de9..2b3565520 100644 --- a/themes/hotel-reservation-theme/_partials/service-products.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products.tpl @@ -45,7 +45,7 @@ {/foreach} {else}
      - {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products init=true} + {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products group='all' init=true}
    {if RoomTypeServiceProduct::WK_NUM_RESULTS < $num_total_service_products}
    diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 57a0add94..96ae9a806 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1201,15 +1201,6 @@ $(document).ready(function() { if (typeof(qty) == 'undefined') { qty = 1; } - var added_service_product = []; - - $('#additional_products input.service_product').each(function () { - added_service_product.push({ - 'id_product': $(this).data('id_product'), - 'quantity':$(this).val(), - }); - }); - $.ajax({ type: 'POST', headers: { @@ -1224,36 +1215,31 @@ $(document).ready(function() { qty: qty, id_product: $('#product_page_product_id').val(), service_product: id_product, - added_service_product: added_service_product, action: 'checkServiceProductWithRoomType', ajax: true, token: static_token }, success: function(result) { - if (result.success) { - if (result.add) { - if ($('input#service_product_'+ id_product).length) { - var prevQty = $('input#service_product_'+ id_product).val(); - if (parseInt(prevQty) > 0) { - qty = parseInt(qty) + parseInt(prevQty); - } - $('input#service_product_'+ id_product).val(qty); - } else { - $('').attr({ - id: 'service_product_'+ id_product, - name: 'service_product['+ id_product +'][]', - class: 'service_product', - 'data-id_product': id_product, - value: qty - }).appendTo('#additional_products'); + if (result.status) { + if ($('input#service_product_'+ id_product).length) { + var prevQty = $('input#service_product_'+ id_product).val(); + if (parseInt(prevQty) > 0) { + qty = parseInt(qty) + parseInt(prevQty); } + $('input#service_product_'+ id_product).val(qty); + } else { + $('').attr({ + id: 'service_product_'+ id_product, + name: 'service_product['+ id_product +'][]', + class: 'service_product', + 'data-id_product': id_product, + value: qty + }).appendTo('#additional_products'); } // reset input $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); - if (result.msg) { - showSuccessMessage(result.msg); - } + showSuccessMessage(cart_extra_service_add); BookingForm.refresh(); } else { if (result.error) { From 2c4694ffe72e20da995580eaf767745d13131cb8 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 9 Mar 2023 16:59:26 +0530 Subject: [PATCH 67/77] php validation to limit service product quantity' --- controllers/front/CartController.php | 24 +++++++--- controllers/front/ProductController.php | 46 +++++++++++++++---- .../hotel-reservation-theme/js/order-opc.js | 4 +- themes/hotel-reservation-theme/js/product.js | 2 +- 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 7736cc76f..69ce2e3e8 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -395,16 +395,26 @@ class CartControllerCore extends FrontController if (Tools::getValue('op', 'up') == 'up') { if ($total_available_rooms < $req_rm) { die(json_encode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms))); - } else { - // validate normal products if available - if ($serviceProducts) { - $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - foreach ($serviceProducts as $key => $standartProduct) { - if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($this->id_product, $standartProduct['id_product'])) { - unset($serviceProducts[$key]); + } else { + // validate service products if available + if ($serviceProducts) { + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + foreach ($serviceProducts as $key => $serviceProduct) { + if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($this->id_product, $serviceProduct['id_product'])) { + unset($serviceProducts[$key]); + } else { + if (Validate::isLoadedObject($objServiceProduct = new Product($serviceProduct['id_product']))) { + if (!$objServiceProduct->allow_multiple_quantity && $serviceProduct['quantity'] > 1) { + $serviceProducts[$key]['quantity'] = 1; + } else if ($objServiceProduct->max_quantity && $objServiceProduct->max_quantity < $serviceProduct['quantity'] ) { + $serviceProducts[$key]['quantity'] = $objServiceProduct->max_quantity; + } + } else { + $response['error'] = Tools::displayError('Service not Found'); } } } + } } } } else { diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 73808d9c9..74f8030fc 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -689,10 +689,22 @@ class ProductControllerCore extends FrontController $serviceProductsPrice = 0; if ($roomServiceProducts = json_decode($roomServiceProducts, true)) { $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); foreach ($roomServiceProducts as &$product) { - $objProduct = new ProductCore($product['id_product'], false, $this->context->language->id); - $product['name'] = $objProduct->name; - $product['allow_multiple_quantity'] = $objProduct->allow_multiple_quantity; + if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $product['id_product'])) { + unset($product); + continue; + } else { + $objServiceProduct = new ProductCore($product['id_product'], false, $this->context->language->id); + if (!$objServiceProduct->allow_multiple_quantity && $product['quantity'] > 1) { + $product['quantity'] = 1; + } else if ($objServiceProduct->max_quantity && $objServiceProduct->max_quantity < $product['quantity'] ) { + $product['quantity'] = $objServiceProduct->max_quantity; + } + + } + $product['name'] = $objServiceProduct->name; + $product['allow_multiple_quantity'] = $objServiceProduct->allow_multiple_quantity; $productPrice = $objRoomTypeServiceProductPrice->getProductPrice($product['id_product'], $idProduct, $product['quantity'], $useTax); $product['price'] = $productPrice; $serviceProductsPrice += $productPrice; @@ -1326,6 +1338,7 @@ class ProductControllerCore extends FrontController $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); $addedServiceProduct = Tools::getValue('added_service_product'); + $qty = Tools::getValue('qty'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1338,16 +1351,31 @@ class ProductControllerCore extends FrontController } else { if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { $response['success'] = true; - if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { - if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { + if (!$objServiceProduct->allow_multiple_quantity) { + if (!empty($addedServiceProduct)) { + if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } else { + $response['msg'] = 'Service already added.'; + } + } else { $response['add'] = true; $response['msg'] = 'Service is added to cart.'; - } else { - $response['msg'] = 'Service already added.'; } } else { - $response['add'] = true; - $response['msg'] = 'Service is added to cart.'; + $totalQty = $qty; + if (!empty($addedServiceProduct)) { + if (($key = array_search($idServiceProduct, array_column($addedServiceProduct, 'id_product')))!== false) { + $totalQty += $addedServiceProduct[$key]['quantity']; + } + } + if ($objServiceProduct->max_quantity && $objServiceProduct->max_quantity < $totalQty ) { + $response['msg'] = Tools::displayError(sprintf('Cannot add more than %d quantity.', $objServiceProduct->max_quantity)); + } else { + $response['add'] = true; + $response['msg'] = Tools::displayError('Service is added to cart.'); + } } } else { $response['error'] = Tools::displayError('Service not Found'); diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index 7f59c444e..23d5f7e26 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -469,7 +469,7 @@ $(document).ready(function() e.preventDefault(); qtyfield = $(this).closest('.qty_container').find('input.qty'); var newQuantity = parseInt(qtyfield.val()) + 1; - if (qtyfield.data('max_quantity') < newQuantity) { + if (qtyfield.data('max_quantity') && qtyfield.data('max_quantity') < newQuantity) { newQuantity = qtyfield.data('max_quantity'); } qtyfield.val(newQuantity).trigger('focusout'); @@ -491,7 +491,7 @@ $(document).ready(function() if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { $(this).val(1); } - if ($(this).data('max_quantity') < qty_wntd) { + if ($(this).data('max_quantity') && $(this).data('max_quantity') < qty_wntd) { $(this).val(qtyfield.data('max_quantity')); } if ($(this).closest('.room_demand_block').find('.change_room_type_service_product').is(':checked')) { diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 01ee8641b..d2b8bb6fc 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1109,7 +1109,7 @@ $(document).ready(function() { e.preventDefault(); qtyfield = $(this).closest('.qty_container').find('input.service_product_qty'); var newQuantity = parseInt(qtyfield.val()) + 1; - if (qtyfield.data('max_quantity') < newQuantity) { + if (qtyfield.data('max_quantity') && qtyfield.data('max_quantity') < newQuantity) { newQuantity = qtyfield.data('max_quantity'); } $(this).closest('.qty_container').find('.qty_count span').text(newQuantity); From acc053e0c8c7b581f1572bf155f0d716d7451283 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 9 Mar 2023 17:26:38 +0530 Subject: [PATCH 68/77] fix specific price selection base on priority --- classes/SpecificPrice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 139b392ab..e5cf02d71 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -359,7 +359,7 @@ class SpecificPriceCore extends ObjectModel AND IF(`from_quantity` > 1, `from_quantity`, 0) <= '; $query .= (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION') || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity); - $query .= ' ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC, `to` DESC, `from` DESC'; + $query .= ' ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `score` DESC, `to` DESC, `from` DESC'; SpecificPrice::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); } From 5709c82de302f2209e936e86703f75d5b798e52e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 10 Mar 2023 11:34:48 +0530 Subject: [PATCH 69/77] fixed same error displayed multiple time on opc page --- .../classes/HotelOrderRestrictDate.php | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php b/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php index e46d9ae5f..785bc515f 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php @@ -103,41 +103,6 @@ class HotelOrderRestrictDate extends ObjectModel )) { $cart_data = array(); foreach ($cart_bk_data as $data) { - $objCartBookingData = new HotelCartBookingData($data['id']); - if ($maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($objCartBookingData->id_hotel)) { - if (strtotime('-1 day', strtotime($maxOrderDate)) < strtotime($objCartBookingData->date_from) - || strtotime($maxOrderDate) < strtotime($objCartBookingData->date_to) - ) { - $objBranchInfo = new HotelBranchInformation( - $objCartBookingData->id_hotel, - $context->language->id - ); - $controller->errors[] = sprintf( - 'You can not book rooms for hotel \'%s\' after date %s. Please remove these rooms to proceed.', - $objBranchInfo->hotel_name, - Tools::displayDate($maxOrderDate) - ); - $error = true; - } - } - $preparationTime = HotelOrderRestrictDate::getPreparationTime($objCartBookingData->id_hotel); - if ($preparationTime !== false) { - $minOrderDate = date('Y-m-d', strtotime('+'. ($preparationTime) .' days')); - if (strtotime($minOrderDate) > strtotime($objCartBookingData->date_from) - || strtotime($minOrderDate . ' +1 day')> strtotime($objCartBookingData->date_to) - ) { - $objBranchInfo = new HotelBranchInformation( - $objCartBookingData->id_hotel, - $context->language->id - ); - $controller->errors[] = sprintf( - 'You can not book rooms for hotel \'%s\' before date %s. Please remove these rooms to proceed.', - $objBranchInfo->hotel_name, - Tools::displayDate($minOrderDate) - ); - $error = true; - } - } $date_join = strtotime($data['date_from']).strtotime($data['date_to']); $cart_data[$date_join]['date_from'] = $data['date_from']; $cart_data[$date_join]['date_to'] = $data['date_to']; @@ -145,6 +110,45 @@ class HotelOrderRestrictDate extends ObjectModel $cart_data[$date_join]['id_rms'][] = $data['id_room']; } foreach ($cart_data as $cl_key => $cl_val) { + if ($maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($cl_val['id_hotel'])) { + if (strtotime('-1 day', strtotime($maxOrderDate)) < strtotime($cl_val['date_from']) + || strtotime($maxOrderDate) < strtotime($cl_val['date_to']) + ) { + $objBranchInfo = new HotelBranchInformation( + $cl_val['id_hotel'], + $context->language->id + ); + $controller->errors[] = sprintf( + 'You can not book rooms for hotel \'%s\' after date %s. Please remove rooms from %s - %s to proceed.', + $objBranchInfo->hotel_name, + Tools::displayDate($maxOrderDate), + Tools::displayDate($cl_val['date_from']), + Tools::displayDate($cl_val['date_to']) + ); + $error = true; + } + } + $preparationTime = HotelOrderRestrictDate::getPreparationTime($cl_val['id_hotel']); + if ($preparationTime !== false) { + $minOrderDate = date('Y-m-d', strtotime('+'. ($preparationTime) .' days')); + if (strtotime($minOrderDate) > strtotime($cl_val['date_from']) + || strtotime($minOrderDate . ' +1 day')> strtotime($cl_val['date_to']) + ) { + $objBranchInfo = new HotelBranchInformation( + $cl_val['id_hotel'], + $context->language->id + ); + $controller->errors[] = sprintf( + 'You can not book rooms for hotel \'%s\' before date %s. Please remove rooms from %s - %s to proceed.', + $objBranchInfo->hotel_name, + Tools::displayDate($minOrderDate), + Tools::displayDate($cl_val['date_from']), + Tools::displayDate($cl_val['date_to']) + ); + $error = true; + } + } + $bookingParams = array( 'date_from' => $cl_val['date_from'], 'date_to' => $cl_val['date_to'], From 8185b31ef0fa0a51cf49fe4c04f79fbc822de123 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 10 Mar 2023 18:46:56 +0530 Subject: [PATCH 70/77] fix mulitple hotel cover image when uploading multiple images --- .../classes/HotelImage.php | 33 +++- .../admin/AdminAddHotelController.php | 30 ++-- .../views/js/hotelImage.js | 149 +++++++----------- .../_partials/htl-images-list-row.tpl | 39 +++++ .../add_hotel/_partials/htl-images-list.tpl | 47 ++++++ .../admin/add_hotel/helpers/form/form.tpl | 48 +----- 6 files changed, 195 insertions(+), 151 deletions(-) create mode 100644 modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl create mode 100644 modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list.tpl diff --git a/modules/hotelreservationsystem/classes/HotelImage.php b/modules/hotelreservationsystem/classes/HotelImage.php index 3c9efcb4b..e3e538706 100644 --- a/modules/hotelreservationsystem/classes/HotelImage.php +++ b/modules/hotelreservationsystem/classes/HotelImage.php @@ -44,7 +44,7 @@ class HotelImage extends ObjectModel $this->source_index = _PS_HOTEL_IMG_DIR_.'index.php'; - $this->image_dir = _PS_HOTEL_IMG_.$this->getImgFolder(); + $this->image_dir = _PS_HOTEL_IMG_DIR_.$this->getImgFolder(); } /** @@ -61,6 +61,33 @@ class HotelImage extends ObjectModel return true; } + /** + * Delete the hotel image from disk and remove the containing folder if empty + * Handles both legacy and new image filesystems + */ + public function deleteImage($force_delete = false) + { + parent::deleteImage(); + // Can we delete the image folder? + if (is_dir($this->image_dir)) { + $delete_folder = true; + foreach (scandir($this->image_dir) as $file) { + if (($file != '.' && $file != '..' && $file != 'index.php')) { + $delete_folder = false; + break; + } + } + } + + if (isset($delete_folder) && $delete_folder) { + // delete index image before deleting folder + unlink($this->image_dir.'index.php'); + @rmdir($this->image_dir); + } + + return true; + } + /** * [getImagesByHotelId :: To get paginated hotel images data] * @param [int] $id_hotel [id_hotel to get images of] @@ -232,9 +259,9 @@ class HotelImage extends ObjectModel } } $addedImage = array( - 'id_image' => $objHtlImage->id, + 'id' => $objHtlImage->id, 'cover' => $objHtlImage->cover, - 'image_url' => Context::getContext()->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id)), + 'image_link' => Context::getContext()->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id)), ); return $addedImage; } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 57e616fce..8dafbd11f 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -576,6 +576,7 @@ class AdminAddHotelController extends ModuleAdminController public function ajaxProcessUploadHotelImages() { + $response = array('success' => false); $idHotel = Tools::getValue('id_hotel'); if ($idHotel) { $invalidImg = ImageManager::validateUpload( @@ -584,27 +585,32 @@ class AdminAddHotelController extends ModuleAdminController ); if (!$invalidImg) { // Add Hotel images - $kwargs = [ - 'id_hotel' => $idHotel, - 'hotel_image' => $_FILES['hotel_image'], - ]; $objHotelImage = new HotelImage(); $imageDetail = $objHotelImage->uploadHotelImages($_FILES['hotel_image'], $idHotel); if ($imageDetail) { - die(json_encode($imageDetail)); + $response['success'] = true; + $imageDetail['image_link'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'],ImageType::getFormatedName('large'))); + $imageDetail['image_link_small'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'], ImageType::getFormatedName('small'))); + $response['data']['image_info'] = $imageDetail; + // get image row + $this->context->smarty->assign(array( + 'image' => $imageDetail, + 'hotel_info' => array('id' => $idHotel) + )); + $response['data']['image_row'] = $this->context->smarty->fetch( + _PS_MODULE_DIR_.$this->module->name. + '/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl' + ); } else { - die(json_encode(array('hasError' => true))); + $response['errors'][] = $this->l('Unable to uploade image. Please try again'); } } else { - die( - json_encode( - array('hasError' => true, 'message' => $_FILES['hotel_image']['name'].': '.$invalidImg) - ) - ); + $response['errors'][] = $_FILES['hotel_image']['name'].': '.$invalidImg; } } else { - die(json_encode(array('hasError' => true))); + $response['errors'][] = $this->l('Hotel info not found. Please try reloading the page'); } + $this->ajaxDie(json_encode($response)); } public function ajaxProcessChangeCoverImage() diff --git a/modules/hotelreservationsystem/views/js/hotelImage.js b/modules/hotelreservationsystem/views/js/hotelImage.js index 81e2ba5f7..f893b9748 100644 --- a/modules/hotelreservationsystem/views/js/hotelImage.js +++ b/modules/hotelreservationsystem/views/js/hotelImage.js @@ -27,104 +27,75 @@ $(document).ready(function () { }); $("#hotel_images").on("change", function(event) { - files = event.target.files; - for (var i = 0; i < files.length; i++) { - var formData = new FormData(); - var file = files[i]; - - if (typeof file != 'undefined') { - if (file.size > maxSizeAllowed) { - showErrorMessage(filesizeError + '[' + file.name + ']'); - } else { - formData.append('hotel_image', file); - uploadHotelImages(formData); - } - } - } - $('#hotel_images').val(null); + const files = Array.from(event.target.files); + uploadSelectedImages(files); }); - function uploadHotelImages(formData) { - var idHotel = $("#id-hotel").val(); - formData.append('id_hotel', idHotel); - formData.append('ajax', true); - formData.append('action', 'uploadHotelImages'); + function uploadSelectedImages(files) + { + if (files.length == 0) return; // all done + let file = files[0]; + files.splice(0, 1); + createImageUploadRequest(file).then((formData) => { + uploadHotelImages(formData).then(() => { + uploadSelectedImages(files) + }); + }) + } - $.ajax({ - type:'POST', - url: adminHotelCtrlUrl, - data: formData, - cache:false, - contentType: false, - processData: false, - success:function(image){ - image = JSON.parse(image); - if (!image.hasError) { - $('.list-empty-tr').remove(); - var html = ''; - html += ''; - html += ''+image.id_image+''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - if(image.cover) { - html += ''; - } else { - html += ''; - } - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - $("#hotel-image-table tbody").append(html); - - showSuccessMessage(imgUploadSuccessMsg); + function createImageUploadRequest(file) + { + return new Promise((resolve, reject) => { + if (typeof file != 'undefined') { + if (file.size > maxSizeAllowed) { + reject(filesizeError + '[' + file.name + ']'); } else { - if (typeof image.message != 'undefined') { - showErrorMessage(image.message); - } else { - showErrorMessage(imgUploadErrorMsg); - } + var formData = new FormData(); + var idHotel = $("#id-hotel").val(); + formData.append('hotel_image', file); + formData.append('id_hotel', idHotel); + formData.append('ajax', true); + formData.append('action', 'uploadHotelImages'); + resolve(formData); } - }, - error: function(data) { - showErrorMessage(imgUploadErrorMsg); } }); } + function uploadHotelImages(formData) { + return new Promise((resolve, reject) => { + $.ajax({ + type:'POST', + dataType:'JSON', + url: adminHotelCtrlUrl, + data: formData, + cache:false, + contentType: false, + processData: false, + success:function(response){ + if (response.success) { + $('.list-empty-tr').remove(); + $("#hotel-image-table tbody").append(response.data.image_row); + showSuccessMessage(imgUploadSuccessMsg); + resolve(imgUploadSuccessMsg); + } else { + if (typeof response.errors != 'undefined') { + showErrorMessage(response.errors); + reject(response.errors); + } else { + showErrorMessage(imgUploadErrorMsg); + reject(imgUploadErrorMsg); + } + } + }, + error: function(data) { + showErrorMessage(imgUploadErrorMsg); + reject(imgUploadErrorMsg); + } + }); + }); + } + $('body').on('click', '.changer-cover-image', function(e){ e.preventDefault(); var idHotel = $(this).attr('data-id-hotel'); diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl new file mode 100644 index 000000000..b8b238731 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl @@ -0,0 +1,39 @@ +{** +* 2010-2022 Webkul. +* +* NOTICE OF LICENSE +* +* All right is reserved, +* Please go through LICENSE.txt file inside our module +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to newer +* versions in the future. If you wish to customize this module for your +* needs please refer to CustomizationPolicy.txt file inside our module for more information. +* +* @author Webkul IN +* @copyright 2010-2022 Webkul IN +* @license LICENSE.txt +*} + + + {$image.id|escape:'html':'UTF-8'} + + + + + + + + {if $image.cover == 1} + + {else} + + {/if} + + + + + + \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list.tpl new file mode 100644 index 000000000..2f132ba9f --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/_partials/htl-images-list.tpl @@ -0,0 +1,47 @@ +{** +* 2010-2022 Webkul. +* +* NOTICE OF LICENSE +* +* All right is reserved, +* Please go through LICENSE.txt file inside our module +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to newer +* versions in the future. If you wish to customize this module for your +* needs please refer to CustomizationPolicy.txt file inside our module for more information. +* +* @author Webkul IN +* @copyright 2010-2022 Webkul IN +* @license LICENSE.txt +*} + +
    + + + + + + + + + + + {if isset($hotelImages) && $hotelImages} + {foreach from=$hotelImages item=image name=hotelImage} + {include file="./htl-images-list-row.tpl"} + {/foreach} + {else} + + + + {/if} + +
    {l s='Image Id' mod='hotelreservationsystem'}{l s='Image' mod='hotelreservationsystem'}{l s='Cover' mod='hotelreservationsystem'}{l s='Action' mod='hotelreservationsystem'}
    +
    + + {l s='No Image Found' mod='hotelreservationsystem'} +
    +
    +
    \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl index 37e41b5f2..57e6d3c6e 100644 --- a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl @@ -304,53 +304,7 @@

    {l s='Hotel Images' mod='hotelreservationsystem'}

    -
    - - - - - - - - - - - {if isset($hotelImages) && $hotelImages} - {foreach from=$hotelImages item=image name=hotelImage} - - - - - - - {/foreach} - {else} - - - - {/if} - -
    {l s='Image Id' mod='hotelreservationsystem'}{l s='Image' mod='hotelreservationsystem'}{l s='Cover' mod='hotelreservationsystem'}{l s='Action' mod='hotelreservationsystem'}
    {$image.id|escape:'html':'UTF-8'} - - - - - - {if $image.cover == 1} - - {else} - - {/if} - - - -
    -
    - - {l s='No Image Found' mod='hotelreservationsystem'} -
    -
    -
    + {include file="../../_partials/htl-images-list.tpl"}
    {else} From 17448c11b4f6a19cad94ca8d685bfdeee2ad8773 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Fri, 10 Mar 2023 18:58:45 +0530 Subject: [PATCH 71/77] resolved unable to create refund request --- controllers/front/OrderDetailController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index ad57e8ae5..e15f445ce 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -231,7 +231,7 @@ class OrderDetailControllerCore extends FrontController } else { foreach ($bookingRefunds as $idHtlBooking) { $objHotelBookingDetail = new HotelBookingDetail($idHtlBooking); - if ($objHotelBookingDetail->id_customer == $order->id_customer + if ($objHotelBookingDetail->id_customer != $order->id_customer || OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking) ) { $hasError = 1; From 99a0a06a1b9ff4575a9c6e2a8fa697bd1aa389fd Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 13 Mar 2023 13:19:37 +0530 Subject: [PATCH 72/77] add access restriction in admin search page --- .../controllers/search/helpers/view/view.tpl | 18 +++---- controllers/admin/AdminSearchController.php | 49 +++++++++++++------ 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/admin/themes/default/template/controllers/search/helpers/view/view.tpl b/admin/themes/default/template/controllers/search/helpers/view/view.tpl index ce4853502..f7577de04 100644 --- a/admin/themes/default/template/controllers/search/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/search/helpers/view/view.tpl @@ -108,39 +108,39 @@ $(function() {
    {/if} - {if isset($products) && $products} + {if isset($num_products) && $num_products}

    - {if $products|@count == 1} + {if $num_products == 1} {l s='1 product'} {else} - {l s='%d products' sprintf=$products|@count} + {l s='%d products' sprintf=$num_products} {/if}

    {$products}
    {/if} - {if isset($customers) && $customers} + {if isset($num_customers) && $num_customers}

    - {if $customers|@count == 1} + {if $num_customers == 1} {l s='1 customer'} {else} - {l s='%d customers' sprintf=$customers|@count} + {l s='%d customers' sprintf=$num_customers} {/if}

    {$customers}
    {/if} - {if isset($orders) && $orders} + {if isset($num_orders) && $num_orders}

    - {if $orders|@count == 1} + {if $num_orders == 1} {l s='1 order'} {else} - {l s='%d orders' sprintf=$orders|@count} + {l s='%d orders' sprintf=$num_orders} {/if}

    {$orders} diff --git a/controllers/admin/AdminSearchController.php b/controllers/admin/AdminSearchController.php index b8dc233dc..2b9e2b5eb 100644 --- a/controllers/admin/AdminSearchController.php +++ b/controllers/admin/AdminSearchController.php @@ -82,12 +82,16 @@ class AdminSearchControllerCore extends AdminController Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)$order->id.'&vieworder'.'&token='.Tools::getAdminTokenLite('AdminOrders')); } else { $row = get_object_vars($order); - $row['id_order'] = $row['id']; - $customer = $order->getCustomer(); - $row['customer'] = $customer->firstname.' '.$customer->lastname; - $order_state = $order->getCurrentOrderState(); - $row['osname'] = $order_state->name[$this->context->language->id]; - $this->_list['orders'] = array($row); + $idHotel = HotelBookingDetail::getIdHotelByIdOrder($row['id']); + if (in_array($idHotel, HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1))) { + $row['id_order'] = $row['id']; + $customer = $order->getCustomer(); + $row['customer'] = $customer->firstname.' '.$customer->lastname; + $order_state = $order->getCurrentOrderState(); + $row['osname'] = $order_state->name[$this->context->language->id]; + $this->_list['orders'] = array($row); + } + } } else { $orders = Order::getByReference($this->query); @@ -99,12 +103,15 @@ class AdminSearchControllerCore extends AdminController foreach ($orders as $order) { /** @var Order $order */ $row = get_object_vars($order); - $row['id_order'] = $row['id']; - $customer = $order->getCustomer(); - $row['customer'] = $customer->firstname.' '.$customer->lastname; - $order_state = $order->getCurrentOrderState(); - $row['osname'] = $order_state->name[$this->context->language->id]; - $this->_list['orders'][] = $row; + $idHotel = HotelBookingDetail::getIdHotelByIdOrder($row['id']); + if (in_array($idHotel, HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1))) { + $row['id_order'] = $row['id']; + $customer = $order->getCustomer(); + $row['customer'] = $customer->firstname.' '.$customer->lastname; + $order_state = $order->getCurrentOrderState(); + $row['osname'] = $order_state->name[$this->context->language->id]; + $this->_list['orders'][] = $row; + } } } elseif ($searchType == 3) { $this->errors[] = Tools::displayError('No order was found with this ID:').' '.Tools::htmlentitiesUTF8($this->query); @@ -162,7 +169,15 @@ class AdminSearchControllerCore extends AdminController public function searchCatalog() { $this->context = Context::getContext(); - $this->_list['products'] = Product::searchByName($this->context->language->id, $this->query); + if ($this->_list['products'] = Product::searchByName($this->context->language->id, $this->query)) { + $objRoomType = new HotelRoomType(); + foreach ($this->_list['products'] as $key => $product) { + $roomInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']); + if (!in_array($roomInfo['id_hotel'], HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1))) { + unset($this->_list['products'][$key]); + } + } + } $this->_list['categories'] = Category::searchByName($this->context->language->id, $this->query); } @@ -299,9 +314,8 @@ class AdminSearchControllerCore extends AdminController $this->show_toolbar = false; $this->fields_list['products'] = array( 'id_product' => array('title' => $this->l('ID'), 'width' => 25), - 'manufacturer_name' => array('title' => $this->l('Manufacturer'), 'align' => 'center', 'width' => 200), - 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150), 'name' => array('title' => $this->l('Name'), 'width' => 'auto'), + 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150), 'price_tax_excl' => array('title' => $this->l('Price (tax excl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60), 'price_tax_incl' => array('title' => $this->l('Price (tax incl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60), 'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool') @@ -350,7 +364,7 @@ class AdminSearchControllerCore extends AdminController } $this->tpl_view_vars['categories'] = $categories; } - if (isset($this->_list['products']) && count($this->_list['products'])) { + if (isset($this->_list['products']) && $this->_list['products']&& count($this->_list['products'])) { $view = ''; $this->initProductList(); @@ -376,6 +390,7 @@ class AdminSearchControllerCore extends AdminController $view = $helper->generateList($this->_list['products'], $this->fields_list['products']); } + $this->tpl_view_vars['num_products'] = count($this->_list['products']); $this->tpl_view_vars['products'] = $view; } if (isset($this->_list['customers']) && count($this->_list['customers'])) { @@ -398,6 +413,7 @@ class AdminSearchControllerCore extends AdminController } $view = $helper->generateList($this->_list['customers'], $this->fields_list['customers']); } + $this->tpl_view_vars['num_customers'] = count($this->_list['customers']); $this->tpl_view_vars['customers'] = $view; } if (isset($this->_list['orders']) && count($this->_list['orders'])) { @@ -417,6 +433,7 @@ class AdminSearchControllerCore extends AdminController if ($this->_list['orders']) { $view = $helper->generateList($this->_list['orders'], $this->fields_list['orders']); } + $this->tpl_view_vars['num_orders'] = count($this->_list['orders']); $this->tpl_view_vars['orders'] = $view; } From 815b8aaf6906c7c259e5d4f375979d42dba30059 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 13 Mar 2023 13:35:06 +0530 Subject: [PATCH 73/77] fic dropdown displacement issue --- themes/hotel-reservation-theme/css/category.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/themes/hotel-reservation-theme/css/category.css b/themes/hotel-reservation-theme/css/category.css index 370a352e6..b7bb6d40b 100644 --- a/themes/hotel-reservation-theme/css/category.css +++ b/themes/hotel-reservation-theme/css/category.css @@ -254,6 +254,9 @@ p.capa_txt { .booking_guest_occupancy_conatiner { display: flex; } +.booking_guest_occupancy_conatiner .booking_occupancy_wrapper { + left: unset; +} @media (min-width: 992px) { .room_features_cont > div { display: flex; From e31f0e5bb0d838088f4de6c6146b290501040453 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 13 Mar 2023 14:36:26 +0530 Subject: [PATCH 74/77] added inital date for full calender --- .../controllers/admin/AdminHotelRoomsBookingController.php | 4 ++++ .../views/js/admin/hotel_rooms_booking.js | 1 + 2 files changed, 5 insertions(+) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 340c92cca..1fb10f737 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -260,6 +260,10 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'booking_product' => $this->booking_product, 'is_occupancy_wise_search' => $isOccupancyWiseSearch, )); + MediaCore::addJsDef(array( + 'initialDate' => $this->date_from + )); + } public function renderView() diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index 5650f469d..7ad138bf2 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -23,6 +23,7 @@ $(document).ready(function() { if ($('#fullcalendar').length) { var calendar = new FullCalendar.Calendar($('#fullcalendar').get(0), { initialView: 'dayGridMonth', + initialDate: initialDate, events: { url: rooms_booking_url, method: 'POST', From 8742b94fe0abbb95d78d1d48b73dbeea650a553d Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 13 Mar 2023 15:24:37 +0530 Subject: [PATCH 75/77] fixes customer address not visible and unable to save address --- controllers/front/AddressController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index 080d96f83..e5dd8801c 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -50,6 +50,19 @@ class AddressControllerCore extends FrontController )); } + /** + * Initialize address controller + * @see FrontController::init() + */ + public function init() + { + parent::init(); + + if ($this->context->customer->id) { + $this->_address = new Address(Customer::getCustomerIdAddress($this->context->customer->id)); + } + } + /** * Start forms process * @see FrontController::postProcess() From 0e1beed76e109d14365dc118db3e0af4eafd5c46 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 14 Mar 2023 13:14:24 +0530 Subject: [PATCH 76/77] fix inconsistent price in list and view admin order --- .../template/controllers/orders/_room_facilities_block.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index abc426f8d..fbe41ba0a 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -35,7 +35,7 @@ {foreach $roomDemand['extra_demands'] as $demand} {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} + {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency} {/foreach} @@ -96,7 +96,7 @@

    {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} + {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency}

    {/foreach} From 98e6bcf54af13f77c1d35ddd7fd0149679fc4c7f Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 14 Mar 2023 18:44:03 +0530 Subject: [PATCH 77/77] enable custom handler in admin controller --- classes/controller/Controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index 0484f6544..a21ca409c 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -93,9 +93,9 @@ abstract class ControllerCore */ public function init() { - // if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { - // set_error_handler(array(__CLASS__, 'myErrorHandler')); - // } + if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { + set_error_handler(array(__CLASS__, 'myErrorHandler')); + } if (!defined('_PS_BASE_URL_')) { define('_PS_BASE_URL_', Tools::getShopDomain(true));