added primary hotel for price calculation
This commit is contained in:
@@ -3036,6 +3036,9 @@ class CartCore extends ObjectModel
|
||||
} else if ($id_hotel) {
|
||||
$addressInfo = HotelBranchInformation::getAddress($id_hotel);
|
||||
return $addressInfo['id_address'];
|
||||
} else {
|
||||
// provide an address for service product.
|
||||
// for now we do not have an address associated with the service product
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3041,17 +3041,30 @@ class ProductCore extends ObjectModel
|
||||
$id_state = 0;
|
||||
$zipcode = 0;
|
||||
|
||||
if ($id_address) {
|
||||
$address_infos = Address::getCountryAndState($id_address);
|
||||
} else {
|
||||
// if ($id_roomtype) {
|
||||
// $address_infos = Address::getCountryAndState(Cart::getIdAddressForTaxCalculation($id_roomtype));
|
||||
// } else {
|
||||
$address_infos = Address::getCountryAndState(Cart::getIdAddressForTaxCalculation($id_product));
|
||||
// }
|
||||
if (!$id_address) {
|
||||
if (!Product::isBookingProduct($id_product)) {
|
||||
if ($id_roomtype) {
|
||||
// if room type is provided with product then we know that the service product price should be calculated accroding to roomt type
|
||||
$id_address = Cart::getIdAddressForTaxCalculation($id_roomtype);
|
||||
}
|
||||
} else {
|
||||
$id_address = Cart::getIdAddressForTaxCalculation($id_product);
|
||||
}
|
||||
}
|
||||
|
||||
if ($address_infos['id_country']) {
|
||||
if (!$id_address) {
|
||||
if ($primaryHotel = ConfigurationCore::get('WK_PRIMARY_HOTEL')) {
|
||||
if ($address = HotelBranchInformation::getAddress($primaryHotel)) {
|
||||
$address_infos['id_country'] = $address['id_country'];
|
||||
$address_infos['id_state'] = $address['id_state'];
|
||||
$address_infos['postcode'] = $address['postcode'];
|
||||
}
|
||||
}
|
||||
} elseif ($id_address) {
|
||||
$address_infos = Address::getCountryAndState($id_address);
|
||||
}
|
||||
|
||||
if (isset($address_infos['id_country'])) {
|
||||
$id_country = (int)$address_infos['id_country'];
|
||||
$id_state = (int)$address_infos['id_state'];
|
||||
$zipcode = $address_infos['postcode'];
|
||||
|
||||
@@ -401,6 +401,8 @@ class HotelHelper
|
||||
$obj_hotel_info->id_category = $cat_hotel;
|
||||
$obj_hotel_info->save();
|
||||
}
|
||||
// save dummy hotel as primary hotel
|
||||
Configuration::updateValue('WK_PRIMARY_HOTEL', $htl_id);
|
||||
|
||||
return $htl_id;
|
||||
}
|
||||
|
||||
@@ -422,6 +422,18 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
|
||||
if ($newIdHotel = $objHotelBranch->id) {
|
||||
|
||||
if ($primaryHotelId = Configuration::get('WK_PRIMARY_HOTEL')) {
|
||||
if ($primaryHotelId == $objHotelBranch->id && !$objHotelBranch->active) {
|
||||
$hotels = $objHotelBranch->hotelBranchesInfo(false, 1);
|
||||
if (!empty($hotel = array_shift($hotels))) {
|
||||
Configuration::updateValue('WK_PRIMARY_HOTEL', $objHotelBranch['id']);
|
||||
} else {
|
||||
$newPrimaryHotelId = Configuration::updateValue('WK_PRIMARY_HOTEL', 0);
|
||||
}
|
||||
}
|
||||
} else if ($objHotelBranch->active) {
|
||||
Configuration::updateValue('WK_PRIMARY_HOTEL', $objHotelBranch->id);
|
||||
}
|
||||
// getHotel address
|
||||
if ($idHotelAddress = $objHotelBranch->getHotelIdAddress()) {
|
||||
$objAddress = new Address($idHotelAddress);
|
||||
@@ -559,6 +571,29 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$this->display = 'add';
|
||||
}
|
||||
}
|
||||
public function processStatus()
|
||||
{
|
||||
parent::processStatus();
|
||||
if (empty($this->errors)) {
|
||||
if (Validate::isLoadedObject($objHotelBranch = new HotelBranchInformation(Tools::getValue('id')))) {
|
||||
if ($primaryHotelId = Configuration::get('WK_PRIMARY_HOTEL')) {
|
||||
if ($primaryHotelId == $objHotelBranch->id && !$objHotelBranch->active) {
|
||||
$hotels = $objHotelBranch->hotelBranchesInfo(false, 1);
|
||||
if (!empty($hotel = array_shift($hotels))) {
|
||||
Configuration::updateValue('WK_PRIMARY_HOTEL', $hotel['id']);
|
||||
} else {
|
||||
$newPrimaryHotelId = Configuration::updateValue('WK_PRIMARY_HOTEL', 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$hotels = $objHotelBranch->hotelBranchesInfo(false, 1);
|
||||
if (!empty($hotel = array_shift($hotels))) {
|
||||
Configuration::updateValue('WK_PRIMARY_HOTEL', $hotel['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessStateByCountryId()
|
||||
{
|
||||
@@ -686,6 +721,8 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
'filesizeError' => $this->l('File exceeds maximum size.'),
|
||||
'maxSizeAllowed' => Tools::getMaxUploadSize(),
|
||||
'sortRowsUrl' => $this->context->link->getAdminLink('AdminAddHotel'),
|
||||
'primaryHotelId' => Configuration::get('WK_PRIMARY_HOTEL'),
|
||||
'disableHotelMsg' => $this->l('Primary hotel for website will be updated to first available active hotel.'),
|
||||
)
|
||||
);
|
||||
// GOOGLE MAP
|
||||
|
||||
@@ -35,6 +35,9 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
if (!$hotelsInfo = $objHotelInfo->hotelBranchesInfo(false, 1)) {
|
||||
$hotelsInfo = array();
|
||||
}
|
||||
foreach ($hotelsInfo as &$hotel) {
|
||||
$hotel['name'] = $hotel['hotel_name'];
|
||||
}
|
||||
$hotelNameDisable = (count($hotelsInfo) > 1 ? true : false);
|
||||
$locationDisable = ((count($hotelsInfo) < 2) && !Configuration::get('WK_HOTEL_NAME_ENABLE')) ? true : false;
|
||||
$this->fields_options = array(
|
||||
@@ -142,6 +145,13 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
'hint' => $this->l('The year when your hotel site was launched.'),
|
||||
'type' => 'text',
|
||||
),
|
||||
'WK_PRIMARY_HOTEL' => array(
|
||||
'title' => $this->l('Primary hotel'),
|
||||
'hint' => $this->l('Primary hotel is used to default address for your business. The hotel address will be considered as your registered business address.'),
|
||||
'type' => 'select',
|
||||
'identifier' => 'id',
|
||||
'list' => $hotelsInfo,
|
||||
),
|
||||
'WK_HTL_CHAIN_NAME' => array(
|
||||
'title' => $this->l('Hotel Name'),
|
||||
'type' => 'textLang',
|
||||
|
||||
@@ -227,6 +227,30 @@ function initGoogleMaps() {
|
||||
|
||||
$(document).ready(function() {
|
||||
//For Add Hotels
|
||||
|
||||
// hotel status change
|
||||
$("#form-htl_branch_info a.list-action-enable.action-enabled").on('click', function(e) {
|
||||
let id_hotel = $(this).closest('tr').find('.row-selector input').val();
|
||||
if (id_hotel == primaryHotelId) {
|
||||
if (!confirm(disableHotelMsg)) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
$("form#htl_branch_info_form").on('submit', function(e) {
|
||||
let id_hotel = $(this).find('#id-hotel').val();
|
||||
let enable = $(this).find('[name="ENABLE_HOTEL"]:checked').val();
|
||||
if (id_hotel == primaryHotelId && !parseInt(enable)) {
|
||||
if (!confirm(disableHotelMsg)) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// delete hotel image
|
||||
$('.deleteHtlImage').on('click', function(){
|
||||
var imgId = $(this).attr('id_htl_img');
|
||||
|
||||
Reference in New Issue
Block a user