Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
</td>
<td>{displayWtPriceWithCurrency price=$room['feature_price_tax_excl'] currency=$currency}</td>
<td>
{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'])}
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands_{$room['id']}">
{displayWtPriceWithCurrency price=($room['demand_price'] + $room['additional_service_price'] + $room['additional_services_auto_add_price'])|escape:'html':'UTF-8' currency=$currency}
</a>
Expand All @@ -118,7 +118,7 @@
{/if}
</td>
<td class="text-right">
{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}
Expand Down Expand Up @@ -166,7 +166,13 @@
</div>
</div>
<div class="col-xs-6">
<p><span class="pull-right extra_demand_option_price">{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}</span></p>
<p><span class="pull-right extra_demand_option_price">
{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}
</span></p>
</div>
</div>
{/if}
Expand Down
30 changes: 22 additions & 8 deletions controllers/admin/AdminCartsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,25 +302,39 @@ public function renderView()
$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') : '--');
}

$helper = new HelperKpi();
$helper->id = 'box-kpi-cart';
$helper->icon = 'icon-shopping-cart';
$helper->color = 'color1';
$helper->title = $this->l('Total Cart', null, null, false);
$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']);
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';
$helper->color = 'color1';
$helper->title = $this->l('Total Cart', null, null, false);
$helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
$helper->value = Tools::displayPrice($total_price, $currency);
$kpi = $helper->generate();
//end
$this->tpl_view_vars = array(
'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data
Expand Down
73 changes: 58 additions & 15 deletions controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5454,6 +5454,15 @@ public function ajaxProcessDeleteRoomLine()
$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;*/
Expand Down Expand Up @@ -5488,6 +5497,7 @@ public function ajaxProcessDeleteRoomLine()
$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']);

Expand All @@ -5508,6 +5518,21 @@ public function ajaxProcessDeleteRoomLine()
// 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*/

Expand Down Expand Up @@ -5586,7 +5611,9 @@ public function ajaxProcessDeleteRoomLine()
$objBookingDetail->id_product,
$objBookingDetail->id_room,
$objBookingDetail->date_from,
$objBookingDetail->date_to
$objBookingDetail->date_to,
1,
$objBookingDetail->id_order
);

$objBookingDetail->delete();
Expand Down Expand Up @@ -6148,24 +6175,17 @@ public function ajaxProcessDeleteRoomProcess()
$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';
}
Expand Down Expand Up @@ -6506,8 +6526,31 @@ public function ajaxProcessDeleteRoomAdditionalService()
$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();
Expand Down Expand Up @@ -6705,12 +6748,12 @@ public function ajaxProcessAddRoomAdditionalServices()
$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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ public function deleteCartBookingData(
$idRoom = 0,
$dateFrom = 0,
$dateTo = 0,
$updPsCart = 1
$updPsCart = 1,
$idOrder = 0
) {
$where = '1';
if ($idCart) {
Expand All @@ -364,8 +365,8 @@ public function deleteCartBookingData(
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function getServiceProductsInCart(

$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`,
Expand All @@ -233,7 +233,8 @@ public function getServiceProductsInCart(
$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;
Expand Down Expand Up @@ -334,6 +335,7 @@ public function getServiceProductsInCart(
'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'],
Expand Down Expand Up @@ -449,6 +451,7 @@ public function getServiceProductsInCart(
'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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public function getSelectedServicesForRoom(
'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'],
Expand All @@ -280,6 +281,7 @@ public function getSelectedServicesForRoom(
'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'],
Expand Down Expand Up @@ -323,4 +325,4 @@ public function delete()
// delete entry from order detail table.
return parent::delete();
}
}
}