Added feature for adding standard product in cart
This commit is contained in:
@@ -71,6 +71,9 @@ class Blockcart extends Module
|
||||
}
|
||||
}
|
||||
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$serviceProducts = $objRoomTypeServiceProductCartDetail->getProducts($params['cart']->id);
|
||||
|
||||
$priceDisplayMethod = Product::getTaxCalculationMethod((int)$this->context->cookie->id_customer);
|
||||
$nbTotalProducts = 0;
|
||||
|
||||
@@ -112,11 +115,49 @@ class Blockcart extends Module
|
||||
$product['is_gift'] = (isset($product['is_gift']) && $product['is_gift'] )? true : false;
|
||||
$product['hasCustomizedDatas'] = false;
|
||||
$product['hasAttributes'] = false;
|
||||
$product['hasOptions'] = false;
|
||||
|
||||
if (!$product['booking_product']) {
|
||||
if (Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE == $product['service_product_type']) {
|
||||
// $nbTotalProducts += (int) $product['cart_quantity'];
|
||||
$product['hasOptions'] = ServiceProductOption::productHasOptions($product['id_product']);
|
||||
if (Product::SERVICE_PRODUCT_STANDALONE == $product['service_product_type']) {
|
||||
$nbTotalProducts += (int) $product['cart_quantity'];
|
||||
$product['total_price_tax_incl'] = 0;
|
||||
$product['total_price_tax_excl'] = 0;
|
||||
$product['amount'] = 0;
|
||||
$product['options'] = array();
|
||||
foreach ($serviceProducts as $key => $serviceProduct) {
|
||||
if ($serviceProduct['id_product'] == $product['id_product']) {
|
||||
$product['options'][] = $serviceProduct;
|
||||
$product['total_price_tax_incl'] += $serviceProduct['total_price_tax_incl'];
|
||||
$product['total_price_tax_excl'] += $serviceProduct['total_price_tax_excl'];
|
||||
$product['amount'] += $useTax ? $serviceProduct['total_price_tax_incl'] : $serviceProduct['total_price_tax_excl'];
|
||||
}
|
||||
}
|
||||
} elseif (Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL == $product['service_product_type']) {
|
||||
$nbTotalProducts += (int) $product['cart_quantity'];
|
||||
foreach ($serviceProducts as $key => $serviceProduct) {
|
||||
if ($serviceProduct['id_product'] == $product['id_product']) {
|
||||
if (!isset($product['hotel_wise_data'][$serviceProduct['id_hotel']])) {
|
||||
$product['hotel_wise_data'][$serviceProduct['id_hotel']] = array(
|
||||
'id_hotel' => $serviceProduct['id_hotel'],
|
||||
'hotel_name' => $serviceProduct['hotel_name'],
|
||||
'options' => array(),
|
||||
'total_qty' => 0,
|
||||
'total_price_tax_incl' => 0,
|
||||
'total_price_tax_excl' => 0,
|
||||
'amount' => 0
|
||||
);
|
||||
}
|
||||
$product['hotel_wise_data'][$serviceProduct['id_hotel']]['total_price_tax_incl'] += $serviceProduct['total_price_tax_incl'];
|
||||
$product['hotel_wise_data'][$serviceProduct['id_hotel']]['total_price_tax_excl'] += $serviceProduct['total_price_tax_excl'];
|
||||
$product['hotel_wise_data'][$serviceProduct['id_hotel']]['amount'] += $useTax ? $serviceProduct['total_price_tax_incl'] : $serviceProduct['total_price_tax_excl'];
|
||||
$product['hotel_wise_data'][$serviceProduct['id_hotel']]['total_qty'] += $serviceProduct['quantity'];
|
||||
$product['hotel_wise_data'][$serviceProduct['id_hotel']]['options'][] = $serviceProduct;
|
||||
}
|
||||
}
|
||||
if (isset($product['hotel_wise_data'])) {
|
||||
$product['hotel_wise_data'] = array_values($product['hotel_wise_data']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// getbooking cart data
|
||||
@@ -252,19 +293,29 @@ class Blockcart extends Module
|
||||
$addedProduct['date_from'] = Tools::displayDate($addedProduct['date_from'], null, $fullDate);
|
||||
$addedProduct['date_to'] = Tools::displayDate($addedProduct['date_to'], null, $fullDate);
|
||||
} else {
|
||||
// @todo get price of added product from front
|
||||
$addedProduct['price'] = ProductCore::getPriceStatic(
|
||||
$objProduct->id,
|
||||
$useTax,
|
||||
null,
|
||||
6,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
$addedProduct['qty']
|
||||
) * $addedProduct['qty'];
|
||||
}
|
||||
if ($objProduct->service_product_type == Product::SERVICE_PRODUCT_STANDALONE) {
|
||||
$addedProduct['unit_price'] = RoomTypeServiceProductPrice::getPrice(
|
||||
$objProduct->id,
|
||||
0,
|
||||
isset($addedProduct['id_service_product_option']) ? $addedProduct['id_service_product_option'] : null,
|
||||
$useTax,
|
||||
$addedProduct['qty']
|
||||
);
|
||||
|
||||
} elseif ($objProduct->service_product_type == Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL) {
|
||||
$addedProduct['unit_price'] = RoomTypeServiceProductPrice::getPrice(
|
||||
$objProduct->id,
|
||||
$addedProduct['id_hotel'],
|
||||
isset($addedProduct['id_service_product_option']) ? $addedProduct['id_service_product_option'] : null,
|
||||
$useTax,
|
||||
$addedProduct['qty']
|
||||
);
|
||||
$objHotel = new HotelBranchInformation($addedProduct['id_hotel'], $this->context->language->id);
|
||||
$addedProduct['hotel_name'] = $objHotel->hotel_name;
|
||||
}
|
||||
$addedProduct['price'] = Tools::displayPrice($addedProduct['unit_price'] * $addedProduct['qty']);
|
||||
$addedProduct['unit_price'] = Tools::displayPrice($addedProduct['unit_price']);
|
||||
}
|
||||
unset($this->context->cookie->currentAddedProduct);
|
||||
}
|
||||
|
||||
@@ -272,6 +323,7 @@ class Blockcart extends Module
|
||||
$totalAdditionalServicesWithAutoAddPrice = $params['cart']->getOrderTotal($useTax, Cart::ONLY_ROOM_SERVICES);
|
||||
$totalConvenienceFee = $params['cart']->getOrderTotal($useTax, Cart::ONLY_CONVENIENCE_FEE);
|
||||
$totalRoomsPrice = $params['cart']->getOrderTotal($useTax, Cart::ONLY_ROOMS);
|
||||
$totalNormalProductPrice = $params['cart']->getOrderTotal($useTax, Cart::ONLY_STANDALONE_PRODUCTS);
|
||||
|
||||
$response = array(
|
||||
'products' => $products,
|
||||
@@ -289,10 +341,13 @@ class Blockcart extends Module
|
||||
'tax_cost' => $tax_cost,
|
||||
'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency),
|
||||
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_PRODUCTS), $currency),
|
||||
'room_total' => Tools::displayPrice($totalRoomsPrice + $totalDemandsPrice + $totalAdditionalServicesWithAutoAddPrice - $totalConvenienceFee),
|
||||
'room_total' => ($totalRoomsPrice + $totalDemandsPrice + $totalAdditionalServicesWithAutoAddPrice),
|
||||
'room_total_format' => Tools::displayPrice($totalRoomsPrice + $totalDemandsPrice + $totalAdditionalServicesWithAutoAddPrice - $totalConvenienceFee),
|
||||
'totalToPay' => $totalToPay,
|
||||
'total_convenience_fee' => $totalConvenienceFee,
|
||||
'total_convenience_fee_format' => Tools::displayPrice(($totalConvenienceFee), $currency),
|
||||
'normal_products_total' => $totalNormalProductPrice,
|
||||
'normal_products_total_format' => Tools::displayPrice(($totalNormalProductPrice), $currency),
|
||||
'total' => Tools::displayPrice($totalToPay, $currency),
|
||||
'order_process' => $orderProcess,
|
||||
'ajax_allowed' => (int) (Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false,
|
||||
@@ -416,10 +471,11 @@ class Blockcart extends Module
|
||||
if ($current_page == 'product') {
|
||||
$id_product = Tools::getValue('id_product');
|
||||
$obj_hotel_room_type = new HotelRoomType();
|
||||
$room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($id_product);
|
||||
$hotel_id = $room_info_by_product_id['id_hotel'];
|
||||
if ($hotel_id) {
|
||||
$max_order_date = HotelOrderRestrictDate::getMaxOrderDate($hotel_id);
|
||||
if ($room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($id_product)) {
|
||||
$hotel_id = $room_info_by_product_id['id_hotel'];
|
||||
if ($hotel_id) {
|
||||
$max_order_date = HotelOrderRestrictDate::getMaxOrderDate($hotel_id);
|
||||
}
|
||||
}
|
||||
} elseif ($current_page == 'category') {
|
||||
$htl_id_category = Tools::getValue('id_category');
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<dl class="products">
|
||||
{foreach from=$products key=data_k item='product' name='myLoop'}
|
||||
{* only show products that are booking or global without room *}
|
||||
{if $product.booking_product || ($product.service_product_type == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE)}
|
||||
{if $product.booking_product || ($product.service_product_type == Product::SERVICE_PRODUCT_STANDALONE)}
|
||||
{assign var='productId' value=$product.id_product}
|
||||
{assign var='productAttributeId' value=$product.id_product_attribute}
|
||||
<dt data-id="cart_block_product_{$product.id_product|intval}_{if $product.id_product_attribute}{$product.id_product_attribute|intval}{else}0{/if}_{if $product.id_address_delivery}{$product.id_address_delivery|intval}{else}0{/if}" class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
|
||||
|
||||
@@ -502,9 +502,10 @@ class HotelCartBookingData extends ObjectModel
|
||||
if ($services = RoomTypeServiceProduct::getAutoAddServices($id_product)) {
|
||||
foreach($services as $service) {
|
||||
$objRoomTypeServiceProductCartDetail->addServiceProductInCart(
|
||||
$id_cart,
|
||||
$service['id_product'],
|
||||
1,
|
||||
$id_cart,
|
||||
false,
|
||||
$obj_htl_cart_booking_data->id
|
||||
);
|
||||
}
|
||||
@@ -512,9 +513,10 @@ class HotelCartBookingData extends ObjectModel
|
||||
if (count($serviceProducts)) {
|
||||
foreach($serviceProducts as $product) {
|
||||
$objRoomTypeServiceProductCartDetail->addServiceProductInCart(
|
||||
$id_cart,
|
||||
$product['id_product'],
|
||||
$product['quantity'],
|
||||
$id_cart,
|
||||
false,
|
||||
$obj_htl_cart_booking_data->id
|
||||
);
|
||||
}
|
||||
|
||||
@@ -383,22 +383,30 @@ class HotelReservationSystemDb
|
||||
KEY `id_product` (`id_product`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
|
||||
"CREATE TABLE `"._DB_PREFIX_."htl_hotel_service_product_cart_detail` (
|
||||
`id_hotel_service_product_cart_detail` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_cart` int(11) unsigned NOT NULL,
|
||||
"CREATE TABLE `"._DB_PREFIX_."service_product_option` (
|
||||
`id_service_product_option` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_product` int(11) UNSIGNED NOT NULL,
|
||||
`id_hotel` int(11) UNSIGNED NOT NULL,
|
||||
`quantity` int(11) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id_hotel_service_product_cart_detail`),
|
||||
KEY `id_product` (`id_product`)
|
||||
`price_impact` decimal(20,6) NOT NULL DEFAULT '0.000000',
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_service_product_option`),
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
|
||||
"CREATE TABLE `"._DB_PREFIX_."service_product_option_lang` (
|
||||
`id_service_product_option` int(10) unsigned NOT NULL,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
`name` varchar(255) character set utf8 NOT NULL,
|
||||
PRIMARY KEY (`id_service_product_option`, `id_lang`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
|
||||
|
||||
"CREATE TABLE `"._DB_PREFIX_."htl_room_type_service_product_cart_detail` (
|
||||
`id_room_type_service_product_cart_detail` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_product` int(11) UNSIGNED NOT NULL,
|
||||
`quantity` int(11) UNSIGNED NOT NULL,
|
||||
`id_cart` int(11) unsigned NOT NULL,
|
||||
`id_hotel` int(11) UNSIGNED NOT NULL,
|
||||
`htl_cart_booking_id` int(11) unsigned NOT NULL,
|
||||
`id_service_product_option` int(11) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id_room_type_service_product_cart_detail`),
|
||||
KEY `id_product` (`id_product`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
@@ -409,14 +417,19 @@ class HotelReservationSystemDb
|
||||
`id_order` int(11) NOT NULL,
|
||||
`id_order_detail` int(11) NOT NULL,
|
||||
`id_cart` int(11) NOT NULL,
|
||||
`id_hotel` int(11) NOT NULL,
|
||||
`id_htl_booking_detail` int(11) NOT NULL,
|
||||
`id_service_product_option` int(11) NOT NULL,
|
||||
`unit_price_tax_excl` decimal(20,6) NOT NULL,
|
||||
`unit_price_tax_incl` decimal(20,6) NOT NULL,
|
||||
`total_price_tax_excl` decimal(20,6) NOT NULL,
|
||||
`total_price_tax_incl` decimal(20,6) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`option_name` varchar(255) DEFAULT NULL,
|
||||
`quantity` INT(11) UNSIGNED NOT NULL,
|
||||
`auto_added` tinyint(1) unsigned NOT NULL,
|
||||
`is_refunded` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_cancelled` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_room_type_service_product_order_detail`)
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2020 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* 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 https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2020 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class HotelServiceProductCartDetail extends ObjectModel
|
||||
{
|
||||
public $id_hotel_service_product_cart_detail;
|
||||
public $id_cart;
|
||||
public $id_product;
|
||||
public $id_hotel;
|
||||
public $quantity;
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'htl_hotel_service_product_cart_detail',
|
||||
'primary' => 'id_hotel_service_product_cart_detail',
|
||||
'fields' => array(
|
||||
'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
),
|
||||
);
|
||||
|
||||
public function alreadyExists(
|
||||
$idProduct,
|
||||
$idHotel,
|
||||
$idCart
|
||||
) {
|
||||
return Db::getInstance()->getValue(
|
||||
'SELECT `id_hotel_service_product_cart_detail` FROM `'._DB_PREFIX_.'htl_hotel_service_product_cart_detail`
|
||||
WHERE `id_cart` = '.(int)$idCart.' AND `id_product` = '.(int)$idProduct.' AND `id_hotel` = '.(int)$idHotel
|
||||
);
|
||||
}
|
||||
|
||||
public function addHotelProductInCart(
|
||||
$idProduct,
|
||||
$quantity,
|
||||
$idHotel,
|
||||
$idCart = null
|
||||
) {
|
||||
|
||||
if (!$idCart) {
|
||||
$context = context::getContext();
|
||||
$idCart = $context->cart->id;
|
||||
}
|
||||
if ($idHotelServiceProductCartDetail = $this->alreadyExists($idProduct, $idHotel, $idCart)) {
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail($idHotelServiceProductCartDetail);
|
||||
$objHotelServiceProductCartDetail->quantity += $quantity;
|
||||
} else {
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
$objHotelServiceProductCartDetail->id_product = $idProduct;
|
||||
$objHotelServiceProductCartDetail->quantity = $quantity;
|
||||
$objHotelServiceProductCartDetail->id_hotel = $idHotel;
|
||||
$objHotelServiceProductCartDetail->id_cart = $idCart;
|
||||
|
||||
}
|
||||
if ($objHotelServiceProductCartDetail->save()) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty($quantity, $idProduct);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeProductFromCart($idProduct, $idHotel, $idCart = null, $quantity = null)
|
||||
{
|
||||
if (!$idCart) {
|
||||
$context = context::getContext();
|
||||
$idCart = $context->cart->id;
|
||||
}
|
||||
|
||||
$updateQunatity = false;
|
||||
if ($idHotelServiceProductCartDetail = $this->alreadyExists($idProduct, $idHotel, $idCart)) {
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail($idHotelServiceProductCartDetail);
|
||||
if ($quantity) {
|
||||
$removedQuantity = $quantity;
|
||||
$objHotelServiceProductCartDetail->quantity -= $quantity;
|
||||
if ($objHotelServiceProductCartDetail->quantity) {
|
||||
$updateQunatity = $objHotelServiceProductCartDetail->save();
|
||||
} else {
|
||||
$updateQunatity = $objHotelServiceProductCartDetail->delete();
|
||||
}
|
||||
} else {
|
||||
$removedQuantity = $objHotelServiceProductCartDetail->quantity;
|
||||
$updateQunatity = $objHotelServiceProductCartDetail->delete();
|
||||
}
|
||||
}
|
||||
|
||||
if ($updateQunatity) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty((int)$removedQuantity, $idProduct, null, false, 'down');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getHotelProductUnitPrice(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$idHotel = 0,
|
||||
$useTax = null
|
||||
) {
|
||||
$totalPrice = $totalQuantity = 0;
|
||||
|
||||
if ($useTax === null) {
|
||||
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
|
||||
}
|
||||
$sql = 'SELECT spcd.`id_product`, spcd.`quantity`, spcd.`id_hotel`
|
||||
FROM `'._DB_PREFIX_.'htl_hotel_service_product_cart_detail` spcd
|
||||
WHERE spcd.`id_cart`='.(int) $idCart.' AND spcd.`id_product`='.(int) $idProduct;
|
||||
if ($idHotel) {
|
||||
$sql .= ' AND spcd.`id_hotel`='.(int) $idHotel;
|
||||
}
|
||||
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
|
||||
foreach ($serviceProducts as $product) {
|
||||
$objProduct = new Product($product['id_product']);
|
||||
if (!$objProduct->booking_product) {
|
||||
$idHotelAddress = Cart::getIdAddressForTaxCalculation($idProduct, $product['id_hotel']);
|
||||
$totalQuantity += $product['quantity'] ? (int)$product['quantity'] : 1;
|
||||
$totalPrice += (ProductCore::getPriceStatic(
|
||||
$idProduct,
|
||||
$useTax,
|
||||
null,
|
||||
6,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
$product['quantity'],
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
$idHotelAddress
|
||||
)* $product['quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($totalPrice && $totalQuantity) {
|
||||
return $totalPrice/(int)$totalQuantity;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getHotelProducts(
|
||||
$idCart,
|
||||
$idProduct = 0,
|
||||
$idHotel = 0,
|
||||
$getTotalPrice = 0,
|
||||
$useTax = null,
|
||||
$idLang = null,
|
||||
$full = false
|
||||
) {
|
||||
if ($useTax === null) {
|
||||
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
|
||||
}
|
||||
|
||||
if (!$idLang) {
|
||||
$language = Context::getContext()->language;
|
||||
} else {
|
||||
$language = new Language($idLang);
|
||||
}
|
||||
|
||||
$sql = 'SELECT spcd.`id_product`, spcd.`quantity`, spcd.`id_hotel`';
|
||||
if (!$getTotalPrice) {
|
||||
$sql .= ', hbil.`hotel_name` ';
|
||||
}
|
||||
$sql .= ' FROM `'._DB_PREFIX_.'htl_hotel_service_product_cart_detail` spcd';
|
||||
if (!$getTotalPrice) {
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = spcd.`id_hotel` AND hbil.`id_lang` = '. $language->id.')
|
||||
INNER JOIN `'._DB_PREFIX_.'address` a ON (a.`id_hotel` = spcd.`id_hotel`)';
|
||||
}
|
||||
$sql .= ' WHERE spcd.`id_cart`='.(int) $idCart;
|
||||
|
||||
if ($idProduct) {
|
||||
$sql .= ' AND spcd.`id_product`='.(int) $idProduct;
|
||||
}
|
||||
if ($idHotel) {
|
||||
$sql .= ' AND spcd.`id_hotel`='.(int) $idHotel;
|
||||
}
|
||||
|
||||
if ($getTotalPrice) {
|
||||
$totalPrice = 0;
|
||||
}
|
||||
|
||||
$selectedProducts = array();
|
||||
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
|
||||
foreach ($serviceProducts as $product) {
|
||||
$objProduct = new Product($product['id_product'], false, $language->id);
|
||||
if (!$objProduct->booking_product) {
|
||||
if ($getTotalPrice) {
|
||||
$idHotelAddress = Cart::getIdAddressForTaxCalculation($objProduct->id, $product['id_hotel']);
|
||||
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
|
||||
$totalPrice += Product::getPriceStatic(
|
||||
$objProduct->id,
|
||||
$useTax,
|
||||
null,
|
||||
6,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
$qty,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
$idHotelAddress
|
||||
);
|
||||
} else {
|
||||
$context = Context::getContext();
|
||||
$idHotelAddress = Cart::getIdAddressForTaxCalculation($objProduct->id, $product['id_hotel']);
|
||||
$priceTaxIncl = Product::getPriceStatic(
|
||||
$objProduct->id,
|
||||
true,
|
||||
null,
|
||||
6,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
$product['quantity'],
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
$idHotelAddress
|
||||
);
|
||||
$priceTaxExcl = Product::getPriceStatic(
|
||||
$objProduct->id,
|
||||
false,
|
||||
null,
|
||||
6,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
$product['quantity'],
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
$idHotelAddress
|
||||
);
|
||||
$coverImageArr = $objProduct->getCover($product['id_product']);
|
||||
if (!empty($coverImageArr)) {
|
||||
$coverImg = $context->link->getImageLink(
|
||||
$objProduct->link_rewrite,
|
||||
$objProduct->id.'-'.$coverImageArr['id_image'],
|
||||
'small_default'
|
||||
);
|
||||
} else {
|
||||
$coverImg = $context->link->getImageLink(
|
||||
$objProduct->link_rewrite,
|
||||
$language->iso_code.'-default',
|
||||
'small_default'
|
||||
);
|
||||
}
|
||||
|
||||
$selectedProducts[$product['id_hotel'].'-'.$product['id_product']] = array(
|
||||
'id_hotel' => $product['id_hotel'],
|
||||
'hotel_name' => $product['hotel_name'],
|
||||
'id_product' =>$objProduct->id,
|
||||
'name' => $objProduct->name,
|
||||
'unit_price_tax_incl' => $priceTaxIncl,
|
||||
'unit_price_tax_excl' => $priceTaxExcl,
|
||||
'quantity' => $product['quantity'],
|
||||
'total_price_tax_incl' => $priceTaxIncl * (int)$product['quantity'],
|
||||
'total_price_tax_excl' => $priceTaxExcl * (int)$product['quantity'],
|
||||
'cover_img' => $coverImg
|
||||
);
|
||||
if ($full) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation();
|
||||
$hotelInfo = $objHotelBranchInformation->hotelBranchesInfo($language->id, 2, 1, $product['id_hotel']);
|
||||
$hotelInfo['location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city'].
|
||||
($hotelInfo['state_name']?', '.$hotelInfo['state_name']:'').', '.
|
||||
$hotelInfo['country_name'].', '.$hotelInfo['postcode'];
|
||||
$selectedProducts[$product['id_hotel'].'-'.$product['id_product']]['hotel_info'] = $hotelInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($getTotalPrice) {
|
||||
return $totalPrice;
|
||||
}
|
||||
return $selectedProducts;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,9 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
public $id_product;
|
||||
public $quantity;
|
||||
public $id_cart;
|
||||
public $id_hotel;
|
||||
public $htl_cart_booking_id;
|
||||
public $id_service_product_option;
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'htl_room_type_service_product_cart_detail',
|
||||
@@ -32,57 +34,40 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'htl_cart_booking_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_service_product_option' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
),
|
||||
);
|
||||
|
||||
public function alreadyExists(
|
||||
$idProduct,
|
||||
$idCart,
|
||||
$idHtlCartData
|
||||
$idProduct,
|
||||
$idHtlCartData = false,
|
||||
$idHotel = false,
|
||||
$idServiceProductOption = false
|
||||
) {
|
||||
return Db::getInstance()->getValue(
|
||||
'SELECT `id_room_type_service_product_cart_detail` FROM `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail`
|
||||
WHERE `id_product` = '.(int)$idProduct.' AND `htl_cart_booking_id` = '.(int)$idHtlCartData.'
|
||||
AND `id_cart` = '.(int)$idCart
|
||||
);
|
||||
}
|
||||
|
||||
public function addServiceProductInCart(
|
||||
$idProduct,
|
||||
$quantity,
|
||||
$idCart,
|
||||
$idHtlCartData
|
||||
) {
|
||||
if ($id_room_type_service_product_cart_detail = $this->alreadyExists($idProduct, $idCart, $idHtlCartData)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($id_room_type_service_product_cart_detail);
|
||||
} else {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$objRoomTypeServiceProductCartDetail->id_product = $idProduct;
|
||||
$objRoomTypeServiceProductCartDetail->htl_cart_booking_id = $idHtlCartData;
|
||||
$objRoomTypeServiceProductCartDetail->id_cart = $idCart;
|
||||
$sql = 'SELECT `id_room_type_service_product_cart_detail` FROM `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail`
|
||||
WHERE `id_product` = '.(int)$idProduct.' AND `id_cart` = '.(int)$idCart;
|
||||
|
||||
if ($idHotel) {
|
||||
$sql .= ' AND `id_hotel` = '.(int)$idHotel;
|
||||
}
|
||||
if ($idHtlCartData) {
|
||||
$sql .= ' AND `htl_cart_booking_id` = '.(int)$idHtlCartData;
|
||||
}
|
||||
if ($idServiceProductOption) {
|
||||
$sql .= ' AND `id_service_product_option` = '.(int)$idServiceProductOption;
|
||||
}
|
||||
|
||||
if ($updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity) {
|
||||
$way = $updateQty > 0 ? 'up' : 'down';
|
||||
$objRoomTypeServiceProductCartDetail->quantity += $updateQty;
|
||||
if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$objHotelCartBookingData = new HotelCartBookingData($idHtlCartData);
|
||||
$numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to);
|
||||
$updateQty *= $numdays;
|
||||
}
|
||||
if ($objRoomTypeServiceProductCartDetail->save()) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
public function removeServiceProductByIdHtlCartBooking($htlCartBookingId, $idService = 0)
|
||||
public function removeServiceProductByIdHtlCartBooking(
|
||||
$htlCartBookingId,
|
||||
$idService = 0
|
||||
)
|
||||
{
|
||||
if ($stadardProductsData = Db::getInstance()->executeS(
|
||||
'SELECT * FROM `' . _DB_PREFIX_ . 'htl_room_type_service_product_cart_detail`
|
||||
@@ -493,35 +478,341 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
return $selectedServiceProducts;
|
||||
}
|
||||
|
||||
public function updateCartServiceProduct(
|
||||
$idHtlCartData,
|
||||
$idProduct,
|
||||
$quantity,
|
||||
public function getProducts(
|
||||
$idCart,
|
||||
$operator
|
||||
$idProduct = 0,
|
||||
$serviceProductType = 0,
|
||||
$idHotel = 0,
|
||||
$htlCartBookingId = 0,
|
||||
$idServiceProductOption = null,
|
||||
$roomTypeIdProduct = 0,
|
||||
$getTotalPrice = 0,
|
||||
$useTax = null,
|
||||
$idLang = null,
|
||||
$full = false
|
||||
) {
|
||||
$id_room_type_service_product_cart_detail = $this->alreadyExists($idProduct, $idCart, $idHtlCartData);
|
||||
if ($useTax === null) {
|
||||
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
|
||||
}
|
||||
|
||||
if (!$idLang) {
|
||||
$language = Context::getContext()->language;
|
||||
} else {
|
||||
$language = new Language($idLang);
|
||||
}
|
||||
|
||||
$sql = 'SELECT spc.`id_room_type_service_product_cart_detail`, p.`service_product_type`, spc.`id_cart`, spc.`id_product`, spc.`quantity`, spc.`id_hotel`,
|
||||
spc.`id_service_product_option`';
|
||||
if (!$getTotalPrice) {
|
||||
$sql .= ', hbil.`hotel_name` ';
|
||||
}
|
||||
$sql .= ' FROM `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` spc';
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = spc.`id_product`)';
|
||||
if (!$getTotalPrice) {
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = spc.`id_hotel` AND hbil.`id_lang` = '. $language->id.')';
|
||||
// $sql .= ' INNER JOIN `'._DB_PREFIX_.'address` a ON (a.`id_hotel` = spc.`id_hotel`)';
|
||||
}
|
||||
$sql .= ' WHERE spc.`id_cart`='.(int) $idCart;
|
||||
if ($idServiceProductOption) {
|
||||
$sql .= ' AND spc.`id_service_product_option` = '.(int)$idServiceProductOption;
|
||||
}
|
||||
if ($serviceProductType) {
|
||||
$sql .= ' AND p.`service_product_type` = '.(int)$serviceProductType;
|
||||
}
|
||||
if ($idProduct) {
|
||||
$sql .= ' AND spc.`id_product`='.(int) $idProduct;
|
||||
}
|
||||
if ($idHotel) {
|
||||
$sql .= ' AND spc.`id_hotel`='.(int) $idHotel;
|
||||
}
|
||||
if ($idServiceProductOption) {
|
||||
$sql .= ' AND spc.`id_service_product_option` = '.(int)$idServiceProductOption;
|
||||
}
|
||||
if ($getTotalPrice) {
|
||||
$totalPrice = 0;
|
||||
}
|
||||
|
||||
$selectedProducts = array();
|
||||
$objServiceProductOption = new ServiceProductOption();
|
||||
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
|
||||
foreach ($serviceProducts as $product) {
|
||||
$objProduct = new Product($product['id_product'], false, $language->id);
|
||||
if (!$objProduct->booking_product) {
|
||||
if ($getTotalPrice) {
|
||||
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
|
||||
$totalPrice += RoomTypeServiceProductPrice::getPrice(
|
||||
$objProduct->id,
|
||||
$product['id_hotel'],
|
||||
$product['id_service_product_option'],
|
||||
$useTax,
|
||||
$qty
|
||||
);
|
||||
} else {
|
||||
$context = Context::getContext();
|
||||
$priceTaxIncl = RoomTypeServiceProductPrice::getPrice(
|
||||
$objProduct->id,
|
||||
$product['id_hotel'],
|
||||
$product['id_service_product_option'],
|
||||
true,
|
||||
$product['quantity']
|
||||
);
|
||||
$priceTaxExcl = RoomTypeServiceProductPrice::getPrice(
|
||||
$objProduct->id,
|
||||
$product['id_hotel'],
|
||||
$product['id_service_product_option'],
|
||||
false,
|
||||
$product['quantity']
|
||||
);
|
||||
$optionDetails = false;
|
||||
if (ServiceProductOption::productHasOptions($product['id_product'])) {
|
||||
$optionDetails = $objServiceProductOption->getProductOptions(
|
||||
$objProduct->id,
|
||||
$product['id_service_product_option']
|
||||
);
|
||||
}
|
||||
$coverImageArr = $objProduct->getCover($product['id_product']);
|
||||
if (!empty($coverImageArr)) {
|
||||
$coverImg = $context->link->getImageLink(
|
||||
$objProduct->link_rewrite,
|
||||
$objProduct->id.'-'.$coverImageArr['id_image'],
|
||||
'small_default'
|
||||
);
|
||||
} else {
|
||||
$coverImg = $context->link->getImageLink(
|
||||
$objProduct->link_rewrite,
|
||||
$language->iso_code.'-default',
|
||||
'small_default'
|
||||
);
|
||||
}
|
||||
$productInfo = array(
|
||||
'id_room_type_service_product_cart_detail' => $product['id_room_type_service_product_cart_detail'],
|
||||
'id_cart' => $product['id_cart'],
|
||||
'id_hotel' => $product['id_hotel'],
|
||||
'hotel_name' => $product['hotel_name'],
|
||||
'id_product' =>$objProduct->id,
|
||||
'service_product_type' => $product['service_product_type'],
|
||||
'id_service_product_option' => $product['id_service_product_option'],
|
||||
'name' => $objProduct->name,
|
||||
'option_name' => isset($optionDetails['name']) ? $optionDetails['name'] : false,
|
||||
'minimal_quantity' => $objProduct->minimal_quantity,
|
||||
'allow_multiple_quantity' => $objProduct->allow_multiple_quantity,
|
||||
'max_quantity' => $objProduct->max_quantity,
|
||||
'unit_price_tax_incl' => $priceTaxIncl,
|
||||
'unit_price_tax_excl' => $priceTaxExcl,
|
||||
'quantity' => $product['quantity'],
|
||||
'total_price_tax_incl' => $priceTaxIncl * (int)$product['quantity'],
|
||||
'total_price_tax_excl' => $priceTaxExcl * (int)$product['quantity'],
|
||||
'cover_img' => $coverImg
|
||||
);
|
||||
if ($full) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation();
|
||||
$hotelInfo = $objHotelBranchInformation->hotelBranchesInfo($language->id, 2, 1, $product['id_hotel']);
|
||||
$hotelInfo['location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city'].
|
||||
($hotelInfo['state_name']?', '.$hotelInfo['state_name']:'').', '.
|
||||
$hotelInfo['country_name'].', '.$hotelInfo['postcode'];
|
||||
$productInfo['hotel_info'] = $hotelInfo;
|
||||
}
|
||||
$selectedProducts[] = $productInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($getTotalPrice) {
|
||||
return $totalPrice;
|
||||
}
|
||||
return $selectedProducts;
|
||||
}
|
||||
|
||||
|
||||
public function updateCartServiceProduct(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$operator,
|
||||
$quantity = false,
|
||||
$idHotel = false,
|
||||
$idHtlCartData = false,
|
||||
$idServiceProductOption = null
|
||||
) {
|
||||
if ($operator == 'up') {
|
||||
return $this->addServiceProductInCart(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$quantity,
|
||||
$idCart,
|
||||
$idHtlCartData
|
||||
$idHotel,
|
||||
$idHtlCartData,
|
||||
$idServiceProductOption
|
||||
);
|
||||
} else {
|
||||
return $this->removeCartServiceProduct(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$quantity,
|
||||
$idHotel,
|
||||
$idHtlCartData,
|
||||
$idServiceProductOption
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addServiceProductInCart(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$quantity,
|
||||
$idHotel = false,
|
||||
$idHtlCartData = false,
|
||||
$idServiceProductOption = null
|
||||
) {
|
||||
if ($quantity <= 0) {
|
||||
$quantity = 1;
|
||||
}
|
||||
if ($id_room_type_service_product_cart_detail = $this->alreadyExists(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$idHtlCartData,
|
||||
$idHotel,
|
||||
$idServiceProductOption
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($id_room_type_service_product_cart_detail);
|
||||
} else {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$objRoomTypeServiceProductCartDetail->id_product = $idProduct;
|
||||
$objRoomTypeServiceProductCartDetail->quantity = 0;
|
||||
$objRoomTypeServiceProductCartDetail->id_hotel = $idHotel;
|
||||
$objRoomTypeServiceProductCartDetail->htl_cart_booking_id = $idHtlCartData;
|
||||
$objRoomTypeServiceProductCartDetail->id_cart = $idCart;
|
||||
$objRoomTypeServiceProductCartDetail->id_service_product_option = $idServiceProductOption;
|
||||
}
|
||||
|
||||
if ($idHtlCartData && Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$objHotelCartBookingData = new HotelCartBookingData($idHtlCartData);
|
||||
$numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to);
|
||||
$quantity *= $numdays;
|
||||
}
|
||||
$objRoomTypeServiceProductCartDetail->quantity += $quantity;
|
||||
|
||||
if ($objRoomTypeServiceProductCartDetail->save()) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty($quantity, $idProduct);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeCartServiceProduct(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$quantity = false,
|
||||
$idHotel = false,
|
||||
$idHtlCartData = false,
|
||||
$idServiceProductOption = null
|
||||
) {
|
||||
$updateQunatity = false;
|
||||
$res = true;
|
||||
|
||||
if ($idHtlCartData) {
|
||||
$id_room_type_service_product_cart_detail = $this->alreadyExists($idCart, $idProduct, $idHtlCartData);
|
||||
if ($id_room_type_service_product_cart_detail) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($id_room_type_service_product_cart_detail);
|
||||
$updateQty = $objRoomTypeServiceProductCartDetail->quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, 'down');
|
||||
if ($quantity) {
|
||||
$removedQuantity = $quantity;
|
||||
$objRoomTypeServiceProductCartDetail->quantity -= $quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->quantity) {
|
||||
$updateQunatity = $objRoomTypeServiceProductCartDetail->save();
|
||||
} else {
|
||||
$updateQunatity = $objRoomTypeServiceProductCartDetail->delete();
|
||||
}
|
||||
} else {
|
||||
$removedQuantity = $objRoomTypeServiceProductCartDetail->quantity;
|
||||
$updateQunatity = $objRoomTypeServiceProductCartDetail->delete();
|
||||
}
|
||||
if ($updateQunatity) {
|
||||
$objCart = new Cart($idCart);
|
||||
if (isset(Context::getContext()->controller->controller_type)) {
|
||||
$controllerType = Context::getContext()->controller->controller_type;
|
||||
} else {
|
||||
$controllerType = 'front';
|
||||
}
|
||||
if ($controllerType == 'admin' || $controllerType == 'moduleadmin') {
|
||||
if ($cartQty = Cart::getProductQtyInCart($idCart, $idProduct)) {
|
||||
if ($removedQuantity < $cartQty) {
|
||||
$res = $res && Db::getInstance()->update(
|
||||
'cart_product',
|
||||
array('quantity' => (int)($cartQty - $removedQuantity)),
|
||||
'`id_product` = '.(int)$idProduct.' AND `id_cart` = '.(int)$idCart
|
||||
);
|
||||
} else {
|
||||
//if room type has no qty remaining in cart then delete row
|
||||
$res = $res && Db::getInstance()->delete(
|
||||
'cart_product',
|
||||
'`id_product` = '.(int)$idProduct.' AND `id_cart` = '.(int)$idCart
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$res = $res && $objCart->updateQty((int)$removedQuantity, $idProduct, null, false, 'down');
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($products = $this->getProducts($idCart, $idProduct, 0, $idHotel, 0, $idServiceProductOption, 0, 0, $idHtlCartData)) {
|
||||
foreach ($products as $product) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($product['id_room_type_service_product_cart_detail']);
|
||||
if ($quantity) {
|
||||
$removedQuantity = $quantity;
|
||||
$objRoomTypeServiceProductCartDetail->quantity -= $quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->quantity) {
|
||||
$updateQunatity = $objRoomTypeServiceProductCartDetail->save();
|
||||
} else {
|
||||
$updateQunatity = $objRoomTypeServiceProductCartDetail->delete();
|
||||
}
|
||||
} else {
|
||||
$removedQuantity = $objRoomTypeServiceProductCartDetail->quantity;
|
||||
$updateQunatity = $objRoomTypeServiceProductCartDetail->delete();
|
||||
}
|
||||
if ($updateQunatity) {
|
||||
$objCart = new Cart($idCart);
|
||||
if (isset(Context::getContext()->controller->controller_type)) {
|
||||
$controllerType = Context::getContext()->controller->controller_type;
|
||||
} else {
|
||||
$controllerType = 'front';
|
||||
}
|
||||
if ($controllerType == 'admin' || $controllerType == 'moduleadmin') {
|
||||
if ($cartQty = Cart::getProductQtyInCart($idCart, $idProduct)) {
|
||||
if ($removedQuantity < $cartQty) {
|
||||
$res = $res && Db::getInstance()->update(
|
||||
'cart_product',
|
||||
array('quantity' => (int)($cartQty - $removedQuantity)),
|
||||
'`id_product` = '.(int)$idProduct.' AND `id_cart` = '.(int)$idCart
|
||||
);
|
||||
} else {
|
||||
//if room type has no qty remaining in cart then delete row
|
||||
$res = $res && Db::getInstance()->delete(
|
||||
'cart_product',
|
||||
'`id_product` = '.(int)$idProduct.' AND `id_cart` = '.(int)$idCart
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$res = $res && $objCart->updateQty((int)$removedQuantity, $idProduct, null, false, 'down');
|
||||
}
|
||||
}
|
||||
if ($quantity) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAllServiceProduct($idCart)
|
||||
@@ -541,9 +832,13 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
$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']);
|
||||
if ($serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
|
||||
$context->cart->id,
|
||||
$product['id_product']
|
||||
)) {
|
||||
foreach ($serviceProducts as $serviceProduct) {
|
||||
$objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,19 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
public $id_order;
|
||||
public $id_order_detail;
|
||||
public $id_cart;
|
||||
public $id_hotel;
|
||||
public $id_htl_booking_detail;
|
||||
public $id_service_product_option;
|
||||
public $unit_price_tax_excl;
|
||||
public $unit_price_tax_incl;
|
||||
public $total_price_tax_excl;
|
||||
public $total_price_tax_incl;
|
||||
public $name;
|
||||
public $option_name;
|
||||
public $quantity;
|
||||
public $auto_added;
|
||||
public $is_refunded;
|
||||
public $is_cancelled;
|
||||
public $date_add;
|
||||
public $date_upd;
|
||||
|
||||
@@ -44,14 +49,19 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_order_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_htl_booking_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_htl_booking_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_service_product_option' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'unit_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
|
||||
'unit_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
|
||||
'total_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
|
||||
'total_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
|
||||
'name' => array('type' => self::TYPE_STRING, 'required' => true),
|
||||
'option_name' => array('type' => self::TYPE_STRING),
|
||||
'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
|
||||
'auto_added' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'is_refunded' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'is_cancelled' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
)
|
||||
@@ -309,6 +319,141 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function getProducts($idOrder, $idOrderDetail = 0, $idProduct = 0, $serviceProductType = 0)
|
||||
{
|
||||
$sql = 'SELECT spo.* FROM `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` spo';
|
||||
|
||||
if ($serviceProductType) {
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = spo.`id_order_detail` AND od.`id_order` = '.(int)$idOrder.')';
|
||||
}
|
||||
|
||||
$sql .= ' WHERE 1 AND spo.`id_order` = '.(int)$idOrder;
|
||||
|
||||
if ($idOrderDetail) {
|
||||
$sql .= ' AND spo.`id_order_detail` = '.(int)$idOrderDetail;
|
||||
}
|
||||
|
||||
if ($idProduct) {
|
||||
$sql .= ' AND spo.`id_product` = '.(int)$idProduct;
|
||||
}
|
||||
|
||||
if ($serviceProductType) {
|
||||
$sql .= ' AND od.`product_service_type` = '.(int)$serviceProductType;
|
||||
}
|
||||
|
||||
$products = Db::getInstance()->executeS($sql);
|
||||
foreach ($products as $key => $product) {
|
||||
// Check if this booking as any refund history then enter refund data
|
||||
if ($refundInfo = OrderReturn::getOrdersReturnDetail($idOrder, 0, 0, $product['id_room_type_service_product_order_detail'])) {
|
||||
$products[$key]['refund_info'] = reset($refundInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
||||
public function processRefundInTable()
|
||||
{
|
||||
if (Validate::isLoadedObject($this)) {
|
||||
$reduction_amount = array(
|
||||
'total_price_tax_excl' => 0,
|
||||
'total_price_tax_incl' => 0,
|
||||
'total_products_tax_excl' => 0,
|
||||
'total_products_tax_incl' => 0,
|
||||
);
|
||||
$objOrder = new Order($this->id_order);
|
||||
$orderTotalPaid = $objOrder->getTotalPaid();
|
||||
$orderDiscounts = $objOrder->getCartRules();
|
||||
|
||||
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
|
||||
|
||||
// things to do if order is not paid
|
||||
if (!$hasOrderDiscountOrPayment) {
|
||||
$objHotelBookingDemands = new HotelBookingDemands();
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
|
||||
$reduction_amount['total_price_tax_excl'] = (float) $this->total_price_tax_excl;
|
||||
$reduction_amount['total_products_tax_excl'] = (float) $this->total_price_tax_excl;
|
||||
$reduction_amount['total_price_tax_incl'] = (float) $this->total_price_tax_incl;
|
||||
$reduction_amount['total_products_tax_incl'] = (float) $this->total_price_tax_incl;
|
||||
}
|
||||
|
||||
// enter refunded quantity in the order detail table
|
||||
$idOrderDetail = $this->id_order_detail;
|
||||
if (Validate::isLoadedObject($objOrderDetail = new OrderDetail($idOrderDetail))) {
|
||||
|
||||
$objOrderDetail->product_quantity_refunded += $this->quantity;
|
||||
if ($objOrderDetail->product_quantity_refunded > $objOrderDetail->product_quantity) {
|
||||
$objOrderDetail->product_quantity_refunded = $objOrderDetail->product_quantity;
|
||||
}
|
||||
|
||||
if (!$hasOrderDiscountOrPayment) {
|
||||
// reduce room amount from order and order detail
|
||||
$objOrderDetail->total_price_tax_incl -= Tools::processPriceRounding(
|
||||
$this->total_price_tax_incl,
|
||||
1,
|
||||
$objOrder->round_type,
|
||||
$objOrder->round_mode
|
||||
);
|
||||
|
||||
$objOrderDetail->total_price_tax_excl -= Tools::processPriceRounding(
|
||||
$this->total_price_tax_excl,
|
||||
1,
|
||||
$objOrder->round_type,
|
||||
$objOrder->round_mode
|
||||
);
|
||||
|
||||
if (Validate::isLoadedObject($objOrder = new Order($this->id_order))) {
|
||||
$objOrder->total_paid = Tools::ps_round(
|
||||
($objOrder->total_paid - $reduction_amount['total_price_tax_incl']),
|
||||
_PS_PRICE_COMPUTE_PRECISION_
|
||||
);
|
||||
$objOrder->total_paid = $objOrder->total_paid > 0 ? $objOrder->total_paid : 0;
|
||||
|
||||
$objOrder->total_paid_tax_excl = Tools::ps_round(($objOrder->total_paid_tax_excl - $reduction_amount['total_price_tax_excl']),
|
||||
_PS_PRICE_COMPUTE_PRECISION_
|
||||
);
|
||||
$objOrder->total_paid_tax_excl = $objOrder->total_paid_tax_excl > 0 ? $objOrder->total_paid_tax_excl : 0;
|
||||
|
||||
$objOrder->total_paid_tax_incl = Tools::ps_round(($objOrder->total_paid_tax_incl - $reduction_amount['total_price_tax_incl']),
|
||||
_PS_PRICE_COMPUTE_PRECISION_
|
||||
);
|
||||
$objOrder->total_paid_tax_incl = $objOrder->total_paid_tax_incl > 0 ? $objOrder->total_paid_tax_incl : 0;
|
||||
|
||||
$objOrder->total_products = Tools::ps_round(($objOrder->total_products - $reduction_amount['total_products_tax_excl']),
|
||||
_PS_PRICE_COMPUTE_PRECISION_
|
||||
);
|
||||
$objOrder->total_products = $objOrder->total_products > 0 ? $objOrder->total_products : 0;
|
||||
|
||||
$objOrder->total_products_wt = Tools::ps_round(($objOrder->total_products_wt - $reduction_amount['total_products_tax_incl']),
|
||||
_PS_PRICE_COMPUTE_PRECISION_
|
||||
);
|
||||
$objOrder->total_products_wt = $objOrder->total_products_wt > 0 ? $objOrder->total_products_wt : 0;
|
||||
|
||||
$objOrder->save();
|
||||
}
|
||||
}
|
||||
|
||||
$objOrderDetail->save();
|
||||
}
|
||||
|
||||
// as refund is completed then set the booking as refunded
|
||||
$this->is_refunded = 1;
|
||||
if (!$hasOrderDiscountOrPayment) {
|
||||
// Reduce room amount from htl_booking_detail
|
||||
$this->is_cancelled = 1;
|
||||
$this->total_price_tax_excl = 0;
|
||||
$this->total_price_tax_incl = 0;
|
||||
}
|
||||
|
||||
$this->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
// delete entry from order detail table.
|
||||
|
||||
@@ -101,6 +101,32 @@ class RoomTypeServiceProductPrice extends ObjectModel
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPrice(
|
||||
$idProduct,
|
||||
$idHotel,
|
||||
$idServiceProductOption = null,
|
||||
$useTax = null,
|
||||
$quantity = 1
|
||||
) {
|
||||
$idHotelAddress = Cart::getIdAddressForTaxCalculation($idProduct, $idHotel);
|
||||
$price = ProductCore::getPriceStatic(
|
||||
$idProduct,
|
||||
$useTax,
|
||||
$idServiceProductOption,
|
||||
6,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
$quantity,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
$idHotelAddress,
|
||||
);
|
||||
|
||||
return $price;
|
||||
}
|
||||
|
||||
public function getServicePrice(
|
||||
$idProduct,
|
||||
$idProductRoomType,
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/license/osl-3-0-php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to support@qloapps.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to a newer
|
||||
* versions in the future. If you wish to customize this module for your needs
|
||||
* please refer to https://store.webkul.com/customisation-guidelines for more information.
|
||||
*
|
||||
* @author Webkul IN
|
||||
* @copyright Since 2010 Webkul
|
||||
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
|
||||
*/
|
||||
|
||||
|
||||
class ServiceProductOption extends ObjectModel
|
||||
{
|
||||
public $id_service_product_option;
|
||||
public $id_product;
|
||||
public $name;
|
||||
public $price_impact;
|
||||
public $date_add;
|
||||
public $date_upd;
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'service_product_option',
|
||||
'primary' => 'id_service_product_option',
|
||||
'multilang' => true,
|
||||
'fields' => array(
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'price_impact' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'lang' => true, 'required' => true),
|
||||
)
|
||||
);
|
||||
|
||||
public function addProductOption($idProduct, $names, $priceImpact)
|
||||
{
|
||||
if (!is_array($names)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$objServiceProductOption = new ServiceProductOption();
|
||||
$objServiceProductOption->id_product = $idProduct;
|
||||
$objServiceProductOption->price_impact = $priceImpact;
|
||||
foreach($names as $id_lang => $name) {
|
||||
$objServiceProductOption->name[$id_lang] = $name;
|
||||
}
|
||||
$objServiceProductOption->save();
|
||||
}
|
||||
|
||||
public static function productHasOptions($idProduct, $idServiceProductOption = false)
|
||||
{
|
||||
|
||||
$sql = 'SELECT po.`id_service_product_option`
|
||||
FROM `'._DB_PREFIX_.'service_product_option` po
|
||||
WHERE po.`id_product` = '.(int)$idProduct;
|
||||
if ($idServiceProductOption) {
|
||||
$sql .= ' AND po.`id_service_product_option` = '.(int)$idServiceProductOption;
|
||||
}
|
||||
return (bool)Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
public function getProductOptions($idProduct, $idServiceProductOption = false, $idLang = false)
|
||||
{
|
||||
if (!$idLang) {
|
||||
$idLang = Context::getContext()->language->id;
|
||||
}
|
||||
|
||||
$sql = 'SELECT po.`id_service_product_option`, po.`id_product`, pol.`id_lang`, pol.`name`, po.`price_impact`
|
||||
FROM `'._DB_PREFIX_.'service_product_option` po
|
||||
INNER JOIN `'._DB_PREFIX_.'service_product_option_lang` pol
|
||||
ON (po.`id_service_product_option` = pol.`id_service_product_option`)
|
||||
WHERE po.`id_product` = '.(int)$idProduct.' AND pol.`id_lang` = '.(int)$idLang;
|
||||
|
||||
if ($idServiceProductOption) {
|
||||
$sql .= ' AND po.`id_service_product_option` = '.(int)$idServiceProductOption;
|
||||
return Db::getInstance()->getRow($sql);
|
||||
} else {
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,9 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->createNewCart();
|
||||
if (isset($this->context->cookie->id_cart)) {
|
||||
$objCart = new Cart($this->context->cookie->id_cart);
|
||||
$objCart = new Cart(74);
|
||||
if (Validate::isLoadedObject($objCart) && !$objCart->orderExists()) {
|
||||
$this->context->cart = $objCart;
|
||||
|
||||
@@ -75,7 +75,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
Guest::setNewGuest($this->context->cookie);
|
||||
}
|
||||
|
||||
$this->context->cart = new Cart();
|
||||
$this->context->cart = new Cart(74);
|
||||
$this->context->cart->gift = 0;
|
||||
$this->context->cart->id_shop = (int) $this->context->shop->id;
|
||||
$this->context->cart->id_lang = (($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : (int) Configuration::get('PS_LANG_DEFAULT'));
|
||||
@@ -149,6 +149,12 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
$occupancy = array();
|
||||
}
|
||||
|
||||
// if (Tools::getValue('booking_product')) {
|
||||
// $booking_product = Tools::getValue('booking_product');
|
||||
// } else {
|
||||
// $booking_product = 1;
|
||||
// }
|
||||
|
||||
$this->id_cart = (int) $this->context->cart->id;
|
||||
$this->id_guest = (int) $this->context->cookie->id_guest;
|
||||
$this->id_hotel = $id_hotel;
|
||||
@@ -393,7 +399,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
'id_guest' => $this->id_guest,
|
||||
);
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
|
||||
if ($cartProducts = $this->context->cart->getProducts()) {
|
||||
if ($cart_bdata = $objHotelCartBookingData->getCartFormatedBookinInfoByIdCart(
|
||||
@@ -401,7 +407,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
)) {
|
||||
$smartyVars['cart_bdata'] = $cart_bdata;
|
||||
}
|
||||
if ($normalCartProduct = $objHotelServiceProductCartDetail->getHotelProducts($this->context->cart->id)) {
|
||||
if ($normalCartProduct = $objRoomTypeServiceProductCartDetail->getProducts($this->context->cart->id)) {
|
||||
$smartyVars['cart_normal_data'] = $normalCartProduct;
|
||||
}
|
||||
}
|
||||
@@ -596,17 +602,19 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
);
|
||||
$id_product = Tools::getValue('id_product');
|
||||
$quantity = Tools::getValue('qty', 1);
|
||||
$id_cart = $this->context->cart->id;
|
||||
$id_hotel = Tools::getValue('id_hotel');
|
||||
$opt = Tools::getValue('opt', 1);
|
||||
|
||||
if (!Validate::isLoadedObject($this->context->cart)) {
|
||||
$this->createNewCart();
|
||||
}
|
||||
$id_cart = $this->context->cart->id;
|
||||
if ($opt) {
|
||||
// validation for adding product in cart
|
||||
$product = new Product($id_product, true, $this->context->language->id);
|
||||
if (!$product->id || !$product->active) {
|
||||
$this->errors[] = $this->l('This product is no longer available.');
|
||||
}
|
||||
if ($product->booking_product || ($product->service_product_type != Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE)) {
|
||||
if ($product->booking_product || ($product->service_product_type != Product::SERVICE_PRODUCT_STANDALONE)) {
|
||||
// cannot be added without room type or is a booking product.
|
||||
$this->errors[] = $this->l('This product is either a room type or additional service and cannot be added thorugh this method.');
|
||||
} elseif (!$product->allow_multiple_quantity) {
|
||||
@@ -628,16 +636,16 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
|
||||
if (empty($this->errors)) {
|
||||
if ($opt) {
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
if ($objHotelServiceProductCartDetail->addHotelProductInCart($product->id, $quantity, $id_hotel)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($objRoomTypeServiceProductCartDetail->addServiceProductInCart($id_cart, $product->id, $quantity, $id_hotel, $quantity)) {
|
||||
$response = array(
|
||||
'status' => true,
|
||||
'total_amount' => $this->context->cart->getOrderTotal()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
if ($objHotelServiceProductCartDetail->removeProductFromCart($id_product, $id_hotel)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($objRoomTypeServiceProductCartDetail->removeCartServiceProduct($id_cart, $id_product, false, $id_hotel)) {
|
||||
$response = array(
|
||||
'status' => true,
|
||||
'total_amount' => $this->context->cart->getOrderTotal()
|
||||
@@ -778,7 +786,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
public function assignServiceProductsForm()
|
||||
{
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts(null, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
$serviceProducts = $objProduct->getServiceProducts(null, Product::SERVICE_PRODUCT_STANDALONE);
|
||||
$hotelAddressInfo = HotelBranchInformation::getAddress($this->id_hotel);
|
||||
$serviceProducts = Product::getProductsProperties($this->context->language->id, $serviceProducts);
|
||||
$this->context->smarty->assign(array(
|
||||
@@ -954,7 +962,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
'ALLOTMENT_AUTO' => HotelBookingDetail::ALLOTMENT_AUTO,
|
||||
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
|
||||
'SERVICE_PRODUCT_WITH_ROOMTYPE' => Product::SERVICE_PRODUCT_WITH_ROOMTYPE,
|
||||
'SERVICE_PRODUCT_WITHOUT_ROOMTYPE' => Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE,
|
||||
'SERVICE_PRODUCT_STANDALONE' => Product::SERVICE_PRODUCT_STANDALONE,
|
||||
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
|
||||
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
|
||||
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
|
||||
|
||||
@@ -216,6 +216,10 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
if ($refundReqProducts = $objOrderReturn->getOrderRefundRequestedProducts($objOrderReturn->id_order, $objOrderReturn->id)){
|
||||
}
|
||||
|
||||
|
||||
$paymentMethods = array();
|
||||
foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
|
||||
$module = Module::getInstanceByName($payment['name']);
|
||||
@@ -235,6 +239,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
'customer_email' => $objCustomer->email,
|
||||
'orderReturnInfo' => (array)$objOrderReturn,
|
||||
'refundReqBookings' => $refundReqBookings,
|
||||
'refundReqProducts' => $refundReqProducts,
|
||||
'orderInfo' => (array) $objOrder,
|
||||
'orderCurrency' => (array) $orderCurrency,
|
||||
'currentOrderStateInfo' => (array) new OrderState($objOrder->current_state,
|
||||
@@ -352,17 +357,21 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
foreach ($idsReturnDetail as $idRetDetail) {
|
||||
$objOrderReturnDetail = new OrderReturnDetail($idRetDetail);
|
||||
// set booking as refunded if return state is refunded/denied
|
||||
$idHtlBooking = $objOrderReturnDetail->id_htl_booking;
|
||||
$reduction_amount = array(
|
||||
'total_price_tax_excl' => 0,
|
||||
'total_price_tax_incl' => 0,
|
||||
'total_products_tax_excl' => 0,
|
||||
'total_products_tax_incl' => 0,
|
||||
);
|
||||
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
// perform booking refund processes in the booking tables
|
||||
$objHtlBooking->processRefundInBookingTables();
|
||||
if ($idHtlBooking = $objOrderReturnDetail->id_htl_booking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
// perform booking refund processes in the booking tables
|
||||
$objHtlBooking->processRefundInBookingTables();
|
||||
} elseif ($id_room_type_service_product_order_detail = $objOrderReturnDetail->id_room_type_service_product_order_detail) {
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($id_room_type_service_product_order_detail);
|
||||
// perform booking refund processes in the service product order tables
|
||||
$objRoomTypeServiceProductOrderDetail->processRefundInTable();
|
||||
}
|
||||
|
||||
// save individual booking amount for every booking refund
|
||||
$refundedAmount = $refundedAmounts[$idRetDetail];
|
||||
@@ -375,22 +384,34 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
$totalRefundedAmount += $refundedAmount;
|
||||
|
||||
if (Tools::isSubmit('generateCreditSlip')) {
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
if ($idHtlBooking = $objOrderReturnDetail->id_htl_booking) {
|
||||
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$idOrderDetail = $objHtlBooking->id_order_detail;
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
|
||||
$bookingList[$idHtlBooking] = array(
|
||||
'id_htl_booking' => $idHtlBooking,
|
||||
'id_order_detail' => $idOrderDetail,
|
||||
'quantity' => $numDays,
|
||||
'num_days' => $numDays,
|
||||
'unit_price' => $refundedAmount / $numDays,
|
||||
'amount' => $refundedAmount,
|
||||
);
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$idOrderDetail = $objHtlBooking->id_order_detail;
|
||||
|
||||
$bookingList[$idHtlBooking] = array(
|
||||
'id_htl_booking' => $idHtlBooking,
|
||||
'id_order_detail' => $idOrderDetail,
|
||||
'quantity' => $numDays,
|
||||
'num_days' => $numDays,
|
||||
'unit_price' => $refundedAmount / $numDays,
|
||||
'amount' => $refundedAmount,
|
||||
);
|
||||
} elseif ($id_room_type_service_product_order_detail = $objOrderReturnDetail->id_room_type_service_product_order_detail) {
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($id_room_type_service_product_order_detail);
|
||||
$bookingList[$idHtlBooking] = array(
|
||||
'id_room_type_service_product_order_detail' => $id_room_type_service_product_order_detail,
|
||||
'id_order_detail' => $objRoomTypeServiceProductOrderDetail->id_order_detail,
|
||||
'quantity' => $objRoomTypeServiceProductOrderDetail->quantity,
|
||||
'unit_price' => $refundedAmount / $objRoomTypeServiceProductOrderDetail->quantity,
|
||||
'amount' => $refundedAmount,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ require_once 'classes/RoomTypeServiceProduct.php';
|
||||
require_once 'classes/RoomTypeServiceProductPrice.php';
|
||||
require_once 'classes/RoomTypeServiceProductCartDetail.php';
|
||||
require_once 'classes/RoomTypeServiceProductOrderDetail.php';
|
||||
require_once 'classes/HotelServiceProductCartDetail.php';
|
||||
require_once 'classes/ServiceProductOption.php';
|
||||
|
||||
|
||||
require_once 'classes/HotelSettingsLink.php';
|
||||
|
||||
@@ -221,6 +221,75 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($refundReqProducts) && $refundReqProducts}
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<label for="id_refund_state" class="control-label">
|
||||
<p><span title="" data-toggle="tooltip" class="label-tooltip" data-original-title='{l s="List of product requested for refund by the customer." mod='hotelreservationsystem'}'><strong>{l s="Products requested for refund" mod='hotelreservationsystem'}</strong></span> :
|
||||
</p>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<table class="table" id="rooms_refund_info">
|
||||
<tr>
|
||||
{if !$isRefundCompleted}
|
||||
<th></th>
|
||||
{/if}
|
||||
<th>{l s='Name' mod='hotelreservationsystem'}</th>
|
||||
<th>{l s='Quantity' mod='hotelreservationsystem'}</th>
|
||||
<th>{l s='Total cost (tax incl.)' mod='hotelreservationsystem'}</th>
|
||||
<th>{l s='Total paid amount (tax incl.)' mod='hotelreservationsystem'}</th>
|
||||
|
||||
{if $hasOrderDiscountOrPayment || $isRefundCompleted}
|
||||
<th>{l s='Refund amount' mod='hotelreservationsystem'}</th>
|
||||
|
||||
{if $isRefundCompleted}
|
||||
<th>{l s='Refund status' mod='hotelreservationsystem'}</th>
|
||||
{/if}
|
||||
{/if}
|
||||
</tr>
|
||||
{foreach $refundReqProducts as $product}
|
||||
<tr>
|
||||
{if !$isRefundCompleted}
|
||||
<td><input type="checkbox" name="id_order_return_detail[]" value="{$product['id_order_return_detail']|escape:'html':'UTF-8'}" checked/></td>
|
||||
{/if}
|
||||
<td>{$product['name']|escape:'htmlall':'UTF-8'}{if isset($product['option_name']) && $product['option_name']} : {$product['option_name']|escape:'htmlall':'UTF-8'}{/if}</td>
|
||||
<td>{$product['quantity']|escape:'htmlall':'UTF-8'}</td>
|
||||
<td>{displayPrice price=$product['total_price_tax_incl'] currency=$orderCurrency['id']}</td>
|
||||
<td>{displayPrice price=$product['paid_amount'] currency=$orderCurrency['id']}</td>
|
||||
{if $hasOrderDiscountOrPayment || $isRefundCompleted}
|
||||
<td>
|
||||
<div class="input-group">
|
||||
{if $isRefundCompleted}
|
||||
{displayPrice price=$product['refunded_amount'] currency=$orderCurrency['id']}
|
||||
{else}
|
||||
<span class="input-group-addon">{$orderCurrency['sign']|escape:'html':'UTF-8'}</span>
|
||||
<input placeholder="" type="text" name="refund_amounts[{$product['id_order_return_detail']|escape:'html':'UTF-8'}]" value="0">
|
||||
<span class="input-group-addon">{l s='tax incl.' mod='hotelreservationsystem'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
{if $isRefundCompleted}
|
||||
<td>
|
||||
{if $product['is_cancelled']}
|
||||
<span class="badge badge-danger">{l s='Cancelled' mod='hotelreservationsystem'}</span>
|
||||
{* used id_customization to check if in this request which bookings are refunded or not*}
|
||||
{else if $product['id_customization']}
|
||||
<span class="badge badge-success">{l s='Refunded' mod='hotelreservationsystem'}</span>
|
||||
{else}
|
||||
<span class="badge badge-danger">{l s='Denied' mod='hotelreservationsystem'}</span>
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<br>
|
||||
|
||||
{if $isRefundCompleted}
|
||||
|
||||
@@ -126,17 +126,20 @@ class QloHotelReview extends Module
|
||||
{
|
||||
if (Tools::getValue('controller') == 'product') {
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
|
||||
$idHotel = $roomTypeInfo['id_hotel'];
|
||||
$reviewImages = QhrHotelReview::getAllImages($idHotel);
|
||||
|
||||
Media::addJsDef(array('qlo_hotel_review_js_vars' => array(
|
||||
$qlo_hotel_review_js_vars = array(
|
||||
'review_ajax_link' => $this->context->link->getModuleLink($this->name),
|
||||
'review_ajax_token' => $this->secure_key,
|
||||
'raty_img_path' => $this->getPathUri().'views/img/raty',
|
||||
'review_images' => $reviewImages,
|
||||
)));
|
||||
);
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct)) {
|
||||
$idHotel = $roomTypeInfo['id_hotel'];
|
||||
$reviewImages = QhrHotelReview::getAllImages($idHotel);
|
||||
$qlo_hotel_review_js_vars['review_images'] = $reviewImages;
|
||||
|
||||
}
|
||||
Media::addJsDef(array('qlo_hotel_review_js_vars' => $qlo_hotel_review_js_vars));
|
||||
|
||||
|
||||
$this->context->controller->addCSS(_PS_JS_DIR_.'raty/jquery.raty.css');
|
||||
$this->context->controller->addJS(_PS_JS_DIR_.'raty/jquery.raty.js');
|
||||
@@ -215,17 +218,19 @@ class QloHotelReview extends Module
|
||||
|
||||
public function hookDisplayRoomTypeDetailRoomTypeNameAfter($params)
|
||||
{
|
||||
$idProduct = $params['id_product'];
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
|
||||
$idHotel = $roomTypeInfo['id_hotel'];
|
||||
$this->smarty->assign(array(
|
||||
'num_reviews' => QhrHotelReview::getReviewCountByIdHotel($idHotel),
|
||||
'avg_rating' => QhrHotelReview::getAverageRatingByIdHotel($idHotel),
|
||||
'ratting_img_path' => _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png',
|
||||
));
|
||||
if ($params['product']->booking_product) {
|
||||
$idProduct = $params['id_product'];
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
|
||||
$idHotel = $roomTypeInfo['id_hotel'];
|
||||
$this->smarty->assign(array(
|
||||
'num_reviews' => QhrHotelReview::getReviewCountByIdHotel($idHotel),
|
||||
'avg_rating' => QhrHotelReview::getAverageRatingByIdHotel($idHotel),
|
||||
'ratting_img_path' => _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png',
|
||||
));
|
||||
|
||||
return $this->display(__FILE__, 'room-type-name-after.tpl');
|
||||
return $this->display(__FILE__, 'room-type-name-after.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function hookActionRoomBookingStatusUpdateAfter($params)
|
||||
@@ -236,48 +241,51 @@ class QloHotelReview extends Module
|
||||
}
|
||||
}
|
||||
|
||||
public function hookDisplayProductTab()
|
||||
public function hookDisplayProductTab($params)
|
||||
{
|
||||
return $this->display(__FILE__, 'product-tab.tpl');
|
||||
if ($params['product']->booking_product) {
|
||||
return $this->display(__FILE__, 'product-tab.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function hookDisplayProductTabContent()
|
||||
public function hookDisplayProductTabContent($params)
|
||||
{
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
|
||||
$idHotel = $roomTypeInfo['id_hotel'];
|
||||
$reviewsAtOnce = (int) Configuration::get('QHR_REVIEWS_AT_ONCE');
|
||||
$reviews = QhrHotelReview::getByHotel(
|
||||
$idHotel,
|
||||
1,
|
||||
$reviewsAtOnce,
|
||||
QhrHotelReview::QHR_SORT_BY_TIME_NEW,
|
||||
$this->context->cookie->id_customer
|
||||
);
|
||||
if ($params['product']->booking_product) {
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$reviewsAtOnce = (int) Configuration::get('QHR_REVIEWS_AT_ONCE');
|
||||
if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct)) {
|
||||
$idHotel = $roomTypeInfo['id_hotel'];
|
||||
$reviews = QhrHotelReview::getByHotel(
|
||||
$idHotel,
|
||||
1,
|
||||
$reviewsAtOnce,
|
||||
QhrHotelReview::QHR_SORT_BY_TIME_NEW,
|
||||
$this->context->cookie->id_customer
|
||||
);
|
||||
if (is_array($reviews) && count($reviews)) {
|
||||
foreach ($reviews as &$review) {
|
||||
$review['images'] = QhrHotelReview::getImagesById($review['id_hotel_review']);
|
||||
}
|
||||
}
|
||||
$summary = QhrHotelReview::getSummaryByHotel($idHotel);
|
||||
if (is_array($summary['categories']) && count($summary['categories'])) {
|
||||
$summary = QhrHotelReviewHelper::prepareCategoriesData($summary);
|
||||
}
|
||||
|
||||
if (is_array($reviews) && count($reviews)) {
|
||||
foreach ($reviews as &$review) {
|
||||
$review['images'] = QhrHotelReview::getImagesById($review['id_hotel_review']);
|
||||
$hasNextPage = QhrHotelReview::hasNextPage($idHotel, 1, $reviewsAtOnce);
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'id_hotel' => $idHotel,
|
||||
'reviews' => $reviews,
|
||||
'summary' => $summary,
|
||||
'images' => QhrHotelReview::getAllImages($idHotel),
|
||||
'logged' => $this->context->customer->isLogged(true),
|
||||
'show_load_more_btn' => $hasNextPage,
|
||||
));
|
||||
return $this->display(__FILE__, 'product-tab-content.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
$summary = QhrHotelReview::getSummaryByHotel($idHotel);
|
||||
if (is_array($summary['categories']) && count($summary['categories'])) {
|
||||
$summary = QhrHotelReviewHelper::prepareCategoriesData($summary);
|
||||
}
|
||||
|
||||
$hasNextPage = QhrHotelReview::hasNextPage($idHotel, 1, $reviewsAtOnce);
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'id_hotel' => $idHotel,
|
||||
'reviews' => $reviews,
|
||||
'summary' => $summary,
|
||||
'images' => QhrHotelReview::getAllImages($idHotel),
|
||||
'logged' => $this->context->customer->isLogged(true),
|
||||
'show_load_more_btn' => $hasNextPage,
|
||||
));
|
||||
return $this->display(__FILE__, 'product-tab-content.tpl');
|
||||
}
|
||||
|
||||
public function hookActionCleanData($params)
|
||||
|
||||
Reference in New Issue
Block a user