Merge branch 'develop' into gli-2166
This commit is contained in:
@@ -1761,81 +1761,359 @@ class HotelBookingDetail extends ObjectModel
|
||||
{
|
||||
$result = true;
|
||||
// get the cart booking data for the given booking
|
||||
if (Validate::isLoadedObject($objHotelBooking = new HotelBookingDetail($idHotelBooking))) {
|
||||
$objHotelCartBooking = new HotelCartBookingData();
|
||||
if ($cartBookingInfo = $objHotelCartBooking->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$objHotelBooking->id_cart,
|
||||
$objHotelBooking->id_product,
|
||||
$objHotelBooking->date_from,
|
||||
$objHotelBooking->date_to,
|
||||
$objHotelBooking->id_room
|
||||
)) {
|
||||
// Reallocate the rooms in the room cart booking table
|
||||
if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($cartBookingInfo['id']))) {
|
||||
$objHotelCartBooking->id_room = $idRoom;
|
||||
$result &= $objHotelCartBooking->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Reallocate the rooms in the room booking table
|
||||
if (Validate::isLoadedObject($objOldHotelBooking = new HotelBookingDetail($idHotelBooking))) {
|
||||
$objHotelRoomInfo = new HotelRoomInformation($idRoom);
|
||||
$idNewRoomType = $objHotelRoomInfo->id_product;
|
||||
if ($objHotelBooking->id_product != $idNewRoomType) {
|
||||
$objHotelBooking->id_product = $idNewRoomType;
|
||||
$objProduct = new Product($idNewRoomType, false, Configuration::get('PS_LANG_DEFAULT'));
|
||||
$objHotelBooking->room_type_name = $objProduct->name;
|
||||
if ($objOldHotelBooking->id_product != $idNewRoomType) {
|
||||
$objOrder = new Order($objOldHotelBooking->id_order);
|
||||
$objOldOrderDetail = new OrderDetail($objOldHotelBooking->id_order_detail);
|
||||
|
||||
// change product name in order detail table
|
||||
$objOrderDetail = new OrderDetail((int) $objHotelBooking->id_order_detail);
|
||||
$objOrderDetail->product_name = $objProduct->name;
|
||||
$productQty = (int)$objOldHotelBooking->getNumberOfDays($objOldHotelBooking->date_from, $objOldHotelBooking->date_to);
|
||||
$oldRoomPriceTaxExcl = $objOldHotelBooking->total_price_tax_excl / $productQty;
|
||||
$newRoomPriceTaxExcl = $oldRoomPriceTaxExcl + $priceDiffTaxExcl;
|
||||
|
||||
// manage the prices in the order tables for the price diffrence
|
||||
if ($priceDiffTaxExcl != 0) {
|
||||
$taxCalculator = $objOrderDetail->getTaxCalculator();
|
||||
$priceDiffTaxIncl = Tools::ps_round($taxCalculator->addTaxes($priceDiffTaxExcl), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$totalRoomPriceTaxIncl = $objOldHotelBooking->total_price_tax_incl;
|
||||
$totalRoomPriceTaxExcl = $objOldHotelBooking->total_price_tax_excl;
|
||||
|
||||
// set price changes in htl_booking_detail table
|
||||
$objHotelBooking->total_price_tax_excl += (float)$priceDiffTaxExcl;
|
||||
$objHotelBooking->total_price_tax_incl += (float)$priceDiffTaxIncl;
|
||||
// ===============================================================
|
||||
// Start: Add Process of the old booking
|
||||
// ===============================================================
|
||||
// Total method
|
||||
$totalMethod = Cart::BOTH_WITHOUT_SHIPPING;
|
||||
// Create new cart
|
||||
$cart = new Cart();
|
||||
$cart->id_shop_group = $objOrder->id_shop_group;
|
||||
$cart->id_shop = $objOrder->id_shop;
|
||||
$cart->id_customer = $objOrder->id_customer;
|
||||
$cart->id_carrier = $objOrder->id_carrier;
|
||||
$cart->id_address_delivery = $objOrder->id_address_delivery;
|
||||
$cart->id_address_invoice = $objOrder->id_address_invoice;
|
||||
$cart->id_currency = $objOrder->id_currency;
|
||||
$cart->id_lang = $objOrder->id_lang;
|
||||
$cart->secure_key = $objOrder->secure_key;
|
||||
$cart->add();
|
||||
|
||||
// set price changes in order_detail table
|
||||
$roomTypeTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$idNewRoomType,
|
||||
$objHotelBooking->date_from,
|
||||
$objHotelBooking->date_to
|
||||
// Save context (in order to apply cart rule)
|
||||
$this->context->cart = $cart;
|
||||
$this->context->customer = new Customer($objOrder->id_customer);
|
||||
$this->context->currency = new Currency($objOrder->id_currency);
|
||||
|
||||
// always add taxes even if not displayed to the customer
|
||||
$useTaxes = true;
|
||||
|
||||
$initialProductPriceTE = Product::getPriceStatic(
|
||||
$idNewRoomType,
|
||||
$useTaxes,
|
||||
null,
|
||||
2,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
1,
|
||||
false,
|
||||
$objOrder->id_customer,
|
||||
$cart->id,
|
||||
$objOrder->id_address_tax
|
||||
);
|
||||
|
||||
// create feature price if needed
|
||||
$createFeaturePrice = $newRoomPriceTaxExcl != $initialProductPriceTE;
|
||||
if ($createFeaturePrice) {
|
||||
$featurePriceParams = array();
|
||||
$featurePriceParams = array(
|
||||
'id_cart' => $this->context->cart->id,
|
||||
'id_guest' => $this->context->cookie->id_guest,
|
||||
'price' => $newRoomPriceTaxExcl,
|
||||
'id_product' => $idNewRoomType,
|
||||
);
|
||||
|
||||
$objOrderDetail->unit_price_tax_excl = Product::getPriceStatic($idNewRoomType, false, null, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$objOrderDetail->unit_price_tax_incl = Tools::ps_round(
|
||||
$taxCalculator->addTaxes($objOrderDetail->unit_price_tax_excl),
|
||||
_PS_PRICE_COMPUTE_PRECISION_
|
||||
);
|
||||
|
||||
$objOrderDetail->total_price_tax_excl += (float)$priceDiffTaxExcl;
|
||||
$objOrderDetail->total_price_tax_incl += (float)$priceDiffTaxIncl;
|
||||
|
||||
// set price changes in orders table
|
||||
$objOrder = new Order($objOrderDetail->id_order);
|
||||
$objOrder->total_products += (float)$priceDiffTaxExcl;
|
||||
$objOrder->total_products_wt += (float)$priceDiffTaxIncl;
|
||||
$objOrder->total_paid += (float)$priceDiffTaxIncl;
|
||||
$objOrder->total_paid_tax_excl += (float)$priceDiffTaxExcl;
|
||||
$objOrder->total_paid_tax_incl += (float)$priceDiffTaxIncl;
|
||||
|
||||
$result &= $objOrder->update();
|
||||
|
||||
// update taxes in order detail
|
||||
$result &= $objOrderDetail->updateTaxAmount($objOrder);
|
||||
}
|
||||
|
||||
$result &= $objOrderDetail->update();
|
||||
}
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
|
||||
$objHotelBooking->id_room = $idRoom;
|
||||
$objHotelBooking->room_num = $objHotelRoomInfo->room_num;
|
||||
// set backorder to 0 as available reallocate rooms will always be free
|
||||
$objHotelBooking->is_back_order = 0;
|
||||
$result &= $objHotelBooking->save();
|
||||
$bookingParams = array(
|
||||
'date_from' => $objOldHotelBooking->date_from,
|
||||
'date_to' => $objOldHotelBooking->date_to,
|
||||
'hotel_id' => $objOldHotelBooking->id_hotel,
|
||||
'id_room_type' => $idNewRoomType,
|
||||
'only_search_data' => 1,
|
||||
);
|
||||
|
||||
if ($roomAvailabilityInfo = $objOldHotelBooking->dataForFrontSearch($bookingParams)) {
|
||||
if ($availableRooms = $roomAvailabilityInfo['rm_data'][$idNewRoomType]['data']['available']) {
|
||||
$roomInfo = reset($availableRooms);
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
$objCartBookingData->id_cart = $this->context->cart->id;
|
||||
$objCartBookingData->id_guest = $this->context->cookie->id_guest;
|
||||
$objCartBookingData->id_customer = $objOrder->id_customer;
|
||||
$objCartBookingData->id_currency = $objOrder->id_currency;
|
||||
$objCartBookingData->id_product = $roomInfo['id_product'];
|
||||
$objCartBookingData->id_room = $roomInfo['id_room'];
|
||||
$objCartBookingData->id_hotel = $roomInfo['id_hotel'];
|
||||
$objCartBookingData->booking_type = 1;
|
||||
$objCartBookingData->quantity = $productQty;
|
||||
$objCartBookingData->date_from = $objOldHotelBooking->date_from;
|
||||
$objCartBookingData->date_to = $objOldHotelBooking->date_to;
|
||||
$objCartBookingData->adults = $objOldHotelBooking->adults;
|
||||
$objCartBookingData->children = $objOldHotelBooking->children;
|
||||
$objCartBookingData->child_ages = $objOldHotelBooking->child_ages;
|
||||
$objCartBookingData->save();
|
||||
|
||||
// create feature price if needed
|
||||
if ($createFeaturePrice) {
|
||||
$featurePriceParams['id_room'] = $roomInfo['id_room'];
|
||||
$featurePriceParams = array_merge(
|
||||
$featurePriceParams,
|
||||
array('date_from' => $objOldHotelBooking->date_from, 'date_to' => $objOldHotelBooking->date_to)
|
||||
);
|
||||
HotelRoomTypeFeaturePricing::createAutoFeaturePrice($featurePriceParams);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$totalRoomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$idNewRoomType,
|
||||
$objCartBookingData->date_from,
|
||||
$objCartBookingData->date_to,
|
||||
0,
|
||||
Group::getCurrent()->id,
|
||||
$this->context->cart->id,
|
||||
$this->context->cookie->id_guest,
|
||||
$objCartBookingData->id_room,
|
||||
0
|
||||
);
|
||||
|
||||
// Add product to cart
|
||||
$updateQuantity = $cart->updateQty(
|
||||
$productQty,
|
||||
$idNewRoomType,
|
||||
null,
|
||||
null,
|
||||
'up',
|
||||
0,
|
||||
new Shop($cart->id_shop)
|
||||
);
|
||||
|
||||
// If order is valid, we can create a new invoice or edit an existing invoice
|
||||
if ($objOrder->hasInvoice()) {
|
||||
$objOrderInvoice = new OrderInvoice($objOldOrderDetail->id_order_invoice);
|
||||
$objOrderInvoice->total_paid_tax_excl += (float)($cart->getOrderTotal(false, $totalMethod));
|
||||
$objOrderInvoice->total_paid_tax_incl += (float)($cart->getOrderTotal($useTaxes, $totalMethod));
|
||||
$objOrderInvoice->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||
$objOrderInvoice->total_products_wt += (float)$cart->getOrderTotal($useTaxes, Cart::ONLY_PRODUCTS);
|
||||
$objOrderInvoice->update();
|
||||
}
|
||||
|
||||
// Create Order detail information
|
||||
$objOrderDetail = new OrderDetail();
|
||||
$objOrderDetail->createList($objOrder, $cart, $objOrder->getCurrentOrderState(), $cart->getProducts(), (isset($objOrderInvoice->id) ? $objOrderInvoice->id : 0), $useTaxes, (int)Tools::getValue('add_product_warehouse'));
|
||||
|
||||
// update totals amount of order
|
||||
$objOrder->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||
$objOrder->total_products_wt += (float)$cart->getOrderTotal($useTaxes, Cart::ONLY_PRODUCTS);
|
||||
|
||||
$objOrder->total_paid += (float)($cart->getOrderTotal(true, $totalMethod));
|
||||
$objOrder->total_paid_tax_excl += (float)($cart->getOrderTotal(false, $totalMethod));
|
||||
$objOrder->total_paid_tax_incl += (float)($cart->getOrderTotal($useTaxes, $totalMethod));
|
||||
|
||||
// Save changes of order
|
||||
$objOrder->update();
|
||||
|
||||
// Update Tax lines
|
||||
$objOrderDetail->updateTaxAmount($objOrder);
|
||||
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$idNewOrderDetail = $objBookingDetail->getLastInsertedRoomIdOrderDetail($objOrder->id);
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
if ($cartBookingsData = $objCartBookingData->getOnlyCartBookingData(
|
||||
$this->context->cart->id,
|
||||
$this->context->cart->id_guest,
|
||||
$idNewRoomType
|
||||
)) {
|
||||
foreach ($cartBookingsData as $cartBookingInfo) {
|
||||
$objCartBookingData = new HotelCartBookingData($cartBookingInfo['id']);
|
||||
$objCartBookingData->id_order = $objOrder->id;
|
||||
$objCartBookingData->save();
|
||||
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$objBookingDetail->id_product = $idNewRoomType;
|
||||
$objBookingDetail->id_order = $objOrder->id;
|
||||
$objBookingDetail->id_order_detail = $idNewOrderDetail;
|
||||
$objBookingDetail->id_cart = $this->context->cart->id;
|
||||
$objBookingDetail->id_room = $objCartBookingData->id_room;
|
||||
$objBookingDetail->id_hotel = $objCartBookingData->id_hotel;
|
||||
$objBookingDetail->id_customer = $objOrder->id_customer;
|
||||
$objBookingDetail->booking_type = $objCartBookingData->booking_type;
|
||||
$objBookingDetail->id_status = 1;
|
||||
$objBookingDetail->comment = $objCartBookingData->comment;
|
||||
$objBookingDetail->room_type_name = Product::getProductName($idNewRoomType, null, $objOrder->id_lang);
|
||||
|
||||
$objBookingDetail->date_from = $objCartBookingData->date_from;
|
||||
$objBookingDetail->date_to = $objCartBookingData->date_to;
|
||||
$objBookingDetail->adults = $objCartBookingData->adults;
|
||||
$objBookingDetail->children = $objCartBookingData->children;
|
||||
$objBookingDetail->child_ages = $objCartBookingData->child_ages;
|
||||
|
||||
$totalRoomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$idNewRoomType,
|
||||
$objCartBookingData->date_from,
|
||||
$objCartBookingData->date_to,
|
||||
0,
|
||||
Group::getCurrent()->id,
|
||||
$this->context->cart->id,
|
||||
$this->context->cookie->id_guest,
|
||||
$objCartBookingData->id_room,
|
||||
0
|
||||
);
|
||||
$objBookingDetail->total_price_tax_excl = $totalRoomTypePrice['total_price_tax_excl'];
|
||||
$objBookingDetail->total_price_tax_incl = $totalRoomTypePrice['total_price_tax_incl'];
|
||||
$objBookingDetail->total_paid_amount = $totalRoomTypePrice['total_price_tax_incl'];
|
||||
|
||||
// Save hotel information/location/contact
|
||||
if (Validate::isLoadedObject($objRoom = new HotelRoomInformation($objCartBookingData->id_room))) {
|
||||
$objBookingDetail->room_num = $objRoom->room_num;
|
||||
}
|
||||
if (Validate::isLoadedObject($objHotelBranch = new HotelBranchInformation(
|
||||
$objCartBookingData->id_hotel,
|
||||
$this->context->cart->id_lang
|
||||
))) {
|
||||
$addressInfo = $objHotelBranch->getAddress($objCartBookingData->id_hotel);
|
||||
$objBookingDetail->hotel_name = $objHotelBranch->hotel_name;
|
||||
$objBookingDetail->city = $addressInfo['city'];
|
||||
$objBookingDetail->state = State::getNameById($addressInfo['id_state']);
|
||||
$objBookingDetail->country = Country::getNameById($this->context->cart->id_lang, $addressInfo['id_country']);
|
||||
$objBookingDetail->zipcode = $addressInfo['postcode'];;
|
||||
$objBookingDetail->phone = $addressInfo['phone'];
|
||||
$objBookingDetail->email = $objHotelBranch->email;
|
||||
$objBookingDetail->check_in_time = $objHotelBranch->check_in;
|
||||
$objBookingDetail->check_out_time = $objHotelBranch->check_out;
|
||||
}
|
||||
|
||||
if ($objBookingDetail->save()) {
|
||||
// Get Booking Demands of the old booking to add in the new booking creation
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
if ($oldBookingDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$objOldHotelBooking->id_order,
|
||||
$objOldHotelBooking->id_product,
|
||||
$objOldHotelBooking->id_room,
|
||||
$objOldHotelBooking->date_from,
|
||||
$objOldHotelBooking->date_to
|
||||
)) {
|
||||
if (isset($oldBookingDemands[$objOldHotelBooking->id_room]['extra_demands']) && $oldBookingDemands[$objOldHotelBooking->id_room]['extra_demands']) {
|
||||
foreach ($oldBookingDemands[$objOldHotelBooking->id_room]['extra_demands'] as $bookingDemand) {
|
||||
$objBookingDemand = new HotelBookingDemands($bookingDemand['id_booking_demand']);
|
||||
$objBookingDemand->id_htl_booking = $objBookingDetail->id;
|
||||
$objBookingDemand->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get Booking services of the old booking to add in the new booking creation
|
||||
$objServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
if ($oldAdditonalServices = $objServiceProductOrderDetail->getSelectedServicesForRoom($idHotelBooking)) {
|
||||
if (isset($oldAdditonalServices['additional_services']) && $oldAdditonalServices['additional_services']) {
|
||||
foreach ($oldAdditonalServices['additional_services'] as $service) {
|
||||
$objServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($service['id_room_type_service_product_order_detail']);
|
||||
$objServiceProductOrderDetail->id_htl_booking_detail = $objBookingDetail->id;
|
||||
$objServiceProductOrderDetail->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete cart feature prices after room addition success
|
||||
HotelRoomTypeFeaturePricing::deleteByIdCart($this->context->cart->id);
|
||||
|
||||
// ===============================================================
|
||||
// END: Add Process of the old booking
|
||||
// ===============================================================
|
||||
|
||||
// ===============================================================
|
||||
// Start: Delete Process of the old booking
|
||||
// ===============================================================
|
||||
$deleteQty = false;
|
||||
if ($productQty >= $objOldOrderDetail->product_quantity) {
|
||||
$deleteQty = true;
|
||||
} else {
|
||||
// Calculate differences of price (Before / After)
|
||||
|
||||
$objOldOrderDetail->total_price_tax_incl -= $totalRoomPriceTaxIncl;
|
||||
$objOldOrderDetail->total_price_tax_excl -= $totalRoomPriceTaxExcl;
|
||||
|
||||
$old_quantity = $objOldOrderDetail->product_quantity;
|
||||
|
||||
$objOldOrderDetail->product_quantity = $old_quantity - $product_quantity;
|
||||
$objOldOrderDetail->reduction_percent = 0;
|
||||
|
||||
// update taxes
|
||||
$res &= $objOldOrderDetail->updateTaxAmount($objOrder);
|
||||
|
||||
// Save order detail
|
||||
$res &= $objOldOrderDetail->update();
|
||||
}
|
||||
|
||||
// Update OrderInvoice of this OrderDetail
|
||||
if ($objOldOrderDetail->id_order_invoice != 0) {
|
||||
// values changes as values are calculated accoding to the quantity of the product by webkul
|
||||
$objOrderInvoice = new OrderInvoice($objOldOrderDetail->id_order_invoice);
|
||||
$objOrderInvoice->total_paid_tax_excl -= $totalRoomPriceTaxExcl;
|
||||
$objOrderInvoice->total_paid_tax_excl = $objOrderInvoice->total_paid_tax_excl > 0 ? $objOrderInvoice->total_paid_tax_excl : 0;
|
||||
|
||||
$objOrderInvoice->total_paid_tax_incl -= $totalRoomPriceTaxIncl;
|
||||
$objOrderInvoice->total_paid_tax_incl = $objOrderInvoice->total_paid_tax_incl > 0 ? $objOrderInvoice->total_paid_tax_incl : 0;
|
||||
|
||||
$objOrderInvoice->total_products -= $totalRoomPriceTaxExcl;
|
||||
$objOrderInvoice->total_products = $objOrderInvoice->total_products > 0 ? $objOrderInvoice->total_products : 0;
|
||||
|
||||
$objOrderInvoice->total_products_wt -= $totalRoomPriceTaxIncl;
|
||||
$objOrderInvoice->total_products_wt = $objOrderInvoice->total_products_wt > 0 ? $objOrderInvoice->total_products_wt : 0;
|
||||
|
||||
$res &= $objOrderInvoice->update();
|
||||
}
|
||||
|
||||
// values changes as values are calculated accoding to the quantity of the product by webkul
|
||||
$objOrder->total_paid -= $totalRoomPriceTaxIncl;
|
||||
$objOrder->total_paid = $objOrder->total_paid > 0 ? $objOrder->total_paid : 0;
|
||||
|
||||
$objOrder->total_paid_tax_incl -= $totalRoomPriceTaxIncl;
|
||||
$objOrder->total_paid_tax_incl = $objOrder->total_paid_tax_incl > 0 ? $objOrder->total_paid_tax_incl : 0;
|
||||
|
||||
$objOrder->total_paid_tax_excl -= $totalRoomPriceTaxExcl;
|
||||
$objOrder->total_paid_tax_excl = $objOrder->total_paid_tax_excl > 0 ? $objOrder->total_paid_tax_excl : 0;
|
||||
|
||||
$objOrder->total_products -= $totalRoomPriceTaxExcl;
|
||||
$objOrder->total_products = $objOrder->total_products > 0 ? $objOrder->total_products : 0;
|
||||
|
||||
$objOrder->total_products_wt -= $totalRoomPriceTaxIncl;
|
||||
$objOrder->total_products_wt = $objOrder->total_products_wt > 0 ? $objOrder->total_products_wt : 0;
|
||||
|
||||
$objOrder->update();
|
||||
|
||||
// Reinject quantity in stock
|
||||
$objOldOrderDetail->reinjectQuantity($objOldOrderDetail, $objOldOrderDetail->product_quantity, $deleteQty);
|
||||
|
||||
// delete the booking detail
|
||||
$objOldHotelBooking = new HotelBookingDetail($idHotelBooking);
|
||||
$objOldHotelBooking->delete();
|
||||
|
||||
// ===============================================================
|
||||
// END Delete Process of the old booking
|
||||
// ===============================================================
|
||||
} else {
|
||||
// If we are reallocating to the same room type then we need to update only the room details
|
||||
$objOldHotelBooking->id_room = $idRoom;
|
||||
$objOldHotelBooking->room_num = $objHotelRoomInfo->room_num;
|
||||
// set backorder to 0 as available reallocate rooms will always be free
|
||||
$objOldHotelBooking->is_back_order = 0;
|
||||
|
||||
$result &= $objOldHotelBooking->save();
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
Hook::exec(
|
||||
@@ -1975,10 +2253,10 @@ class HotelBookingDetail extends ObjectModel
|
||||
*
|
||||
* @return [boolean] [true if updated otherwise false]
|
||||
*/
|
||||
public function updateOrderRefundStatus($id_order, $date_from = false, $date_to = false, $id_rooms = array(), $is_refunded = 1)
|
||||
public function updateOrderRefundStatus($id_order, $date_from = false, $date_to = false, $id_rooms = array(), $is_refunded = 1, $is_cancelled = 0)
|
||||
{
|
||||
$table = 'htl_booking_detail';
|
||||
$data = array('is_refunded' => (int) $is_refunded);
|
||||
$data = array('is_refunded' => (int) $is_refunded, 'is_cancelled' => (int) $is_cancelled);
|
||||
|
||||
if ($id_rooms) {
|
||||
foreach ($id_rooms as $key_rm => $val_rm) {
|
||||
@@ -2196,7 +2474,7 @@ class HotelBookingDetail extends ObjectModel
|
||||
$order_detail_data[$key]['child_ages'] = json_decode($value['child_ages']);
|
||||
|
||||
// Check if this booking as any refund history then enter refund data
|
||||
if ($refundInfo = OrderReturnCore::getOrdersReturnDetail($id_order, 0, $value['id'])) {
|
||||
if ($refundInfo = OrderReturn::getOrdersReturnDetail($id_order, 0, $value['id'])) {
|
||||
$order_detail_data[$key]['refund_info'] = reset($refundInfo);
|
||||
}
|
||||
}
|
||||
@@ -2870,9 +3148,12 @@ class HotelBookingDetail extends ObjectModel
|
||||
);
|
||||
$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 ((float) $orderTotalPaid <= 0) {
|
||||
if (!$hasOrderDiscountOrPayment) {
|
||||
$objHotelBookingDemands = new HotelBookingDemands();
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
|
||||
@@ -2919,8 +3200,14 @@ class HotelBookingDetail extends ObjectModel
|
||||
$objOrderDetail->product_quantity_refunded = $objOrderDetail->product_quantity;
|
||||
}
|
||||
|
||||
$objOrderDetail->total_price_tax_excl -= Tools::ps_round((float) $objRoomTypeServiceProductOrderDetail->total_price_tax_excl, 6);
|
||||
$objOrderDetail->total_price_tax_incl -= Tools::ps_round((float) $objRoomTypeServiceProductOrderDetail->total_price_tax_incl, 6);
|
||||
$objOrderDetail->total_price_tax_excl = Tools::ps_round(
|
||||
($objOrderDetail->total_price_tax_excl - $objRoomTypeServiceProductOrderDetail->total_price_tax_excl),
|
||||
6
|
||||
);
|
||||
$objOrderDetail->total_price_tax_incl = Tools::ps_round(
|
||||
($objOrderDetail->total_price_tax_incl - $objRoomTypeServiceProductOrderDetail->total_price_tax_incl),
|
||||
6
|
||||
);
|
||||
|
||||
$objOrderDetail->save();
|
||||
}
|
||||
@@ -2945,16 +3232,47 @@ class HotelBookingDetail extends ObjectModel
|
||||
$objOrderDetail->product_quantity_refunded = $objOrderDetail->product_quantity;
|
||||
}
|
||||
|
||||
if ((float) $orderTotalPaid <= 0) {
|
||||
if (!$hasOrderDiscountOrPayment) {
|
||||
// reduce room amount from order and order detail
|
||||
$objOrderDetail->total_price_tax_incl -= Tools::ps_round((float) $this->total_price_tax_incl, 6);
|
||||
$objOrderDetail->total_price_tax_excl -= Tools::ps_round((float) $this->total_price_tax_excl, 6);
|
||||
$objOrderDetail->total_price_tax_incl = Tools::ps_round(
|
||||
($objOrderDetail->total_price_tax_incl - $this->total_price_tax_incl),
|
||||
6
|
||||
);
|
||||
$objOrderDetail->total_price_tax_excl = Tools::ps_round(
|
||||
($objOrderDetail->total_price_tax_excl - $this->total_price_tax_excl),
|
||||
6
|
||||
);
|
||||
if (Validate::isLoadedObject($objOrder = new Order($this->id_order))) {
|
||||
$objOrder->total_paid -= $reduction_amount['total_price_tax_incl'];
|
||||
$objOrder->total_paid_tax_excl -= Tools::ps_round((float) $reduction_amount['total_price_tax_excl'], 6);
|
||||
$objOrder->total_paid_tax_incl -= Tools::ps_round((float) $reduction_amount['total_price_tax_incl'], 6);
|
||||
$objOrder->total_products -= Tools::ps_round((float) $reduction_amount['total_products_tax_excl'], 6);
|
||||
$objOrder->total_products_wt -= Tools::ps_round((float) $reduction_amount['total_products_tax_incl'], 6);
|
||||
$objOrder->total_paid = Tools::ps_round(
|
||||
($objOrder->total_paid - $reduction_amount['total_price_tax_incl']),
|
||||
6
|
||||
);
|
||||
$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']),
|
||||
6
|
||||
);
|
||||
$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']),
|
||||
6
|
||||
);
|
||||
$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']),
|
||||
6
|
||||
);
|
||||
$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']),
|
||||
6
|
||||
);
|
||||
$objOrder->total_products_wt = $objOrder->total_products_wt > 0 ? $objOrder->total_products_wt : 0;
|
||||
|
||||
$objOrder->save();
|
||||
}
|
||||
}
|
||||
@@ -2964,7 +3282,7 @@ class HotelBookingDetail extends ObjectModel
|
||||
|
||||
// as refund is completed then set the booking as refunded
|
||||
$this->is_refunded = 1;
|
||||
if ((float) $orderTotalPaid <= 0) {
|
||||
if (!$hasOrderDiscountOrPayment) {
|
||||
// Reduce room amount from htl_booking_detail
|
||||
$this->is_cancelled = 1;
|
||||
$this->total_price_tax_excl = 0;
|
||||
@@ -2979,66 +3297,6 @@ class HotelBookingDetail extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setBookingCancellationMessage($message, $byAdmin = 0)
|
||||
{
|
||||
if (Validate::isLoadedObject($this)) {
|
||||
// First save the message for the admin for the refund
|
||||
$objectMessage = new Message();
|
||||
$objectMessage->message = $message;
|
||||
$objectMessage->id_cart = (int)$this->id_cart;
|
||||
$objectMessage->id_customer = (int)($this->id_customer);
|
||||
$objectMessage->id_order = (int)$this->id_order;
|
||||
$objectMessage->private = 1;
|
||||
|
||||
// If cancelled by admin then set the employee id who is doing this cancellation else put 0
|
||||
$context = Context::getContext();
|
||||
if ($byAdmin) {
|
||||
$objectMessage->id_employee = (int)$context->employee->id;
|
||||
} else {
|
||||
$objectMessage->id_employee = 0;
|
||||
}
|
||||
|
||||
$objectMessage->add();
|
||||
|
||||
// save this message for the customer
|
||||
$objCustomer = new Customer($this->id_customer);
|
||||
$idCustomerThread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($objCustomer->email, $this->id_order);
|
||||
if (!$idCustomerThread) {
|
||||
$objCustomerThread = new CustomerThread();
|
||||
$objCustomerThread->id_contact = 0;
|
||||
$objCustomerThread->id_customer = (int)$this->id_customer;
|
||||
$objCustomerThread->id_shop = (int)$context->shop->id;
|
||||
$objCustomerThread->id_order = (int)$this->id_order;
|
||||
$objCustomerThread->id_lang = (int)$context->language->id;
|
||||
$objCustomerThread->email = $objCustomer->email;
|
||||
$objCustomerThread->status = 'open';
|
||||
$objCustomerThread->token = Tools::passwdGen(12);
|
||||
$objCustomerThread->add();
|
||||
} else {
|
||||
$objCustomerThread = new CustomerThread((int)$idCustomerThread);
|
||||
}
|
||||
|
||||
$objCustomerMessage = new CustomerMessage();
|
||||
$objCustomerMessage->id_customer_thread = $objCustomerThread->id;
|
||||
|
||||
// If cancelled by admin then set the employee id who is doing this cancellation else put 0
|
||||
if ($byAdmin) {
|
||||
$objCustomerMessage->id_employee = (int)$context->employee->id;
|
||||
} else {
|
||||
$objCustomerMessage->id_employee = 0;
|
||||
}
|
||||
|
||||
$objCustomerMessage->message = $message;
|
||||
$objCustomerMessage->private = 0;
|
||||
|
||||
$objCustomerMessage->add();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get overbooked rooms in the order|hotel
|
||||
* @param [int] $idOrder : id of the order
|
||||
|
||||
@@ -199,6 +199,8 @@ class HotelHelper
|
||||
|
||||
Configuration::updateValue('WK_HOTEL_LOCATION_ENABLE', 1);
|
||||
Configuration::updateValue('WK_HOTEL_NAME_ENABLE', 1);
|
||||
Configuration::updateValue('WK_HOTEL_NAME_SEARCH_THRESHOLD', 5);
|
||||
Configuration::updateValue('WK_SEARCH_AUTO_FOCUS_NEXT_FIELD', 1);
|
||||
Configuration::updateValue('WK_ROOM_LEFT_WARNING_NUMBER', 10);
|
||||
Configuration::updateValue('WK_HTL_ESTABLISHMENT_YEAR', 2010);
|
||||
|
||||
|
||||
@@ -972,4 +972,31 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
|
||||
return $this->update($null_values);
|
||||
}
|
||||
|
||||
public static function createAutoFeaturePrice($params)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$featurePriceName = array();
|
||||
foreach (Language::getIDs(true) as $idLang) {
|
||||
$featurePriceName[$idLang] = 'Auto-generated';
|
||||
}
|
||||
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
$objFeaturePricing->id_product = (int) $params['id_product'];
|
||||
$objFeaturePricing->id_cart = (int) $params['id_cart'];
|
||||
$objFeaturePricing->id_guest = (int) $params['id_guest'];
|
||||
$objFeaturePricing->id_room = (int) $params['id_room'];
|
||||
$objFeaturePricing->feature_price_name = $featurePriceName;
|
||||
$objFeaturePricing->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
|
||||
$objFeaturePricing->date_from = date('Y-m-d', strtotime($params['date_from']));
|
||||
$objFeaturePricing->date_to = date('Y-m-d', strtotime($params['date_to']));
|
||||
$objFeaturePricing->is_special_days_exists = 0;
|
||||
$objFeaturePricing->special_days = json_encode(false);
|
||||
$objFeaturePricing->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
|
||||
$objFeaturePricing->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
$objFeaturePricing->impact_value = $params['price'];
|
||||
$objFeaturePricing->active = 1;
|
||||
$objFeaturePricing->groupBox = array_column(Group::getGroups($context->language->id), 'id_group');
|
||||
$objFeaturePricing->add();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,10 @@ class RoomTypeServiceProductPrice extends ObjectModel
|
||||
if ($result = Db::getInstance()->getRow('
|
||||
SELECT spp.`price`, spp.`id_tax_rules_group`, p.`auto_add_to_cart`, p.`price_addition_type`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` sp ON (sp.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_price` spp ON (spp.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` sp
|
||||
ON (sp.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_price` spp
|
||||
ON (spp.`id_product` = sp.`id_product` AND spp.`id_element` = sp.`id_element` AND spp.`element_type` = sp.`element_type`)
|
||||
WHERE p.`id_product`='.(int)$idProduct.
|
||||
' AND sp.`id_element`='.(int)$idElement.
|
||||
' AND sp.`element_type`='.(int)$elementType)
|
||||
|
||||
@@ -81,6 +81,32 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
'hint' => $this->l('This option can be disabled if only one active hotel in the website.
|
||||
In case of more than one active hotel, Hotel Name will always be shown in the search panel.'),
|
||||
),
|
||||
'WK_SEARCH_AUTO_FOCUS_NEXT_FIELD' => array(
|
||||
'title' => $this->l('Focus next field automatically'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool',
|
||||
'default' => '0',
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
),
|
||||
),
|
||||
'hint' => $this->l('Enable if you want the next booking search field to be focused automatically after setting value for a field.'),
|
||||
),
|
||||
'WK_HOTEL_NAME_SEARCH_THRESHOLD' => array(
|
||||
'title' => $this->l('Hotel name search threshold'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedInt',
|
||||
'hint' => $this->l('Enter the number of hotels after which user can search hotel by name.'),
|
||||
'desc' => $this->l('Set to 0 to always show the search box.'),
|
||||
'class' => 'fixed-width-xxl',
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
@@ -312,6 +338,8 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitOptions'.$this->table)) {
|
||||
$hotelNameSearchThreshold = Tools::getValue('WK_HOTEL_NAME_SEARCH_THRESHOLD');
|
||||
|
||||
// check if field is atleast in default language. Not available in default prestashop
|
||||
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
|
||||
$objDefaultLanguage = Language::getLanguage((int) $defaultLangId);
|
||||
@@ -324,6 +352,12 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
|
||||
// End occupancy fields validation
|
||||
|
||||
if (!$hotelNameSearchThreshold && $hotelNameSearchThreshold !== '0') {
|
||||
$this->errors[] = $this->l('Hotel name search threshold field is required.');
|
||||
} elseif (!Validate::isUnsignedInt($hotelNameSearchThreshold)) {
|
||||
$this->errors[] = $this->l('Hotel name search threshold field is invalid.');
|
||||
}
|
||||
|
||||
if (!trim(Tools::getValue('WK_HTL_CHAIN_NAME_'.$defaultLangId))) {
|
||||
$this->errors[] = $this->l('Hotel chain name is required at least in ').$objDefaultLanguage['name'];
|
||||
} else {
|
||||
|
||||
@@ -177,86 +177,95 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelRoomsBooking').'&'.http_build_query($urlData));
|
||||
}
|
||||
|
||||
// Process reallocation of rooms
|
||||
// Process reallocation of rooms
|
||||
if (Tools::isSubmit('realloc_allocated_rooms')) {
|
||||
$idOrder = Tools::getValue('id_order');
|
||||
$idHtlBookingFrom = Tools::getValue('id_htl_booking');
|
||||
$idNewRoomType = Tools::getValue('realloc_avail_room_type');
|
||||
$idRoomToReallocate = Tools::getValue('realloc_avail_rooms');
|
||||
$priceDiff = Tools::getValue('reallocation_price_diff');
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$idOrder = Tools::getValue('id_order');
|
||||
$idHtlBookingFrom = Tools::getValue('id_htl_booking');
|
||||
$idNewRoomType = Tools::getValue('realloc_avail_room_type');
|
||||
$idRoomToReallocate = Tools::getValue('realloc_avail_rooms');
|
||||
$priceDiff = Tools::getValue('reallocation_price_diff');
|
||||
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
if ($idRoomToReallocate) {
|
||||
// check if room is from selected room type
|
||||
if (Validate::isLoadedObject($objRoomInfo = new HotelRoomInformation($idRoomToReallocate))) {
|
||||
if ($objRoomInfo->id_product != $idNewRoomType) {
|
||||
$this->errors[] = $this->l('Invalid room selected for reallocation.');
|
||||
} elseif (!Validate::isLoadedObject($objHotelBooking = new HotelBookingDetail($idHtlBookingFrom))) {
|
||||
$this->errors[] = $this->l('Invalid booking found for reallocation.');
|
||||
} elseif (!$availableRooms = $objBookingDetail->getAvailableRoomsForReallocation(
|
||||
$objHotelBooking->date_from,
|
||||
$objHotelBooking->date_to,
|
||||
$idNewRoomType,
|
||||
$objHotelBooking->id_hotel
|
||||
)) {
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
if ($idRoomToReallocate) {
|
||||
// check if room is from selected room type
|
||||
if (Validate::isLoadedObject($objRoomInfo = new HotelRoomInformation($idRoomToReallocate))) {
|
||||
if ($objRoomInfo->id_product != $idNewRoomType) {
|
||||
$this->errors[] = $this->l('Invalid room selected for reallocation.');
|
||||
} elseif (!Validate::isLoadedObject($objHotelBooking = new HotelBookingDetail($idHtlBookingFrom))) {
|
||||
$this->errors[] = $this->l('Invalid booking found for reallocation.');
|
||||
} elseif (!$availableRooms = $objBookingDetail->getAvailableRoomsForReallocation(
|
||||
$objHotelBooking->date_from,
|
||||
$objHotelBooking->date_to,
|
||||
$idNewRoomType,
|
||||
$objHotelBooking->id_hotel
|
||||
)) {
|
||||
$this->errors[] = $this->l('Selected room is not available for reallocation.');
|
||||
} elseif (!in_array($idRoomToReallocate, array_column($availableRooms, 'id_room'))) {
|
||||
$this->errors[] = $this->l('Selected room is not available for reallocation.');
|
||||
} elseif (!Validate::isFloat($priceDiff)) {
|
||||
$this->errors[] = $this->l('Invalid price difference of the room types.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Selected room is not available for reallocation.');
|
||||
} elseif (!in_array($idRoomToReallocate, array_column($availableRooms, 'id_room'))) {
|
||||
$this->errors[] = $this->l('Selected room is not available for reallocation.');
|
||||
} elseif (!Validate::isFloat($priceDiff)) {
|
||||
$this->errors[] = $this->l('Invalid price difference of the room types.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Selected room is not available for reallocation.');
|
||||
$this->errors[] = $this->l('Please select a room to reallocate with this room.');
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
// Finally, reallocate the room
|
||||
if ($objBookingDetail->reallocateBooking($idHtlBookingFrom, $idRoomToReallocate, $priceDiff)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $idOrder.'&vieworder&conf=52&token='.$this->token);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured. Please try again.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Please select a room to reallocate with this room.');
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
// Finally, reallocate the room
|
||||
if ($objBookingDetail->reallocateBooking($idHtlBookingFrom, $idRoomToReallocate, $priceDiff)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=52&token='.$this->token);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured. Please try again.');
|
||||
}
|
||||
$this->errors[] = $this->l('You do not have permission to edit this.');
|
||||
}
|
||||
}
|
||||
|
||||
// Process swap of rooms
|
||||
if (Tools::isSubmit('swap_allocated_rooms')) {
|
||||
$idOrder = Tools::getValue('id_order');
|
||||
$idHtlBookingFrom = Tools::getValue('id_htl_booking');
|
||||
$idHtlBookingToSwap = Tools::getValue('swap_avail_rooms');
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$idOrder = Tools::getValue('id_order');
|
||||
$idHtlBookingFrom = Tools::getValue('id_htl_booking');
|
||||
$idHtlBookingToSwap = Tools::getValue('swap_avail_rooms');
|
||||
|
||||
if (!Validate::isLoadedObject($objHotelBooking = new HotelBookingDetail($idHtlBookingFrom))) {
|
||||
$this->errors[] = $this->l('Selected room is not available to swap.');
|
||||
} else {
|
||||
if (!Validate::isLoadedObject($objHotelBookingTo = new HotelBookingDetail($idHtlBookingToSwap))) {
|
||||
$this->errors[] = $this->l('Please select a room to swap with this room booking.');
|
||||
if (!Validate::isLoadedObject($objHotelBooking = new HotelBookingDetail($idHtlBookingFrom))) {
|
||||
$this->errors[] = $this->l('Selected room is not available to swap.');
|
||||
} else {
|
||||
if ($availableRooms = $objHotelBooking->getAvailableRoomsForSwapping(
|
||||
$objHotelBooking->date_from,
|
||||
$objHotelBooking->date_to,
|
||||
$objHotelBooking->id_product,
|
||||
$objHotelBooking->id_hotel,
|
||||
$objHotelBooking->id_room
|
||||
)) {
|
||||
if (!in_array($idHtlBookingToSwap, array_column($availableRooms, 'id_hotel_booking'))) {
|
||||
if (!Validate::isLoadedObject($objHotelBookingTo = new HotelBookingDetail($idHtlBookingToSwap))) {
|
||||
$this->errors[] = $this->l('Please select a room to swap with this room booking.');
|
||||
} else {
|
||||
if ($availableRooms = $objHotelBooking->getAvailableRoomsForSwapping(
|
||||
$objHotelBooking->date_from,
|
||||
$objHotelBooking->date_to,
|
||||
$objHotelBooking->id_product,
|
||||
$objHotelBooking->id_hotel,
|
||||
$objHotelBooking->id_room
|
||||
)) {
|
||||
if (!in_array($idHtlBookingToSwap, array_column($availableRooms, 'id_hotel_booking'))) {
|
||||
$this->errors[] = $this->l('Selected room is not available to swap.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Selected room is not available to swap.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Selected room is not available to swap.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
if ($objBookingDetail->swapBooking($idHtlBookingFrom, $idHtlBookingToSwap)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=53&token='.$this->token);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured. Please try again.');
|
||||
if (!count($this->errors)) {
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
if ($objBookingDetail->swapBooking($idHtlBookingFrom, $idHtlBookingToSwap)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int)$idOrder.'&vieworder&conf=53&token='.$this->token);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured. Please try again.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('You do not have permission to edit this.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -870,8 +879,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
$newRoomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$idNewRoomType,
|
||||
$objHotelBooking->date_from,
|
||||
$objHotelBooking->date_to
|
||||
$objHotelBooking->date_to,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
if ($objHotelBooking->total_price_tax_excl != $newRoomTotalPrice['total_price_tax_excl']) {
|
||||
$result['has_price_changes'] = 1;
|
||||
$result['price_diff'] = $newRoomTotalPrice['total_price_tax_excl'] - $objHotelBooking->total_price_tax_excl;
|
||||
@@ -887,6 +903,35 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
$this->ajaxDie(json_encode($result));
|
||||
}
|
||||
|
||||
public function ajaxProcessInitRoomReallocationModal()
|
||||
{
|
||||
// set modal details
|
||||
$response['hasError'] = 1;
|
||||
if (Validate::isLoadedObject($objOrder = new Order(Tools::getValue('id_order')))) {
|
||||
$htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus();
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'order' => $objOrder,
|
||||
'currency' => new Currency($objOrder->id_currency),
|
||||
'reallocate_form_action' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'),
|
||||
)
|
||||
);
|
||||
$modal = array(
|
||||
'modal_id' => 'room-reallocation-modal',
|
||||
'modal_class' => 'modal-md order_detail_modal',
|
||||
'modal_title' => '<i class="icon icon-refresh"></i>  '.$this->l('Room Reallocation / Swap'),
|
||||
'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_room_reallocation.tpl'),
|
||||
'modal_actions' => null,
|
||||
);
|
||||
|
||||
$this->context->smarty->assign($modal);
|
||||
$response['hasError'] = 0;
|
||||
$response['modalHtml'] = $this->context->smarty->fetch('modal.tpl');
|
||||
}
|
||||
|
||||
die(Tools::jsonEncode($response));
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
@@ -915,6 +960,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
'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,
|
||||
'rooms_reallocation_url' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'),
|
||||
'rooms_booking_url' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'),
|
||||
'opt_select_all' => $this->l('All Types', null, true),
|
||||
'slt_another_htl' => $this->l('Select Another Hotel', null, true),
|
||||
@@ -927,6 +973,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
'remove' => $this->l('Remove', null, true),
|
||||
'noRoomTypeAvlTxt' => $this->l('No room type available.', null, true),
|
||||
'slct_rm_err' => $this->l('Please select a room first.', null, true),
|
||||
'slct_rm_type_err' => $this->l('Please select a room type first.', null, true),
|
||||
'product_added_cart_txt' => $this->l('Product added in cart', null, true),
|
||||
'info_icon_path' => _MODULE_DIR_.$this->module->name.'/views/img/Slices/info-icon.svg',
|
||||
'select_age_txt' => $this->l('Select age', null, true),
|
||||
@@ -971,5 +1018,8 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
|
||||
$this->addCSS(array(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css'));
|
||||
$this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin/hotel_rooms_booking.js');
|
||||
|
||||
// add js for reallocation process
|
||||
$this->addJS(_PS_JS_DIR_.'admin/reallocation.js');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +28,23 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
$this->list_no_link = true;
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->_select = ' COUNT(IF(a.`state` = '.(int) Configuration::get('PS_ORS_PENDING').', 1, NULL)) AS total_pending_requests,
|
||||
ord.`id_currency`, ord.`total_paid_tax_incl` AS total_order, SUM(a.`refunded_amount`) AS refunded_amount, CONCAT(firstname, " ", lastname) AS cust_name, os.`color`, os.`id_order_state`';
|
||||
$this->_select = ' ord.`id_currency`, CONCAT(firstname, " ", lastname) AS cust_name';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'orders` ord ON (a.`id_order` = ord.`id_order`)';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_state os ON (os.`id_order_state` = ord.`current_state`)';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_state_lang osl ON (osl.`id_order_state` = os.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'customer` cust ON (cust.`id_customer` = ord.`id_customer`)';
|
||||
|
||||
$this->_orderWay = 'DESC';
|
||||
$this->_group = 'GROUP BY ord.`id_order`';
|
||||
if ($idOrder = Tools::getValue('id_order')) {
|
||||
$this->_select .= ', orsl.`name` as `status_name`, ors.`color`';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state ors ON (ors.`id_order_return_state` = a.`state`)';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
$this->_where = ' AND a.`id_order`='. (int)$idOrder;
|
||||
$this->_group = '';
|
||||
} else {
|
||||
$this->_select .= ', ord.`total_paid_tax_incl` AS total_order, os.`id_order_state`, os.`color`, COUNT(IF(a.`state` = '.(int) Configuration::get('PS_ORS_PENDING').', 1, NULL)) AS total_pending_requests, SUM(a.`refunded_amount`) AS refunded_amount';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_state os ON (os.`id_order_state` = ord.`current_state`)';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_state_lang osl ON (osl.`id_order_state` = os.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
$this->_group = 'GROUP BY ord.`id_order`';
|
||||
}
|
||||
|
||||
$orderStatuses = OrderState::getOrderStates($this->context->language->id);
|
||||
$ordStatuses = array();
|
||||
@@ -44,38 +52,85 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
$ordStatuses[$status['id_order_state']] = $status['name'];
|
||||
}
|
||||
/*for showing status of booking with badge_danger or success*/
|
||||
$this->fields_list = array(
|
||||
'id_order' => array(
|
||||
$this->fields_list = array();
|
||||
|
||||
if ($idOrder = Tools::getValue('id_order')) {
|
||||
$refundStatuses = OrderReturnStateCore::getOrderReturnStates($this->context->language->id);
|
||||
|
||||
$retStatuses = array();
|
||||
foreach ($refundStatuses as $status) {
|
||||
$retStatuses[$status['id_order_return_state']] = $status['name'];
|
||||
}
|
||||
$this->fields_list['id_order_return'] = array(
|
||||
'title' => $this->l('Request ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs',
|
||||
);
|
||||
$this->fields_list['id_order'] = array(
|
||||
'title' => $this->l('Order ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs',
|
||||
'callback' => 'setOrderLink',
|
||||
'havingFilter' => true,
|
||||
),
|
||||
'cust_name' => array(
|
||||
);
|
||||
$this->fields_list['cust_name'] = array(
|
||||
'title' => $this->l('Customer Name'),
|
||||
'align' => 'center',
|
||||
'havingFilter' => true,
|
||||
'callback' => 'setCustomerLink',
|
||||
),
|
||||
'total_order' => array(
|
||||
'title' => $this->l('Total Order Amount'),
|
||||
'align' => 'center',
|
||||
'callback' => 'setOrderCurrency',
|
||||
'havingFilter' => true,
|
||||
),
|
||||
'refunded_amount' => array(
|
||||
);
|
||||
$this->fields_list['refunded_amount'] = array(
|
||||
'title' => $this->l('Refunded Amount'),
|
||||
'align' => 'center',
|
||||
'callback' => 'setOrderCurrency',
|
||||
'havingFilter' => true,
|
||||
),
|
||||
'total_pending_requests' => array(
|
||||
);
|
||||
$this->fields_list['status_name'] = array(
|
||||
'title' => $this->l('Refund Status'),
|
||||
'type' => 'select',
|
||||
'color' => 'color',
|
||||
'list' => $retStatuses,
|
||||
'filter_key' => 'ors!id_order_return_state',
|
||||
'filter_type' => 'int',
|
||||
);
|
||||
$this->fields_list['date_add'] = array(
|
||||
'title' => $this->l('Requested Date'),
|
||||
'type' => 'datetime',
|
||||
'havingFilter' => true,
|
||||
'filter_key' => 'a!date_add',
|
||||
);
|
||||
} else {
|
||||
$this->fields_list['id_order'] = array(
|
||||
'title' => $this->l('Order ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs',
|
||||
'callback' => 'setOrderLink',
|
||||
'havingFilter' => true,
|
||||
);
|
||||
$this->fields_list['cust_name'] = array(
|
||||
'title' => $this->l('Customer Name'),
|
||||
'align' => 'center',
|
||||
'havingFilter' => true,
|
||||
'callback' => 'setCustomerLink',
|
||||
);
|
||||
$this->fields_list['refunded_amount'] = array(
|
||||
'title' => $this->l('Refunded Amount'),
|
||||
'align' => 'center',
|
||||
'callback' => 'setOrderCurrency',
|
||||
'havingFilter' => true,
|
||||
);
|
||||
$this->fields_list['total_order'] = array(
|
||||
'title' => $this->l('Total Order Amount'),
|
||||
'align' => 'center',
|
||||
'callback' => 'setOrderCurrency',
|
||||
'havingFilter' => true,
|
||||
);
|
||||
$this->fields_list['total_pending_requests'] = array(
|
||||
'title' => $this->l('Pending Requests'),
|
||||
'align' => 'center',
|
||||
'havingFilter' => true,
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
$this->addRowAction('view');
|
||||
$this->identifier = 'id_order_return';
|
||||
|
||||
@@ -88,15 +143,20 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
|
||||
parent::__construct();
|
||||
|
||||
// work on renderlist filter on render view page
|
||||
if (Tools::isSubmit('submitResetorder_return') && Tools::getValue('id_order')) {
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminOrderRefundRequests').'&id_order='.Tools::getValue('id_order').'&view'.$this->table);
|
||||
}
|
||||
|
||||
$this->_conf[101] = $this->l('Refund request has been denied successfully.');
|
||||
$this->_conf[102] = $this->l('Refund request has been completed successfully.');
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
if ($idOrder = Tools::getValue('id_order')) {
|
||||
self::$currentIndex = self::$currentIndex.'&id_order='.(int) $idOrder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function setOrderCurrency($echo, $row)
|
||||
{
|
||||
return Tools::displayPrice($echo, (int) $row['id_currency']);
|
||||
@@ -122,7 +182,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
{
|
||||
if (!Tools::getValue('id_order')) {
|
||||
$objOrderReturn = new OrderReturn($idOrderReturn);
|
||||
return '<a href="'.$this->context->link->getAdminLink('AdminOrderRefundRequests').'&id_order_return='.(int)$idOrderReturn.'&id_order='.(int)$objOrderReturn->id_order.'&view'.$this->table.'" title="'.$this->l('Cancel').'">
|
||||
return '<a href="'.$this->context->link->getAdminLink('AdminOrderRefundRequests').'&id_order='.(int)$objOrderReturn->id_order.'" >
|
||||
<i class="icon-search-plus"></i> '.$this->l('View').
|
||||
'</a>';
|
||||
} else {
|
||||
@@ -139,137 +199,61 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
return;
|
||||
}
|
||||
$refundStatuses = OrderReturnStateCore::getOrderReturnStates($this->context->language->id);
|
||||
if ($idOrder = Tools::getValue('id_order')) {
|
||||
// work on renderlist filter on renderview page
|
||||
if (!Tools::isSubmit('submitFilterorder_return')) {
|
||||
$this->processResetFilters();
|
||||
$objCustomer = new Customer($objOrderReturn->id_customer);
|
||||
$objOrder = new Order($objOrderReturn->id_order);
|
||||
$orderCurrency = new Currency($objOrder->id_currency);
|
||||
|
||||
$objRefundRules = new HotelOrderRefundRules();
|
||||
if ($refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrderReturn->id_order, $objOrderReturn->id)){
|
||||
foreach ($refundReqBookings as &$booking) {
|
||||
$bookingCharges = $objRefundRules->getBookingCancellationDetails(
|
||||
$objOrderReturn->id_order,
|
||||
$objOrderReturn->id,
|
||||
$booking['id']
|
||||
);
|
||||
$booking = array_merge($booking, array_shift($bookingCharges));
|
||||
}
|
||||
|
||||
$this->table = 'order_return';
|
||||
$this->identifier = 'id_order_return';
|
||||
|
||||
/*for showing status of booking with badge_danger or success*/
|
||||
$this->_select = ' CONCAT(cust.`firstname`, " ", cust.`lastname`) AS `cust_name`, ors.`color`, orsl.`name` as `status_name`, ord.`id_currency`';
|
||||
$this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` cust ON (cust.`id_customer` = a.`id_customer`)';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'orders` ord ON (ord.`id_order` = a.`id_order`)';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state ors ON (ors.`id_order_return_state` = a.`state`)';
|
||||
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
|
||||
$this->_where = ' AND a.`id_order`='. (int)$idOrder;
|
||||
$this->_group = '';
|
||||
|
||||
$retStatuses = array();
|
||||
foreach ($refundStatuses as $status) {
|
||||
$retStatuses[$status['id_order_return_state']] = $status['name'];
|
||||
}
|
||||
$this->fields_list = array(
|
||||
'id_order_return' => array(
|
||||
'title' => $this->l('Request ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs',
|
||||
),
|
||||
'id_order' => array(
|
||||
'title' => $this->l('Order ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs',
|
||||
'callback' => 'setOrderLink',
|
||||
'havingFilter' => true,
|
||||
'filter_key' => 'a!id_order',
|
||||
'filter_type' => 'int',
|
||||
),
|
||||
'cust_name' => array(
|
||||
'title' => $this->l('Customer Name'),
|
||||
'align' => 'center',
|
||||
'havingFilter' => true,
|
||||
'callback' => 'setCustomerLink',
|
||||
),
|
||||
'status_name' => array(
|
||||
'title' => $this->l('Refund Status'),
|
||||
'type' => 'select',
|
||||
'color' => 'color',
|
||||
'list' => $retStatuses,
|
||||
'filter_key' => 'ors!id_order_return_state',
|
||||
'filter_type' => 'int',
|
||||
),
|
||||
'refunded_amount' => array(
|
||||
'title' => $this->l('Refunded Amount'),
|
||||
'align' => 'center',
|
||||
'callback' => 'setOrderCurrency',
|
||||
'havingFilter' => true,
|
||||
),
|
||||
'date_add' => array(
|
||||
'title' => $this->l('Requested Date'),
|
||||
'type' => 'datetime',
|
||||
'havingFilter' => true,
|
||||
'filter_key' => 'a!date_add',
|
||||
),
|
||||
);
|
||||
|
||||
$this->identifier = 'id_order_return';
|
||||
|
||||
if (Tools::isSubmit('submitFilterorder_return')) {
|
||||
$this->processFilter();
|
||||
}
|
||||
|
||||
return parent::renderList();
|
||||
} else {
|
||||
$objCustomer = new Customer($objOrderReturn->id_customer);
|
||||
$objOrder = new Order($objOrderReturn->id_order);
|
||||
$orderCurrency = new Currency($objOrder->id_currency);
|
||||
|
||||
$objRefundRules = new HotelOrderRefundRules();
|
||||
if ($refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrderReturn->id_order, $objOrderReturn->id)){
|
||||
foreach ($refundReqBookings as &$booking) {
|
||||
$bookingCharges = $objRefundRules->getBookingCancellationDetails(
|
||||
$objOrderReturn->id_order,
|
||||
$objOrderReturn->id,
|
||||
$booking['id']
|
||||
);
|
||||
$booking = array_merge($booking, array_shift($bookingCharges));
|
||||
}
|
||||
}
|
||||
|
||||
$paymentMethods = array();
|
||||
foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
|
||||
$module = Module::getInstanceByName($payment['name']);
|
||||
if (Validate::isLoadedObject($module) && $module->active) {
|
||||
$paymentMethods[] = $module->displayName;
|
||||
}
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array (
|
||||
'orderTotalPaid' => $objOrder->getTotalPaid(),
|
||||
'customer_name' => $objCustomer->firstname.' '.$objCustomer->lastname,
|
||||
'customer_email' => $objCustomer->email,
|
||||
'orderReturnInfo' => (array)$objOrderReturn,
|
||||
'refundReqBookings' => $refundReqBookings,
|
||||
'orderInfo' => (array) $objOrder,
|
||||
'orderCurrency' => (array) $orderCurrency,
|
||||
'currentOrderStateInfo' => (array) new OrderState($objOrder->current_state,
|
||||
$this->context->language->id),
|
||||
'currentStateInfo' => (array) new OrderReturnState($objOrderReturn->state,
|
||||
$this->context->language->id),
|
||||
'current_id_lang' => $this->context->language->id,
|
||||
'refundStatuses' => $refundStatuses,
|
||||
'isRefundCompleted' => $objOrderReturn->hasBeenCompleted(),
|
||||
'paymentMethods' => $paymentMethods,
|
||||
'name_controller' => Tools::getValue('controller'),
|
||||
'info_icon_path' => $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icon-info.svg')
|
||||
)
|
||||
);
|
||||
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
$paymentMethods = array();
|
||||
foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
|
||||
$module = Module::getInstanceByName($payment['name']);
|
||||
if (Validate::isLoadedObject($module) && $module->active) {
|
||||
$paymentMethods[] = $module->displayName;
|
||||
}
|
||||
}
|
||||
|
||||
$orderTotalPaid = $objOrder->getTotalPaid();
|
||||
$orderDiscounts = $objOrder->getCartRules();
|
||||
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
|
||||
$this->context->smarty->assign(
|
||||
array (
|
||||
'hasOrderDiscountOrPayment' => $hasOrderDiscountOrPayment,
|
||||
'orderTotalPaid' => $orderTotalPaid,
|
||||
'customer_name' => $objCustomer->firstname.' '.$objCustomer->lastname,
|
||||
'customer_email' => $objCustomer->email,
|
||||
'orderReturnInfo' => (array)$objOrderReturn,
|
||||
'refundReqBookings' => $refundReqBookings,
|
||||
'orderInfo' => (array) $objOrder,
|
||||
'orderCurrency' => (array) $orderCurrency,
|
||||
'currentOrderStateInfo' => (array) new OrderState($objOrder->current_state,
|
||||
$this->context->language->id),
|
||||
'currentStateInfo' => (array) new OrderReturnState($objOrderReturn->state,
|
||||
$this->context->language->id),
|
||||
'current_id_lang' => $this->context->language->id,
|
||||
'refundStatuses' => $refundStatuses,
|
||||
'isRefundCompleted' => $objOrderReturn->hasBeenCompleted(),
|
||||
'paymentMethods' => $paymentMethods,
|
||||
'name_controller' => Tools::getValue('controller'),
|
||||
'info_icon_path' => $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icon-info.svg')
|
||||
)
|
||||
);
|
||||
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
// for the filteration
|
||||
if (Tools::isSubmit('submitFilterorder_return') && Tools::isSubmit('order_returnFilter_ors!id_order_return_state')) {
|
||||
self::$currentIndex .= '&id_order_return=1&id_order=1&vieworder_return';
|
||||
}
|
||||
|
||||
/*If Admin update the status of the order cancellation request*/
|
||||
if (Tools::isSubmit('submitRefundReqBookings') || Tools::isSubmit('submitRefundReqBookingsAndStay')) {
|
||||
$idOrderReturn = Tools::getValue('id_order_return');
|
||||
@@ -277,11 +261,14 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
if (Validate::isLoadedObject($objOrderReturn = new OrderReturn($idOrderReturn))) {
|
||||
$objOrder = new Order($objOrderReturn->id_order);
|
||||
$orderTotalPaid = $objOrder->getTotalPaid();
|
||||
$orderDiscounts = $objOrder->getCartRules();
|
||||
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
|
||||
|
||||
$idRefundState = Tools::getValue('id_refund_state');
|
||||
if (Validate::isLoadedObject($objRefundState = new OrderReturnState($idRefundState))) {
|
||||
if ($objRefundState->refunded) {
|
||||
$refundedAmounts = Tools::getValue('refund_amounts');
|
||||
if ((float) $orderTotalPaid > 0) {
|
||||
if ($hasOrderDiscountOrPayment) {
|
||||
if ($idsReturnDetail && count($idsReturnDetail)) {
|
||||
if ($refundedAmounts) {
|
||||
foreach ($idsReturnDetail as $idRetDetail) {
|
||||
@@ -366,6 +353,8 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
// save individual booking amount for every booking refund
|
||||
$refundedAmount = $refundedAmounts[$idRetDetail];
|
||||
$objOrderReturnDetail->refunded_amount = $refundedAmount;
|
||||
// set the id_customization to check if in this request which bookings are refunded or not for future
|
||||
$objOrderReturnDetail->id_customization = 1;
|
||||
$objOrderReturnDetail->save();
|
||||
|
||||
// sum the refund amount for total order refund amount
|
||||
@@ -392,7 +381,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
}
|
||||
|
||||
// if bookings are refunded then set the payment information
|
||||
if ((float) $orderTotalPaid > 0) {
|
||||
if ($hasOrderDiscountOrPayment) {
|
||||
if (Tools::isSubmit('refundTransactionAmount')) {
|
||||
$objOrderReturn->payment_mode = $paymentMode;
|
||||
$objOrderReturn->id_transaction = $idTransaction;
|
||||
@@ -415,7 +404,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
$idOrderState = 0;
|
||||
if ($objOrder->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) {
|
||||
$idOrderState = Configuration::get('PS_OS_REFUND');
|
||||
} elseif ($objOrder->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) {
|
||||
} elseif ($objOrder->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) {
|
||||
$idOrderState = Configuration::get('PS_OS_CANCELED');
|
||||
}
|
||||
|
||||
@@ -569,9 +558,10 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
$this->addJqueryUI('ui.tooltip', 'base', true);
|
||||
|
||||
$this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin/wk_refund_request.js');
|
||||
$this->addCSS(_MODULE_DIR_.$this->module->name.'/views/css/admin/wk_refund_request.css');
|
||||
if ($this->display == 'view') {
|
||||
$this->addJqueryUI('ui.tooltip', 'base', true);
|
||||
$this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin/wk_refund_request.js');
|
||||
$this->addCSS(_MODULE_DIR_.$this->module->name.'/views/css/admin/wk_refund_request.css');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,7 +484,11 @@ class HotelReservationSystem extends Module
|
||||
|
||||
// Make rooms available for booking if order status is cancelled, refunded or error
|
||||
if (in_array($params['newOrderStatus']->id, $objHtlBkDtl->getOrderStatusToFreeBookedRoom())) {
|
||||
if (!$objHtlBkDtl->updateOrderRefundStatus($params['id_order'])) {
|
||||
$isCancelled = 0;
|
||||
if ($params['newOrderStatus']->id == Configuration::get('PS_OS_CANCELED')) {
|
||||
$isCancelled = 1;
|
||||
}
|
||||
if (!$objHtlBkDtl->updateOrderRefundStatus($params['id_order'], false, false, array(), 1, $isCancelled)) {
|
||||
$this->context->controller->errors[] = $this->l('Error while making booked rooms available, attached with this order. Please try again !!');
|
||||
}
|
||||
}
|
||||
@@ -509,6 +513,7 @@ class HotelReservationSystem extends Module
|
||||
'htl_room_type_global_demand',
|
||||
'htl_room_type_global_demand_advance_option',
|
||||
'htl_order_refund_rules',
|
||||
'htl_settings_link',
|
||||
);
|
||||
//If Admin update new language when we do entry in module all lang tables.
|
||||
HotelHelper::updateLangTables($newIdLang, $langTables);
|
||||
|
||||
@@ -595,4 +595,12 @@ body.adminhotelroomsbooking .ui-tooltip {
|
||||
border: unset;
|
||||
padding: 10px;
|
||||
box-shadow: 0px 0px 15px 0px #00000026;
|
||||
}
|
||||
|
||||
#room-reallocation-modal .modal-footer {
|
||||
padding: 15px 0px 0px 0px
|
||||
}
|
||||
#room-reallocation-modal .modal-body, #room-reallocation-modal .tab-content {
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd
|
||||
}
|
||||
@@ -1000,180 +1000,4 @@ $(document).ready(function() {
|
||||
return [true, ""];
|
||||
}
|
||||
}
|
||||
|
||||
$('#mySwappigModal').on('hidden.bs.modal', function (e) {
|
||||
$(".modal_curr_room_num").val('');
|
||||
$(".modal_id_htl_booking").val('');
|
||||
$("#reallocation_price_diff_block .order_currency_sign").html('');
|
||||
$(".cust_name").text('');
|
||||
$(".cust_email").text('');
|
||||
$(".swp_rm_opts").remove();
|
||||
$(".realloc_rm_type_opts").remove();
|
||||
$(".realloc_rm_opts").remove();
|
||||
});
|
||||
|
||||
$('#mySwappigModal').on('shown.bs.modal', function (e)
|
||||
{
|
||||
$(".loading_overlay").show();
|
||||
|
||||
$(".modal_id_htl_booking").val(e.relatedTarget.dataset.id_htl_booking);
|
||||
$("#reallocation_price_diff_block .order_currency_sign").html(e.relatedTarget.dataset.currency_sign);
|
||||
$(".modal_curr_room_num").val(e.relatedTarget.dataset.room_num + ', ' + e.relatedTarget.dataset.room_type_name);
|
||||
$(".cust_name").text(e.relatedTarget.dataset.cust_name);
|
||||
$(".cust_email").text(e.relatedTarget.dataset.cust_email);
|
||||
|
||||
// reset price difference fields
|
||||
$("#reallocation_price_diff").val(0);
|
||||
$("#reallocation_price_diff_block").hide();
|
||||
$(".realloc_roomtype_change_message").hide();
|
||||
|
||||
// For Rooms Swapping
|
||||
var json_arr_rm_swp = JSON.parse(e.relatedTarget.dataset.avail_rm_swap);
|
||||
if (e.relatedTarget.dataset.avail_rm_swap != 'false' && json_arr_rm_swp.length != 0) {
|
||||
html = '<select class="form-control" name="swap_avail_rooms" id="swap_avail_rooms">';
|
||||
$.each(json_arr_rm_swp, function(key,val) {
|
||||
html += '<option class="swp_rm_opts" value="'+val.id_hotel_booking+'" >'+val.room_num+'</option>';
|
||||
});
|
||||
html += '</select>';
|
||||
|
||||
$("#swap_allocated_rooms").removeAttr('disabled');
|
||||
$(".swap_avail_rooms_container").empty().append(html);
|
||||
} else {
|
||||
$(".swap_avail_rooms_container").empty().text(no_swap_rm_avail_txt).addClass('text-danger');
|
||||
$("#swap_allocated_rooms").attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
// For Rooms Reallocation
|
||||
var json_arr_realloc_room_types = JSON.parse(e.relatedTarget.dataset.avail_realloc_room_types);
|
||||
if (e.relatedTarget.dataset.avail_realloc_room_types != 'false' && json_arr_realloc_room_types.length != 0) {
|
||||
var idCurrentRoomType = e.relatedTarget.dataset.id_room_type;
|
||||
var roomsTypesHtml = '<select data-id_htl_booking="' + e.relatedTarget.dataset.id_htl_booking + '" class="form-control" name="realloc_avail_room_type" id="realloc_avail_room_type">';
|
||||
$.each(json_arr_realloc_room_types, function(key, room_type) {
|
||||
roomsTypesHtml += "<option rooms_available='" + JSON.stringify(room_type.rooms) + "' class='realloc_rm_type_opts' value='" + room_type.id_product + "'";
|
||||
if (idCurrentRoomType == room_type.id_product) {
|
||||
roomsTypesHtml += ' selected="selected"';
|
||||
}
|
||||
roomsTypesHtml += '>' + room_type.room_type_name + '</option>';
|
||||
});
|
||||
roomsTypesHtml += '</select>';
|
||||
|
||||
setRoomsForReallocation(json_arr_realloc_room_types[idCurrentRoomType]['rooms']);
|
||||
|
||||
$("#realloc_allocated_rooms").removeAttr('disabled');
|
||||
$(".realloc_avail_room_type_container").empty().append(roomsTypesHtml);
|
||||
} else {
|
||||
$(".realloc_avail_rooms_container").empty().text(no_realloc_rm_avail_txt).addClass('text-danger');
|
||||
$(".realloc_avail_room_type_container").empty().text(no_realloc_rm_type_avail_txt).addClass('text-danger');
|
||||
$("#realloc_allocated_rooms").attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
$(".loading_overlay").hide();
|
||||
});
|
||||
|
||||
// change room type for reallocation
|
||||
$(document).on("change", "#realloc_avail_room_type", function(e) {
|
||||
$(".loading_overlay").show();
|
||||
|
||||
var idHotelBooking = $(this).data('id_htl_booking');
|
||||
$("#reallocation_price_diff").val(0);
|
||||
$("#reallocation_price_diff_block").hide();
|
||||
if (parseInt(idHotelBooking) > 0) {
|
||||
var optionSelected = $(this).find('option:selected');
|
||||
var roomsAvailable = JSON.parse(optionSelected.attr('rooms_available'));
|
||||
|
||||
// set the rooms of the selceted room type
|
||||
setRoomsForReallocation(roomsAvailable);
|
||||
|
||||
// send an ajax for fetching if price has changes in the new room type seleceted
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: {
|
||||
"cache-control": "no-cache"
|
||||
},
|
||||
url: rooms_booking_url,
|
||||
dataType: 'JSON',
|
||||
cache: false,
|
||||
data: {
|
||||
id_htl_booking: idHotelBooking,
|
||||
id_new_room_type: $(this).val(),
|
||||
action: 'changeRoomTypeToReallocate',
|
||||
ajax: true
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.success == 1) {
|
||||
// has room type changed for reallocation
|
||||
if (result.has_room_type_change == 1) {
|
||||
$(".realloc_roomtype_change_message").show();
|
||||
// has room type price changed for reallocation
|
||||
if (result.has_price_changes == 1) {
|
||||
$("#reallocation_price_diff").val(result.price_diff);
|
||||
$("#reallocation_price_diff_block").show();
|
||||
}
|
||||
} else {
|
||||
$(".realloc_roomtype_change_message").hide();
|
||||
}
|
||||
$('#room_type_change_info').empty();
|
||||
if (result.is_changes_present == 1) {
|
||||
}
|
||||
} else if (typeof(result.error) != 'undefinded' && result.error) {
|
||||
showErrorMessage(result.error);
|
||||
} else {
|
||||
showErrorMessage(txtSomeErr);
|
||||
}
|
||||
|
||||
$(".loading_overlay").hide();
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
$(".loading_overlay").hide();
|
||||
showErrorMessage(txtSomeErr);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(".loading_overlay").hide();
|
||||
showErrorMessage(txtSomeErr);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/*For reallocating rooms in the modal*/
|
||||
$("#realloc_allocated_rooms").on('click', function(e){
|
||||
$(".error_text").text('');
|
||||
var room_to_reallocate = $('#realloc_avail_rooms').val();
|
||||
var room_type_to_reallocate = $('#realloc_avail_room_type').val();
|
||||
|
||||
if (typeof room_type_to_reallocate == 'undefined' || room_type_to_reallocate == 0) {
|
||||
$("#realloc_sel_rm_type_err_p").text(slct_rm_type_err);
|
||||
return false;
|
||||
}
|
||||
if (typeof room_to_reallocate == 'undefined' || room_to_reallocate == 0) {
|
||||
$("#realloc_sel_rm_err_p").text(slct_rm_err);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/*For swaping rooms in the modal*/
|
||||
$("#swap_allocated_rooms").on('click', function(e){
|
||||
$(".error_text").text('');
|
||||
var room_to_swap = $('#swap_avail_rooms').val();
|
||||
if (typeof room_to_swap == 'undefined' || room_to_swap == 0) {
|
||||
$("#swap_sel_rm_err_p").text(slct_rm_err);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function setRoomsForReallocation(roomsAvailable)
|
||||
{
|
||||
if (typeof(roomsAvailable) != 'undefined' && roomsAvailable.length) {
|
||||
var roomsHtml = '<select class="form-control" name="realloc_avail_rooms" id="realloc_avail_rooms">';
|
||||
roomsHtml += '<option class="realloc_rm_opts" value="0">---- ' + select_room_txt + ' ----</option>';
|
||||
$.each(roomsAvailable, function(key, roomInfo) {
|
||||
roomsHtml += '<option class="realloc_rm_opts" value="' + roomInfo.id_room + '">' + roomInfo.room_num + '</option>';
|
||||
});
|
||||
roomsHtml += '</select>';
|
||||
|
||||
$(".realloc_avail_rooms_container").empty().append(roomsHtml);
|
||||
} else {
|
||||
$(".realloc_avail_rooms_container").empty().text(no_realloc_rm_avail_txt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
</td>
|
||||
<td>
|
||||
{if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO}
|
||||
<button type="button" class="btn btn-primary" id="reallocate_room_{$rm_dtl_v['id_htl_booking']}" data-room_type_name="{$rm_dtl_v['room_type_name']}" data-toggle="modal" data-target="#mySwappigModal" data-id_htl_booking="{$rm_dtl_v['id_htl_booking']}" data-id_order="{$rm_dtl_v['id_order']}" data-room_num='{$booked_v['room_num']}' data-currency_sign='{$rm_dtl_v['currency_sign']}' data-id_room_type='{$booked_v['id_product']}' data-cust_name='{$rm_dtl_v['alloted_cust_name']}' data-cust_email='{$rm_dtl_v['alloted_cust_email']}' data-avail_rm_swap='{$rm_dtl_v['avail_rooms_to_swap']|@json_encode}' data-avail_realloc_room_types='{$rm_dtl_v['avail_room_types_to_realloc']|@json_encode}'>
|
||||
<button type="button" class="btn btn-primary room_reallocate_swap" id="reallocate_room_{$rm_dtl_v['id_htl_booking']}" data-room_type_name="{$rm_dtl_v['room_type_name']}" data-id_htl_booking="{$rm_dtl_v['id_htl_booking']}" data-id_order="{$rm_dtl_v['id_order']}" data-room_num='{$booked_v['room_num']}' data-currency_sign='{$rm_dtl_v['currency_sign']}' data-id_room_type='{$booked_v['id_product']}' data-cust_name='{$rm_dtl_v['alloted_cust_name']}' data-cust_email='{$rm_dtl_v['alloted_cust_email']}' data-avail_rm_swap='{$rm_dtl_v['avail_rooms_to_swap']|@json_encode}' data-avail_realloc_room_types='{$rm_dtl_v['avail_room_types_to_realloc']|@json_encode}'>
|
||||
{l s='Reallocate Room' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
{else}
|
||||
|
||||
@@ -221,137 +221,7 @@
|
||||
<div class="modal fade" id="cartModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
{include file="./_partials/booking-cart.tpl"}
|
||||
</div>
|
||||
<!-- Modal for reallocation of rooms -->
|
||||
<div class="modal fade" id="mySwappigModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active"><a href="#reallocate_room_tab" aria-controls="reallocate" role="tab" data-toggle="tab">{l s='Room Reallocation' mod='hotelreservationsystem'}</a></li>
|
||||
<li role="presentation"><a href="#swap_room_tab" aria-controls="swap" role="tab" data-toggle="tab">{l s='Swap Room' mod='hotelreservationsystem'}</a></li>
|
||||
</ul>
|
||||
<div class="tab-content active">
|
||||
<div role="tabpanel" class="tab-pane active" id="reallocate_room_tab">
|
||||
<form method="post" action="">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="realloc_myModalLabel">{l s='Reallocate Rooms' mod='hotelreservationsystem'}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="curr_room_num" class="control-label model-label">{l s='Current Room Number:' mod='hotelreservationsystem'}</label>
|
||||
<input type="text" class="form-control modal_curr_room_num" name="modal_curr_room_num" readonly="true">
|
||||
<input type="hidden" class="form-control modal_id_htl_booking" name="id_htl_booking">
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-heading"><i class="icon-user"></i> {l s='Currently Alloted Customer' mod='hotelreservationsystem'}</div>
|
||||
<div class="panel-content">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label model-label">{l s='Name' mod='hotelreservationsystem'} :</label>
|
||||
<div class="dol-sm-9 cust_name"></div>
|
||||
</div>
|
||||
<div class="">
|
||||
<label class="col-sm-3 control-label model-label">{l s='Email' mod='hotelreservationsystem'} :</label>
|
||||
<div class="dol-sm-9 cust_email"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="realloc_avail_room_type" class="control-label model-label">{l s='Room Type To Reallocate:' mod='hotelreservationsystem'}</label>
|
||||
<div class="realloc_avail_room_type_container">
|
||||
<select class="form-control" name="realloc_avail_room_type" id="realloc_avail_room_type">
|
||||
<option value="0" selected="selected">{l s='Select Room Type' mod='hotelreservationsystem'}</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="error_text" id="realloc_sel_rm_type_err_p"></p>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="realloc_avail_rooms" class="control-label model-label">{l s='Room To Reallocate:' mod='hotelreservationsystem'}</label>
|
||||
<div class="realloc_avail_rooms_container">
|
||||
<select class="form-control" name="realloc_avail_rooms" id="realloc_avail_rooms">
|
||||
<option value="0" selected="selected">{l s='Select Rooms' mod='hotelreservationsystem'}</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="error_text" id="realloc_sel_rm_err_p"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="reallocation_price_diff_block" style="display:none;">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="reallocation_price_diff" class="control-label model-label alert-warning">{l s='Price Difference' mod='hotelreservationsystem'} *</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon order_currency_sign"></span>
|
||||
<input type="text" name="reallocation_price_diff" id="reallocation_price_diff" value="0" />
|
||||
<span class="input-group-addon">{l s='Tax excl.' mod='hotelreservationsystem'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="alert alert-warning col-sm-12 realloc_roomtype_change_message" style="display:none">
|
||||
<p>{l s="If room type is changed while room reallocation then all additional facilities and services will be assigned to the selected room of new room type." mod='hotelreservationsystem'}</p>
|
||||
<p>{l s="If you want to change additional facilities or services, you can update by editing the room after reallocation." mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{l s="Close" mod='hotelreservationsystem'}</button>
|
||||
<input type="submit" id="realloc_allocated_rooms" name="realloc_allocated_rooms" class="btn btn-primary" value="Reallocate">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="swap_room_tab">
|
||||
<form method="post" action="">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="swap_myModalLabel">{l s='Swap Rooms' mod='hotelreservationsystem'}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="swap_curr_room_num" class="control-label model-label">{l s='Current Room Number:' mod='hotelreservationsystem'}</label>
|
||||
<input type="text" class="form-control modal_curr_room_num" name="modal_curr_room_num" readonly="true">
|
||||
<input type="hidden" class="form-control modal_id_htl_booking" name="id_htl_booking">
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-heading"><i class="icon-user"></i> {l s='Currently Alloted Customer' mod='hotelreservationsystem'}</div>
|
||||
<div class="panel-content">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label model-label">{l s='Name' mod='hotelreservationsystem'} :</label>
|
||||
<div class="dol-sm-9 cust_name"></div>
|
||||
</div>
|
||||
<div class="">
|
||||
<label class="col-sm-3 control-label model-label">{l s='Email' mod='hotelreservationsystem'} :</label>
|
||||
<div class="dol-sm-9 cust_email"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="swap_avail_rooms" class="control-label model-label">{l s='Rooms To Swap:' mod='hotelreservationsystem'}</label>
|
||||
<div class="swap_avail_rooms_container"></div>
|
||||
<p class="error_text" id="swap_sel_rm_err_p"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{l s="Close" mod='hotelreservationsystem'}</button>
|
||||
<input type="submit" id="swap_allocated_rooms" name="swap_allocated_rooms" class="btn btn-primary" value="Swap">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* loader before loading data *}
|
||||
<div class="loading_overlay">
|
||||
<img src='{$link->getMediaLink("`$img_dir`admin/ajax-loader.gif")}' class="loading-img"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="date-stats-tooltop" style="display:none">
|
||||
<div class="tooltip_cont">
|
||||
<div class="tip_header">
|
||||
|
||||
@@ -131,8 +131,12 @@
|
||||
{if !$isRefundCompleted}
|
||||
<th>{l s='Rooms cancelation charges' mod='hotelreservationsystem'}</th>
|
||||
{/if}
|
||||
{if $orderTotalPaid|floatval}
|
||||
{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 $refundReqBookings as $booking}
|
||||
@@ -184,11 +188,11 @@
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{if $orderTotalPaid|floatval}
|
||||
{if $hasOrderDiscountOrPayment || $isRefundCompleted}
|
||||
<td>
|
||||
<div class="input-group">
|
||||
{if $isRefundCompleted}
|
||||
{displayPrice price=$booking['refunded_amount'] currency=$orderCurrency['id']}
|
||||
{displayPrice price=$booking['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[{$booking['id_order_return_detail']|escape:'html':'UTF-8'}]" value="{if ($booking['room_paid_amount'] + $booking['extra_service_total_paid_amount'] - $booking['cancelation_charge']) > 0}{Tools::ps_round(($booking['room_paid_amount'] + $booking['extra_service_total_paid_amount'] - $booking['cancelation_charge']), 2)}{else}0{/if}">
|
||||
@@ -196,6 +200,18 @@
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
{if $isRefundCompleted}
|
||||
<td>
|
||||
{if $booking['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 $booking['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}
|
||||
@@ -279,7 +295,7 @@
|
||||
</div>
|
||||
|
||||
{* Fields to submit refund information *}
|
||||
{if $orderTotalPaid|floatval}
|
||||
{if $hasOrderDiscountOrPayment}
|
||||
<div class="refunded_state_fields" style="display:none;">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-3">
|
||||
|
||||
@@ -228,6 +228,7 @@ class WkRoomSearchHelper
|
||||
$smartyVars['hotels_info'] = $hotelsInfo;
|
||||
$smartyVars['show_hotel_name'] = Configuration::get('WK_HOTEL_NAME_ENABLE');
|
||||
$smartyVars['max_child_age'] = Configuration::get('WK_GLOBAL_CHILD_MAX_AGE');
|
||||
$smartyVars['hotel_name_search_threshold'] = (int) Configuration::get('WK_HOTEL_NAME_SEARCH_THRESHOLD');
|
||||
|
||||
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($idHotel);
|
||||
$smartyVars['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate));
|
||||
|
||||
@@ -22,44 +22,51 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
$result = array();
|
||||
$this->display_column_left = false;
|
||||
$this->display_column_right = false;
|
||||
|
||||
$result = array('status' => false);
|
||||
$search_data = Tools::getValue('to_search_data');
|
||||
$location_category_id = Tools::getValue('location_category_id');
|
||||
$obj_htl_info = new HotelBranchInformation();
|
||||
if (isset($search_data) && $search_data) {
|
||||
$return_data = $obj_htl_info->getHotelCategoryTree($search_data);
|
||||
if ($return_data) {
|
||||
$html = '';
|
||||
foreach ($return_data as $value) {
|
||||
$html .= '<li value="'.$value['id_category'].'" tabindex="-1" class="search_result_li">'.
|
||||
$value['name'].'</li>';
|
||||
}
|
||||
$result['status'] = 'success';
|
||||
$locationCategories = $obj_htl_info->getHotelCategoryTree($search_data);
|
||||
if ($locationCategories) {
|
||||
$this->context->smarty->assign(array('location_categories' => $locationCategories));
|
||||
$html = $this->context->smarty->fetch(
|
||||
$this->module->getTemplatePath('location-options.tpl')
|
||||
);
|
||||
$result['status'] = true;
|
||||
$result['data'] = $html;
|
||||
}
|
||||
} elseif (isset($location_category_id) && $location_category_id) {
|
||||
$cat_ids = Category::getAllCategoriesName($location_category_id);
|
||||
if ($cat_ids) {
|
||||
$html = '';
|
||||
foreach ($cat_ids as $value) {
|
||||
if ($hotel_info = $obj_htl_info->hotelBranchInfoByCategoryId($value['id_category'])) {
|
||||
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info['id']);
|
||||
$locationCategories = Category::getAllCategoriesName($location_category_id);
|
||||
if ($locationCategories) {
|
||||
$hotelsInfo = array();
|
||||
foreach ($locationCategories as $category) {
|
||||
if ($hotelInfo = $obj_htl_info->hotelBranchInfoByCategoryId($category['id_category'])) {
|
||||
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotelInfo['id']);
|
||||
$maxOrderDate = date('Y-m-d', strtotime($maxOrderDate));
|
||||
$html .= '<li tabindex="-1" class="search_result_li" data-id-hotel="'.$hotel_info['id'].'" data-hotel-cat-id="'.
|
||||
$hotel_info['id_category'].'" data-max_order_date="'.$maxOrderDate.'">'.
|
||||
$hotel_info['hotel_name'].'</li>';
|
||||
|
||||
$hotelsInfo[] = array(
|
||||
'id_hotel' => $hotelInfo['id'],
|
||||
'id_category' => $hotelInfo['id_category'],
|
||||
'hotel_name' => $hotelInfo['hotel_name'],
|
||||
'max_order_date' => $maxOrderDate,
|
||||
);
|
||||
}
|
||||
}
|
||||
$result['status'] = 'success';
|
||||
$result['data'] = $html;
|
||||
} else {
|
||||
$result['status'] = 'failed2';
|
||||
|
||||
$this->context->smarty->assign(array('hotels_info' => $hotelsInfo));
|
||||
$html = $this->context->smarty->fetch(
|
||||
$this->module->getTemplatePath('hotel-options.tpl')
|
||||
);
|
||||
|
||||
$result['status'] = true;
|
||||
$result['html_hotel_options'] = $html;
|
||||
}
|
||||
} else {
|
||||
$result['status'] = 'failed3';
|
||||
}
|
||||
die(json_encode($result));
|
||||
|
||||
$this->ajaxDie(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
||||
470
modules/wkroomsearchblock/views/css/chosen.css
Normal file
470
modules/wkroomsearchblock/views/css/chosen.css
Normal file
@@ -0,0 +1,470 @@
|
||||
/**
|
||||
* 2010-2024 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through LICENSE.txt file inside our module
|
||||
*
|
||||
* 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 CustomizationPolicy.txt file inside our module for more information.
|
||||
*
|
||||
* @author Webkul IN
|
||||
* @copyright 2010-2024 Webkul IN
|
||||
* @license LICENSE.txt
|
||||
*/
|
||||
|
||||
/* @group Base */
|
||||
.chosen-container {
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
font-size: 14px;
|
||||
zoom: 1;
|
||||
/* display: inline; */
|
||||
-moz-user-select: -moz-none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.chosen-container .chosen-drop {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -9999px;
|
||||
z-index: 1010;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
border-top: 0;
|
||||
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
.chosen-container.chosen-container-single-nosearch .chosen-drop {
|
||||
top: 100%;
|
||||
}
|
||||
.chosen-container.chosen-with-drop .chosen-drop {
|
||||
left: 0;
|
||||
}
|
||||
.chosen-container a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
/* @group Single Chosen */
|
||||
.chosen-container-single .chosen-single {
|
||||
position: relative;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding-left: 35px;
|
||||
height: 100%;
|
||||
border: 1px solid #555555;
|
||||
border-radius: 4px;
|
||||
background-clip: padding-box;
|
||||
box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1);
|
||||
color: #444;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
line-height: 24px;
|
||||
background: #fff url('../img/icon-hotel.svg') no-repeat 10px 50%;
|
||||
min-height: 55px;
|
||||
}
|
||||
.chosen-container-single.error_border {
|
||||
border: none !important;
|
||||
}
|
||||
.chosen-container-single.error_border .chosen-single {
|
||||
border: 2px solid red !important;
|
||||
}
|
||||
|
||||
.chosen-container-single .chosen-default {
|
||||
color: #999;
|
||||
}
|
||||
.chosen-container-single .chosen-single span {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
margin-right: 26px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
top: 15px;
|
||||
color: #333;
|
||||
}
|
||||
.chosen-container-single .chosen-single-with-deselect span {
|
||||
margin-right: 38px;
|
||||
}
|
||||
.chosen-container-single .chosen-single abbr {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 26px;
|
||||
display: block;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: url('chosen-sprite.png') -42px 1px no-repeat;
|
||||
font-size: 1px;
|
||||
}
|
||||
.chosen-container-single .chosen-single abbr:hover {
|
||||
background-position: -42px -10px;
|
||||
}
|
||||
.chosen-container-single.chosen-disabled .chosen-single abbr:hover {
|
||||
background-position: -42px -10px;
|
||||
}
|
||||
.chosen-container-single .chosen-single div {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
display: block;
|
||||
width: 18px;
|
||||
height: 100%;
|
||||
}
|
||||
.chosen-container-single .chosen-single div b {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: url('../../../../themes/hotel-reservation-theme/img/icon/icon-dropdown-arrow.svg') no-repeat calc(100% - 8px) 50%;
|
||||
}
|
||||
.chosen-container-single .chosen-search {
|
||||
position: relative;
|
||||
z-index: 1010;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
height: 55px;
|
||||
}
|
||||
.chosen-container-single .chosen-search::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 1px;
|
||||
height: 22px;
|
||||
width: 19px;
|
||||
background: url('../../../../themes/hotel-reservation-theme/img/icon/icon-dropdown-arrow.svg') no-repeat calc(100% - 8px) 50%;
|
||||
/* background: url('../img/icon-hotel.svg') no-repeat 9px 50%; */
|
||||
}
|
||||
.chosen-container-single .chosen-search input[type="text"] {
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-left: 35px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
outline: 0;
|
||||
border: none;
|
||||
font-size: 1em;
|
||||
line-height: normal;
|
||||
border-radius: 4px;
|
||||
background: url('../img/icon-hotel.svg') no-repeat 9px 50%;
|
||||
}
|
||||
.chosen-container-single.chosen-container-active .chosen-search input[type="text"] {
|
||||
border: 2px solid #1292FF;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
||||
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
||||
}
|
||||
.chosen-container-single .chosen-drop {
|
||||
margin-top: -1px;
|
||||
border-radius: 0 0 4px 4px;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
.chosen-container-single.chosen-container-single-nosearch .chosen-search {
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
/* @group Results */
|
||||
.chosen-container .chosen-results {
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
max-height: 240px;
|
||||
background: #fff;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.chosen-container .chosen-results li {
|
||||
display: none;
|
||||
margin: 0;
|
||||
padding: 15px;
|
||||
list-style: none;
|
||||
color: #333;
|
||||
}
|
||||
.chosen-container .chosen-results li.active-result {
|
||||
display: list-item;
|
||||
cursor: pointer;
|
||||
}
|
||||
.chosen-container .chosen-results li.disabled-result {
|
||||
display: list-item;
|
||||
color: #ccc;
|
||||
cursor: default;
|
||||
}
|
||||
.chosen-container .chosen-results li.highlighted {
|
||||
background-color: #379bf0;
|
||||
color: #fff;
|
||||
}
|
||||
.chosen-container .chosen-results li.no-results {
|
||||
display: list-item;
|
||||
background: #f4f4f4;
|
||||
}
|
||||
.chosen-container .chosen-results li.group-result {
|
||||
display: list-item;
|
||||
font-weight: bold;
|
||||
cursor: default;
|
||||
}
|
||||
.chosen-container .chosen-results li.group-option {
|
||||
padding-left: 15px;
|
||||
}
|
||||
.chosen-container .chosen-results li em {
|
||||
font-style: normal;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
/* @group Multi Chosen */
|
||||
.chosen-container-multi .chosen-choices {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: auto !important;
|
||||
height: 1%;
|
||||
border: 1px solid #aaa;
|
||||
background-color: #fff;
|
||||
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iI2VlZWVlZSIvPjxzdG9wIG9mZnNldD0iMTUlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
|
||||
background-size: 100%;
|
||||
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background-image: -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
background-image: -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
cursor: text;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li {
|
||||
float: left;
|
||||
list-style: none;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-field {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
|
||||
margin: 1px 0;
|
||||
padding: 5px;
|
||||
height: 15px;
|
||||
outline: 0;
|
||||
border: 0 !important;
|
||||
background: transparent !important;
|
||||
box-shadow: none;
|
||||
color: #666;
|
||||
font-size: 100%;
|
||||
line-height: normal;
|
||||
border-radius: 0;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-field .default {
|
||||
color: #999;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-choice {
|
||||
position: relative;
|
||||
margin: 3px 0 3px 5px;
|
||||
padding: 3px 20px 3px 5px;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 3px;
|
||||
background-color: #e4e4e4;
|
||||
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIyMCUiIHN0b3AtY29sb3I9IiNmNGY0ZjQiLz48c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2YwZjBmMCIvPjxzdG9wIG9mZnNldD0iNTIlIiBzdG9wLWNvbG9yPSIjZThlOGU4Ii8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZWVlZWVlIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
|
||||
background-size: 100%;
|
||||
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
|
||||
background-image: -moz-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -webkit-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-clip: padding-box;
|
||||
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
|
||||
color: #333;
|
||||
line-height: 13px;
|
||||
cursor: default;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 3px;
|
||||
display: block;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: url('chosen-sprite.png') -42px 1px no-repeat;
|
||||
font-size: 1px;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
|
||||
background-position: -42px -10px;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-choice-disabled {
|
||||
padding-right: 5px;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #e4e4e4;
|
||||
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIyMCUiIHN0b3AtY29sb3I9IiNmNGY0ZjQiLz48c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2YwZjBmMCIvPjxzdG9wIG9mZnNldD0iNTIlIiBzdG9wLWNvbG9yPSIjZThlOGU4Ii8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZWVlZWVlIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
|
||||
background-size: 100%;
|
||||
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
|
||||
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
|
||||
color: #666;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-choice-focus {
|
||||
background: #d4d4d4;
|
||||
}
|
||||
.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
|
||||
background-position: -42px -10px;
|
||||
}
|
||||
.chosen-container-multi .chosen-results {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.chosen-container-multi .chosen-drop .result-selected {
|
||||
display: list-item;
|
||||
color: #ccc;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
/* @group Active */
|
||||
.chosen-container-active .chosen-single {
|
||||
border: 2px solid #1292FF;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
||||
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
||||
}
|
||||
.chosen-container-active.chosen-with-drop .chosen-single div {
|
||||
border-left: none;
|
||||
background: transparent;
|
||||
}
|
||||
.chosen-container-active .chosen-choices {
|
||||
border: 1px solid #5897fb;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.chosen-container-active .chosen-choices li.search-field input[type="text"] {
|
||||
color: #111 !important;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
/* @group Disabled Support */
|
||||
.chosen-disabled {
|
||||
opacity: 0.5 !important;
|
||||
cursor: default;
|
||||
}
|
||||
.chosen-disabled .chosen-single {
|
||||
cursor: default;
|
||||
}
|
||||
.chosen-disabled .chosen-choices .search-choice .search-choice-close {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* chosen-drop top - start */
|
||||
.hotel-selector-wrap .chosen-container .chosen-drop.top .chosen-results {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
bottom: calc(100% + 2px);
|
||||
}
|
||||
.hotel-selector-wrap .chosen-container.chosen-container-single-nosearch .chosen-drop.top .chosen-results {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
bottom: calc(100% + 55px);
|
||||
}
|
||||
/* chosen-drop top - end */
|
||||
|
||||
|
||||
/* @end */
|
||||
/* @group Right to Left */
|
||||
.chosen-rtl {
|
||||
text-align: right;
|
||||
}
|
||||
.chosen-rtl .chosen-single {
|
||||
overflow: visible;
|
||||
padding: 0 8px 0 0;
|
||||
}
|
||||
.chosen-rtl .chosen-single span {
|
||||
margin-right: 0;
|
||||
margin-left: 26px;
|
||||
direction: rtl;
|
||||
}
|
||||
.chosen-rtl .chosen-single-with-deselect span {
|
||||
margin-left: 38px;
|
||||
}
|
||||
.chosen-rtl .chosen-single div {
|
||||
right: auto;
|
||||
left: 3px;
|
||||
}
|
||||
.chosen-rtl .chosen-single abbr {
|
||||
right: auto;
|
||||
left: 26px;
|
||||
}
|
||||
.chosen-rtl .chosen-choices li {
|
||||
float: right;
|
||||
}
|
||||
.chosen-rtl .chosen-choices li.search-field input[type="text"] {
|
||||
direction: rtl;
|
||||
}
|
||||
.chosen-rtl .chosen-choices li.search-choice {
|
||||
margin: 3px 5px 3px 0;
|
||||
padding: 3px 5px 3px 19px;
|
||||
}
|
||||
.chosen-rtl .chosen-choices li.search-choice .search-choice-close {
|
||||
right: auto;
|
||||
left: 4px;
|
||||
}
|
||||
.chosen-rtl.chosen-container-single-nosearch .chosen-search,
|
||||
.chosen-rtl .chosen-drop {
|
||||
left: 9999px;
|
||||
}
|
||||
.chosen-rtl.chosen-container-single .chosen-results {
|
||||
margin: 0 0 4px 4px;
|
||||
padding: 0 4px 0 0;
|
||||
}
|
||||
.chosen-rtl .chosen-results li.group-option {
|
||||
padding-right: 15px;
|
||||
padding-left: 0;
|
||||
}
|
||||
.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div {
|
||||
border-right: none;
|
||||
}
|
||||
.chosen-rtl .chosen-search input[type="text"] {
|
||||
padding: 4px 5px 4px 20px;
|
||||
background: #fff url('chosen-sprite.png') no-repeat -30px -20px;
|
||||
background: url('chosen-sprite.png') no-repeat -30px -20px, url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iI2VlZWVlZSIvPjxzdG9wIG9mZnNldD0iMTUlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
|
||||
background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
|
||||
background: url('chosen-sprite.png') no-repeat -30px -20px, -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
background: url('chosen-sprite.png') no-repeat -30px -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
|
||||
direction: rtl;
|
||||
}
|
||||
.chosen-rtl.chosen-container-single .chosen-single div b {
|
||||
background-position: 6px 2px;
|
||||
}
|
||||
.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b {
|
||||
background-position: -12px 2px;
|
||||
}
|
||||
|
||||
.chosen-container .chosen-drop.dropup {
|
||||
border-bottom: 0;
|
||||
border-top: 1px solid #aaa;
|
||||
top: auto;
|
||||
bottom: 40px;
|
||||
}
|
||||
|
||||
.chosen-container.chosen-with-drop .chosen-single.dropup {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.chosen-container.chosen-with-drop .chosen-drop.dropup {
|
||||
box-shadow: none;
|
||||
margin-bottom: -16px;
|
||||
}
|
||||
|
||||
/* search results page - start */
|
||||
#category .chosen-container-single .chosen-single span {
|
||||
min-height: 45px;
|
||||
top: 11px;
|
||||
}
|
||||
/* search results page - end */
|
||||
@@ -48,6 +48,12 @@
|
||||
height: unset;
|
||||
min-height: 45px;
|
||||
}
|
||||
#search_hotel_block_form .hotel-selector-wrap .chosen-container-single .chosen-single {
|
||||
min-height: 45px;
|
||||
}
|
||||
#search_hotel_block_form .hotel-selector-wrap .chosen-container-single .chosen-search {
|
||||
height: 45px;
|
||||
}
|
||||
/* #search_hotel_block_form #search_room_submit {
|
||||
height: 45px;
|
||||
} */
|
||||
|
||||
@@ -63,6 +63,9 @@
|
||||
column-gap: 5px;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
.fancybox-wrap #search_hotel_block_form .form-group.xs-calendar {
|
||||
position: relative;
|
||||
}
|
||||
/* #search_hotel_block_form {
|
||||
display: grid;
|
||||
grid-template-columns: 0.8fr repeat(3, 1fr) 0.6fr;
|
||||
@@ -100,6 +103,9 @@
|
||||
#search_hotel_block_form .header-rmsearch-input:active, #search_hotel_block_form .header-rmsearch-input:focus {
|
||||
border: 2px solid #1292FF;}
|
||||
#search_hotel_block_form #id_hotel_button {
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
padding-left: 35px;
|
||||
background: url("../../views/img/icon-hotel.svg") no-repeat 10px 50%, url("../../views/img/icon-dropdown-arrow.svg") no-repeat calc(100% - 10px) 50%;
|
||||
background-color: #FFF;}
|
||||
#search_hotel_block_form #guest_occupancy {
|
||||
@@ -109,6 +115,8 @@
|
||||
#search_hotel_block_form .input-date {
|
||||
display: grid;
|
||||
cursor: text;}
|
||||
#search_hotel_block_form .input-date.focused {
|
||||
border: 2px solid #1292FF; }
|
||||
#search_hotel_block_form .input-date span {
|
||||
align-self: center;}
|
||||
#search_hotel_block_form .input-date span i {
|
||||
@@ -117,14 +125,16 @@
|
||||
color: #333;}
|
||||
.header-rmsearch-input:-moz-placeholder {
|
||||
/* Firefox 18- */
|
||||
color: #999999;
|
||||
font-weight: 400;}
|
||||
color: #333;
|
||||
font-weight: 400;
|
||||
opacity: 1;}
|
||||
.header-rmsearch-input::-moz-placeholder {
|
||||
/* Firefox 19+ */
|
||||
color: #999999;
|
||||
font-weight: 400;}
|
||||
color: #333;
|
||||
font-weight: 400;
|
||||
opacity: 1;}
|
||||
.header-rmsearch-input:-ms-input-placeholder {
|
||||
color: #999999;
|
||||
color: #333;
|
||||
font-weight: 400;}
|
||||
.search_block_container .dropdown-toggle {
|
||||
background-color: #f2f2f2;
|
||||
@@ -138,15 +148,6 @@
|
||||
position: relative;}
|
||||
.header-rmsearch-wrapper .dropdown-menu {
|
||||
margin: 0px;}
|
||||
.header-rmsearch-wrapper .hotel_dropdown_ul {
|
||||
position: absolute;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
box-shadow: 0 8px 25px -4px rgba(0,0,0,0.39);
|
||||
max-height: 145px;
|
||||
overflow-y: auto;}
|
||||
.header-rmsearch-wrapper .location_search_results_ul {
|
||||
position: absolute;
|
||||
font-size: 14px;
|
||||
@@ -157,7 +158,7 @@
|
||||
box-shadow: 0 8px 25px -4px rgba(0,0,0,0.39);
|
||||
max-height: 145px;
|
||||
overflow-y: auto;}
|
||||
.header-rmsearch-wrapper .location_search_results_ul li, .header-rmsearch-wrapper .hotel_dropdown_ul li {
|
||||
.header-rmsearch-wrapper .location_search_results_ul li {
|
||||
background-color: #fff;
|
||||
color: #333333;
|
||||
cursor: pointer;
|
||||
@@ -165,10 +166,16 @@
|
||||
font-size: 14px;
|
||||
list-style: outside none none;
|
||||
padding: 15px;}
|
||||
.header-rmsearch-wrapper .location_search_results_ul li:hover, .header-rmsearch-wrapper .location_search_results_ul li:focus, .header-rmsearch-wrapper .location_search_results_ul li:active, .header-rmsearch-wrapper .hotel_dropdown_ul li:hover, .header-rmsearch-wrapper .hotel_dropdown_ul li:focus, .header-rmsearch-wrapper .hotel_dropdown_ul li:active {
|
||||
.header-rmsearch-wrapper .location_search_results_ul li:hover, .header-rmsearch-wrapper .location_search_results_ul li:focus, .header-rmsearch-wrapper .location_search_results_ul li:active {
|
||||
background-color: #379bf0;
|
||||
color: #FFFFFF;}
|
||||
|
||||
.header-rmsearch-wrapper .location_search_results_ul.top {
|
||||
top: unset;
|
||||
bottom: 55px; }
|
||||
.header-rmsearch-wrapper .location_search_results_ul.bottom {
|
||||
top: 100%; }
|
||||
|
||||
|
||||
.header-rmsearch-wrapper .label-desc-txt {
|
||||
font-size: 12px;
|
||||
@@ -217,6 +224,11 @@
|
||||
box-shadow: 0 8px 25px -4px rgba(0,0,0,0.39);
|
||||
left: 0px;
|
||||
padding: 20px;}
|
||||
#search_occupancy_wrapper.top {
|
||||
top: unset;
|
||||
bottom: 100%; }
|
||||
#search_occupancy_wrapper.bottom {
|
||||
top: 100%; }
|
||||
#search_occupancy_wrapper .occupancy-info-separator {
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
|
||||
BIN
modules/wkroomsearchblock/views/img/chosen-sprite.png
Normal file
BIN
modules/wkroomsearchblock/views/img/chosen-sprite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 646 B |
BIN
modules/wkroomsearchblock/views/img/chosen-sprite@2x.png
Normal file
BIN
modules/wkroomsearchblock/views/img/chosen-sprite@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 872 B |
@@ -17,7 +17,327 @@
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
const BookingSearchManager = {
|
||||
inputSteps: {
|
||||
'location': {
|
||||
init: function() {
|
||||
$('.location_search_results_ul').hide();
|
||||
|
||||
// search location with users searched characters
|
||||
$(document).on('keyup', '#hotel_location', function(e) {
|
||||
BookingSearchManager.inputSteps['location'].onInput.call(this, e);
|
||||
});
|
||||
|
||||
// set data on clicking the searched location on dropdown
|
||||
$(document).on('click', '.location_search_results_ul li', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
BookingSearchManager.inputSteps['location'].onInputComplete.call(this, e);
|
||||
});
|
||||
|
||||
// handle Tab key press on hotel location field
|
||||
$(document).on('keydown', '#hotel_location', function (e) {
|
||||
if (e.which == 9) { // Tab key
|
||||
e.preventDefault();
|
||||
|
||||
if ($('.location_search_results_ul').is(':visible')) {
|
||||
$('.location_search_results_ul li:first').focus().click();
|
||||
} else {
|
||||
BookingSearchManager.activateStep('hotel');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// handle Tab key press on hotel location list
|
||||
$(document).on('keydown', '.location_search_results_ul li', function (e) {
|
||||
if (e.which == 9) { // Tab key
|
||||
e.preventDefault();
|
||||
$(this).click();
|
||||
}
|
||||
});
|
||||
|
||||
// navigate to prev and next li in the location dropdown
|
||||
$('body').on('keydown', '.location_search_results_ul li', function(e) {
|
||||
if (e.which == 40 || e.which == 38) {
|
||||
var ulElement = $(this).closest('ul');
|
||||
var ulLength = ulElement.find('li').length;
|
||||
$(this).blur();
|
||||
ulElement.scrollTop($(this).index() * $(this).outerHeight());
|
||||
if (e.which == 40) {
|
||||
if ($(this).index() != (ulLength - 1)) {
|
||||
$(this).next('li.search_result_li').focus();
|
||||
} else {
|
||||
ulElement.find('li:first').focus();
|
||||
}
|
||||
} else if (e.which == 38) {
|
||||
if ($(this).index()) {
|
||||
$(this).prev('li.search_result_li').focus();
|
||||
} else {
|
||||
ulElement.find('li:last').focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
activate: function() {
|
||||
$('#hotel_location').focus();
|
||||
},
|
||||
inputHasValue: function () {
|
||||
return ($('#hotel_location').val() != '') && ($('#location_category_id').val() != '');
|
||||
},
|
||||
onInput: function (e) {
|
||||
if (e.which == 13) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (($('.location_search_results_ul').is(':visible')) && (e.which == 40 || e.which == 38)) {
|
||||
$(this).blur();
|
||||
if (e.which == 40) {
|
||||
$('.location_search_results_ul li:first').focus();
|
||||
} else if (e.which == 38) {
|
||||
$('.location_search_results_ul li:last').focus();
|
||||
}
|
||||
} else {
|
||||
$('.location_search_results_ul').empty().hide();
|
||||
if ($(this).val() != '') {
|
||||
abortRunningAjax();
|
||||
ajax_check_var = $.ajax({
|
||||
url: autocomplete_search_url,
|
||||
data: {
|
||||
to_search_data: $(this).val(),
|
||||
},
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(result) {
|
||||
if (result.status) {
|
||||
$('.location_search_results_ul').html(result.data);
|
||||
$('.location_search_results_ul').show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onInputComplete: function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('.location_search_results_ul').empty().hide();
|
||||
$('#hotel_location').attr('value', $(this).html());
|
||||
$('#location_category_id').val($(this).val());
|
||||
|
||||
// fetch hotels for selected location
|
||||
$.ajax({
|
||||
url: autocomplete_search_url,
|
||||
data: {
|
||||
location_category_id: $('#location_category_id').val(),
|
||||
},
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(result) {
|
||||
if (result.status) {
|
||||
$('#hotel_cat_id').val('');
|
||||
$('#id_hotel_button').html(result.html_hotel_options);
|
||||
$('#id_hotel_button').trigger('chosen:updated');
|
||||
|
||||
if (search_auto_focus_next_field) {
|
||||
BookingSearchManager.activateStep('hotel');
|
||||
}
|
||||
} else {
|
||||
alert(no_results_found_cond);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
'hotel': {
|
||||
init: function() {
|
||||
$('select#id_hotel_button').chosen({
|
||||
search_contains: true,
|
||||
disable_search: !hotel_name_has_search,
|
||||
width: '100%',
|
||||
});
|
||||
|
||||
$(document).on('change', '#id_hotel_button', function() {
|
||||
if ($(this).find('option:selected').val().trim() != '') {
|
||||
$('#id_hotel_button_chosen .chosen-search input').blur();
|
||||
BookingSearchManager.inputSteps['hotel'].onInputComplete.call(this);
|
||||
}
|
||||
});
|
||||
|
||||
// prevents calendar from closing on hotel selection
|
||||
$(document).on('click', '#id_hotel_button_chosen li', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(document).on('keydown', '#id_hotel_button_chosen.chosen-container-active', function (e) {
|
||||
if (e.which == 9) { // Tab key
|
||||
e.preventDefault();
|
||||
if ($('#daterange_value').length) {
|
||||
$('#daterange_value').focus();
|
||||
$('#daterange_value').click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('keydown', '#id_hotel_button_chosen .chosen-search input', function (e) {
|
||||
if (e.which == 9 && $('#daterange_value').siblings('.date-picker-wrapper').is(':visible')) { // Tab key
|
||||
e.preventDefault();
|
||||
$('#daterange_value').data('dateRangePicker').close();
|
||||
|
||||
if (is_occupancy_wise_search) {
|
||||
BookingSearchManager.activateStep('occupancy');
|
||||
} else {
|
||||
BookingSearchManager.activateStep('submit');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// if chosen will not be initialized add placeholder to hotel select element as first option
|
||||
if (!BookingSearchManager.isBrowserSupported()) {
|
||||
$('select#id_hotel_button option').first().html(select_htl_txt);
|
||||
}
|
||||
|
||||
if (hotel_name_has_search) {
|
||||
$('select#id_hotel_button').on('chosen:showing_dropdown', function() {
|
||||
$(this).siblings('.chosen-container').find('.chosen-single').addClass('invisible')
|
||||
});
|
||||
|
||||
$('select#id_hotel_button').on('chosen:hiding_dropdown', function() {
|
||||
$(this).siblings('.chosen-container').find('.chosen-single').removeClass('invisible')
|
||||
});
|
||||
}
|
||||
},
|
||||
activate: function() {
|
||||
$('#id_hotel_button').trigger('chosen:open');
|
||||
},
|
||||
inputHasValue: function () {
|
||||
return ($('#id_hotel').val() != '') && ($('#hotel_cat_id').val() != '');
|
||||
},
|
||||
onInputComplete: function () {
|
||||
$('#id_hotel_button_chosen .chosen-search input').blur();
|
||||
const selectedHotel = $(this).find('option:selected');
|
||||
|
||||
if ($(selectedHotel).val().trim() != '') {
|
||||
const maxOrderDate = $(selectedHotel).attr('data-max_order_date');
|
||||
const preparationTime = $(selectedHotel).attr('data-preparation_time')
|
||||
|
||||
createDateRangePicker(maxOrderDate, preparationTime, $('#check_in_time').val(), $('#check_out_time').val());
|
||||
|
||||
$('#max_order_date').val(maxOrderDate);
|
||||
$('#preparation_time').val(preparationTime);
|
||||
$('#id_hotel').val($(selectedHotel).attr('data-id-hotel'));
|
||||
$('#hotel_cat_id').val($(selectedHotel).attr('data-hotel-cat-id'));
|
||||
|
||||
if (search_auto_focus_next_field) {
|
||||
setTimeout(function () {
|
||||
if ($('#id_hotel_button').data('chosen') != undefined) {
|
||||
$('#id_hotel_button').data('chosen').close_field();
|
||||
}
|
||||
|
||||
BookingSearchManager.activateStep('date_range');
|
||||
}, 10);
|
||||
}
|
||||
} else {
|
||||
$('#id_hotel').val('');
|
||||
$('#hotel_cat_id').val('');
|
||||
}
|
||||
},
|
||||
},
|
||||
'date_range': {
|
||||
init: function() {
|
||||
$(document).on('keydown', '#daterange_value', function (e) {
|
||||
if (e.which == 9) { // Tab key
|
||||
e.preventDefault();
|
||||
$('#daterange_value').removeClass('focused').blur();
|
||||
|
||||
if ($('#daterange_value').data('dateRangePicker') != undefined) {
|
||||
$('#daterange_value').data('dateRangePicker').close();
|
||||
}
|
||||
|
||||
if (is_occupancy_wise_search) {
|
||||
BookingSearchManager.activateStep('occupancy');
|
||||
} else {
|
||||
BookingSearchManager.activateStep('submit');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
activate: function() {
|
||||
$('#daterange_value').data('dateRangePicker').open();
|
||||
},
|
||||
inputHasValue: function () {
|
||||
return ($('#check_in_time').val() != '') && ($('#check_out_time').val() != '');
|
||||
},
|
||||
},
|
||||
'occupancy': {
|
||||
init: function() {
|
||||
$(document).on('keydown', '#guest_occupancy', function (e) {
|
||||
if (e.which == 9) { // Tab key
|
||||
e.preventDefault();
|
||||
if ($('#search_occupancy_wrapper').css('display') != 'none') {
|
||||
$('#guest_occupancy').click();
|
||||
}
|
||||
|
||||
BookingSearchManager.activateStep('submit');
|
||||
}
|
||||
});
|
||||
},
|
||||
activate: function() {
|
||||
if ($('#search_occupancy_wrapper').css('display') == 'none') {
|
||||
$('#guest_occupancy').click().focus();
|
||||
}
|
||||
},
|
||||
inputHasValue: function () {
|
||||
return false;
|
||||
},
|
||||
},
|
||||
'submit': {
|
||||
activate: function() {
|
||||
$('#search_room_submit').focus();
|
||||
},
|
||||
inputHasValue: function () {
|
||||
return false;
|
||||
},
|
||||
},
|
||||
},
|
||||
init: function () {
|
||||
this.inputSteps['location'].init();
|
||||
this.inputSteps['hotel'].init();
|
||||
this.inputSteps['date_range'].init();
|
||||
if (is_occupancy_wise_search) {
|
||||
this.inputSteps['occupancy'].init();
|
||||
}
|
||||
},
|
||||
activateStep: function (step) {
|
||||
if (step in this.inputSteps) {
|
||||
this.inputSteps[step].activate();
|
||||
}
|
||||
},
|
||||
allFieldsFilled: function () {
|
||||
return this.inputSteps['hotel'].inputHasValue()
|
||||
&& this.inputSteps['date_range'].inputHasValue()
|
||||
},
|
||||
isBrowserSupported: function() { // defined as it is from chosen to decide if chosen will be initialized
|
||||
if (window.navigator.appName === "Microsoft Internet Explorer") {
|
||||
return document.documentMode >= 8;
|
||||
}
|
||||
if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
|
||||
return false;
|
||||
}
|
||||
if (/Android/i.test(window.navigator.userAgent)) {
|
||||
if (/Mobile/i.test(window.navigator.userAgent)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// initialize booking search fields
|
||||
BookingSearchManager.init();
|
||||
|
||||
// for screen size changes for room search
|
||||
var window_width = $(window).width();
|
||||
if (window_width > 767) {
|
||||
@@ -54,10 +374,8 @@ $(document).ready(function() {
|
||||
|
||||
/*END*/
|
||||
var ajax_check_var = '';
|
||||
$('.location_search_results_ul').hide();
|
||||
|
||||
function createDateRangePicker(max_order_date, preparation_time, dateFrom, dateTo)
|
||||
{
|
||||
createDateRangePicker = function (max_order_date, preparation_time, dateFrom, dateTo) {
|
||||
let start_date = new Date();
|
||||
if (preparation_time) {
|
||||
start_date.setDate(start_date.getDate() + parseInt(preparation_time));
|
||||
@@ -111,18 +429,63 @@ $(document).ready(function() {
|
||||
}
|
||||
},
|
||||
endDate: max_order_date,
|
||||
}).on('datepicker-first-date-selected', function() {
|
||||
calendarFirstDateSelected = true;
|
||||
}).on('datepicker-change', function(event,obj){
|
||||
$('#check_in_time').val($.datepicker.formatDate('yy-mm-dd', obj.date1));
|
||||
$('#check_out_time').val($.datepicker.formatDate('yy-mm-dd', obj.date2));
|
||||
focusNextOnCalendarClose = true;
|
||||
calendarFirstDateSelected = false;
|
||||
}).on('datepicker-open', function() {
|
||||
$('#daterange_value').addClass('focused').focus();
|
||||
}).on('datepicker-close', function() {
|
||||
$('#daterange_value').removeClass('focused').blur();
|
||||
}).on('datepicker-closed', function() {
|
||||
if (search_auto_focus_next_field && focusNextOnCalendarClose) {
|
||||
if (is_occupancy_wise_search) {
|
||||
if ($('#check_in_time').val() != '' && $('#check_out_time').val() != '') {
|
||||
BookingSearchManager.activateStep('occupancy');
|
||||
}
|
||||
} else {
|
||||
if (BookingSearchManager.allFieldsFilled()) {
|
||||
BookingSearchManager.activateStep('submit');
|
||||
}
|
||||
}
|
||||
|
||||
focusNextOnCalendarClose = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#daterange_value').dateRangePicker({
|
||||
startDate: $.datepicker.formatDate('dd-mm-yy', new Date()),
|
||||
startDate: start_date,
|
||||
endDate: max_order_date,
|
||||
}).on('datepicker-first-date-selected', function() {
|
||||
calendarFirstDateSelected = true;
|
||||
}).on('datepicker-change', function(event,obj){
|
||||
$('#check_in_time').val($.datepicker.formatDate('yy-mm-dd', obj.date1));
|
||||
$('#check_out_time').val($.datepicker.formatDate('yy-mm-dd', obj.date2));
|
||||
focusNextOnCalendarClose = true;
|
||||
calendarFirstDateSelected = false;
|
||||
}).on('datepicker-open', function() {
|
||||
$('#daterange_value').addClass('focused').focus();
|
||||
}).on('datepicker-close', function() {
|
||||
$('#daterange_value').removeClass('focused').blur();
|
||||
calendarFirstDateSelected = false;
|
||||
}).on('datepicker-closed', function() {
|
||||
if (search_auto_focus_next_field && focusNextOnCalendarClose) {
|
||||
if (is_occupancy_wise_search) {
|
||||
if ($('#check_in_time').val() != '' && $('#check_out_time').val() != '') {
|
||||
BookingSearchManager.activateStep('occupancy');
|
||||
}
|
||||
} else {
|
||||
if (BookingSearchManager.allFieldsFilled()) {
|
||||
BookingSearchManager.activateStep('submit');
|
||||
}
|
||||
}
|
||||
|
||||
focusNextOnCalendarClose = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,151 +495,21 @@ $(document).ready(function() {
|
||||
$.datepicker.formatDate('dd-mm-yy', $.datepicker.parseDate('yy-mm-dd', dateTo))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function abortRunningAjax() {
|
||||
abortRunningAjax = function () {
|
||||
if (ajax_check_var) {
|
||||
ajax_check_var.abort();
|
||||
}
|
||||
}
|
||||
|
||||
// search location with users searched characters
|
||||
$(document).on('keyup', "#hotel_location", function(e) {
|
||||
if (($('.location_search_results_ul').is(':visible')) && (e.which == 40 || e.which == 38)) {
|
||||
$(this).blur();
|
||||
if (e.which == 40) {
|
||||
$(".location_search_results_ul li:first").focus();
|
||||
} else if (e.which == 38) {
|
||||
$(".location_search_results_ul li:last").focus();
|
||||
}
|
||||
} else {
|
||||
$('.location_search_results_ul').empty().hide();
|
||||
if ($(this).val() != '') {
|
||||
abortRunningAjax();
|
||||
ajax_check_var = $.ajax({
|
||||
url: autocomplete_search_url,
|
||||
data: {
|
||||
to_search_data: $(this).val(),
|
||||
},
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(result) {
|
||||
if (result.status == 'success') {
|
||||
$('.location_search_results_ul').html(result.data);
|
||||
$('.location_search_results_ul').show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// if user clicks anywhere and location/hotel li is visible the select first li as selection
|
||||
$('body').on('click', function(e) {
|
||||
if ($('.location_search_results_ul').is(':visible') && e.target.className != "search_result_li" && e.target.id != "hotel_location") {
|
||||
$('.location_search_results_ul .search_result_li:first').click();
|
||||
}
|
||||
|
||||
if ($('.hotel_dropdown_ul').is(':visible') && e.target.className != "search_result_li" && e.target.id != "hotel_location") {
|
||||
$('.hotel_dropdown_ul .search_result_li:first').click();
|
||||
}
|
||||
});
|
||||
|
||||
// set data on clicking the searched location on dropdown
|
||||
$(document).on('click', '.location_search_results_ul li', function(e) {
|
||||
$('#hotel_location').attr('value', $(this).html());
|
||||
$('#location_category_id').val($(this).val());
|
||||
|
||||
$('.location_search_results_ul').empty().hide();
|
||||
|
||||
$.ajax({
|
||||
url: autocomplete_search_url,
|
||||
data: {
|
||||
location_category_id: $('#location_category_id').val(),
|
||||
},
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(result) {
|
||||
if (result.status == 'success') {
|
||||
$('#hotel_cat_id').val('');
|
||||
$('#hotel_cat_name').html('Select Hotel');
|
||||
$('.hotel_dropdown_ul').empty();
|
||||
$('.hotel_dropdown_ul').html(result.data);
|
||||
} else {
|
||||
alert(no_results_found_cond);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// navigate to prev and next li in the location/hotel dropdown
|
||||
$('body').on('keyup', 'li.search_result_li', function(e) {
|
||||
if (e.which == 40 || e.which == 38) {
|
||||
var ulElement = $(this).closest('ul');
|
||||
var ulLength = ulElement.find('li').length;
|
||||
$(this).blur();
|
||||
ulElement.scrollTop($(this).index() * $(this).outerHeight());
|
||||
if (e.which == 40) {
|
||||
if ($(this).index() != (ulLength - 1)) {
|
||||
$(this).next('li.search_result_li').focus();
|
||||
} else {
|
||||
ulElement.find("li:first").focus();
|
||||
}
|
||||
} else if (e.which == 38) {
|
||||
if ($(this).index()) {
|
||||
$(this).prev('li.search_result_li').focus();
|
||||
} else {
|
||||
ulElement.find("li:last").focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// when focus goes from hotel button to li list of hotels
|
||||
$(document).on('keyup', "#id_hotel_button", function(e) {
|
||||
if ($('.hotel_dropdown_ul').is(':visible')) {
|
||||
if ($('.hotel_dropdown_ul .search_result_li').length) {
|
||||
$(".hotel_dropdown_ul li:first").focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// if user is selecting the location by keydown / up key
|
||||
$(document).on('keydown', 'body', function(e) {
|
||||
if ((e.which == 40 || e.which == 38) && ($('.location_search_results_ul li.search_result_li').is(':visible') || $('.hotel_dropdown_ul li.search_result_li').is(':visible'))) {
|
||||
return false;
|
||||
} else if (e.which == 13 && e.target.className == 'search_result_li') {
|
||||
e.target.click();
|
||||
} else if (e.which == 9 && $('.location_search_results_ul').is(':visible')) {
|
||||
if ($('.location_search_results_ul .search_result_li').length) {
|
||||
$('.location_search_results_ul li.search_result_li:first').click();
|
||||
}
|
||||
} else if (e.which == 9 && $('.hotel_dropdown_ul').is(':visible')) {
|
||||
if ($('.hotel_dropdown_ul .search_result_li').length) {
|
||||
$('.hotel_dropdown_ul li.search_result_li:first').click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.hotel_dropdown_ul li', function() {
|
||||
let max_order_date = $(this).attr('data-max_order_date');
|
||||
let preparation_time = $(this).attr('data-preparation_time')
|
||||
createDateRangePicker(max_order_date, preparation_time, $('#check_in_time').val(), $('#check_out_time').val());
|
||||
$("#max_order_date").val(max_order_date);
|
||||
$('#preparation_time').val(preparation_time);
|
||||
$('#id_hotel').val($(this).attr('data-id-hotel'));
|
||||
$('#hotel_cat_id').val($(this).attr('data-hotel-cat-id'));
|
||||
$('#hotel_cat_name').html($(this).html());
|
||||
});
|
||||
|
||||
// If only one hotel then set max order date on date pickers
|
||||
var max_order_date = $('#max_order_date').val();
|
||||
var preparation_time = $('#preparation_time').val();
|
||||
createDateRangePicker(max_order_date, preparation_time, $('#check_in_time').val(), $('#check_out_time').val());
|
||||
|
||||
// validations on the submit of the search fields
|
||||
$('#search_room_submit').on('click', function(e) {
|
||||
$(document).on('click', '#search_room_submit', function() {
|
||||
var check_in_time = $("#check_in_time").val();
|
||||
var check_out_time = $("#check_out_time").val();
|
||||
var max_order_date = $("#max_order_date").val();
|
||||
@@ -291,7 +524,7 @@ $(document).ready(function() {
|
||||
$("#hotel_location").addClass("error_border");
|
||||
error = true;
|
||||
}
|
||||
$("#id_hotel_button").addClass("error_border");
|
||||
$("#id_hotel_button_chosen").addClass("error_border");
|
||||
$('#select_htl_error_p').text(hotel_name_cond);
|
||||
error = true;
|
||||
}
|
||||
@@ -333,9 +566,10 @@ $(document).ready(function() {
|
||||
else
|
||||
return true;
|
||||
});
|
||||
|
||||
// Occupancy field dropdown
|
||||
// add occupancy info block
|
||||
$('#search_occupancy_wrapper .add_new_occupancy_btn').on('click', function(e) {
|
||||
$(document).on('click', '#search_occupancy_wrapper .add_new_occupancy_btn', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var occupancy_block = '';
|
||||
@@ -512,64 +746,167 @@ $(document).ready(function() {
|
||||
// toggle occupancy block
|
||||
$('#guest_occupancy').on('click', function(e) {
|
||||
e.stopPropagation();
|
||||
if ($('#daterange_value').siblings('.date-picker-wrapper').is(':visible')) {
|
||||
$('#daterange_value').data('dateRangePicker').close();
|
||||
}
|
||||
$("#search_occupancy_wrapper").toggle();
|
||||
});
|
||||
|
||||
// close the occupancy block when clink anywhere in the body outside occupancy block
|
||||
function validateOccupancies() {
|
||||
let hasErrors = 0;
|
||||
|
||||
let adults = $("#search_occupancy_wrapper").find(".num_adults").map(function(){return $(this).val();}).get();
|
||||
let children = $("#search_occupancy_wrapper").find(".num_children").map(function(){return $(this).val();}).get();
|
||||
let child_ages = $("#search_occupancy_wrapper").find(".guest_child_age").map(function(){return $(this).val();}).get();
|
||||
|
||||
// start validating above values
|
||||
if (!adults.length || (adults.length != children.length)) {
|
||||
hasErrors = 1;
|
||||
showErrorMessage(invalid_occupancy_txt);
|
||||
} else {
|
||||
$("#search_occupancy_wrapper").find('.occupancy_count').removeClass('error_border');
|
||||
|
||||
// validate values of adults and children
|
||||
adults.forEach(function (item, index) {
|
||||
if (isNaN(item) || parseInt(item) < 1) {
|
||||
hasErrors = 1;
|
||||
$("#search_occupancy_wrapper .num_adults").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
|
||||
}
|
||||
if (isNaN(children[index])) {
|
||||
hasErrors = 1;
|
||||
$("#search_occupancy_wrapper .num_children").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
|
||||
}
|
||||
});
|
||||
|
||||
// validate values of selected child ages
|
||||
$("#search_occupancy_wrapper").find('.guest_child_age').removeClass('error_border');
|
||||
child_ages.forEach(function (age, index) {
|
||||
age = parseInt(age);
|
||||
if (isNaN(age) || (age < 0) || (age >= parseInt(max_child_age))) {
|
||||
hasErrors = 1;
|
||||
$("#search_occupancy_wrapper .guest_child_age").eq(index).addClass('error_border');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (hasErrors == 0) {
|
||||
$("#search_occupancy_wrapper").hide();
|
||||
$("#search_hotel_block_form #guest_occupancy").removeClass('error_border');
|
||||
} else {
|
||||
$("#search_hotel_block_form #guest_occupancy").addClass('error_border');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Body Events - start
|
||||
var focusNextOnCalendarClose = true;
|
||||
var calendarFirstDateSelected = false;
|
||||
$('body').on('click', function(e) {
|
||||
// @TODO better approach to be found
|
||||
// if user clicks anywhere and location li is visible then close it
|
||||
if ($('.location_search_results_ul').is(':visible')
|
||||
&& e.target.className != 'search_result_li'
|
||||
&& e.target.id != 'hotel_location'
|
||||
) {
|
||||
$('.location_search_results_ul').hide();
|
||||
$('#hotel_location').attr('placeholder', hotel_location_txt);
|
||||
}
|
||||
|
||||
// check if user clicked outside calendar
|
||||
if ($('#daterange_value').siblings('.date-picker-wrapper').is(':visible')) {
|
||||
if (!$(e.target).closest('.form-group').find('.date-picker-wrapper').length) {
|
||||
focusNextOnCalendarClose = false;
|
||||
}
|
||||
}
|
||||
|
||||
// close the occupancy block when clink anywhere in the body outside occupancy block
|
||||
if ($('#search_occupancy_wrapper').length) {
|
||||
if ($('#search_occupancy_wrapper').css('display') !== 'none') {
|
||||
if (!($(e.target).closest("#search_occupancy_wrapper").length)) {
|
||||
// Before closing the occupancy block validate the vaules inside
|
||||
let hasErrors = 0;
|
||||
|
||||
let adults = $("#search_occupancy_wrapper").find(".num_adults").map(function(){return $(this).val();}).get();
|
||||
let children = $("#search_occupancy_wrapper").find(".num_children").map(function(){return $(this).val();}).get();
|
||||
let child_ages = $("#search_occupancy_wrapper").find(".guest_child_age").map(function(){return $(this).val();}).get();
|
||||
|
||||
// start validating above values
|
||||
if (!adults.length || (adults.length != children.length)) {
|
||||
hasErrors = 1;
|
||||
showErrorMessage(invalid_occupancy_txt);
|
||||
} else {
|
||||
$("#search_occupancy_wrapper").find('.occupancy_count').removeClass('error_border');
|
||||
|
||||
// validate values of adults and children
|
||||
adults.forEach(function (item, index) {
|
||||
if (isNaN(item) || parseInt(item) < 1) {
|
||||
hasErrors = 1;
|
||||
$("#search_occupancy_wrapper .num_adults").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
|
||||
}
|
||||
if (isNaN(children[index])) {
|
||||
hasErrors = 1;
|
||||
$("#search_occupancy_wrapper .num_children").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
|
||||
}
|
||||
});
|
||||
|
||||
// validate values of selected child ages
|
||||
$("#search_occupancy_wrapper").find('.guest_child_age').removeClass('error_border');
|
||||
child_ages.forEach(function (age, index) {
|
||||
age = parseInt(age);
|
||||
if (isNaN(age) || (age < 0) || (age >= parseInt(max_child_age))) {
|
||||
hasErrors = 1;
|
||||
$("#search_occupancy_wrapper .guest_child_age").eq(index).addClass('error_border');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (hasErrors == 0) {
|
||||
$("#search_occupancy_wrapper").hide();
|
||||
$("#search_hotel_block_form #guest_occupancy").removeClass('error_border');
|
||||
} else {
|
||||
$("#search_hotel_block_form #guest_occupancy").addClass('error_border');
|
||||
return false;
|
||||
}
|
||||
// Before closing the occupancy block validate the values inside
|
||||
return validateOccupancies();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var isEnterKeyHeldOnLocation = false;
|
||||
$('body').on('keydown', function(e) {
|
||||
let preventDefault = false;
|
||||
|
||||
// fix for: if user pressed Tab after selecting only first date
|
||||
if (e.which == 9
|
||||
&& $('#daterange_value').siblings('.date-picker-wrapper').is(':visible')
|
||||
&& calendarFirstDateSelected
|
||||
) {
|
||||
preventDefault = true;
|
||||
$('#daterange_value').data('dateRangePicker').close();
|
||||
|
||||
setTimeout(function () {
|
||||
if (is_occupancy_wise_search) {
|
||||
BookingSearchManager.activateStep('occupancy');
|
||||
} else {
|
||||
BookingSearchManager.activateStep('submit');
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// if user is selecting the location by Up, Down, Enter or Tab keys
|
||||
if ((e.which == 40 || e.which == 38) && $('.location_search_results_ul li.search_result_li').is(':visible')) {
|
||||
return false;
|
||||
} else if (e.which == 13 && e.target.className == 'search_result_li') {
|
||||
// select location only after held Enter key is unheld
|
||||
preventDefault = true;
|
||||
isEnterKeyHeldOnLocation = true;
|
||||
} else if (e.which == 9 && $('.location_search_results_ul').is(':visible')) {
|
||||
preventDefault = true;
|
||||
$(e.target).click();
|
||||
}
|
||||
|
||||
// check if submit button must be focused
|
||||
if (e.which == 9 && $('#search_occupancy_wrapper:visible').length) {
|
||||
preventDefault = true;
|
||||
if (validateOccupancies()) {
|
||||
BookingSearchManager.activateStep('submit');
|
||||
}
|
||||
}
|
||||
|
||||
if (preventDefault) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// select location only after held Enter key is unheld
|
||||
$('body').on('keyup', function(e) {
|
||||
if ($(e.target).is('.location_search_results_ul li')
|
||||
&& isEnterKeyHeldOnLocation
|
||||
&& e.which == 13
|
||||
) {
|
||||
$(e.target).click();
|
||||
}
|
||||
});
|
||||
// Body Events - end
|
||||
|
||||
// set positions of popups when required
|
||||
if (page_name == 'index') {
|
||||
$('#hotel_location, #id_hotel_button, #guest_occupancy').focus(function () {
|
||||
setBookingSearchPositions();
|
||||
});
|
||||
|
||||
// after chosen has been initialized
|
||||
$('select#id_hotel_button').on('chosen:ready', function() {
|
||||
$('#id_hotel_button_chosen .chosen-search input').focus(function () {
|
||||
setBookingSearchPositions();
|
||||
});
|
||||
});
|
||||
|
||||
$('#daterange_value').click(function () {
|
||||
setBookingSearchPositions();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// function to set occupancy infor in guest occupancy field(search form)
|
||||
function setGuestOccupancy()
|
||||
{
|
||||
@@ -601,4 +938,45 @@ function setGuestOccupancy()
|
||||
guestButtonVal += ', ' + parseInt(rooms) + ' ' + room_txt;
|
||||
}
|
||||
$('#guest_occupancy > span').text(guestButtonVal);
|
||||
}
|
||||
}
|
||||
|
||||
// position dropdowns
|
||||
function setBookingSearchPositions() {
|
||||
// calculate available spaces
|
||||
let searchForm = $('#search_hotel_block_form');
|
||||
|
||||
let inputFieldsAndDropdowns = [
|
||||
{ input: $('#hotel_location'), dropdown: $('.location_search_results_ul')},
|
||||
{ input: $('.hotel-selector-wrap'), dropdown: $('#id_hotel_button_chosen .chosen-drop')},
|
||||
{ input: $('#guest_occupancy'), dropdown: $('#search_occupancy_wrapper')},
|
||||
];
|
||||
|
||||
let positionClass = 'bottom';
|
||||
if (!searchForm.closest('.fancybox-wrap').length) {
|
||||
let searchFormHeight = searchForm.outerHeight();
|
||||
let spaceTop = searchForm.offset().top - $(window).scrollTop();
|
||||
let spaceBottom = $(window).height() - searchFormHeight - spaceTop;
|
||||
|
||||
// calculate max height for dropdowns
|
||||
let maxHeightNeeded = 0;
|
||||
$(inputFieldsAndDropdowns).each(function (i, inputFieldAndDropdown) {
|
||||
if (!inputFieldAndDropdown.input.length) return false;
|
||||
|
||||
// find needed space height
|
||||
let cssMaxHeight = parseInt(inputFieldAndDropdown.dropdown.css('max-height'));
|
||||
if (Number.isInteger(cssMaxHeight)) {
|
||||
maxHeightNeeded = Math.max(maxHeightNeeded, cssMaxHeight);
|
||||
}
|
||||
});
|
||||
|
||||
// determine position class
|
||||
if (spaceBottom < maxHeightNeeded && spaceTop > spaceBottom) {
|
||||
positionClass = 'top';
|
||||
}
|
||||
}
|
||||
|
||||
// position dropdowns
|
||||
$(inputFieldsAndDropdowns).each(function (i, inputFieldAndDropdown) {
|
||||
inputFieldAndDropdown.dropdown.removeClass('top bottom').addClass(positionClass);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{**
|
||||
* 2010-2024 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through LICENSE.txt file inside our module
|
||||
*
|
||||
* 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 CustomizationPolicy.txt file inside our module for more information.
|
||||
*
|
||||
* @author Webkul IN
|
||||
* @copyright 2010-2024 Webkul IN
|
||||
* @license LICENSE.txt
|
||||
*}
|
||||
|
||||
<option value=""></option>
|
||||
{if isset($hotels_info) && is_array($hotels_info)}
|
||||
{foreach from=$hotels_info item=hotel_info}
|
||||
<option class="search_result_li" data-id-hotel="{$hotel_info.id_hotel}" data-hotel-cat-id="{$hotel_info.id_category}" data-max_order_date="{$hotel_info.max_order_date}" tabindex="-1">
|
||||
{$hotel_info.hotel_name}
|
||||
</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
29
modules/wkroomsearchblock/views/templates/front/index.php
Normal file
29
modules/wkroomsearchblock/views/templates/front/index.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2024 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through LICENSE.txt file inside our module
|
||||
*
|
||||
* 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 CustomizationPolicy.txt file inside our module for more information.
|
||||
*
|
||||
* @author Webkul IN
|
||||
* @copyright 2010-2024 Webkul IN
|
||||
* @license LICENSE.txt
|
||||
*/
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,24 @@
|
||||
{**
|
||||
* 2010-2024 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through LICENSE.txt file inside our module
|
||||
*
|
||||
* 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 CustomizationPolicy.txt file inside our module for more information.
|
||||
*
|
||||
* @author Webkul IN
|
||||
* @copyright 2010-2024 Webkul IN
|
||||
* @license LICENSE.txt
|
||||
*}
|
||||
|
||||
{if isset($location_categories) && is_array($location_categories)}
|
||||
{foreach from=$location_categories item=category}
|
||||
<li class="search_result_li" value="{$category.id_category}" tabindex="-1">{$category.name}</li>
|
||||
{/foreach}
|
||||
{/if}
|
||||
@@ -1,7 +1,7 @@
|
||||
<form method="POST" id="search_hotel_block_form" class="grid">
|
||||
{if isset($location_enabled) && $location_enabled}
|
||||
<div class="form-group area-{$column_widths['location']}">
|
||||
<input type="text" class="form-control header-rmsearch-input input-location" id="hotel_location" name="hotel_location" autocomplete="off" placeholder="{l s='Hotel location' mod='wkroomsearchblock'}" {if isset($search_data)}value="{$search_data['location']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input type="text" class="form-control header-rmsearch-input input-location" id="hotel_location" name="hotel_location" autocomplete="off" placeholder="{l s='Hotel Location' mod='wkroomsearchblock'}" {if isset($search_data)}value="{$search_data['location']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input hidden="hidden" name="location_category_id" id="location_category_id" {if isset($search_data)}value="{$search_data['location_category_id']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<div class="dropdown">
|
||||
<ul class="location_search_results_ul dropdown-menu"></ul>
|
||||
@@ -16,29 +16,19 @@
|
||||
<input type="hidden" id="htl_name" class="form-control header-rmsearch-input" value="{$hotels_info[0]['hotel_name']}" readonly>
|
||||
{else}
|
||||
<div class="form-group area-{$column_widths['hotel']}">
|
||||
{if isset($hotels_info) && count($hotels_info)}
|
||||
<div class="dropdown">
|
||||
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id" {if isset($search_data)}value="{$search_data['htl_dtl']['id_category']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input type="hidden" id="id_hotel" name="id_hotel" {if isset($search_data)}value="{$search_data['htl_dtl']['id']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input type="hidden" id="max_order_date" name="max_order_date" value="{if isset($max_order_date)}{$max_order_date|escape:'htmlall':'UTF-8'}{/if}">
|
||||
<input type="hidden" id="preparation_time" name="preparation_time" value="{if isset($preparation_time)}{$preparation_time|escape:'htmlall':'UTF-8'}{/if}">
|
||||
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id" {if isset($search_data)}value="{$search_data['htl_dtl']['id_category']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input type="hidden" id="id_hotel" name="id_hotel" {if isset($search_data)}value="{$search_data['htl_dtl']['id']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input type="hidden" id="max_order_date" name="max_order_date" value="{if isset($max_order_date)}{$max_order_date|escape:'htmlall':'UTF-8'}{/if}">
|
||||
<input type="hidden" id="preparation_time" name="preparation_time" value="{if isset($preparation_time)}{$preparation_time|escape:'htmlall':'UTF-8'}{/if}">
|
||||
|
||||
<button class="form-control header-rmsearch-input input-hotel {if isset($error) && $error == 1}error_border{/if}" type="button" data-toggle="dropdown" id="id_hotel_button">
|
||||
{if isset($search_data)}
|
||||
<span id="hotel_cat_name" class="pull-left">{$search_data['htl_dtl']['hotel_name']|escape:'htmlall':'UTF-8'}</span>
|
||||
{else}
|
||||
<span id="hotel_cat_name" class="pull-left">{l s='Select Hotel' mod='wkroomsearchblock'}</span>
|
||||
{/if}
|
||||
</button>
|
||||
<ul class="dropdown-menu hotel_dropdown_ul">
|
||||
{if isset($hotels_info) && $hotels_info}
|
||||
{foreach $hotels_info as $name_val}
|
||||
<li tabindex="-1" class="search_result_li" data-id-hotel="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-hotel-cat-id="{$name_val['id_category']|escape:'htmlall':'UTF-8'}" data-max_order_date="{$name_val['max_order_date']}" data-preparation_time="{$name_val['preparation_time']|escape:'htmlall':'UTF-8'}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="hotel-selector-wrap">
|
||||
<select name="id_hotel" class="chosen header-rmsearch-input" data-placeholder="{l s='Select Hotel' mod='wkroomsearchblock'}" id="id_hotel_button">
|
||||
<option value=""></option>
|
||||
{foreach $hotels_info as $name_val}
|
||||
<option class="search_result_li" value="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-id-hotel="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-hotel-cat-id="{$name_val['id_category']|escape:'htmlall':'UTF-8'}" data-max_order_date="{$name_val['max_order_date']}" data-preparation_time="{$name_val['preparation_time']|escape:'htmlall':'UTF-8'}" {if isset($search_data) && $name_val['id'] == $search_data['htl_dtl']['id']}selected{/if}>{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{if isset($multiple_dates_input) && $multiple_dates_input}
|
||||
@@ -56,7 +46,7 @@
|
||||
<div class="form-group area-{$column_widths['date']}">
|
||||
<input type="hidden" id="check_in_time" name="check_in_time" {if isset($search_data)}value="{$search_data['date_from']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input type="hidden" id="check_out_time" name="check_out_time" {if isset($search_data)}value="{$search_data['date_to']|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<div class="form-control header-rmsearch-input input-date" id="daterange_value" autocomplete="off" placeholder="{l s='Check-in - Check-out' mod='wkroomsearchblock'}"><span>{l s='Check-in' mod='wkroomsearchblock'} <i class="icon icon-minus"></i> {l s='Check-out' mod='wkroomsearchblock'}</span></div>
|
||||
<div class="form-control header-rmsearch-input input-date" id="daterange_value" autocomplete="off" placeholder="{l s='Check-in - Check-out' mod='wkroomsearchblock'}" tabindex="-1"><span>{l s='Check-in' mod='wkroomsearchblock'} <i class="icon icon-minus"></i> {l s='Check-out' mod='wkroomsearchblock'}</span></div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -51,9 +51,16 @@ class WkRoomSearchBlock extends Module
|
||||
$objHotelBranchInformation = new HotelBranchInformation();
|
||||
$hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(0, 1);
|
||||
if (is_array($hotelBranchesInfo) && count($hotelBranchesInfo)) {
|
||||
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/jquery.chosen.js');
|
||||
$this->context->controller->addCSS($this->_path.'/views/css/chosen.css');
|
||||
|
||||
$this->context->controller->addCSS($this->_path.'/views/css/wk-global-search.css');
|
||||
$this->context->controller->addJS($this->_path.'/views/js/wk-room-search-block.js');
|
||||
|
||||
$isOccupancyWiseSearch = false;
|
||||
if (Configuration::get('PS_FRONT_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
|
||||
$isOccupancyWiseSearch = true;
|
||||
}
|
||||
Media::addJsDef(
|
||||
array (
|
||||
'autocomplete_search_url' => $this->context->link->getModuleLink(
|
||||
@@ -66,6 +73,7 @@ class WkRoomSearchBlock extends Module
|
||||
'check_out_time_cond' => $this->l('Please enter Check Out time', false, true),
|
||||
'less_checkin_date' => $this->l('Check In date can not be before current date.', false, true),
|
||||
'more_checkout_date' => $this->l('Check Out date must be greater than Check In date.', false, true),
|
||||
'hotel_location_txt' => $this->l('Hotel Location', false, true),
|
||||
'select_htl_txt' => $this->l('Select Hotel', false, true),
|
||||
'select_age_txt' => $this->l('Select age', false, true),
|
||||
'under_1_age' => $this->l('Under 1', false, true),
|
||||
@@ -80,6 +88,9 @@ class WkRoomSearchBlock extends Module
|
||||
'years_txt' => $this->l('years', false, true),
|
||||
'all_children_txt' => $this->l('All Children', false, true),
|
||||
'invalid_occupancy_txt' => $this->l('Invalid occupancy(adults/children) found.', false, true),
|
||||
'hotel_name_has_search' => count($hotelBranchesInfo) >= Configuration::get('WK_HOTEL_NAME_SEARCH_THRESHOLD'),
|
||||
'search_auto_focus_next_field' => (bool) Configuration::get('WK_SEARCH_AUTO_FOCUS_NEXT_FIELD'),
|
||||
'is_occupancy_wise_search' => $isOccupancyWiseSearch,
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -116,7 +127,10 @@ class WkRoomSearchBlock extends Module
|
||||
// In the xs sceen the booking button on the landing page
|
||||
public function hookDisplayAfterHeaderHotelDesc()
|
||||
{
|
||||
return $this->display(__FILE__, 'landingPageXsBtn.tpl');
|
||||
$objHotelInfo = new HotelBranchInformation();
|
||||
if ($objHotelInfo->hotelBranchesInfo(0, 1)) {
|
||||
return $this->display(__FILE__, 'landingPageXsBtn.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
// search panel block on the category page on left block
|
||||
|
||||
Reference in New Issue
Block a user