Fixed: issues in testing
This commit is contained in:
@@ -1636,25 +1636,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.change_room_type_service_product', function() {
|
||||
updateServiceProducts(this);
|
||||
});
|
||||
|
||||
// when the price of a service product is changed and focus is out
|
||||
$(document).on('change', '#room_type_services_desc .service_cart_price_input', function() {
|
||||
updateServiceProducts(this);
|
||||
});
|
||||
|
||||
$(document).on('change', '#rooms_type_extra_demands .qty', function(e) {
|
||||
var qty_wntd = $(this).val();
|
||||
if (qty_wntd == '' || !$.isNumeric(qty_wntd)) {
|
||||
$(this).val(1);
|
||||
}
|
||||
if ($(this).closest('.room_demand_block').find('.change_room_type_service_product').is(':checked')) {
|
||||
updateServiceProducts($(this).closest('.room_demand_block').find('.change_room_type_service_product'));
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('keyup', '#payment_module_name', function() {
|
||||
let paymentMethod = $('#payment_module_name').val().trim().toLowerCase();
|
||||
|
||||
@@ -1782,49 +1763,54 @@
|
||||
});
|
||||
});
|
||||
|
||||
function updateServiceProducts(element)
|
||||
{
|
||||
var qty = $(element).closest('.room_demand_block').find('input.qty').val();
|
||||
var dataElement = $(element).closest('.room_demand_block').find('.change_room_type_service_product');
|
||||
var operator = $(dataElement).is(':checked') ? 'up' : 'down';
|
||||
var id_product = $(dataElement).val();
|
||||
var id_cart_booking = $(dataElement).data('id_cart_booking');
|
||||
var service_price = $("#service_cart_price_"+id_cart_booking+"_"+id_product).val();
|
||||
|
||||
if (typeof(qty) == 'undefined') {
|
||||
qty = 1;
|
||||
}
|
||||
$(document).on('click', '.change_room_type_service_product', function() {
|
||||
if ($(this).prop('checked')) {
|
||||
$("#selected_service_product_"+$(this).val()).val(1);
|
||||
} else {
|
||||
$("#selected_service_product_"+$(this).val()).val(0);
|
||||
}
|
||||
});
|
||||
$(document).on('submit', '#update_selected_room_services_form', function(e) {
|
||||
e.preventDefault();
|
||||
var form_data = new FormData(this);
|
||||
form_data.append('ajax', true);
|
||||
form_data.append('action', 'updateSelectedRoomServices');
|
||||
|
||||
$(".loading_overlay").show();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: {
|
||||
"cache-control": "no-cache"
|
||||
},
|
||||
url: "{$link->getAdminLink('AdminCarts')|addslashes}",
|
||||
dataType: 'JSON',
|
||||
cache: false,
|
||||
data: {
|
||||
operator: operator,
|
||||
id_product: id_product,
|
||||
id_cart_booking: id_cart_booking,
|
||||
qty: qty,
|
||||
price: service_price,
|
||||
action: 'updateServiceProduct',
|
||||
ajax: true
|
||||
},
|
||||
success: function(jsonData) {
|
||||
if (!jsonData.hasError) {
|
||||
showSuccessMessage(txtExtraDemandSucc);
|
||||
} else {
|
||||
showErrorMessage(jsonData.errors);
|
||||
}
|
||||
},
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: {
|
||||
"cache-control": "no-cache"
|
||||
},
|
||||
url: "{$link->getAdminLink('AdminCarts')|addslashes}",
|
||||
dataType: 'JSON',
|
||||
cache: false,
|
||||
data: form_data,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(jsonData) {
|
||||
if (!jsonData.hasError) {
|
||||
if (jsonData.service_panel) {
|
||||
$('#room_type_service_product_desc').replaceWith(jsonData.service_panel);
|
||||
}
|
||||
showSuccessMessage(txtExtraDemandSucc);
|
||||
} else {
|
||||
if (jsonData.errors != 'undefined' && jsonData.errors.length) {
|
||||
var errorHtml = error_found_txt + ':<br>';
|
||||
errorHtml += '<ol>';
|
||||
$.each(jsonData.errors, function(key, errorMsg) {
|
||||
errorHtml += '<li>' + errorMsg + '</li>';
|
||||
});
|
||||
errorHtml += '</ol>';
|
||||
showErrorMessage(errorHtml);
|
||||
}
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
$(".loading_overlay").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -31,62 +31,71 @@
|
||||
<div class="row room_demands_container">
|
||||
<div class="col-sm-12 room_demand_detail">
|
||||
{if isset($serviceProducts) && $serviceProducts}
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>{l s='Name'}</th>
|
||||
<th class="fixed-width-sm"></th>
|
||||
<th class="fixed-width-sm">{l s='Quantity'}</th>
|
||||
<th>{l s='Unit Price (tax excl.)'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $serviceProducts as $product}
|
||||
<tr class="room_demand_block">
|
||||
<td>
|
||||
<input data-id_cart_booking="{$selectedRoomServiceProduct['id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}checked{/if}/>
|
||||
</td>
|
||||
<td>
|
||||
<p>{$product['name']|escape:'html':'UTF-8'}</p>
|
||||
</td>
|
||||
<td>
|
||||
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
|
||||
<span class="badge badge-info label">{l s='Convenience fee'}</span>
|
||||
{/if}
|
||||
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
|
||||
<span class="badge badge-info label">{l s='Auto added'}</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{if $product.allow_multiple_quantity}
|
||||
<div class="qty_container">
|
||||
<input type="number" class="form-control room_type_service_product_qty qty" id="qty_{$product.id_product}" name="service_product_qty_{$product.id_product}" data-id-product="{$product.id_product}" min="1" data-max-quantity="{$product.max_quantity}" value="{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}{$selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity']}{else}1{/if}">
|
||||
<p style="display:{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity'] > $product.max_quantity}block{else}none{/if}; margin-top: 4px;">
|
||||
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$product.max_quantity}</span>
|
||||
</p>
|
||||
</div>
|
||||
{else}
|
||||
--
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)}
|
||||
<div id="service_cart_price_{$selectedRoomServiceProduct['id']}_{$product['id_product']}_input" class="input-group">
|
||||
<span class="input-group-addon">
|
||||
{$cartCurrency->sign}
|
||||
</span>
|
||||
<input class="service_cart_price_input" id="service_cart_price_{$selectedRoomServiceProduct['id']}_{$product['id_product']}" type="text" value="{$product.price_tax_exc}"/>
|
||||
{if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']}
|
||||
<span class="input-group-addon">{l s='/ night'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
<form id="update_selected_room_services_form">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>{l s='Name'}</th>
|
||||
<th class="fixed-width-sm"></th>
|
||||
<th class="fixed-width-sm">{l s='Quantity'}</th>
|
||||
<th>{l s='Unit Price (tax excl.)'}</th>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $serviceProducts as $product}
|
||||
<tr class="room_demand_block">
|
||||
<td>
|
||||
<input data-id_cart_booking="{$selectedRoomServiceProduct['id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}checked{/if}/>
|
||||
|
||||
<input id="selected_service_product_{$product['id_product']}" type="hidden" value="{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}1{else}0{/if}" name="selected_service_product[{$product.id_product}]"/>
|
||||
</td>
|
||||
<td>
|
||||
<p>{$product['name']|escape:'html':'UTF-8'}</p>
|
||||
</td>
|
||||
<td>
|
||||
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
|
||||
<span class="badge badge-info label">{l s='Convenience fee'}</span>
|
||||
{/if}
|
||||
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
|
||||
<span class="badge badge-info label">{l s='Auto added'}</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{if $product.allow_multiple_quantity}
|
||||
<div class="qty_container">
|
||||
<input type="number" class="form-control room_type_service_product_qty qty" id="qty_{$product.id_product}" name="service_qty[{$product.id_product}]" data-id-product="{$product.id_product}" min="1" data-max-quantity="{$product.max_quantity}" value="{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}{$selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity']}{else}1{/if}" name="service_qty[{$product['id_product']|escape:'html':'UTF-8'}]">
|
||||
|
||||
<p style="display:{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity'] > $product.max_quantity}block{else}none{/if}; margin-top: 4px;">
|
||||
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$product.max_quantity}</span>
|
||||
</p>
|
||||
</div>
|
||||
{else}
|
||||
--
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)}
|
||||
<div id="service_cart_price_{$selectedRoomServiceProduct['id']}_{$product['id_product']}_input" class="input-group">
|
||||
<span class="input-group-addon">
|
||||
{$cartCurrency->sign}
|
||||
</span>
|
||||
<input class="service_cart_price_input" id="service_cart_price_{$selectedRoomServiceProduct['id']}_{$product['id_product']}" type="text" value="{$product.price_tax_exc}" name="service_price[{$product['id_product']|escape:'html':'UTF-8'}]"/>
|
||||
{if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']}
|
||||
<span class="input-group-addon">{l s='/ night'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" name="id_hotel_cart_booking" value="{$id_hotel_cart_booking}">
|
||||
<div class="modal-footer">
|
||||
<button type="submit" id="update_selected_services" class="btn btn-primary"><i class="icon icon-save"></i> {l s="Update Services"}</button>
|
||||
</div>
|
||||
</form>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1110,7 +1110,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
|
||||
@@ -1256,7 +1256,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
{
|
||||
$response = array('hasError' => false);
|
||||
// Check tab access is allowed to edit
|
||||
if ($this->tabAccess['edit'] == 1) {
|
||||
if ($this->tabAccess['add'] == 1) {
|
||||
if (Configuration::get('PS_ALLOW_CREATE_CUSTOM_SERVICES_IN_BOOKING')) {
|
||||
$idHotelCartBooking = Tools::getValue('id_hotel_cart_booking');
|
||||
// valiadate services being added
|
||||
@@ -1330,7 +1330,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
$objServiceProduct->show_at_front = false;
|
||||
$objServiceProduct->indexed = false;
|
||||
$objServiceProduct->minimal_quantity = 1;
|
||||
$objServiceProduct->active = false;
|
||||
$objServiceProduct->active = true;
|
||||
$objServiceProduct->max_quantity = 99999;
|
||||
|
||||
// ======= Create Service product END =========
|
||||
@@ -1392,7 +1392,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function getBookingServicesTabContent($idHotelCartBooking)
|
||||
@@ -1402,7 +1402,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($objCartBookingData->id_product, 1, 0, false, 2, null);
|
||||
@@ -1455,111 +1455,127 @@ class AdminCartsControllerCore extends AdminController
|
||||
return $servicesTpl;
|
||||
}
|
||||
|
||||
|
||||
public function ajaxProcessUpdateServiceProduct()
|
||||
// Process to update selected services
|
||||
public function ajaxProcessUpdateSelectedRoomServices()
|
||||
{
|
||||
$operator = Tools::getValue('operator', 'up');
|
||||
$idServiceProduct = Tools::getValue('id_product');
|
||||
$idCartBooking = Tools::getValue('id_cart_booking');
|
||||
$qty = Tools::getValue('qty');
|
||||
$price = Tools::getValue('price');
|
||||
$response = array('hasError' => false);
|
||||
// Check tab access is allowed to edit
|
||||
if ($this->tabAccess['add'] == 1) {
|
||||
$idCartBooking = Tools::getValue('id_hotel_cart_booking');
|
||||
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
|
||||
$objCart = new Cart($objHotelCartBookingData->id_cart);
|
||||
if ($selectedServiceProducts = Tools::getValue('selected_service_product')) {
|
||||
$serviceQuantities = Tools::getValue('service_qty');
|
||||
$serviceUnitPrices = Tools::getValue('service_price');
|
||||
// Validate selected services
|
||||
foreach ($selectedServiceProducts as $idServiceProduct => $selected) {
|
||||
if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct, false, $objCart->id_lang))) {
|
||||
if ($objProduct->allow_multiple_quantity) {
|
||||
if (!isset($serviceQuantities[$idServiceProduct])) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Quantity not provided for service').': '.$objProduct->name;
|
||||
} else if (!Validate::isUnsignedInt($serviceQuantities[$idServiceProduct])) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Invalid quantity provided for service').': '.$objProduct->name;
|
||||
}
|
||||
} elseif ($serviceQuantities[$idServiceProduct] > 1) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Can not order multiple quanitity for service').': '.$objProduct->name;
|
||||
}
|
||||
|
||||
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if (!$objProduct->allow_multiple_quantity) {
|
||||
$serviceQuantities[$idServiceProduct] = 1;
|
||||
}
|
||||
|
||||
if ($operator == 'up') {
|
||||
// validate quanitity
|
||||
if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) {
|
||||
if ($objProduct->allow_multiple_quantity) {
|
||||
if (!Validate::isUnsignedInt($qty)) {
|
||||
$this->errors[] = Tools::displayError('The quantity you\'ve entered is invalid.');
|
||||
// } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) {
|
||||
// $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity));
|
||||
if (!isset($serviceUnitPrices[$idServiceProduct])
|
||||
|| !ValidateCore::isPrice($serviceUnitPrices[$idServiceProduct])
|
||||
) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Invalid unit price for service').': '.$objProduct->name;
|
||||
}
|
||||
|
||||
} else {
|
||||
die($idServiceProduct);
|
||||
$response['errors'] = $this->l('Some services not found. please try after refreshing the page');
|
||||
}
|
||||
} else {
|
||||
$qty = 1;
|
||||
}
|
||||
// validate price
|
||||
if (!ValidateCore::isPrice($price)) {
|
||||
$this->errors[] = Tools::displayError('Invalid service unit price.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This Service is not available.');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->errors)) {
|
||||
if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct(
|
||||
$idCartBooking,
|
||||
$idServiceProduct,
|
||||
$qty,
|
||||
$objHotelCartBookingData->id_cart,
|
||||
$operator
|
||||
)) {
|
||||
$objCart = new Cart($objHotelCartBookingData->id_cart);
|
||||
$originalPrice = Product::getPriceStatic($idServiceProduct, false);
|
||||
// if price is different than the original service price then update the price
|
||||
if ($operator == 'up' && $originalPrice != $price) {
|
||||
if ($specificPriceInfo = SpecificPrice::getSpecificPrice(
|
||||
(int)$idServiceProduct,
|
||||
0,
|
||||
$objCart->id_currency,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
$objCart->id_customer,
|
||||
$objCart->id
|
||||
)) {
|
||||
$objSpecificPrice = new SpecificPrice($specificPriceInfo['id_specific_price']);
|
||||
} else {
|
||||
$objSpecificPrice = new SpecificPrice();
|
||||
if (!$response['hasError']) {
|
||||
$result = true;
|
||||
$objRoomTypeServiceProductCart = new RoomTypeServiceProductCartDetail();
|
||||
foreach ($selectedServiceProducts as $idServiceProduct => $selected) {
|
||||
if ($selected) {
|
||||
$operator = 'up';
|
||||
} else {
|
||||
$operator = 'down';
|
||||
}
|
||||
$quantity = $serviceQuantities[$idServiceProduct];
|
||||
$unitPrice = $serviceUnitPrices[$idServiceProduct];
|
||||
if ($result &= $objRoomTypeServiceProductCart->updateCartServiceProduct(
|
||||
$idCartBooking,
|
||||
$idServiceProduct,
|
||||
$quantity,
|
||||
$objHotelCartBookingData->id_cart,
|
||||
$operator,
|
||||
)) {
|
||||
$originalPrice = Product::getPriceStatic($idServiceProduct, false);
|
||||
// if price is different than the original service price then update the price
|
||||
if ($operator == 'up' && $originalPrice != $price) {
|
||||
if ($specificPriceInfo = SpecificPrice::getSpecificPrice(
|
||||
(int)$idServiceProduct,
|
||||
0,
|
||||
$objCart->id_currency,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
$objCart->id_customer,
|
||||
$objCart->id
|
||||
)) {
|
||||
$objSpecificPrice = new SpecificPrice($specificPriceInfo['id_specific_price']);
|
||||
} else {
|
||||
$objSpecificPrice = new SpecificPrice();
|
||||
}
|
||||
$objSpecificPrice->id_shop = 0;
|
||||
$objSpecificPrice->id_shop_group = 0;
|
||||
$objSpecificPrice->id_cart = $objCart->id;
|
||||
$objSpecificPrice->id_currency = $objCart->id_currency;
|
||||
$objSpecificPrice->id_country = 0;
|
||||
$objSpecificPrice->id_group = 0;
|
||||
$objSpecificPrice->id_customer = $objCart->id_customer;
|
||||
$objSpecificPrice->id_product = $idServiceProduct;
|
||||
$objSpecificPrice->id_product_attribute = 0;
|
||||
$objSpecificPrice->price = $unitPrice;
|
||||
$objSpecificPrice->from_quantity = 1;
|
||||
$objSpecificPrice->reduction = 0;
|
||||
$objSpecificPrice->reduction_type = 'amount';
|
||||
$objSpecificPrice->reduction_tax = 0;
|
||||
$objSpecificPrice->from = '0000-00-00 00:00:00';
|
||||
$objSpecificPrice->to = '0000-00-00 00:00:00';
|
||||
|
||||
$result &= $objSpecificPrice->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
$objSpecificPrice->id_shop = 0;
|
||||
$objSpecificPrice->id_shop_group = 0;
|
||||
$objSpecificPrice->id_cart = $objCart->id;
|
||||
$objSpecificPrice->id_currency = $objCart->id_currency;
|
||||
$objSpecificPrice->id_country = 0;
|
||||
$objSpecificPrice->id_group = 0;
|
||||
$objSpecificPrice->id_customer = $objCart->id_customer;
|
||||
$objSpecificPrice->id_product = $idServiceProduct;
|
||||
$objSpecificPrice->id_product_attribute = 0;
|
||||
$objSpecificPrice->price = $price;
|
||||
$objSpecificPrice->from_quantity = 1;
|
||||
$objSpecificPrice->reduction = 0;
|
||||
$objSpecificPrice->reduction_type = 'amount';
|
||||
$objSpecificPrice->reduction_tax = 0;
|
||||
$objSpecificPrice->from = '0000-00-00 00:00:00';
|
||||
$objSpecificPrice->to = '0000-00-00 00:00:00';
|
||||
if ($objSpecificPrice->save()) {
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'hasError' => false
|
||||
)));
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Some error has been occurred. Please try reloading the page.');
|
||||
}
|
||||
} else {
|
||||
// delete specific price if price is same as original price
|
||||
if (SpecificPrice::deleteByIdCart($objCart->id, $idServiceProduct)) {
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'hasError' => false,
|
||||
'down' => 1,
|
||||
)));
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.');
|
||||
|
||||
if (!$result) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Error while updating services, please try again after refresing the page');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.');
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('No service found');
|
||||
}
|
||||
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Room info not found');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Room not found. Please try reloading the page.');
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('You do not have permission to edit this order.');
|
||||
}
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'hasError' => true,
|
||||
'errors' => $this->errors
|
||||
)));
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +388,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
// validate cart for removing invalid data from cart before new order creation
|
||||
// remove not linked services with room types from cart if not allowed to book them
|
||||
$this->errors = array_merge($this->errors, HotelCartBookingData::validateCartBookings(!Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')));
|
||||
$this->errors = array_merge(
|
||||
$this->errors,
|
||||
HotelCartBookingData::validateCartBookings(!Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING'))
|
||||
);
|
||||
|
||||
$cart_detail_data = array();
|
||||
$cart_detail_data_obj = new HotelCartBookingData();
|
||||
@@ -953,7 +956,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
|
||||
@@ -1700,7 +1703,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->context->cart = $objCart;
|
||||
$this->context->currency = new Currency((int)$objCart->id_currency);
|
||||
|
||||
$this->errors = HotelCartBookingData::validateCartBookings();
|
||||
$this->errors = HotelCartBookingData::validateCartBookings(!Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING'));
|
||||
$orderTotal = $objCart->getOrderTotal(true, Cart::BOTH);
|
||||
if ($objCart->is_advance_payment) {
|
||||
$advancePaymentAmount = $objCart->getOrderTotal(true, Cart::ADVANCE_PAYMENT);
|
||||
@@ -6297,7 +6300,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
|
||||
@@ -6549,7 +6552,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$response['errors'] = $this->l('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessAddExistingRoomServices()
|
||||
@@ -6785,7 +6788,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
// Add new custom services to room
|
||||
@@ -7103,7 +7106,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
|
||||
@@ -7187,7 +7190,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$response['errors'] = $this->l('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
// Process when admin changes extra demands of any room while order creation process form.tpl
|
||||
|
||||
@@ -490,6 +490,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
if ($getTotalPrice) {
|
||||
return $totalPrice;
|
||||
}
|
||||
|
||||
return $selectedServiceProducts;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user