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 41f4ee2fe..09decd44b 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -109,7 +109,7 @@ {displayWtPriceWithCurrency price=$room['feature_price_tax_excl'] currency=$currency} - {if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])} + {if (isset($room['selected_demands']) && $room['selected_demands']) || (isset($room['selected_services']) && $room['selected_services'])} {displayWtPriceWithCurrency price=($room['demand_price'] + $room['additional_service_price'] + $room['additional_services_auto_add_price'])|escape:'html':'UTF-8' currency=$currency} @@ -118,7 +118,7 @@ {/if} - {if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])} + {if (isset($room['selected_demands']) && $room['selected_demands']) || (isset($room['selected_services']) && $room['selected_services'])} {displayWtPriceWithCurrency price=($room['amt_with_qty'] + $room['additional_services_auto_add_price'] + $room['demand_price'] + $room['additional_service_price'])|escape:'html':'UTF-8' currency=$currency} {else} {displayWtPriceWithCurrency price=$room['amt_with_qty']|escape:'html':'UTF-8' currency=$currency} @@ -166,7 +166,13 @@
-

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

+

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

{/if} diff --git a/classes/Cart.php b/classes/Cart.php index e826b3f97..fc3fc8c7e 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -733,11 +733,18 @@ class CartCore extends ObjectModel $totalPriceByProductTaxExcl = 0; $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id); foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $cartRoomInfo['id_product'], $cartRoomInfo['date_from'], $cartRoomInfo['date_to'], - 0, + $occupancy, Group::getCurrent()->id, $cartRoomInfo['id_cart'], $cartRoomInfo['id_guest'], @@ -1780,12 +1787,19 @@ class CartCore extends ObjectModel $totalPriceByProduct = 0; $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id); foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); // get the real price of the room type $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $cartRoomInfo['id_product'], $cartRoomInfo['date_from'], $cartRoomInfo['date_to'], - 0, + $occupancy, Group::getCurrent()->id, $cartRoomInfo['id_cart'], $cartRoomInfo['id_guest'], diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 7a32be778..e15ac46d1 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -808,11 +808,18 @@ abstract class PaymentModuleCore extends Module $objBookingDetail->is_back_order = $objCartBookingData->is_back_order; $objBookingDetail->comment = $objCartBookingData->comment; + $occupancy = array( + array( + 'adults' => $objCartBookingData->adults, + 'children' => $objCartBookingData->children, + 'child_ages' => json_decode($objCartBookingData->child_ages) + ) + ); $total_price = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $objCartBookingData->date_from, $objCartBookingData->date_to, - 0, + $occupancy, Group::getCurrent()->id, $objCartBookingData->id_cart, $objCartBookingData->id_guest, @@ -1700,6 +1707,7 @@ abstract class PaymentModuleCore extends Module } else { $cart_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); } + if ($cart_bk_data) { $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id']); @@ -1720,11 +1728,20 @@ abstract class PaymentModuleCore extends Module $cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; $cart_htl_data[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; + $occupancy = array( + array( + 'adults' => $data_v['adults'], + 'children' => $data_v['children'], + 'child_ages' => json_decode($data_v['child_ages']) + ) + ); - - - $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($type_value['id_product'], $data_v['date_from'], $data_v['date_to']); - + $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( + $type_value['id_product'], + $data_v['date_from'], + $data_v['date_to'], + $occupancy + ); $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $roomTypeDateRangePrice['total_price_tax_incl']*$vart_quant; $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; @@ -1745,9 +1762,7 @@ abstract class PaymentModuleCore extends Module $cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults']; $cart_htl_data[$type_key]['date_diff'][$date_join]['children'] = $data_v['children']; - - - // extra demands prices + // extra demands prices $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( $order->id, $type_value['product_id'], @@ -1831,6 +1846,7 @@ abstract class PaymentModuleCore extends Module } $result['cart_htl_data'] = $cart_htl_data; } + return $result; } } diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index e9628c6a8..8908d6159 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -649,8 +649,8 @@ abstract class ControllerCore $method = $bt[1]['function']; } - Hook::exec('actionBeforeAjaxDie', array('controller' => $controller, 'method' => $method, 'value' => $value)); - Hook::exec('actionBeforeAjaxDie'.$controller.$method, array('value' => $value)); + Hook::exec('actionBeforeAjaxDie', array('controller' => $controller, 'method' => $method, 'value' => &$value)); + Hook::exec('actionBeforeAjaxDie'.$controller.$method, array('value' => &$value)); die($value); } diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index e2a82cbf0..2066ae493 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -314,10 +314,17 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $service_product_data = array(); $room_extra_demands = array(); $room_additinal_services = array(); + $formattedHotelAddress = ''; if (Module::isInstalled('hotelreservationsystem')) { $obj_htl_bk_dtl = new HotelBookingDetail(); - $obj_rm_type = new HotelRoomType(); $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); + $objHotelBranchInfo = new HotelBranchInformation((int) HotelBookingDetail::getIdHotelByIdOrder($order_obj->id), $this->context->language->id); + $invoiceAddressPatternRules['avoid'][] = 'lastname'; + if ($idHotelAddress = $objHotelBranchInfo->getHotelIdAddress()) { + $objHotelAddress = new Address((int) $idHotelAddress); + $objHotelAddress->firstname = $objHotelBranchInfo->hotel_name; + $formattedHotelAddress = AddressFormat::generateAddress($objHotelAddress, $invoiceAddressPatternRules, '
', ' '); + } $customer = new Customer($this->order->id_customer); if (!empty($order_details)) { @@ -591,6 +598,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate 'cart_rules' => $cart_rules, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, + 'hotel_address' => $formattedHotelAddress, 'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address), 'tax_excluded_display' => $tax_excluded_display, 'display_product_images' => $display_product_images, diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index afc8f587b..f130c202e 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -380,6 +380,21 @@ class AdminAddressesControllerCore extends AdminController return parent::renderForm(); } + public function processExport($text_delimiter = '"') + { + $this->fields_list = array_merge($this->fields_list, array( + 'email' => array('title' => $this->l('Customer Email')), + 'phone' => array('title' => $this->l('Phone')), + 'phone_mobile' => array('title' => $this->l('Mobile phone')), + 'address1' => array('title' => $this->l('Address (2)')), + 'dni' => array('title' => $this->l('Identification Number')), + 'vat_number' => array('title' => $this->l('VAT number')), + 'other' => array('title' => $this->l('Other')), + )); + + return parent::processExport($text_delimiter); + } + // public function postProcess() // { diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 8f26b9294..4c7ac661a 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -302,6 +302,31 @@ class AdminCartsControllerCore extends AdminController $product['image'] = (isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$image_product->getExistingImgPath().'.jpg', 'product_mini_'.(int)$product['id_product'].(isset($product['id_product_attribute']) ? '_'.(int)$product['id_product_attribute'] : '').'.jpg', 45, 'jpg') : '--'); } + // by webkul to show rooms available in the cart + $cartHtlData = array(); + $objHotelCartBookingData = new HotelCartBookingData(); + $objHotelRoomType = new HotelRoomType(); + if ($cartHtlData = $objHotelCartBookingData->getCartFormatedBookinInfoByIdCart((int) $cart->id)) { + foreach ($cartHtlData as $key => $value) { + $cartHtlData[$key]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value['id_product']); + if (isset($value['selected_services']) && $value['selected_services']) { + foreach ($value['selected_services'] as $service) { + if ($service['id_cart'] != $value['id_cart']) { + if ($tax_calculation_method == PS_TAX_EXC) { + $total_price += ($service['quantity'] * $service['total_price_tax_excl']); + $total_products += ($service['quantity'] * $service['total_price_tax_excl']); + } else { + $total_price += ($service['quantity'] * $service['total_price_tax_incl']); + $total_products += ($service['quantity'] * $service['total_price_tax_incl']); + } + } + } + } + } + } else { + $cartHtlData = array(); + } + $helper = new HelperKpi(); $helper->id = 'box-kpi-cart'; $helper->icon = 'icon-shopping-cart'; @@ -310,17 +335,6 @@ class AdminCartsControllerCore extends AdminController $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id); $helper->value = Tools::displayPrice($total_price, $currency); $kpi = $helper->generate(); - // by webkul to show rooms available in the cart - $cartHtlData = array(); - $objHotelCartBookingData = new HotelCartBookingData(); - $objHotelRoomType = new HotelRoomType(); - if ($cartHtlData = $objHotelCartBookingData->getCartFormatedBookinInfoByIdCart((int) $cart->id)) { - foreach ($cartHtlData as $key => $value) { - $cartHtlData[$key]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value['id_product']); - } - } else { - $cartHtlData = array(); - } //end $this->tpl_view_vars = array( 'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 997cb0508..f81342a8f 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -97,13 +97,16 @@ class AdminCustomersControllerCore extends AdminController 'order_key' => 'gl!name' ), 'firstname' => array( - 'title' => $this->l('First name') + 'title' => $this->l('First name'), + 'filter_key' => 'a!firstname' ), 'lastname' => array( - 'title' => $this->l('Last name') + 'title' => $this->l('Last name'), + 'filter_key' => 'a!lastname' ), 'email' => array( - 'title' => $this->l('Email address') + 'title' => $this->l('Email address'), + 'filter_key' => 'a!email' ), ); @@ -143,6 +146,7 @@ class AdminCustomersControllerCore extends AdminController ), 'phone' => array( 'title' => $this->l('Phone'), + 'filter_key' => 'a!phone', 'optional' => true, 'visible_default' => false, ), @@ -152,7 +156,8 @@ class AdminCustomersControllerCore extends AdminController 'active' => 'status', 'type' => 'bool', 'orderby' => false, - 'filter_key' => 'a!active' + 'filter_key' => 'a!active', + 'callback' => 'formatStatusAsLabel', ), 'newsletter' => array( 'title' => $this->l('Newsletter'), @@ -184,6 +189,7 @@ class AdminCustomersControllerCore extends AdminController 'title' => $this->l('Banned'), 'type' => 'bool', 'displayed' => false, + 'callback' => 'getCustomerStatusLabel', ), 'order_date' => array( 'title' => $this->l('Order date'), @@ -235,6 +241,28 @@ class AdminCustomersControllerCore extends AdminController } } + public function formatStatusAsLabel($val, $row) + { + if ($val) { + $str_return = $this->l('Yes'); + } else { + $str_return = $this->l('No'); + } + + return $str_return; + } + + public function getCustomerStatusLabel($deleted, $tr) + { + if ($deleted == Customer::STATUS_DELETED) { + return $this->l('Deleted'); + } else if ($deleted == Customer::STATUS_BANNED) { + return $this->l('Banned'); + } + + return; + } + public function initContent() { if ($this->action == 'select_delete') { @@ -268,8 +296,11 @@ class AdminCustomersControllerCore extends AdminController public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = null) { - parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $id_lang_shop); + if ($this->action == 'export') { + $this->deleted = false; + } + parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $id_lang_shop); if ($this->_list) { foreach ($this->_list as &$row) { $row['badge_success'] = $row['total_spent'] > 0; @@ -1040,6 +1071,14 @@ class AdminCustomersControllerCore extends AdminController } } + public function processExport($text_delimiter = '"') + { + $this->fields_list['newsletter']['callback'] = 'formatStatusAsLabel'; + $this->fields_list['optin']['callback'] = 'formatStatusAsLabel'; + + return parent::processExport($text_delimiter); + } + protected function processBulkDelete() { // If customer is going to be deleted permanently then if customer has orders the change this customer as an anonymous customer diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 66dc1c963..08956e267 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -257,12 +257,14 @@ class AdminNormalProductsControllerCore extends AdminController 'title' => $this->l('Available for order'), 'filter_key' => 'a!available_for_order', 'type' => 'bool', + 'callback' => 'formatStatusAsLabel', ); $this->fields_list['price_addition_type'] = array( 'displayed' => false, 'title' => $this->l('Price display preference'), 'filter_key' => 'a!price_addition_type', 'type' => 'select', + 'callback' => 'getPriceDisplayPreference', 'list' => $priceAdditionType, ); $this->fields_list['price_calculation_method_txt'] = array( @@ -311,7 +313,8 @@ class AdminNormalProductsControllerCore extends AdminController 'title' => $this->l('Base price'), 'type' => 'price', 'align' => 'text-left', - 'filter_key' => 'a!price' + 'filter_key' => 'a!price', + 'callback' => 'displayPrice', ); $this->fields_list['price_final'] = array( 'title' => $this->l('Final price'), @@ -319,7 +322,8 @@ class AdminNormalProductsControllerCore extends AdminController 'align' => 'text-left', 'havingFilter' => true, 'orderby' => false, - 'search' => false + 'search' => false, + 'callback' => 'displayPrice', ); $this->fields_list['active'] = array( @@ -329,6 +333,7 @@ class AdminNormalProductsControllerCore extends AdminController 'align' => 'text-center', 'type' => 'bool', 'class' => 'fixed-width-sm', + 'callback' => 'formatStatusAsLabel', 'orderby' => false ); @@ -342,6 +347,34 @@ class AdminNormalProductsControllerCore extends AdminController } } + public function formatStatusAsLabel($val, $row) + { + if ($val) { + $str_return = $this->l('Yes'); + } else { + $str_return = $this->l('No'); + } + + return $str_return; + } + + public function getPriceDisplayPreference($val, $row) + { + $str_return = $val; + if ($val == Product::PRICE_ADDITION_TYPE_WITH_ROOM) { + $str_return = $this->l('Add price in room price'); + } else if ($val == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { + $str_return = $this->l('Convenience Fee'); + } + + return $str_return; + } + + public static function displayPrice($basePrice, $tr) + { + return Tools::displayPrice($basePrice, (int) Configuration::get('PS_CURRENCY_DEFAULT')); + } + private function buildCategoryOptions($category) { $space = str_repeat(' ', 5 * (($category['level_depth'] - $this->objLocationsCategory->level_depth) - 1)); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index bb32323e3..a8e5ea8b6 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -79,8 +79,7 @@ class AdminOrdersControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int) $this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id_order` = a.`id_order`) - LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = hbd.`id_hotel`)'; - + LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = hbd.`id_hotel` AND osl.`id_lang` = hbil.`id_lang`)'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; @@ -1194,6 +1193,127 @@ class AdminOrdersControllerCore extends AdminController return parent::renderList(); } + public function getList( + $id_lang, + $order_by = null, + $order_way = null, + $start = 0, + $limit = null, + $id_lang_shop = false + ){ + if ($this->action == 'export' && empty($this->_listsql)) { + $this->_select .= ', c.`email`, cgd.`phone`, a.`total_paid_real`, + orf.`cancellation_date`, orf.`cancellation_fee`, + cy.`iso_code` AS country, st.`iso_code` as state, ad.`city`, + CONCAT(ad.`address1`, \', \', ad.`postcode`) AS `cus_address`, hbdtl.*'; + + $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'cart_customer_guest_detail` cgd ON cgd.`email` = c.`email` AND cgd.`id_cart` = 0 + LEFT JOIN `'._DB_PREFIX_.'address` ad ON a.`id_customer`= ad.`id_customer` AND ad.`id_customer`!=0 + LEFT JOIN `'._DB_PREFIX_.'country` cy ON cy.`id_country`= ad.`id_country` + LEFT JOIN `'._DB_PREFIX_.'state` st ON st.`id_state`= ad.`id_state` + LEFT JOIN ( + SELECT ref.`id_order`, IF(refst.refunded = 1, GROUP_CONCAT(ref.`date_upd`), NULL) AS `cancellation_date`, + IF(refst.refunded = 1, SUM(ref.`refunded_amount`), NULL) AS `cancellation_fee` + FROM `'._DB_PREFIX_.'order_return` ref + LEFT JOIN `'._DB_PREFIX_.'order_return_state` refst + ON refst.`id_order_return_state` = ref.`state` AND refst.`refunded` = 1 + GROUP BY ref.`id_order` + ) AS orf ON orf.`id_order` = a.`id_order` + LEFT JOIN ( + SELECT GROUP_CONCAT( + CASE + WHEN `id_status`='.HotelBookingDetail::STATUS_ALLOTED.' THEN \''.$this->l('Alloted').'\' + WHEN `id_status`='.HotelBookingDetail::STATUS_CHECKED_IN.' THEN \''.$this->l('Checked in').'\' + WHEN `id_status`='.HotelBookingDetail::STATUS_CHECKED_OUT.' THEN \''.$this->l('Checked out').'\' + ELSE \''.$this->l('Invalid status').'\' + END + ) AS `room_status`, `id_order`, + GROUP_CONCAT(DISTINCT(`room_type_name`)) AS `room_types`, + GROUP_CONCAT(`date_from`) AS `date_from`, + GROUP_CONCAT(`date_to`) AS `date_to`, + GROUP_CONCAT(`room_num`) AS `rooms`, + GROUP_CONCAT(`check_in`) AS `check_in_dates`, + GROUP_CONCAT(`check_out`) AS `check_out_dates` + FROM `'._DB_PREFIX_.'htl_booking_detail` + GROUP BY `id_order` + ) AS hbdtl ON hbdtl.`id_order` = a.`id_order`'; + + $this->fields_list = array_merge($this->fields_list, array( + 'email' => array( + 'title' => $this->l('Email') + ), + 'phone' => array( + 'title' => $this->l('Phone') + ), + 'room_types' => array( + 'title' => $this->l('Room Types') + ), + 'rooms' => array( + 'title' => $this->l('Rooms') + ), + 'currency' => array( + 'title' => $this->l('Currency') + ), + 'total_paid_real' => array( + 'title' => $this->l('Amount Paid') + ), + 'check_in_dates' => array( + 'title' => $this->l('Check In') + ), + 'check_out_dates' => array( + 'title' => $this->l('Check Out') + ), + 'date_from' => array( + 'title' => $this->l('Date From'), + 'filter_key' => 'hbd!date_from', + ), + 'date_to' => array( + 'title' => $this->l('Date To'), + 'filter_key' => 'hbd!date_to', + ), + 'date_add' => array( + 'title' => $this->l('Reservation Date'), + 'filter_key' => 'a!date_add', + ), + 'room_status' => array( + 'title' => $this->l('Room Status'), + ), + 'country' => array( + 'title' => $this->l('Country'), + ), + 'state' => array( + 'title' => $this->l('State'), + ), + 'city' => array( + 'title' => $this->l('City'), + ), + 'cus_address' => array( + 'title' => $this->l('Address'), + ), + 'cancellation_date' => array( + 'title' => $this->l('Cancellation date'), + ), + 'cancellation_fee' => array( + 'title' => $this->l('Cancellation fee'), + ), + )); + + unset($this->fields_list['id_status']); + unset($this->fields_list['id_room_information']); + unset($this->fields_list['room_type_name']); + unset($this->fields_list['id_currency']); + } + + parent::getList( + $id_lang, + $order_by, + $order_way, + $start, + $limit, + $id_lang_shop + ); + } + public function postProcess() { // Process reallocation of rooms @@ -3508,7 +3628,7 @@ class AdminOrdersControllerCore extends AdminController } } } - $this->content = json_encode($to_return); + $this->ajaxDie(json_encode($to_return)); } // public function ajaxProcessSearchProducts() @@ -4581,11 +4701,19 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail->children = $objCartBookingData->children; $objBookingDetail->child_ages = $objCartBookingData->child_ages; + $occupancy = array( + array( + 'adults' => $objCartBookingData->adults, + 'children' => $objCartBookingData->children, + 'child_ages' => json_decode($objCartBookingData->child_ages) + ) + ); + $total_price = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $objCartBookingData->date_from, $objCartBookingData->date_to, - 0, + $occupancy, Group::getCurrent()->id, $this->context->cart->id, $this->context->cookie->id_guest, @@ -5454,6 +5582,15 @@ class AdminOrdersControllerCore extends AdminController $idHotelBooking ); + //This is added to remove the services from the cart along with room deletion process. + $objHotelCartBookingData = new HotelCartBookingData(); + $roomHtlCartInfo = $objHotelCartBookingData->getRoomRowByIdProductIdRoomInDateRange( + $objBookingDetail->id_cart, + $objBookingDetail->id_product, + $objBookingDetail->date_from, + $objBookingDetail->date_to, + $objBookingDetail->id_room + ); /*$totalProductPriceBeforeTE = $order_detail->total_price_tax_excl; $totalProductPriceBeforeTI = $order_detail->total_price_tax_incl;*/ @@ -5488,6 +5625,7 @@ class AdminOrdersControllerCore extends AdminController $res &= $order_detail->update(); } // update order detail for selected aditional services + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); foreach ($selectedAdditonalServices['additional_services'] as $service) { $serviceOrderDetail = new OrderDetail($service['id_order_detail']); @@ -5508,6 +5646,21 @@ class AdminOrdersControllerCore extends AdminController // Save order detail $res &= $serviceOrderDetail->update(); } + + if (isset($roomHtlCartInfo['id'])) { + if ($idRoomTypServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists( + $service['id_product'], + $service['id_cart'], + $roomHtlCartInfo['id'] + )) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $idRoomTypServiceProductCartDetail); + $serviceQuantity = $objRoomTypeServiceProductCartDetail->quantity; + if ($objRoomTypeServiceProductCartDetail->delete()) { + $objCart = new Cart($service['id_cart']); + $objCart->updateQty((int)abs($serviceQuantity), $service['id_product'], null, false, 'down'); + } + } + } } /*End*/ @@ -5586,7 +5739,9 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail->id_product, $objBookingDetail->id_room, $objBookingDetail->date_from, - $objBookingDetail->date_to + $objBookingDetail->date_to, + 1, + $objBookingDetail->id_order ); $objBookingDetail->delete(); @@ -6148,24 +6303,17 @@ class AdminOrdersControllerCore extends AdminController $del_id = Tools::getValue('del_id'); $room_id = Tools::getValue('id_room'); $obj_hotel_cart_detail = new HotelCartBookingData(); - $deleted = $obj_hotel_cart_detail->deleteCartBookingData($cart_id, $id_product, $room_id, $dt_frm, $dt_to); - if ($deleted) { + if ($obj_hotel_cart_detail->deleteCartBookingData($cart_id, $id_product, $room_id, $dt_frm, $dt_to)) { $obj_product_process = new HotelCartBookingData(); $num_cart_rooms = 0; + $dt_to = date('Y-m-d H:i:s', strtotime($dt_to) - _TIME_1_DAY_); + HotelRoomTypeFeaturePricing::deleteFeaturePrices($cart_id, $id_product, $room_id, $dt_frm, $dt_to); if ($rooms = $obj_hotel_cart_detail->getCartCurrentDataByCartId($cart_id)) { $num_cart_rooms = count($rooms); } - $numDays = HotelHelper::getNumberOfDays($dt_frm, $dt_to); - $dt_to = date('Y-m-d H:i:s', strtotime($dt_to) - _TIME_1_DAY_); - HotelRoomTypeFeaturePricing::deleteFeaturePrices($cart_id, $id_product, $room_id, $dt_frm, $dt_to); - $changed = $obj_product_process->changeProductDataByRoomId($room_id, $id_product, $numDays, $cart_id); - if ($changed) { - $result['status'] = 'deleted'; - $result['cart_rooms'] = $num_cart_rooms; - } else { - $result['status'] = 'failed'; - } + $result['status'] = 'deleted'; + $result['cart_rooms'] = $num_cart_rooms; } else { $result['status'] = 'failed'; } @@ -6506,8 +6654,31 @@ class AdminOrdersControllerCore extends AdminController $quantity = $objRoomTypeServiceProductOrderDetail->quantity; $res = true; $objHotelBookingDetail = new HotelBookingDetail($objRoomTypeServiceProductOrderDetail->id_htl_booking_detail); + $idServiceProduct = $objRoomTypeServiceProductOrderDetail->id_product; + $objHotelCartBookingData = new HotelCartBookingData(); + $roomHtlCartInfo = $objHotelCartBookingData->getRoomRowByIdProductIdRoomInDateRange( + $objHotelBookingDetail->id_cart, + $objHotelBookingDetail->id_product, + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to, + $objHotelBookingDetail->id_room + ); + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); if ($res &= $objRoomTypeServiceProductOrderDetail->delete()) { + if (isset($roomHtlCartInfo['id'])) { + if ($idRoomTypServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists( + $idServiceProduct, + $objRoomTypeServiceProductOrderDetail->id_cart, + $roomHtlCartInfo['id'] + )) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($idRoomTypServiceProductCartDetail); + if ($objRoomTypeServiceProductCartDetail->delete()) { + $objCart = new Cart($objRoomTypeServiceProductOrderDetail->id_cart); + $objCart->updateQty((int)abs($quantity), $objRoomTypeServiceProductOrderDetail->id_product, null, false, 'down'); + } + } + } $order = new Order($objRoomTypeServiceProductOrderDetail->id_order); if ($quantity >= $objOrderDetail->product_quantity) { $objOrderDetail->delete(); @@ -6705,12 +6876,12 @@ class AdminOrdersControllerCore extends AdminController $unitPriceTaxExcl = 0; foreach ($productList as &$product) { // This is used to get the actual quanity of the service as it is calculated incorrectly if the service is per night - if ($id_room_type_service_product_cart_detail = $objRoomTypeServiceProductCartDetail->alreadyExists( + if ($idRoomTypServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists( $service['id'], $cart->id, $roomHtlCartInfo['id']) ) { - $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $id_room_type_service_product_cart_detail); + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $idRoomTypServiceProductCartDetail); $unitPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice( (int)$product['id_product'], @@ -7196,6 +7367,13 @@ class AdminOrdersControllerCore extends AdminController // set context currency So that we can get prices in the order currency $objOrder = new Order($objHotelBooking->id_order); $this->context->currency = new Currency($objOrder->id_currency); + $occupancy = array( + array( + 'adults' => $objHotelBooking->adults, + 'children' => $objHotelBooking->children, + 'child_ages' => json_decode($objHotelBooking->child_ages) + ) + ); $newRoomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idNewRoomType, $objHotelBooking->date_from, diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index f1038c05d..b1e5932b8 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -201,7 +201,13 @@ class AdminProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`) LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_product` = a.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_room_type_demand` hrtd ON (hrtd.`id_product` = a.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` hrtsp ON ((hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_HOTEL.' AND hrtsp.`id_element` = hrt.`id_hotel`) OR (hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND hrtsp.`id_element` = a.`id_product`)) + LEFT JOIN ( + SELECT rsp.*, GROUP_CONCAT(pl.`name`) AS service_products + FROM `'._DB_PREFIX_.'htl_room_type_service_product` rsp + LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = rsp.`id_product`) + WHERE pl.`id_lang`='.$this->context->language->id.' + GROUP BY rsp.`id_element`) + AS hrtsp ON ((hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_HOTEL.' AND hrtsp.`id_element` = hrt.`id_hotel`) OR (hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND hrtsp.`id_element` = a.`id_product`)) LEFT JOIN `'._DB_PREFIX_.'htl_advance_payment` hap ON (hap.`id_product` = a.`id_product`)'; $this->_select .= ' a.`show_at_front`, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; @@ -213,7 +219,7 @@ class AdminProductsControllerCore extends AdminController if ($join_category) { $this->_join .= ' INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.') '; - $this->_select .= ' , cp.`position`, '; + $this->_select .= ' , cp.`position` '; } // show the list of the product according to the booking or service products @@ -277,6 +283,13 @@ class AdminProductsControllerCore extends AdminController 'type' => 'range', 'align' => 'center', ); + $this->fields_list['max_guests'] = array( + 'title' => $this->l('Maximum Occupancy'), + 'filter_key' => 'hrt!max_guests', + 'type' => 'range', + 'align' => 'center', + 'optional' => true, + ); // use it for total rooms $this->fields_list['num_rooms'] = array( 'title' => $this->l('Total Rooms'), @@ -290,7 +303,7 @@ class AdminProductsControllerCore extends AdminController 'validation' => 'isFloat', 'align' => 'text-left', 'filter_key' => 'a!price', - 'callback' => 'displayBasePrice', + 'callback' => 'displayPrice', ); $this->fields_list['price_final'] = array( 'title' => $this->l('Final price'), @@ -298,7 +311,8 @@ class AdminProductsControllerCore extends AdminController 'align' => 'text-left', 'havingFilter' => true, 'orderby' => false, - 'search' => false + 'search' => false, + 'callback' => 'displayPrice', ); $this->fields_list['active'] = array( @@ -307,25 +321,18 @@ class AdminProductsControllerCore extends AdminController 'filter_key' => $alias.'!active', 'align' => 'text-center', 'type' => 'select', + 'callback' => 'formatStatusAsLabel', 'list' => array(1 => $this->l('Yes'), 0 => $this->l('No')), 'optional' => true, 'visible_default' => true, 'orderby' => false ); - - $this->fields_list['max_guests'] = array( - 'title' => $this->l('Maximum Occupancy'), - 'filter_key' => 'hrt!max_guests', - 'type' => 'range', - 'align' => 'center', - 'optional' => true, - ); - $this->fields_list['show_at_front'] = array( 'title' => $this->l('Show at front'), 'align' => 'text-center', 'type' => 'bool', 'active' => 'show_at_front', + 'callback' => 'formatStatusAsLabel', 'optional' => true, 'havingFilter' => true, 'visible_default' => true, @@ -335,7 +342,7 @@ class AdminProductsControllerCore extends AdminController if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) { $this->fields_list['advance_payment'] = array( 'title' => $this->l('Advance Payment'), - 'callback' => 'getAdvancePaymentStatus', + 'callback' => 'formatStatusAsLabel', 'badge_success' => true, 'badge_danger' => true, 'align' => 'text-center', @@ -446,7 +453,7 @@ class AdminProductsControllerCore extends AdminController } } - public function getAdvancePaymentStatus($val, $row) + public function formatStatusAsLabel($val, $row) { if ($val) { $str_return = $this->l('Yes'); @@ -457,7 +464,6 @@ class AdminProductsControllerCore extends AdminController return $str_return; } - private function buildCategoryOptions($category) { $space = str_repeat(' ', 5 * (($category['level_depth'] - $this->objLocationsCategory->level_depth) - 1)); @@ -470,7 +476,7 @@ class AdminProductsControllerCore extends AdminController } } - public static function displayBasePrice($basePrice, $tr) + public static function displayPrice($basePrice, $tr) { return Tools::displayPrice($basePrice, (int) Configuration::get('PS_CURRENCY_DEFAULT')); } @@ -629,6 +635,48 @@ class AdminProductsControllerCore extends AdminController $orderBy = 'id_'.$this->table; $orderWay = 'ASC'; } + if ($this->action == 'export' && empty($this->_listsql)) { + $this->_select .= ' , trg.`name` AS `id_tax_rules_group`, `features`, hrtdl.`global_demands`'; + $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'tax_rules_group` trg + ON trg.`id_tax_rules_group` = a.`id_tax_rules_group` + LEFT JOIN (SELECT GROUP_CONCAT(fpl.`name`) AS features, fp.`id_product` + FROM `'._DB_PREFIX_.'feature_lang` fpl + LEFT JOIN `'._DB_PREFIX_.'feature_product` fp + ON (fp.`id_feature` = fpl.`id_feature`) + WHERE fpl.`id_lang`='.(int) $this->context->language->id.' + GROUP BY fp.`id_product` + ) AS fpl ON (a.`id_product` = fpl.`id_product`)'; + + $this->_join .= ' LEFT JOIN (SELECT hrtgd.`id_product`, `id_lang`, GROUP_CONCAT(`name`) AS `global_demands` + FROM `'._DB_PREFIX_.'htl_room_type_global_demand_lang` hrtgdl + LEFT JOIN `'._DB_PREFIX_.'htl_room_type_demand` hrtgd + ON hrtgd.`id_global_demand` = hrtgdl.`id_global_demand` + WHERE `id_lang`='.(int) $this->context->language->id.' + GROUP BY hrtgd.`id_product` + ) AS hrtdl ON (hrtdl.`id_product` = a.`id_product`)'; + + $this->fields_list = array_merge($this->fields_list, array( + 'id_tax_rules_group' => array( + 'title' => $this->l('Id Tax Rules group'), + 'filter_key' => 'a!id_tax_rules_group', + ), + 'features' => array( + 'title' => $this->l('Features'), + ), + 'service_products' => array( + 'title' => $this->l('Services Products'), + ), + 'global_demands' => array( + 'title' => $this->l('Additional Facilities'), + ) + ) + ); + + unset($this->fields_list['id_category_default']); + unset($this->fields_list['id_global_demand']); + unset($this->fields_list['id_feature']); + unset($this->fields_list['id_service_product']); + } parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $this->context->shop->id); /* update product quantity with attributes ...*/ diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 83d3bb857..7d99916f9 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -419,7 +419,7 @@ class ProductControllerCore extends FrontController ) ); - $occupancy_value = array(); + $occupancy_value = Tools::getValue('occupancy', array()); if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY) { $occupancy_value = 1; } else { @@ -450,10 +450,10 @@ class ProductControllerCore extends FrontController // product price after imposing feature prices... if ($useTax) { $priceProduct = Product::getPriceStatic($this->product->id, true); - $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, true); + $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, true, 0, 0, 0, 0, 1, 1, $occupancy_value); } else { $priceProduct = Product::getPriceStatic($this->product->id, false); - $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, false); + $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, false, 0, 0, 0, 0, 1, 1, $occupancy_value); } $productPriceWithoutReduction = $this->product->getPriceWithoutReduct(!$useTax); $feature_price_diff = (float)($productPriceWithoutReduction - $feature_price); @@ -649,7 +649,7 @@ class ProductControllerCore extends FrontController $idProduct, $dateFrom, $dateTo, - 0, + $occupancy, 0, 0, 0, @@ -660,7 +660,8 @@ class ProductControllerCore extends FrontController $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $dateFrom, - $dateTo + $dateTo, + $occupancy ); $featurePrice = 0; @@ -669,7 +670,14 @@ class ProductControllerCore extends FrontController $idProduct, $dateFrom, $dateTo, - true + true, + 0, + 0, + 0, + 0, + 1, + 1, + $occupancy ); $roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_incl']; $totalPriceWithoutDiscount = $priceWithoutDiscount['total_price_tax_incl']; @@ -679,14 +687,20 @@ class ProductControllerCore extends FrontController $idProduct, $dateFrom, $dateTo, - false + false, + 0, + 0, + 0, + 0, + 1, + 1, + $occupancy ); $roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_excl']; $totalPriceWithoutDiscount = $priceWithoutDiscount['total_price_tax_excl']; } - $totalPriceWithoutDiscount *= $quantity; - $totalRoomPrice = $roomTypeDateRangePrice * $quantity; + $totalRoomPrice = $roomTypeDateRangePrice; // calculate demand price now $demandsPricePerRoom = 0; $roomTypeDemands = $objHRTDemand->getRoomTypeDemands($idProduct); diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 32033875c..cda227fd6 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -241,7 +241,7 @@ class Blockcart extends Module $objProduct->id, $addedProduct['date_from'], $addedProduct['date_to'], - $addedProduct['req_rm'] + $addedProduct['occupancy'] ); if ($priceDisplayMethod == PS_TAX_EXC) { $addedProduct['price'] = Tools::displayPrice($price['total_price_tax_excl']); diff --git a/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php b/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php index 076663010..b2702b310 100644 --- a/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php +++ b/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php @@ -105,11 +105,18 @@ class HotelAdvancedPayment extends ObjectModel $objHtlCartBook = new HotelCartBookingData(); if ($roomTypesByIdProduct = $objHtlCartBook->getCartInfoIdCartIdProduct((int) $idCart, (int)$idProduct)) { foreach ($roomTypesByIdProduct as $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); $roomTotalPrices = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $cartRoomInfo['id_product'], $cartRoomInfo['date_from'], $cartRoomInfo['date_to'], - 0, + $occupancy, 0, $idCart, $cartRoomInfo['id_guest'], diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 8f73e01b7..6f777861d 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1701,7 +1701,7 @@ class HotelBookingDetail extends ObjectModel continue; } } - $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); + $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 1, $bookingParams['occupancy']); if (!empty($price) && ($price['from'] > $productFeaturePrice || $price['to'] < $productFeaturePrice)) { unset($bookingData['rm_data'][$key]); continue; @@ -1709,7 +1709,7 @@ class HotelBookingDetail extends ObjectModel if (count($value['data']['available']) || (isset($get_all_room_types) && $get_all_room_types)) { $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); - $productPriceWithoutReduction = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 0); + $productPriceWithoutReduction = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 0, $bookingParams['occupancy']); $cover_image_arr = Product::getCover($value['id_product']); if (!empty($cover_image_arr)) { $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); @@ -2065,11 +2065,19 @@ class HotelBookingDetail extends ObjectModel $objBookingDetail->children = $objCartBookingData->children; $objBookingDetail->child_ages = $objCartBookingData->child_ages; + $occupancy = array( + array( + 'adults' => $objCartBookingData->adults, + 'children' => $objCartBookingData->children, + 'child_ages' => json_decode($objCartBookingData->child_ages) + ) + ); + $totalRoomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idNewRoomType, $objCartBookingData->date_from, $objCartBookingData->date_to, - 0, + $occupancy, Group::getCurrent()->id, $this->context->cart->id, $this->context->cookie->id_guest, diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 7ad74427a..a970c60d4 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -346,7 +346,8 @@ class HotelCartBookingData extends ObjectModel $idRoom = 0, $dateFrom = 0, $dateTo = 0, - $updPsCart = 1 + $updPsCart = 1, + $idOrder = 0 ) { $where = '1'; if ($idCart) { @@ -364,8 +365,8 @@ class HotelCartBookingData extends ObjectModel if ($dateTo) { $where .= ' AND `date_to`=\''.pSQL($dateTo).'\''; } - // we have to delete only rows which order is not created - $where .= ' AND `id_order`= 0'; + + $where .= ' AND `id_order`='.(int) $idOrder; // If rooms is deleting from cart the we need to delete the ps_cart quantity of the product from table // if product will delete the prestashop will handle $numRooms = 0; @@ -1112,7 +1113,13 @@ class HotelCartBookingData extends ObjectModel $cart_detail_data[$key]['date_to'] = $value['date_to']; $cart_detail_data[$key]['child_ages'] = json_decode($value['child_ages']); - + $occupancy = array( + array( + 'adults' => $value['adults'], + 'children' => $value['children'], + 'child_ages' => json_decode($value['child_ages']) + ) + ); $unit_price = Product::getPriceStatic($value['id_product'], true); $unit_price_tax_excl = Product::getPriceStatic($value['id_product'], false); $productPriceWithoutReduction = $productObj->getPriceWithoutReduct(false); @@ -1125,7 +1132,9 @@ class HotelCartBookingData extends ObjectModel $id_cart, $value['id_guest'], $value['id_room'], - 0 + 0, + 1, + $occupancy ); $feature_price_tax_excl = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( $value['id_product'], @@ -1136,7 +1145,9 @@ class HotelCartBookingData extends ObjectModel $id_cart, $value['id_guest'], $value['id_room'], - 0 + 0, + 1, + $occupancy ); $feature_price_diff = (float)($productPriceWithoutReduction - $feature_price); $cart_detail_data[$key]['product_price'] = $unit_price; @@ -1238,7 +1249,7 @@ class HotelCartBookingData extends ObjectModel $value['id_product'], $value['date_from'], $value['date_to'], - 0, + $occupancy, 0, $id_cart, $value['id_guest'], @@ -1556,7 +1567,13 @@ class HotelCartBookingData extends ObjectModel 1 ); $totalAdditionalServicePrice = $demandPrice + $serviceProductPrice; - + $occupancy = array( + array( + 'adults' => $data_v['adults'], + 'children' => $data_v['children'], + 'child_ages' => json_decode($data_v['child_ages']) + ) + ); if (isset($cartHotelData[$prodKey]['date_diff'][$dateJoin])) { $numDays = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); $cartHotelData[$prodKey]['date_diff'][$dateJoin]['demand_price'] += $totalAdditionalServicePrice; @@ -1572,7 +1589,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1582,7 +1599,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1593,7 +1610,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1634,7 +1651,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1644,7 +1661,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1655,7 +1672,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php index b63d922cf..d9005e630 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php @@ -636,7 +636,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $id_product, $date_from, $date_to, - $quantity = 0, + $occupancy = null, $id_group = 0, $id_cart = 0, $id_guest = 0, @@ -657,6 +657,12 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $taxRate = 0; } + if (is_array($occupancy) && count($occupancy)) { + $quantity = count($occupancy); + } else { + $quantity = $occupancy; + } + // Initializations if (!$id_group) { $id_group = (int)Group::getCurrent()->id; @@ -726,7 +732,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel 'id_guest' => $id_guest, 'id_group' => $id_group, 'use_reduc' => $use_reduc, - 'tax_rate' => $taxRate + 'tax_rate' => $taxRate, + 'occupancy' => $occupancy ) ); if ($with_auto_room_services) { @@ -805,7 +812,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $id_guest = 0, $id_room = 0, $with_auto_room_services = 1, - $use_reduc = 1 + $use_reduc = 1, + $occupancy = array() ) { $dateFrom = date('Y-m-d H:i:s', strtotime($date_from)); $dateTo = date('Y-m-d H:i:s', strtotime($date_to)); @@ -813,7 +821,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $id_product, $dateFrom, $dateTo, - 0, + $occupancy, $id_group, $id_cart, $id_guest, diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index fec2fed2c..753d4ec3e 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -217,7 +217,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $idLang = Context::getContext()->language->id; - $sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, cbd.`id` as `htl_cart_booking_id` , + $sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, rscd.`id_cart` as service_id_cart, cbd.`id` as `htl_cart_booking_id` , cbd.`id_product` as `room_type_id_product`, cbd.`adults`, cbd.`children`, cbd.`date_from`, cbd.`date_to`'; if (!$getTotalPrice) { $sql .= ', pl.`name`, cbd.`id_guest`, cbd.`id_customer`, p.`auto_add_to_cart`, p.`price_addition_type`, @@ -233,7 +233,8 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$idLang.')'; } - $sql .= ' WHERE 1'; + + $sql .= ' WHERE 1 AND rscd.`id_product`!=0'; if (!is_null($autoAddToCart)) { $sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart; @@ -334,6 +335,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel 'name' => $product['name'], 'quantity' => $product['quantity'], 'auto_add_to_cart' => $product['auto_add_to_cart'], + 'id_cart' => $product['service_id_cart'], 'allow_multiple_quantity' => $product['allow_multiple_quantity'], 'price_addition_type' => $product['price_addition_type'], 'price_calculation_method' => $product['price_calculation_method'], @@ -449,6 +451,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel 'quantity' => $product['quantity'], 'auto_add_to_cart' => $product['auto_add_to_cart'], 'allow_multiple_quantity' => $product['allow_multiple_quantity'], + 'id_cart' => $product['service_id_cart'], 'price_addition_type' => $product['price_addition_type'], 'price_calculation_method' => $product['price_calculation_method'], 'unit_price_tax_excl' => ($objRoomTypeServiceProductPrice->getServicePrice( diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php index 2d7059469..f08a92f72 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php @@ -254,6 +254,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel 'id_order_detail' => $product['id_order_detail'], 'id_product' => $product['id_product'], 'name' => $product['name'], + 'id_cart' => $product['id_cart'], 'quantity' => $product['quantity'], 'allow_multiple_quantity' => $product['product_allow_multiple_quantity'], 'max_quantity' => $product['max_quantity'], @@ -280,6 +281,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel 'id_order_detail' => $product['id_order_detail'], 'id_product' => $product['id_product'], 'name' => $product['name'], + 'id_cart' => $product['id_cart'], 'quantity' => $product['quantity'], 'allow_multiple_quantity' => $product['product_allow_multiple_quantity'], 'max_quantity' => $product['max_quantity'], @@ -323,4 +325,4 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel // delete entry from order detail table. return parent::delete(); } -} \ No newline at end of file +} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 6cbe0183c..24e060f1b 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -199,7 +199,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $this->errors[] = $this->l('Selected room is not available for reallocation.'); } elseif (!in_array($idRoomToReallocate, array_column($availableRooms, 'id_room'))) { $this->errors[] = $this->l('Selected room is not available for reallocation.'); - } elseif (!Validate::isFloat($priceDiff)) { + } elseif (!Validate::isPrice($priceDiff)) { $this->errors[] = $this->l('Invalid price difference of the room types.'); } } else { @@ -875,11 +875,18 @@ class AdminHotelRoomsBookingController extends ModuleAdminController // if room is changing in the reallocation if ($objHotelBooking->id_product != $idNewRoomType) { $result['has_room_type_change'] = 1; + $occupancy = array( + array( + 'adults' => $objHotelBooking->adults, + 'children' => $objHotelBooking->children, + 'child_ages' => json_decode($objHotelBooking->child_ages) + ) + ); $newRoomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idNewRoomType, $objHotelBooking->date_from, $objHotelBooking->date_to, - 0, + $occupancy, 0, 0, 0, diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index 315dfeb1b..d35064fe9 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -33,6 +33,8 @@ class AdminOrderRefundRequestsController extends ModuleAdminController $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'customer` cust ON (cust.`id_customer` = ord.`id_customer`)'; $this->_orderWay = 'DESC'; + $this->allow_export = true; + $this->_new_list_header_design = true; if ($idOrder = Tools::getValue('id_order')) { $this->_select .= ', orsl.`name` as `status_name`, ors.`color`, COUNT(ordrd.`id_order_return_detail`) as num_rooms'; $this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state ors ON (ors.`id_order_return_state` = a.`state`)'; @@ -176,9 +178,83 @@ class AdminOrderRefundRequestsController extends ModuleAdminController public function setCustomerLink($customerName, $row) { + if ($this->action == 'export') { + return $customerName.' (#'.$row['id_customer'].')'; + } + return ''.$customerName.' (#'.$row['id_customer'].')'; } + public function getList( + $id_lang, + $order_by = null, + $order_way = null, + $start = 0, + $limit = null, + $id_lang_shop = false + ){ + if ($this->action == 'export' && empty($this->_listsql)) { + if (Tools::getValue('id_order')) { + $this->_select .= ', ordtl.*'; + } else { + $this->_select .= ', GROUP_CONCAT(ordtl.`room_num`) AS `room_num`, + GROUP_CONCAT(DISTINCT ordtl.`room_type_name`) AS `room_type_name`, + ordtl.`hotel_name`, ordtl.`id_order`, + GROUP_CONCAT(ordtl.`date_from`) AS `date_from`, + GROUP_CONCAT(ordtl.`date_to`) AS `date_to`'; + } + + $this->_join .= ' LEFT JOIN ( + SELECT GROUP_CONCAT(hbd.`room_num`) AS room_num, + GROUP_CONCAT(DISTINCT(hbd.`room_type_name`)) AS room_type_name, + ord.`id_order_return`, hbd.`hotel_name`, hbd.`id_order`, + GROUP_CONCAT(hbd.`date_from`) AS date_from, + GROUP_CONCAT(hbd.`date_to`) AS date_to + FROM `'._DB_PREFIX_.'order_return_detail` ord + LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON ord.`id_htl_booking` = hbd.`id` + GROUP BY ord.`id_order_return` + ) AS ordtl ON (ordtl.`id_order_return` = a.`id_order_return`)'; + $this->fields_list = array_merge($this->fields_list, array( + 'room_num' => array( + 'title' => $this->l('Room num(s)') + ), + 'room_type_name' => array( + 'title' => $this->l('Room type(s)'), + 'callback' => 'getUniqueRoomTypeNames' + ), + 'hotel_name' => array( + 'title' => $this->l('Hotel') + ), + 'date_from' => array( + 'title' => $this->l('Date From') + ), + 'date_to' => array( + 'title' => $this->l('Date To') + ), + )); + } + + parent::getList( + $id_lang, + $order_by, + $order_way, + $start, + $limit, + $id_lang_shop + ); + } + + public function getUniqueRoomTypeNames($roomTypeNames, $tr) + { + if ($roomTypeNames) { + $roomTypeNames = explode(',', $roomTypeNames); + $roomTypeNames = array_unique($roomTypeNames); + $roomTypeNames = implode(',', $roomTypeNames); + } + + return $roomTypeNames; + } + public function initToolbar() { parent::initToolbar(); diff --git a/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php b/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php index 46e32a741..389bd3107 100644 --- a/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php +++ b/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php @@ -351,10 +351,18 @@ class WkPaypalCommerceHelper $idProduct )) { foreach ($roomTypeBookings as $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $cartRoomInfo['date_from'], - $cartRoomInfo['date_to'] + $cartRoomInfo['date_to'], + $occupancy ); $roomTotalPriceTE = $roomTotalPrice['total_price_tax_excl']; $roomTotalPriceTI = $roomTotalPrice['total_price_tax_incl']; diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 81c2bb24f..055f488cc 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -182,7 +182,6 @@ class wkhotelfilterblock extends Module $max_adult = HotelRoomType::getMaxAdults($id_hotel); $max_child = HotelRoomType::getMaxChild($id_hotel); - $category = new Category($htl_id_category); $urlData = array (); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d H:i:s'); @@ -203,15 +202,15 @@ class wkhotelfilterblock extends Module $obj_rm_type = new HotelRoomType(); $room_types = $obj_rm_type->getIdProductByHotelId($id_hotel, 0, 1, 1); + $occupancy = Tools::getValue('occupancy'); $prod_price = array(); if ($room_types) { foreach ($room_types as $key => $value) { - $prod_price[] = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, HotelBookingDetail::useTax()); + $prod_price[] = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, HotelBookingDetail::useTax(), 0, 0, 0, 0, 1, 1, $occupancy); } } - // Create URL of category if (Configuration::get('PS_REWRITING_SETTINGS')) { $categoryUrl = $this->context->link->getCategoryLink( new Category($htl_id_category, $this->context->language->id), diff --git a/pdf/invoice.addresses-tab.tpl b/pdf/invoice.addresses-tab.tpl index 0b743c4f0..fe6efc706 100644 --- a/pdf/invoice.addresses-tab.tpl +++ b/pdf/invoice.addresses-tab.tpl @@ -31,7 +31,12 @@ {$delivery_address} {/if} --> - + + {l s='Hotel Detail' pdf='true'}

+ {if $hotel_address} + {$hotel_address} + {/if} + {l s='Customer Detail' pdf='true'}

diff --git a/pdf/invoice.product-tab.tpl b/pdf/invoice.product-tab.tpl index d6721f5d9..ed6859cf6 100644 --- a/pdf/invoice.product-tab.tpl +++ b/pdf/invoice.product-tab.tpl @@ -27,14 +27,13 @@ - + {if $display_product_images} {/if} - {* {if isset($layout.before_discount)} @@ -62,11 +61,6 @@ {$data_v['name']}

-
{l s='Rooms Details' pdf='true'}{l s='Rooms Details' pdf='true'}
{l s='Room Image' pdf='true'}{l s='Room Description' pdf='true'}{l s='Hotel' pdf='true'} {l s='Tax Rate(s)' pdf='true'}{l s='Base price' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
-

- {$data_v['hotel_name']} -

-
{$data_v['order_detail_tax_label']}