Merge 'origin/develop' into gli-838
This commit is contained in:
@@ -68,7 +68,7 @@ class AddressControllerCore extends FrontController
|
||||
$id_address = (int)$this->context->cart->id_address_invoice;
|
||||
}
|
||||
} else {
|
||||
$id_address = (int)Tools::getValue('id_address', 0);
|
||||
$id_address = Customer::getCustomerIdAddress($this->context->customer->id);
|
||||
}
|
||||
|
||||
// Initialize address
|
||||
@@ -91,7 +91,7 @@ class AddressControllerCore extends FrontController
|
||||
} elseif ($this->ajax) {
|
||||
exit;
|
||||
} else {
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
// Tools::redirect('index.php?controller=addresses');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ class AddressControllerCore extends FrontController
|
||||
$mod = Tools::getValue('mod');
|
||||
Tools::redirect('index.php?controller='.$back.($mod ? '&back='.$mod : ''));
|
||||
} else {
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
Tools::redirect('index.php?controller=address');
|
||||
}
|
||||
}
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating your address.');
|
||||
|
||||
@@ -50,6 +50,8 @@ class AddressesControllerCore extends FrontController
|
||||
{
|
||||
parent::init();
|
||||
|
||||
Tools::redirect($this->context->link->getPageLink('address'));
|
||||
|
||||
if (!Validate::isLoadedObject($this->context->customer)) {
|
||||
die(Tools::displayError('The customer could not be found.'));
|
||||
}
|
||||
|
||||
@@ -218,6 +218,8 @@ class CategoryControllerCore extends FrontController
|
||||
|
||||
public function displayAjaxFilterResults()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
|
||||
$this->display_header = false;
|
||||
$this->display_footer = false;
|
||||
|
||||
@@ -231,7 +233,6 @@ class CategoryControllerCore extends FrontController
|
||||
|
||||
$adult = 0;
|
||||
$child = 0;
|
||||
$ratting = -1;
|
||||
$amenities = 0;
|
||||
$price = 0;
|
||||
|
||||
@@ -241,8 +242,6 @@ class CategoryControllerCore extends FrontController
|
||||
$adult = min($value);
|
||||
} elseif ($key == 'children') {
|
||||
$child = min($value);
|
||||
} elseif ($key == 'ratting') {
|
||||
$ratting = min($value);
|
||||
} elseif ($key == 'amenities') {
|
||||
$amenities = array();
|
||||
foreach ($value as $a_k => $a_v) {
|
||||
@@ -265,7 +264,7 @@ class CategoryControllerCore extends FrontController
|
||||
$id_guest = $this->context->cookie->id_guest;
|
||||
|
||||
$obj_booking_dtl = new HotelBookingDetail();
|
||||
$booking_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $id_hotel, 0, 0, $adult, $child, $ratting, $amenities, $price, $id_cart, $id_guest);
|
||||
$booking_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $id_hotel, 0, 0, $adult, $child, -1, $amenities, $price, $id_cart, $id_guest);
|
||||
// reset array keys from 0
|
||||
$booking_data['rm_data'] = array_values($booking_data['rm_data']);
|
||||
if ($sort_by && $sort_value) {
|
||||
@@ -277,18 +276,18 @@ class CategoryControllerCore extends FrontController
|
||||
$direction = SORT_DESC;
|
||||
}
|
||||
foreach ($booking_data['rm_data'] as $s_k => $s_v) {
|
||||
if ($sort_by == 1) {
|
||||
$indi_arr[$s_k] = $s_v['ratting'];
|
||||
} elseif ($sort_by == 2) {
|
||||
$indi_arr[$s_k] = $s_v['price'];
|
||||
}
|
||||
$indi_arr[$s_k] = $s_v['price'];
|
||||
}
|
||||
|
||||
array_multisort($indi_arr, $direction, $booking_data['rm_data']);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array('booking_data' => $booking_data));
|
||||
$html = $this->context->smarty->fetch('_partials/room_type_list.tpl');
|
||||
$response['status'] = true;
|
||||
$response['html_room_type_list'] = $html;
|
||||
}
|
||||
die($this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/room_type_list.tpl'));
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -271,11 +271,11 @@ class ContactControllerCore extends FrontController
|
||||
if (isset($hotel['id_cover_img'])
|
||||
&& $hotel['id_cover_img']
|
||||
&& Validate::isLoadedObject(
|
||||
$objHtlImg = new HotelImage($hotel['id_cover_img'])
|
||||
$objHotelImage = new HotelImage($hotel['id_cover_img'])
|
||||
)
|
||||
) {
|
||||
// by webkul to get media link.
|
||||
$htlImgLink = $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/'.$objHtlImg->hotel_image_id.'.jpg');
|
||||
$htlImgLink = $this->context->link->getMediaLink($objHotelImage->getImageLink($hotel['id_cover_img'], ImageType::getFormatedName('medium')));
|
||||
|
||||
if ((bool)Tools::file_get_contents($htlImgLink)) {
|
||||
$hotel['image_url'] = $htlImgLink;
|
||||
@@ -287,7 +287,8 @@ class ContactControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
}
|
||||
$contactKey = md5(uniqid(microtime(), true));
|
||||
|
||||
$contactKey = md5(uniqid(microtime(), true));
|
||||
$this->context->cookie->__set('contactFormKey', $contactKey);
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
@@ -297,7 +298,7 @@ class ContactControllerCore extends FrontController
|
||||
'gblHtlAddress' => $gblHtlAddress,
|
||||
'contacts' => Contact::getContacts($this->context->language->id),
|
||||
'message' => html_entity_decode(Tools::getValue('message')),
|
||||
'contactKey' => $contactKey,
|
||||
'contactKey' => $contactKey,
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -135,6 +135,34 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$this->ajaxDie(json_encode($return));
|
||||
break;
|
||||
|
||||
case 'transformGuestAccount':
|
||||
$passwd = Tools::getValue('passwd');
|
||||
|
||||
if (!$passwd) {
|
||||
$this->errors[] = Tools::displayError('Please enter a password.');
|
||||
}
|
||||
|
||||
if ($passwd && !Validate::isPasswd($passwd)) {
|
||||
$this->errors[] = Tools::displayError('Please enter a valid password.');
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$customer = new Customer($this->context->customer->id);
|
||||
if ($customer->transformToCustomer($this->context->language->id, $passwd)) {
|
||||
$this->updateContext($customer);
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while transforming your account into a registered customer.');
|
||||
}
|
||||
}
|
||||
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
);
|
||||
|
||||
$this->ajaxDie(json_encode($return));
|
||||
break;
|
||||
|
||||
case 'getAddressBlockAndCarriersAndPayments':
|
||||
if ($this->context->customer->isLogged() || $this->context->customer->isGuest()) {
|
||||
// check if customer have addresses
|
||||
@@ -1021,4 +1049,20 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
}
|
||||
$this->context->cart->save();
|
||||
}
|
||||
|
||||
public function updateContext(Customer $customer)
|
||||
{
|
||||
$this->context->cookie->id_customer = (int)$customer->id;
|
||||
$this->context->cookie->customer_lastname = $customer->lastname;
|
||||
$this->context->cookie->customer_firstname = $customer->firstname;
|
||||
$this->context->cookie->passwd = $customer->passwd;
|
||||
$this->context->cookie->logged = 1;
|
||||
$this->context->cookie->email = $customer->email;
|
||||
$this->context->cookie->is_guest = 0;
|
||||
|
||||
$this->context->cart->secure_key = $customer->secure_key;
|
||||
|
||||
$customer->logged = 1;
|
||||
$this->context->customer = $customer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,13 @@ class ProductControllerCore extends FrontController
|
||||
if (Configuration::get('PS_DISPLAY_JQZOOM') == 1) {
|
||||
$this->addJqueryPlugin('jqzoom');
|
||||
}
|
||||
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
|
||||
$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function canonicalRedirection($canonical_url = '')
|
||||
@@ -264,7 +271,6 @@ class ProductControllerCore extends FrontController
|
||||
/*By webkul To send All needed Hotel Information on product.tpl*/
|
||||
#####################################################################
|
||||
|
||||
$total_available_rooms = 0;
|
||||
$htl_features = array();
|
||||
$obj_hotel_room_type = new HotelRoomType();
|
||||
$room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id);
|
||||
@@ -304,32 +310,7 @@ class ProductControllerCore extends FrontController
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_from)));
|
||||
}
|
||||
|
||||
$obj_htl_cart_booking_data = new HotelCartBookingData();
|
||||
$obj_booking_detail = new HotelBookingDetail();
|
||||
$num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to);
|
||||
//$price_tax_incl = Product::getPriceStatic($this->product->id, HotelBookingDetail::useTax());
|
||||
//$total_price = $price_tax_incl * $num_days;
|
||||
//// By webkul New way to calculate product prices with feature Prices
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($this->product->id, $date_from, $date_to);
|
||||
if ($useTax) {
|
||||
$total_price = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
} else {
|
||||
$total_price = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
}
|
||||
//END
|
||||
$obj_booking_dtl = new HotelBookingDetail();
|
||||
$hotel_room_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $hotel_id, $this->product->id, 1);
|
||||
|
||||
if ($hotel_room_data) {
|
||||
$total_available_rooms = $hotel_room_data['stats']['num_avail'];
|
||||
}
|
||||
$hotel_branch_obj = new HotelBranchInformation($hotel_id);
|
||||
if (isset($this->context->cart->id)) {
|
||||
$num_cart_rooms = $obj_htl_cart_booking_data->getCountRoomsByIdCartIdProduct($this->context->cart->id, $this->product->id, $date_from, $date_to);
|
||||
if ($num_cart_rooms) {
|
||||
$total_available_rooms = $total_available_rooms - $num_cart_rooms;
|
||||
}
|
||||
}
|
||||
/*Max date of ordering for order restrict*/
|
||||
$order_date_restrict = false;
|
||||
$max_order_date = HotelOrderRestrictDate::getMaxOrderDate($hotel_id);
|
||||
@@ -342,42 +323,57 @@ class ProductControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
/*End*/
|
||||
// booking preparation time
|
||||
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id);
|
||||
|
||||
$hotelImageLink = null;
|
||||
if ($coverImage = HotelImage::getCover($hotel_id)) {
|
||||
$hotelImagesBaseDir = _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/';
|
||||
$hotelImageLink = $this->context->link->getMediaLink(
|
||||
$hotelImagesBaseDir.$coverImage['hotel_image_id'].'.jpg'
|
||||
);
|
||||
}
|
||||
|
||||
Media::addJsDef(array(
|
||||
'hotel_loc' => array(
|
||||
'latitude' => $hotel_branch_obj->latitude,
|
||||
'longitude' => $hotel_branch_obj->longitude,
|
||||
)
|
||||
));
|
||||
|
||||
if (Tools::getValue('error')) {
|
||||
$this->context->smarty->assign('error', Tools::getValue('error'));
|
||||
}
|
||||
if (Module::isInstalled('productcomments')) {
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'num_reviews' => ProductComment::getCommentNumber($this->product->id),
|
||||
'ratting' => ProductComment::getAverageGrade($this->product->id)['grade'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'isHotelRefundable' => $hotel_branch_obj->isRefundable(),
|
||||
'max_order_date' => $max_order_date,
|
||||
'preparation_time' => $preparationTime,
|
||||
'warning_num' => Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'),
|
||||
'ratting_img_path' => _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png',
|
||||
'total_available_rooms' => $total_available_rooms,
|
||||
'total_price' => $total_price,
|
||||
'product_controller_url' => $this->context->link->getPageLink('product'),
|
||||
'num_days' => $num_days,
|
||||
'date_from' => $date_from,
|
||||
'date_to' => $date_to,
|
||||
'hotel_check_in' => date('h:i a', strtotime($hotel_branch_obj->check_in)),
|
||||
'hotel_check_out' => date('h:i a', strtotime($hotel_branch_obj->check_out)),
|
||||
'hotel_location' => $hotel_location,
|
||||
'hotel_latitude' => $hotel_branch_obj->latitude,
|
||||
'hotel_longitude' => $hotel_branch_obj->longitude,
|
||||
'hotel_map_input_text' => $hotel_branch_obj->map_input_text,
|
||||
'hotel_address1' => $addressInfo['address1'],
|
||||
'hotel_phone' => $addressInfo['phone'],
|
||||
'hotel_name' => $hotel_name,
|
||||
'hotel_policies' => $hotel_policies,
|
||||
'hotel_features' => $htl_features,
|
||||
'hotel_image_link' => $hotelImageLink,
|
||||
'hotel_has_images' => (bool) HotelImage::getCover($hotel_id),
|
||||
'ftr_img_src' => _PS_IMG_.'rf/',
|
||||
'order_date_restrict' => $order_date_restrict
|
||||
)
|
||||
);
|
||||
|
||||
$this->assignBookingFormVars($this->product->id, $date_from, $date_to);
|
||||
|
||||
// product price after imposing feature prices...
|
||||
if ($useTax) {
|
||||
$priceProduct = Product::getPriceStatic($this->product->id, true);
|
||||
@@ -452,12 +448,145 @@ class ProductControllerCore extends FrontController
|
||||
'category-'.(isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : ''),
|
||||
),
|
||||
'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'),
|
||||
'display_google_maps' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'),
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->setTemplate(_PS_THEME_DIR_.'product.tpl');
|
||||
}
|
||||
|
||||
public function assignBookingFormVars(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$quantity = 1,
|
||||
$jsonDemands = ''
|
||||
) {
|
||||
$objProduct = new Product($idProduct, true, $this->context->language->id, $this->context->shop->id);
|
||||
if (!Validate::isLoadedObject($objProduct)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$smartyVars = array();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$objHotel = new HotelBranchInformation();
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$objHRTDemand = new HotelRoomTypeDemand();
|
||||
$objHRTDemandPrice = new HotelRoomTypeDemandPrice();
|
||||
|
||||
$idCart = (int) $this->context->cart->id;
|
||||
$idGuest = (int) $this->context->cart->id_guest;
|
||||
$warningCount = (int) Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER');
|
||||
|
||||
$roomType = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
|
||||
$idHotel = $roomType['id_hotel'];
|
||||
$hotel = $objHotel->hotelBranchesInfo(false, 2, 1, $idHotel);
|
||||
$hotelLocation = $hotel['city'].', '.(isset($hotel['state_name']) ? ' '.$hotel['state_name'].', ' : '').
|
||||
' '.$hotel['country_name'];
|
||||
|
||||
$orderDateRestrict = false;
|
||||
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($idHotel);
|
||||
if ($maxOrderDate) {
|
||||
$maxOrderDate = date('Y-m-d', strtotime($maxOrderDate));
|
||||
if (strtotime('-1 day', strtotime($maxOrderDate)) < strtotime($dateFrom)
|
||||
|| strtotime($maxOrderDate) < strtotime($dateTo)
|
||||
) {
|
||||
$orderDateRestrict = true;
|
||||
}
|
||||
}
|
||||
|
||||
$numDays = $objBookingDetail->getNumberOfDays($dateFrom, $dateTo);
|
||||
|
||||
$hotelRoomData = $objBookingDetail->DataForFrontSearch(
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$idHotel,
|
||||
$idProduct,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
$idCart,
|
||||
$idGuest
|
||||
);
|
||||
|
||||
if ($hotelRoomData) {
|
||||
$totalAvailableRooms = $hotelRoomData['stats']['num_avail'];
|
||||
$quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity;
|
||||
}
|
||||
|
||||
// calculate room type price first
|
||||
$useTax = HotelBookingDetail::useTax();
|
||||
$totalPrice = 0;
|
||||
$productPriceWithoutReduction = $objProduct->getPriceWithoutReduct(!$useTax);
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
);
|
||||
|
||||
$featurePrice = 0;
|
||||
if ($useTax) {
|
||||
$featurePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
true
|
||||
);
|
||||
$roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
} else {
|
||||
$featurePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
false
|
||||
);
|
||||
$roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
}
|
||||
$featurePriceDiff = (float) ($productPriceWithoutReduction - $featurePrice);
|
||||
|
||||
$totalRoomPrice = $roomTypeDateRangePrice * $quantity;
|
||||
|
||||
// calculate demand price now
|
||||
$demandsPrice = 0;
|
||||
$roomTypeDemands = $objHRTDemand->getRoomTypeDemands($idProduct);
|
||||
if ($jsonDemands !== '') {
|
||||
$cartDemands = json_decode($jsonDemands, true);
|
||||
$demandsPrice = $objHRTDemandPrice->getRoomTypeDemandsTotalPrice(
|
||||
$idProduct,
|
||||
$cartDemands,
|
||||
$useTax,
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
);
|
||||
|
||||
$demandsPrice *= $quantity;
|
||||
}
|
||||
|
||||
// calculate total price
|
||||
$totalPrice = $totalRoomPrice + $demandsPrice;
|
||||
|
||||
$smartyVars['hotel_location'] = $hotelLocation;
|
||||
$smartyVars['order_date_restrict'] = $orderDateRestrict;
|
||||
$smartyVars['max_order_date'] = $maxOrderDate;
|
||||
$smartyVars['date_from'] = $dateFrom;
|
||||
$smartyVars['date_to'] = $dateTo;
|
||||
$smartyVars['allow_oosp'] = $objProduct->isAvailableWhenOutOfStock((int) $objProduct->out_of_stock);
|
||||
$smartyVars['quantity'] = $quantity;
|
||||
$smartyVars['num_days'] = $numDays;
|
||||
$smartyVars['warning_count'] = $warningCount;
|
||||
$smartyVars['total_available_rooms'] = $totalAvailableRooms;
|
||||
$smartyVars['has_room_type_demands'] = $roomTypeDemands ? true : false; // whether to show price breakup
|
||||
$smartyVars['rooms_price'] = $totalRoomPrice;
|
||||
$smartyVars['demands_price'] = $demandsPrice;
|
||||
$smartyVars['total_price'] = $totalPrice;
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign price and tax to the template
|
||||
*/
|
||||
@@ -923,6 +1052,33 @@ class ProductControllerCore extends FrontController
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function displayAjaxRefreshBookingForm()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
$idProduct = (int) Tools::getValue('id_product');
|
||||
$dateFrom = Tools::getValue('date_from');
|
||||
$dateTo = Tools::getValue('date_to');
|
||||
$quantity = (int) Tools::getValue('quantity');
|
||||
$roomTypeDemands = Tools::getValue('room_type_demands');
|
||||
|
||||
$dateFrom = date('Y-m-d', strtotime($dateFrom));
|
||||
$dateTo = date('Y-m-d', strtotime($dateTo));
|
||||
|
||||
if ($this->assignBookingFormVars(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$quantity,
|
||||
$roomTypeDemands
|
||||
)) {
|
||||
$html = $this->context->smarty->fetch('_partials/booking-form.tpl');
|
||||
$response['status'] = true;
|
||||
$response['html_booking_form'] = $html;
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function displayAjaxCheckRoomAvailabilityAndRate()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
Reference in New Issue
Block a user