Merge branch 'develop' into gli-2941

This commit is contained in:
amit sharma
2026-09-02 11:48:40 +05:30
58 changed files with 2333 additions and 617 deletions

View File

@@ -220,6 +220,40 @@
</div>
{/if}
{if $hotels.unselected|@count + $hotels.selected|@count > 1}
<p class="checkbox">
<label>
<input type="checkbox" id="hotel_restriction" name="hotel_restriction" value="1" {if $hotels.unselected|@count}checked="checked"{/if} />
{l s='Hotel selection'}
</label>
</p>
<div id="hotel_restriction_div">
<br />
<table class="table">
<tr>
<td>
<p>{l s='Unselected hotels'}</p>
<select id="hotel_select_1" class="input-large" multiple>
{foreach from=$hotels.unselected item='hotel'}
<option value="{$hotel.id_hotel|intval}">&nbsp;{$hotel.hotel_name|escape}</option>
{/foreach}
</select>
<a id="hotel_select_add" class="btn btn-default btn-block clearfix" >{l s='Add'} <i class="icon-arrow-right"></i></a>
</td>
<td>
<p>{l s='Selected hotels'}</p>
<select name="hotel_select[]" class="input-large" id="hotel_select_2" multiple>
{foreach from=$hotels.selected item='hotel'}
<option value="{$hotel.id_hotel|intval}">&nbsp;{$hotel.hotel_name|escape}</option>
{/foreach}
</select>
<a id="hotel_select_remove" class="btn btn-default btn-block clearfix" ><i class="icon-arrow-left"></i> {l s='Remove'}</a>
</td>
</tr>
</table>
</div>
{/if}
{if $cart_rules.unselected|@count + $cart_rules.selected|@count > 0}
<p class="checkbox">
<label>

View File

@@ -147,7 +147,7 @@ function updateProductRuleShortDescription(item)
$('#' + id2 + '_match').val(length);
}
var restrictions = new Array('country', 'carrier', 'group', 'cart_rule', 'shop');
var restrictions = new Array('country', 'carrier', 'group', 'hotel', 'cart_rule', 'shop');
for (i in restrictions)
{
toggleCartRuleFilter($('#' + restrictions[i] + '_restriction'));

View File

@@ -0,0 +1,41 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{if $hotel_names_first}
<span>{$hotel_names_first|escape:'html':'UTF-8'}</span>
{if $hotel_names_remaining}
{capture name='hotel_names_tooltip'}
<div class="tooltip_cont">
<div class="tip_header"><div class="tip_date">{l s='Selected Hotels'}</div></div>
<ul>
{foreach from=$selected_hotels item='hotel'}
<li class="tip_element_value">{$hotel|escape:'html':'UTF-8'}</li>
{/foreach}
</ul>
</div>
{/capture}
{capture name='hotel_names_tooltip_title'}<span class="badge tooltip-trigger">+{$hotel_names_remaining|@count}</span>{/capture}
{include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.hotel_names_tooltip tooltip_title=$smarty.capture.hotel_names_tooltip_title}
{/if}
{else}
--
{/if}

View File

@@ -0,0 +1,24 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{l s='Total credit slip amount for this order:'} <strong><span id="booking-total-slip-amount">-</span></strong><br>
<span id="booking-slip-ids-wrapper" style="display:none;">{l s='Credit slip generated for this order: '} <strong><span id="booking-slip-ids"></span></strong></span>

View File

@@ -0,0 +1,25 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{l s='Total room price:'} <strong><span id="booking-room-amount">-</span></strong><br>
{l s='Total service price:'} <strong><span id="booking-service-amount">-</span></strong><br>
{l s='Total room booking price:'} <strong><span id="booking-amount">-</span></strong><br>

View File

@@ -0,0 +1,27 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{if $id_order}
<a class="btn btn-link" href="{$link->getAdminLink('AdminOrders')|escape:'html':'UTF-8'}&id_order={$id_order}&vieworder" target="_blank">
#{$id_order}
</a>
{/if}

View File

@@ -24,6 +24,8 @@
<a class="btn btn-link" href="{$link->getAdminLink('AdminCartRules')|escape:'html':'UTF-8'}&updatecart_rule&id_cart_rule={$id_cart_rule}" target="_blank">
#{$id_cart_rule}
</a>
{elseif $row['redeem_status'] == OrderSlip::REDEEM_STATUS_REDEEMED}
--
{else}
<a href="{$link->getAdminLink('AdminSlip')|escape:'html':'UTF-8'}&generateVoucher=1&id_order_slip={$row['id_order_slip']}" class="btn btn-default" title="{l s='Generate voucher for credit slip'}">
<i class="icon-refresh"></i> {l s='Generate Voucher'}

View File

@@ -0,0 +1,29 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
<span id="order-info" style="display:none; margin-right:15px;"></span>
<a id="order-view-link" href="#" target="_blank" style="display:none;">
{l s='View Order'} <i class="icon-external-link"></i>
</a>
<span id="order-total-amount-wrapper" style="display:none;"><br>{l s='Total order amount:'} <strong><span id="order-total-amount">-</span></strong></span>
<span id="order-total-paid-wrapper" style="display:none;"><br>{l s='Total paid amount:'} <strong><span id="order-total-paid">-</span></strong></span>
<span id="order-total-return-wrapper" style="display:none;"><br>{l s='Total return amount (Refund + Credit Slip):'} <strong><span id="order-total-return">-</span></strong></span>

View File

@@ -22,7 +22,11 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
<h4 class="modal-title"><i class="icon icon-exclamation-triangle"></i>&nbsp;{l s='Confirm Update'}</h4>
<p>{l s='This action is irreversable, Are you sure you want to change the status?'}</p>
<p>
{l s='This action is irreversible. Once the status is changed, you will not be able to create a voucher.'}
<br>
{l s='Are you sure you want to change the status?'}
</p>
</div>
<div class="modal-body">
<div class="row">

View File

@@ -3997,6 +3997,38 @@ class CartCore extends ObjectModel
}
}
$totalRoomsCount = 0;
if ($htlCartData = HotelCartBookingData::getHotelCartBookingData(0)) {
foreach ($htlCartData as $roomTypeCart) {
$totalRoomsCount += $roomTypeCart['total_num_rooms'];
}
}
$nbTotalProducts = 0;
$objServiceProductCartDetail = new ServiceProductCartDetail();
foreach ($products as &$product) {
if (!$product['booking_product']) {
if (Product::SELLING_PREFERENCE_WITH_STANDALONE == $product['selling_preference_type']) {
$nbTotalProducts += (int) $product['cart_quantity'];
} elseif (Product::SELLING_PREFERENCE_WITH_HOTEL == $product['selling_preference_type']
|| Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE == $product['selling_preference_type']
) {
if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart(
$this->id,
[Product::SELLING_PREFERENCE_HOTEL_STANDALONE, Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE],
null,
0,
null,
$product['id_product']
)) {
foreach ($serviceProducts as $serviceProduct) {
if ($serviceProduct['id_hotel'] && $serviceProduct['id_product'] == $product['id_product']) {
$nbTotalProducts += (int) $serviceProduct['quantity'];
}
}
}
}
}
}
$objHotelAdvancedPayment = new HotelAdvancedPayment();
$total_rooms_with_services_without_discount_te = $total_rooms + $total_demands + $total_additional_services + $total_additional_services_auto_add + $total_standalone_service_products;
$total_rooms_with_services_without_discount_ti = $total_rooms_wt + $total_demands_wt + $total_additional_services_wt + $total_additional_services_auto_add_wt + $total_standalone_service_products_wt;
@@ -4053,7 +4085,8 @@ class CartCore extends ObjectModel
'total_rooms_with_services_without_discount_ti' => $total_rooms_with_services_without_discount_ti,
'cart_total_without_discount_te' => $cart_total_without_discount_te,
'cart_total_without_discount_ti' => $cart_total_without_discount_ti,
'total_tax_without_discount' => $total_tax_without_discount
'total_tax_without_discount' => $total_tax_without_discount,
'total_products_in_cart' => $totalRoomsCount + $nbTotalProducts,
);
$hook = Hook::exec('actionCartSummary', $summary, null, true);
if (is_array($hook)) {

View File

@@ -59,6 +59,7 @@ class CartRuleCore extends ObjectModel
public $cart_rule_restriction;
public $product_restriction;
public $shop_restriction;
public $hotel_restriction;
public $free_shipping;
public $reduction_percent;
public $reduction_amount;
@@ -102,6 +103,7 @@ class CartRuleCore extends ObjectModel
'cart_rule_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'product_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'shop_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'hotel_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'free_shipping' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'reduction_percent' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPercentage'),
'reduction_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
@@ -163,6 +165,7 @@ class CartRuleCore extends ObjectModel
$r &= Db::getInstance()->delete('cart_rule_carrier', '`id_cart_rule` = '.(int)$this->id);
$r &= Db::getInstance()->delete('cart_rule_shop', '`id_cart_rule` = '.(int)$this->id);
$r &= Db::getInstance()->delete('cart_rule_group', '`id_cart_rule` = '.(int)$this->id);
$r &= Db::getInstance()->delete('cart_rule_hotel', '`id_cart_rule` = '.(int)$this->id);
$r &= Db::getInstance()->delete('cart_rule_country', '`id_cart_rule` = '.(int)$this->id);
$r &= Db::getInstance()->delete('cart_rule_combination', '`id_cart_rule_1` = '.(int)$this->id.' OR `id_cart_rule_2` = '.(int)$this->id);
$r &= Db::getInstance()->delete('cart_rule_product_rule_group', '`id_cart_rule` = '.(int)$this->id);
@@ -355,6 +358,28 @@ class CartRuleCore extends ObjectModel
unset($result[$key]);
}
}
// Remove cart rule if the cart contains a product from a hotel not covered by its hotel restriction
foreach ($result as $key => $cart_rule) {
if (isset($cart_rule['hotel_restriction']) && $cart_rule['hotel_restriction']) {
$total_cart_products = (int)Db::getInstance()->getValue('
SELECT COUNT(cp.id_product)
FROM '._DB_PREFIX_.'cart_product cp
WHERE cp.id_cart = '.(int)$cart->id
);
$allowed_cart_products = (int)Db::getInstance()->getValue('
SELECT COUNT(cp.id_product)
FROM '._DB_PREFIX_.'cart_product cp
INNER JOIN '._DB_PREFIX_.'htl_room_type hrt ON hrt.id_product = cp.id_product
INNER JOIN '._DB_PREFIX_.'cart_rule_hotel crh ON crh.id_hotel = hrt.id_hotel
WHERE crh.id_cart_rule = '.(int)$cart_rule['id_cart_rule'].'
AND cp.id_cart = '.(int)$cart->id
);
if (!$total_cart_products || $total_cart_products != $allowed_cart_products) {
unset($result[$key]);
}
}
}
}
$result_bak = $result;
@@ -637,6 +662,26 @@ class CartRuleCore extends ObjectModel
}
}
// Check if all the products in the cart belong to the restricted hotel(s)
if ($this->hotel_restriction) {
$total_cart_products = (int)Db::getInstance()->getValue('
SELECT COUNT(cp.id_product)
FROM '._DB_PREFIX_.'cart_product cp
WHERE cp.id_cart = '.(int)$context->cart->id
);
$allowed_cart_products = (int)Db::getInstance()->getValue('
SELECT COUNT(cp.id_product)
FROM '._DB_PREFIX_.'cart_product cp
INNER JOIN '._DB_PREFIX_.'htl_room_type hrt ON hrt.id_product = cp.id_product
INNER JOIN '._DB_PREFIX_.'cart_rule_hotel crh ON crh.id_hotel = hrt.id_hotel
WHERE crh.id_cart_rule = '.(int)$this->id.'
AND cp.id_cart = '.(int)$context->cart->id
);
if (!$total_cart_products || $total_cart_products != $allowed_cart_products) {
return (!$display_error) ? false : Tools::displayError('You cannot use this voucher with the selected hotels');
}
}
// Check if the products chosen by the customer are usable with the cart rule
if ($this->product_restriction) {
$r = $this->checkProductRestrictions($context, false, $display_error, $alreadyInCart);
@@ -1370,6 +1415,49 @@ class CartRuleCore extends ObjectModel
return $array;
}
public function getHotelRestrictions($id_profile = null)
{
$array = array('selected' => array(), 'unselected' => array());
$id_lang = (int)Context::getContext()->language->id;
$hotel_access_condition = '';
if ($id_profile) {
$accessible_hotels = HotelBranchInformation::getProfileAccessedHotels($id_profile, 1, 1);
if (!empty($accessible_hotels)) {
$hotel_access_condition = ' AND hbi.`id` IN ('.implode(',', array_map('intval', $accessible_hotels)).')';
}
}
if (!Validate::isLoadedObject($this) || $this->hotel_restriction == 0) {
$array['selected'] = Db::getInstance()->executeS('
SELECT hbi.`id` AS id_hotel, hbl.`hotel_name`, 1 AS selected
FROM `'._DB_PREFIX_.'htl_branch_info` hbi
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl
ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.$id_lang.')
WHERE hbi.`active` = 1'.$hotel_access_condition.'
ORDER BY hbl.`hotel_name` ASC
');
} else {
$resource = Db::getInstance()->query('
SELECT hbi.`id` AS id_hotel, hbl.`hotel_name`,
IF(crh.id_hotel IS NULL, 0, 1) AS selected
FROM `'._DB_PREFIX_.'htl_branch_info` hbi
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl
ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.$id_lang.')
LEFT JOIN (
SELECT id_hotel FROM `'._DB_PREFIX_.'cart_rule_hotel`
WHERE id_cart_rule = '.(int)$this->id.'
) crh ON hbi.`id` = crh.id_hotel
WHERE hbi.`active` = 1'.$hotel_access_condition.'
ORDER BY hbl.`hotel_name` ASC
');
while ($row = Db::getInstance()->nextRow($resource)) {
$array[$row['selected'] ? 'selected' : 'unselected'][] = $row;
}
}
return $array;
}
public static function autoRemoveFromCart($context = null)
{
if (!$context) {

View File

@@ -737,6 +737,7 @@ class MediaCore
} else {
$content .= Media::packJS($tmp_content);
}
$content .= ";\n";
} else {
$compressed_js_files_not_found[] = $file_infos['path'];
}

View File

@@ -3047,7 +3047,8 @@ class ProductCore extends ObjectModel
* @param null $specific_price_output If a specific price applies regarding the previous parameters,
* this variable is filled with the corresponding SpecificPrice object
* @param bool $with_ecotax Insert ecotax in price output.
* @param bool $use_group_reduction
* @param bool $use_group_reduction @deprecated no longer applied here; call
* Product::applyGroupDiscount() explicitly on your final total.
* @param Context $context
* @param bool $use_customer_price
* @return float Product price
@@ -3216,7 +3217,8 @@ class ProductCore extends ObjectModel
* @param bool $with_ecotax insert ecotax in price output.
* @param null $specific_price If a specific price applies regarding the previous parameters,
* this variable is filled with the corresponding SpecificPrice object
* @param bool $use_group_reduction
* @param bool $use_group_reduction @deprecated no longer applied here; call
* Product::applyGroupDiscount() explicitly on your final total.
* @param int $id_customer
* @param bool $use_customer_price
* @param int $id_cart
@@ -3470,18 +3472,6 @@ class ProductCore extends ObjectModel
$price -= $specific_price_reduction;
}
// Group reduction
if ($use_group_reduction) {
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
if ($reduction_from_category !== false) {
$group_reduction = $price * (float)$reduction_from_category;
} else { // apply group reduction if there is no group reduction for this category
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0;
}
$price -= $group_reduction;
}
if ($only_reduc) {
return Tools::ps_round($specific_price_reduction, $decimals);
}
@@ -3496,6 +3486,32 @@ class ProductCore extends ObjectModel
return self::$_prices[$cache_id];
}
/**
* Applies the group discount to an already-computed price.
* @param float $price The price to discount (tax-incl. or tax-excl., either works).
* @param int $id_product
* @param int $id_group
* @param bool $use_group_reduction
* @return float
*/
public static function applyGroupDiscount($price, $id_product, $id_group, $use_group_reduction = true)
{
if (!$use_group_reduction) {
return $price;
}
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
if ($reduction_from_category !== false) {
$group_reduction = $price * (float)$reduction_from_category;
} else { // apply group reduction if there is no group reduction for this category
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0;
}
$price -= $group_reduction;
return $price < 0 ? 0 : $price;
}
public static function convertAndFormatPrice($price, $currency = false, ?Context $context = null)
{
if (!$context) {
@@ -6886,7 +6902,16 @@ class ProductCore extends ObjectModel
);
$price = $price * $numdays;
return $price * (int)$quantity;
$price = $price * (int)$quantity;
if (!$specificPrice || ($specificPrice['id_cart'] == 0 && $specificPrice['id_htl_cart_booking'] == 0)) {
if (!$idGroup || !Validate::isLoadedObject(new Group((int)$idGroup))) {
$idGroup = (int)Group::getCurrent()->id;
}
$price = Product::applyGroupDiscount($price, $idProduct, $idGroup);
}
return $price;
}

View File

@@ -1039,12 +1039,21 @@ class OrderCore extends ObjectModel
return $orders;
}
public static function getOrdersWithInformations($limit = null, ?Context $context = null)
public static function getOrdersWithInformations($limit = null, ?Context $context = null, $applyHotelRestriction = false)
{
if (!$context) {
$context = Context::getContext();
}
$hotelJoin = '';
$hotelRestriction = '';
$groupBy = '';
if ($applyHotelRestriction) {
$hotelJoin = ' INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id_order` = o.`id_order`)';
$hotelRestriction = HotelBranchInformation::addHotelRestriction(false, 'hbd');
$groupBy = ' GROUP BY o.`id_order`';
}
$sql = 'SELECT *, (
SELECT osl.`name`
FROM `'._DB_PREFIX_.'order_state_lang` osl
@@ -1054,8 +1063,11 @@ class OrderCore extends ObjectModel
) AS `state_name`, o.`date_add` AS `date_add`, o.`date_upd` AS `date_upd`
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)
'.$hotelJoin.'
WHERE 1
'.Shop::addSqlRestriction(false, 'o').'
'.$hotelRestriction.'
'.$groupBy.'
ORDER BY o.`date_add` DESC
'.((int)$limit ? 'LIMIT 0, '.(int)$limit : '');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);

View File

@@ -77,8 +77,12 @@ class OrderSlipCore extends ObjectModel
/** @var int */
public $order_slip_type = 0;
public $remark;
const REDEEM_STATUS_ACTIVE = 1;
const REDEEM_STATUS_REDEEMED = 2;
const ORDER_SLIP_TYPE_REFUND = 1;
const ORDER_SLIP_TYPE_MANUAL = 2;
/**
* @see ObjectModel::$definition
@@ -101,9 +105,10 @@ class OrderSlipCore extends ObjectModel
'partial' => array('type' => self::TYPE_INT),
'redeem_status' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_cart_rule' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'order_slip_type' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'remark' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'order_slip_type' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
),
);
@@ -155,6 +160,25 @@ class OrderSlipCore extends ObjectModel
ORDER BY `date_add` DESC');
}
public static function getTotalOrderSlipAmountByOrder($id_order = false)
{
$sql = 'SELECT SUM(`amount`) FROM `'._DB_PREFIX_.'order_slip`';
if ($id_order) {
$sql .= ' WHERE `id_order` = '.(int)$id_order;
}
return (float) Db::getInstance()->getValue($sql);
}
public static function getSlipIdsByOrder($id_order = false)
{
$sql = 'SELECT * FROM `'._DB_PREFIX_.'order_slip`';
if ($id_order) {
$sql .= ' WHERE `id_order` = '.(int)$id_order;
}
$sql .= ' ORDER BY `id_order_slip` ASC';
return Db::getInstance()->executeS($sql);
}
public static function getOrdersSlipDetail($id_order_slip = false, $id_order_detail = false)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
@@ -276,6 +300,7 @@ class OrderSlipCore extends ObjectModel
SELECT `id_order_slip`
FROM `'._DB_PREFIX_.'order_slip` os
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = os.`id_order`)
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (o.id_order = hbd.id_order)
WHERE os.`date_add` BETWEEN \''.pSQL($dateFrom).' 00:00:00\' AND \''.pSQL($dateTo).' 23:59:59\'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o'). ' ' .HotelBranchInformation::addHotelRestriction(false).'
ORDER BY os.`date_add` ASC');
@@ -310,7 +335,7 @@ class OrderSlipCore extends ObjectModel
return OrderSlip::create($order, $product_list, $shipping);
}
public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true)
public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true , $orderSlipType = false, $remark = '')
{
$currency = new Currency((int)$order->id_currency);
$order_slip = new OrderSlip();
@@ -365,17 +390,6 @@ class OrderSlipCore extends ObjectModel
}
$price = (float)$product_row['unit_price'];
$order_slip_resume = OrderSlip::getProductSlipResume((int)$order_detail->id);
if ($quantity + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
$quantity = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
}
if ($quantity == 0) {
continue;
}
if (!Tools::isSubmit('cancelProduct') && $order->hasBeenPaid()) {
$order_detail->product_quantity_refunded += $quantity;
}
@@ -442,11 +456,11 @@ class OrderSlipCore extends ObjectModel
$order_slip->{'total_products_tax_'.$inc_or_ex_2} -= (float)$amount && !$amount_choosen ? (float)$amount : 0;
$order_slip->amount = $amount_choosen ? (float)$amount : $order_slip->{'total_products_tax_'.$inc_or_ex_1};
if ((float)$amount && !$amount_choosen) {
$order_slip->order_slip_type = 1;
if (isset($orderSlipType) && $orderSlipType) {
$order_slip->order_slip_type = $orderSlipType;
}
if (((float)$amount && $amount_choosen)) {
$order_slip->order_slip_type = 2;
if (isset($remark) && $remark) {
$order_slip->remark = $remark;
}
if (!$order_slip->add()) {

View File

@@ -47,6 +47,7 @@ class AdminCartRulesControllerCore extends AdminController
$this->fields_list = array(
'id_cart_rule' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'),
'name' => array('title' => $this->l('Name')),
'hotel_names' => array('title' => $this->l('Hotels'), 'orderby' => false, 'havingFilter' => true, 'filter_key' => 'hotel_names', 'callback' => 'formatHotelNames'),
'priority' => array('title' => $this->l('Priority'), 'align' => 'center', 'class' => 'fixed-width-xs'),
'code' => array('title' => $this->l('Code'), 'class' => 'fixed-width-sm'),
'quantity' => array('title' => $this->l('Quantity'), 'align' => 'center', 'class' => 'fixed-width-xs'),
@@ -54,6 +55,15 @@ class AdminCartRulesControllerCore extends AdminController
'active' => array('title' => $this->l('Status'), 'active' => 'status', 'type' => 'bool', 'align' => 'center', 'class' => 'fixed-width-xs', 'orderby' => false),
);
$this->_select = 'GROUP_CONCAT(DISTINCT hbl.`hotel_name` ORDER BY hbl.`hotel_name` ASC SEPARATOR "|||") AS hotel_names';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'cart_rule_hotel` crh ON (crh.`id_cart_rule` = a.`id_cart_rule`)
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hbi ON (
(a.`hotel_restriction` = 1 AND hbi.`id` = crh.`id_hotel`)
OR (a.`hotel_restriction` = 0 AND hbi.`active` = 1)
)
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.(int)Context::getContext()->language->id.')';
$this->_group = 'GROUP BY a.`id_cart_rule`';
// START send access query information to the admin controller
$this->access_select = ' SELECT a.`id_cart_rule` FROM '._DB_PREFIX_.'cart_rule a';
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
@@ -76,6 +86,20 @@ class AdminCartRulesControllerCore extends AdminController
parent::__construct();
}
public function formatHotelNames($hotelNames, $row)
{
$hotels = !empty($hotelNames) ? explode('|||', $hotelNames) : array();
$this->context->smarty->assign(array(
'hotel_names_first' => !empty($hotels) ? $hotels[0] : null,
'hotel_names_remaining' => count($hotels) > 1 ? array_slice($hotels, 1) : array(),
'selected_hotels' => $hotels,
));
return $this->context->smarty->fetch(
'controllers/cart_rules/helpers/list/_hotel_names_tooltip.tpl'
);
}
public function ajaxProcessLoadCartRules()
{
$type = $token = $search = '';
@@ -254,6 +278,7 @@ class AdminCartRulesControllerCore extends AdminController
'room_rmv_txt' => $this->l('Unselect below room types'),
)
);
$this->addJqueryUI('ui.tooltip', 'base', true);
$this->addJS(_PS_JS_DIR_.'admin/cart-rules.js');
$this->addJqueryPlugin(array('typewatch', 'fancybox', 'autocomplete'));
}
@@ -324,7 +349,7 @@ class AdminCartRulesControllerCore extends AdminController
}
// These are checkboxes (which aren't sent through POST when they are not check), so they are forced to 0
foreach (array('country', 'carrier', 'group', 'cart_rule', 'product', 'shop') as $type) {
foreach (array('country', 'carrier', 'group', 'cart_rule', 'product', 'shop', 'hotel') as $type) {
if (!Tools::getValue($type.'_restriction')) {
$_POST[$type.'_restriction'] = 0;
}
@@ -380,7 +405,7 @@ class AdminCartRulesControllerCore extends AdminController
{
// All the associations are deleted for an update, then recreated when we call the "afterAdd" method
$id_cart_rule = Tools::getValue('id_cart_rule');
foreach (array('country', 'carrier', 'group', 'product_rule_group', 'shop') as $type) {
foreach (array('country', 'carrier', 'group', 'hotel', 'product_rule_group', 'shop') as $type) {
Db::getInstance()->delete('cart_rule_'.$type, '`id_cart_rule` = '.(int)$id_cart_rule);
}
Db::getInstance()->delete('cart_rule_product_rule', 'NOT EXISTS (SELECT 1 FROM `'._DB_PREFIX_.'cart_rule_product_rule_group`
@@ -414,7 +439,7 @@ class AdminCartRulesControllerCore extends AdminController
*/
protected function afterAdd($currentObject)
{
// Add restrictions for generic entities like country, carrier and group
// Add restrictions for generic entities like country, carrier, group, hotel and shop
foreach (array('country', 'carrier', 'group', 'shop') as $type) {
if (Tools::getValue($type.'_restriction') && is_array($array = Tools::getValue($type.'_select')) && count($array)) {
$values = array();
@@ -424,6 +449,14 @@ class AdminCartRulesControllerCore extends AdminController
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_'.$type.'` (`id_cart_rule`, `id_'.$type.'`) VALUES '.implode(',', $values));
}
}
// Add hotel restrictions
if (Tools::getValue('hotel_restriction') && is_array($array = Tools::getValue('hotel_select')) && count($array)) {
$values = array();
foreach ($array as $id) {
$values[] = '('.(int)$currentObject->id.','.(int)$id.')';
}
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_hotel` (`id_cart_rule`, `id_hotel`) VALUES '.implode(',', $values));
}
// Add cart rule restrictions
if (Tools::getValue('cart_rule_restriction') && is_array($array = Tools::getValue('cart_rule_select')) && count($array)) {
$values = array();
@@ -803,6 +836,7 @@ class AdminCartRulesControllerCore extends AdminController
$languages = Language::getLanguages();
$countries = $current_object->getAssociatedRestrictions('country', true, true);
$groups = $current_object->getAssociatedRestrictions('group', false, true);
$hotels = $current_object->getHotelRestrictions($this->context->employee->id_profile);
$shops = $current_object->getAssociatedRestrictions('shop', false, false);
$cart_rules = $current_object->getAssociatedRestrictions('cart_rule', false, true, 0, $limit);
$carriers = $current_object->getAssociatedRestrictions('carrier', true, false);
@@ -862,6 +896,7 @@ class AdminCartRulesControllerCore extends AdminController
'countries' => $countries,
'carriers' => $carriers,
'groups' => $groups,
'hotels' => $hotels,
'shops' => $shops,
'cart_rules' => $cart_rules,
'product_rule_groups' => $product_rule_groups,

View File

@@ -484,7 +484,7 @@ class AdminOrdersControllerCore extends AdminController
if (!$cart_order_exists) {
$this->context->cart = $cart;
$this->context->currency = new Currency((int)$cart->id_currency);
$this->context->customer = new Customer((int)$cart->id_customer);
// validate cart for removing invalid data from cart before new order creation
// remove not linked services with room types from cart if not allowed to book them
$this->errors = array_merge(

View File

@@ -52,20 +52,23 @@ class AdminSlipControllerCore extends AdminController
),
'id_order' => array(
'title' => $this->l('Order ID'),
'align' => 'left',
'align' => 'center',
'class' => 'fixed-width-md',
'havingFilter' => true
'havingFilter' => true,
'callback' => 'displayOrderLink',
),
'date_add' => array(
'title' => $this->l('Date issued'),
'type' => 'date',
'align' => 'right',
'class' => 'fixed-width-md',
'align' => 'center',
'filter_key' => 'a!date_add'
),
'id_pdf' => array(
'title' => $this->l('PDF'),
'align' => 'center',
'callback' => 'printPDFIcons',
'class' => 'fixed-width-xxl',
'orderby' => false,
'search' => false,
'remove_onclick' => true
@@ -80,13 +83,20 @@ class AdminSlipControllerCore extends AdminController
'align' => 'center',
'filter_key' => 'a!redeem_status',
'callback' => 'displayRedeemStatus',
'class' => 'fixed-width-md',
'class' => 'fixed-width-xxl',
),
'id_cart_rule' => array(
'title' => $this->l('Voucher'),
'align' => 'center',
'callback' => 'displayVoucherLink',
'class' => 'fixed-width-lg',
'class' => 'fixed-width-xxl',
),
'remark' => array(
'title' => $this->l('Remark'),
'filter_key' => 'a!remark',
'align' => 'center',
'orderby' => false,
'callback' => 'displayRemark',
),
);
@@ -113,35 +123,131 @@ class AdminSlipControllerCore extends AdminController
$this->_conf['33'] = $this->l('Voucher generated successfully');
}
public function initPageHeaderToolbar()
public function initPageHeaderToolbar()
{
if (empty($this->display) || $this->display == 'list') {
$this->page_header_toolbar_btn['new_credit_slip'] = array(
'href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token,
'desc' => $this->l('Add Credit Slip', null, null, false),
'icon' => 'process-icon-new'
);
}
parent::initPageHeaderToolbar();
}
public function renderForm()
public function renderForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Print a PDF'),
'icon' => 'icon-print'
),
'input' => array(
array(
'type' => 'date',
'label' => $this->l('From'),
'name' => 'date_from',
'maxlength' => 10,
'required' => true,
'hint' => $this->l('Format: 2011-12-31 (inclusive).')
if ($this->display == 'add') {
$orderList = Order::getOrdersWithInformations(null, null, true);
foreach ($orderList as &$order) {
$order['order_label'] = $order['reference'] . ' #' . (int) $order['id_order'];
}
unset($order);
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Credit slip'),
'icon' => 'icon-print'
),
array(
'type' => 'date',
'label' => $this->l('To'),
'name' => 'date_to',
'maxlength' => 10,
'required' => true,
'hint' => $this->l('Format: 2012-12-31 (inclusive).')
'description' => '<strong>' . $this->l('Note: Before generating the credit slip, please review all details carefully. Once the credit slip is generated, it cannot be modified.') . '</strong>',
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Order id'),
'name' => 'id_order',
'required' => true,
'hint' => $this->l('Select an Order ID to generate the credit slip'),
'class' => 'chosen',
'col' => 3,
'desc' => $this->context->smarty->fetch(
_PS_ADMIN_DIR_ . '/themes/default/template/controllers/slip/_order_info_desc.tpl'
),
'options' => array(
'query' => $orderList,
'id' => 'id_order',
'name' => 'order_label'
)
),
array(
'type' => 'select',
'label' => $this->l('Room Type'),
'name' => 'id_room_type',
'required' => true,
'hint' => $this->l('Select a room type'),
'col' => 3,
'options' => array(
'query' => array(),
'id' => 'id',
'name' => 'name'
)
),
array(
'type' => 'select',
'label' => $this->l('Room'),
'name' => 'id_booking_detail',
'required' => true,
'hint' => $this->l('Select a room to generate the credit slip for'),
'col' => 3,
'desc' => $this->context->smarty->fetch(
_PS_ADMIN_DIR_ . '/themes/default/template/controllers/slip/_booking_room_service_total_desc.tpl'
),
'options' => array(
'query' => array(),
'id' => 'id',
'name' => 'room_label'
)
),
array(
'type' => 'text',
'label' => $this->l('Amount of credit slip'),
'hint' => $this->l('Enter the amount of the credit slip for the customer'),
'name' => 'credit_slip_amount',
'required' => true,
'col' => 3,
'suffix' => $this->context->currency->sign,
'desc' => $this->context->smarty->fetch(
_PS_ADMIN_DIR_ . '/themes/default/template/controllers/slip/_booking_amount_desc.tpl'
),
),
array(
'type' => 'textarea',
'label' => $this->l('Remark'),
'hint' => $this->l('Enter any remark for this credit slip'),
'name' => 'remark',
'required' => true,
'col' => 9,
'rows' => 3,
),
),
'submit' => array(
'title' => $this->l('Generate'),
'name' => 'submitCreditSlip',
)
);
} else {
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Print a PDF'),
'icon' => 'icon-print'
),
'input' => array(
array(
'type' => 'date',
'label' => $this->l('From'),
'name' => 'date_from',
'maxlength' => 10,
'required' => true,
'hint' => $this->l('Format: 2011-12-31 (inclusive).')
),
array(
'type' => 'date',
'label' => $this->l('To'),
'name' => 'date_to',
'maxlength' => 10,
'required' => true,
'hint' => $this->l('Format: 2012-12-31 (inclusive).')
)
),
'submit' => array(
'title' => $this->l('Generate PDF file'),
@@ -149,6 +255,7 @@ class AdminSlipControllerCore extends AdminController
'icon' => 'process-icon-download-alt'
)
);
}
$this->fields_value = array(
'date_from' => date('Y-m-d'),
@@ -159,9 +266,83 @@ class AdminSlipControllerCore extends AdminController
return parent::renderForm();
}
public function postProcess()
public function postProcess()
{
if (Tools::getValue('submitAddorder_slip')) {
if (Tools::getValue('submitCreditSlip')) {
$creditSlipAmount = trim(Tools::getValue('credit_slip_amount'));
if (empty($creditSlipAmount)) {
$this->errors[] = $this->l('Credit slip amount is required.');
} elseif (!is_numeric($creditSlipAmount)) {
$this->errors[] = $this->l('Credit slip amount is not valid');
} elseif ((float) $creditSlipAmount <= 0) {
$this->errors[] = $this->l('Credit slip amount must be greater than 0');
}
$remark = trim(Tools::getValue('remark'));
if (empty($remark)) {
$this->errors[] = $this->l('Remark is required.');
} elseif (!Validate::isString($remark) || !Validate::isMessage($remark) || !Validate::isCleanHtml($remark)) {
$this->errors[] = $this->l('Remark must be a valid text.');
}
if (!count($this->errors)) {
$objOrder = new Order(Tools::getValue('id_order'));
$creditAmount = $creditSlipAmount;
$idBookingDetail = Tools::getValue('id_booking_detail');
$customer = new Customer($objOrder->id_customer);
$bookingList = array();
$objHotelBookingDetail = new HotelBookingDetail($idBookingDetail);
if ($idHtlBooking = $objHotelBookingDetail->id) {
$numDays = HotelHelper::getNumberOfDays(
$objHotelBookingDetail->date_from,
$objHotelBookingDetail->date_to
);
$idOrderDetail = $objHotelBookingDetail->id_order_detail;
$bookingList = array(
array(
'id_htl_booking' => $idHtlBooking,
'id_order_detail' => $idOrderDetail,
'quantity' => $numDays,
'num_days' => $numDays,
'unit_price' => (float) $creditAmount / $numDays,
'amount' => (float) $creditAmount,
)
);
}
if (!$idCreditSlip = OrderSlip::create($objOrder, $bookingList, 0, $creditAmount, $creditAmount, 0 , OrderSlip::ORDER_SLIP_TYPE_MANUAL, $remark)) {
$this->errors[] = $this->l('A credit slip cannot be generated. ');
} else {
Hook::exec('actionOrderSlipAdd', array('order' => $objOrder, 'bookingList' => $bookingList));
$params['{credit_slip_url}'] = $this->context->link->getPageLink('order-slip', true);
@Mail::Send(
(int)$objOrder->id_lang,
'credit_slip',
Mail::l('New credit slip generated for you', (int)$objOrder->id_lang),
$params,
$customer->email,
$customer->firstname.' '.$customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
true,
(int)$objOrder->id_shop
);
}
Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token . '&conf=3');
} else {
$this->display = 'add';
return;
}
} else if (Tools::getValue('submitAddorder_slip')) {
if (!Validate::isDate(Tools::getValue('date_from'))) {
$this->errors[] = $this->l('Invalid "From" date');
}
@@ -236,9 +417,13 @@ class AdminSlipControllerCore extends AdminController
$this->initTabModuleList();
$this->initToolbar();
$this->initPageHeaderToolbar();
$this->content .= $this->renderList();
if ($this->display != "add") {
$this->content .= $this->renderList();
}
$this->content .= $this->renderForm();
$this->content .= $this->renderOptions();
if ($this->display != "add") {
$this->content .= $this->renderOptions();
}
$this->context->smarty->assign(array(
'content' => $this->content,
@@ -288,6 +473,31 @@ class AdminSlipControllerCore extends AdminController
return $this->createTemplate('_display_voucher_link.tpl')->fetch();
}
public function displayOrderLink($idOrder, $row)
{
$this->context->smarty->assign(array(
'id_order' => (int) $idOrder,
));
return $this->createTemplate('_display_order_link.tpl')->fetch();
}
public function displayRemark($remark, $row)
{
if (empty($remark)) {
return '--';
}
$maxLength = 100;
if (Tools::strlen($remark) > $maxLength) {
return '<span title="' . htmlspecialchars($remark, ENT_QUOTES, 'UTF-8') . '">'
. htmlspecialchars(Tools::substr($remark, 0, $maxLength), ENT_QUOTES, 'UTF-8')
. '<strong style="cursor:pointer;">...</strong></span>';
}
return htmlspecialchars($remark, ENT_QUOTES, 'UTF-8');
}
public function displayStatusChangeLink($token, $id)
{
$objOrderSlip = new OrderSlip($id);
@@ -342,12 +552,73 @@ class AdminSlipControllerCore extends AdminController
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessGetBookingDetails()
{
$idOrder = (int) Tools::getValue('id_order');
$objOrder = new Order($idOrder);
$currency = Currency::getCurrency((int)$objOrder->id_currency);
$objHotelBookingDetail = new HotelBookingDetail();
$bookingDetails = $objHotelBookingDetail->getBookingDataByOrderId($idOrder);
$objBookingDemands = new HotelBookingDemands();
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
foreach ($bookingDetails as &$booking) {
$booking['extra_service_total_price_tax_incl'] = 0;
$extraDemands = $objBookingDemands->getRoomTypeBookingExtraDemands(
$idOrder,
$booking['id_product'],
$booking['id_room'],
$booking['date_from'],
$booking['date_to'],
0,
0,
1,
$booking['id']
);
if ($extraDemands) {
foreach ($extraDemands as $demand) {
$booking['extra_service_total_price_tax_incl'] += (float) $demand['total_price_tax_incl'];
}
}
$roomServices = $objServiceProductOrderDetail->getRoomTypeServiceProducts(
0, 0, 0, 0, 0, 0, 0, 0, null, null, null, 0, $booking['id']
);
if ($roomServices && isset($roomServices[$booking['id']]['additional_services'])) {
foreach ($roomServices[$booking['id']]['additional_services'] as $service) {
$booking['extra_service_total_price_tax_incl'] += (float) $service['total_price_tax_incl'];
}
}
}
unset($booking);
$totalSlipAmount = OrderSlip::getTotalOrderSlipAmountByOrder($idOrder);
$slipIds = array_column(OrderSlip::getSlipIdsByOrder($idOrder), 'id_order_slip');
$objOrderReturn = new OrderReturn();
$refundedAmount = $objOrderReturn->getRefundedAmount($idOrder);
die(Tools::jsonEncode(array(
'bookings' => $bookingDetails,
'currency' => $currency,
'total_slip_amount' => $totalSlipAmount,
'slip_ids' => $slipIds,
'order_total_amount' => (float) $objOrder->total_paid,
'order_total_paid' => (float) $objOrder->total_paid_real,
'order_refunded_amount' => (float) $refundedAmount
)));
}
public function setMedia()
{
parent::setMedia();
Media::addJsDef(
array(
'admin_order_slip_tab_link' => $this->context->link->getAdminLink('AdminSlip'),
'admin_order_view_link' => $this->context->link->getAdminLink('AdminOrders'),
'restoreRoomTypeId' => (int) Tools::getValue('id_room_type'),
'restoreBookingDetailId' => (int) Tools::getValue('id_booking_detail'),
)
);
$this->addJS(_PS_JS_DIR_.'admin/slips.js');

View File

@@ -155,8 +155,8 @@ class CartControllerCore extends FrontController
$result = $this->context->cart->deleteProduct($this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery);
// now get updated available rooms
$date_from = Tools::getValue('dateFrom');
$date_to = Tools::getValue('dateTo');
$date_from = Tools::getValue('date_from');
$date_to = Tools::getValue('date_to');
$date_from = date("Y-m-d H:i:s", strtotime($date_from));
$date_to = date("Y-m-d H:i:s", strtotime($date_to));
$objRoomType = new HotelRoomType();
@@ -315,7 +315,7 @@ class CartControllerCore extends FrontController
}
if ($occupancyRequiredForBooking && $operator == 'up') {
if ($occupancy = json_decode(Tools::getValue('occupancy'), true)) {
if ($occupancy = Tools::getValue('occupancy')) {
$this->qty = count($occupancy);
} else {
$this->errors[] = Tools::displayError('Invalid occupnacy.');
@@ -337,11 +337,21 @@ class CartControllerCore extends FrontController
if (!$this->errors) {
$objRoomType = new HotelRoomType();
if ($roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($this->id_product)) {
$date_from = Tools::getValue('dateFrom');
$date_to = Tools::getValue('dateTo');
$date_from = Tools::getValue('date_from');
$date_to = Tools::getValue('date_to');
$date_from = date("Y-m-d H:i:s", strtotime($date_from));
$date_to = date("Y-m-d H:i:s", strtotime($date_to));
$serviceProducts = json_decode(Tools::getValue('serviceProducts'),true);
$rawServiceProducts = Tools::getValue('service_product');
$serviceProducts = [];
if (is_array($rawServiceProducts) && !empty($rawServiceProducts)) {
foreach ($rawServiceProducts as $id_product => $data) {
$serviceProducts[] = [
'id_product' => (int) $id_product,
'quantity' => isset($data['quantity']) ? (int) $data['quantity'] : 1,
];
}
}
// valdiate occupancy if providede
if ($operator == 'up' && $occupancyRequiredForBooking) {
@@ -419,7 +429,11 @@ class CartControllerCore extends FrontController
$total_available_rooms = $hotelRoomData['stats']['num_avail'];
if (Tools::getValue('op', 'up') == 'up') {
if ($total_available_rooms < $req_rm) {
die(json_encode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms)));
if (Tools::getValue('ajax')) {
die(json_encode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms)));
} else {
$this->errors[] = Tools::displayError('All rooms are sold out for the selected dates. Please try with different dates.');
}
} else {
// validate service products if available
if ($serviceProducts) {
@@ -450,10 +464,18 @@ class CartControllerCore extends FrontController
}
}
} else {
die(json_encode(array('status' => 'failed3')));
if (Tools::getValue('ajax')) {
die(json_encode(array('status' => 'failed3')));
} else {
$this->errors[] = Tools::displayError('An error occurred while processing your request.');
}
}
} else {
die(json_encode(array('status' => 'failed4')));
if (Tools::getValue('ajax')) {
die(json_encode(array('status' => 'failed4')));
} else {
$this->errors[] = Tools::displayError('An error occurred while processing your request.');
}
}
}
} else {
@@ -612,7 +634,7 @@ class CartControllerCore extends FrontController
*/
if ($product->booking_product) {
$objHotelCartBookingData = new HotelCartBookingData();
$roomDemand = json_decode(Tools::getValue('roomDemands'), true);
$roomDemand = json_decode(Tools::getValue('room_demands'), true);
$roomDemand = json_encode($roomDemand);
$availQty = $total_available_rooms;
$update_quantity = $objHotelCartBookingData->updateCartBooking(

View File

@@ -59,6 +59,7 @@ class CategoryControllerCore extends FrontController
$this->addCSS(_THEME_CSS_DIR_.'occupancy.css');
$this->addJS(_THEME_JS_DIR_.'occupancy.js');
$this->addJS(_THEME_JS_DIR_.'room-type-service-products.js');
$scenes = Scene::getScenes($this->category->id, $this->context->language->id, true, false);
if ($scenes && count($scenes)) {
$this->addJS(_THEME_JS_DIR_.'scenes.js');

View File

@@ -311,7 +311,7 @@ class ContactControllerCore extends FrontController
)
) {
// by webkul to get media link.
$htlImgLink = $this->context->link->getMediaLink($objHotelImage->getImageLink($hotel['id_cover_img'], ImageType::getFormatedName('medium')));
$htlImgLink = $this->context->link->getMediaLink($objHotelImage->getImageLink($hotel['id_cover_img'], ImageType::getFormatedName('large')));
if ((bool)Tools::file_get_contents($htlImgLink)) {
$hotel['image_url'] = $htlImgLink;
@@ -330,7 +330,6 @@ class ContactControllerCore extends FrontController
$this->context->smarty->assign(
array(
'hotelsInfo' => $hotelsInfo,
'viewOnMap' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'),
'displayHotels' => Configuration::get('WK_DISPLAY_CONTACT_PAGE_HOTEL_LIST'),
'gblHtlPhone' => $gblHtlPhone,
'gblHtlEmail' => $gblHtlEmail,

View File

@@ -110,6 +110,12 @@ class GuestTrackingControllerCore extends FrontController
{
$response = array('extra_demands' => false);
$order = new Order((int) Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order) || $order->secure_key != Tools::getValue('secure_key')) {
$this->ajaxDie(json_encode($response));
}
if (($idProduct = Tools::getValue('id_product'))
&& ($idOrder = Tools::getValue('id_order'))
&& ($dateFrom = Tools::getValue('date_from'))

View File

@@ -49,7 +49,7 @@ class OurPropertiesControllerCore extends FrontController
&& $hotel['id_cover_img']
&& Validate::isLoadedObject($objHotelImage = new HotelImage($hotel['id_cover_img']))
) {
$htlImgLink = $this->context->link->getMediaLink($objHotelImage->getImageLink($hotel['id_cover_img'], ImageType::getFormatedName('medium')));
$htlImgLink = $this->context->link->getMediaLink($objHotelImage->getImageLink($hotel['id_cover_img'], ImageType::getFormatedName('large')));
if ((bool)Tools::file_get_contents($htlImgLink)) {
$hotelsInfo[$hotelKey]['image_url'] = $htlImgLink;
} else {
@@ -128,7 +128,6 @@ class OurPropertiesControllerCore extends FrontController
array(
'hotelsInfo' => $hotelsInfo,
'hotelLocationArray' => $hotelLocationArray,
'viewOnMap' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'),
'displayHotelMap' => $displayHotelMap,
'WK_HTL_SHORT_DESC' => Configuration::get('WK_HTL_SHORT_DESC', $this->context->language->id),
'currentIndex' => $this->context->link->getPageLink('our-properties')

View File

@@ -50,6 +50,7 @@ class ProductControllerCore extends FrontController
$this->addJS(array(
_THEME_JS_DIR_.'tools.js', // retro compat themes 1.5
_THEME_JS_DIR_.'product.js',
_THEME_JS_DIR_.'room-type-service-products.js',
));
} else {
$this->addJqueryPlugin(array('scrollTo', 'serialScroll'));
@@ -1459,8 +1460,8 @@ class ProductControllerCore extends FrontController
$response = array('status' => false);
$idProduct = (int) Tools::getValue('id_product');
if ($this->product->booking_product) {
$dateFrom = Tools::getValue('room_check_in');
$dateTo = Tools::getValue('room_check_out');
$dateFrom = Tools::getValue('date_from');
$dateTo = Tools::getValue('date_to');
$occupancy = Tools::getValue('occupancy');
if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
if (!Validate::isOccupancy($occupancy)) {
@@ -1487,7 +1488,7 @@ class ProductControllerCore extends FrontController
$idHotel = Tools::getValue('service_id_hotel');
$buying_option = Tools::getValue('buying_option');
$id_product_option = Tools::getValue('id_product_option');
$quantity = Tools::getValue('service_product_qty');
$quantity = Tools::getValue('qty');
$this->assignServiceProductVars(
$id_product_option,
$quantity,
@@ -1496,6 +1497,7 @@ class ProductControllerCore extends FrontController
);
}
$this->context->smarty->assign('static_token', Tools::getToken(false));
$html = $this->context->smarty->fetch('_partials/booking-form.tpl');
$response['status'] = true;
$response['html_booking_form'] = $html;

View File

@@ -226,6 +226,7 @@ CREATE TABLE `PREFIX_cart_rule` (
`cart_rule_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0',
`product_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0',
`shop_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0',
`hotel_restriction` tinyint(1) unsigned NOT NULL DEFAULT '0',
`free_shipping` tinyint(1) NOT NULL DEFAULT '0',
`reduction_percent` decimal(5,2) NOT NULL DEFAULT '0',
`reduction_amount` decimal(17,2) NOT NULL DEFAULT '0',
@@ -264,6 +265,12 @@ CREATE TABLE `PREFIX_cart_rule_group` (
PRIMARY KEY (`id_cart_rule`, `id_group`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION;
CREATE TABLE `PREFIX_cart_rule_hotel` (
`id_cart_rule` int(10) unsigned NOT NULL,
`id_hotel` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_cart_rule`, `id_hotel`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION;
CREATE TABLE `PREFIX_cart_rule_carrier` (
`id_cart_rule` int(10) unsigned NOT NULL,
`id_carrier` int(10) unsigned NOT NULL,
@@ -1409,6 +1416,7 @@ CREATE TABLE `PREFIX_order_slip` (
`redeem_status` TINYINT(1) NOT NULL DEFAULT '0',
`id_cart_rule` int(10) unsigned NOT NULL DEFAULT '0',
`order_slip_type` TINYINT(1) unsigned NOT NULL DEFAULT '0',
`remark` text,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_order_slip`),

View File

@@ -103,4 +103,179 @@ $(document).ready(function() {
});
});
}
var allBookings = [];
var currencySign = '';
if (typeof $.fn.chosen !== 'undefined') {
$('select[name="id_order"]').chosen('destroy').chosen({
width: '100%',
search_contains: true
});
$('select[name="id_room_type"]').chosen({
width: '100%',
search_contains: true
});
$('select[name="id_booking_detail"]').chosen({
width: '100%',
search_contains: true
});
}
$('select[name="id_order"]').on('change', function () {
var idOrder = $(this).val();
var $roomTypeSelect = $('select[name="id_room_type"]');
var $bookingSelect = $('select[name="id_booking_detail"]');
allBookings = [];
$roomTypeSelect.empty().trigger('chosen:updated');
$bookingSelect.empty().trigger('chosen:updated');
if (!idOrder) {
$('#order-info').hide();
$('#order-view-link').hide();
$('#booking-total-slip-amount').text('-');
$('#booking-slip-ids').html('');
$('#booking-slip-ids-wrapper').hide();
$('#order-total-amount').text('-');
$('#order-total-amount-wrapper').hide();
$('#order-total-paid').text('-');
$('#order-total-paid-wrapper').hide();
$('#order-total-return').text('-');
$('#order-total-return-wrapper').hide();
return;
}
var selectedLabel = $('select[name="id_order"] option:selected').text();
$('#order-info').text(selectedLabel).show();
$('#order-view-link')
.attr('href', admin_order_view_link + '&id_order=' + idOrder + '&vieworder')
.show();
$.ajax({
url: admin_order_slip_tab_link,
type: 'POST',
dataType: 'json',
data: {
ajax: 1,
action: 'GetBookingDetails',
id_order: idOrder
},
success: function (response) {
allBookings = response.bookings || [];
currencySign = response.currency.sign;
var totalSlipAmount = parseFloat(response.total_slip_amount || 0);
$('#booking-total-slip-amount').text(currencySign + ' ' + totalSlipAmount.toFixed(2));
var orderTotalAmount = parseFloat(response.order_total_amount || 0);
$('#order-total-amount').text(currencySign + ' ' + orderTotalAmount.toFixed(2));
$('#order-total-amount-wrapper').show();
var orderTotalPaid = parseFloat(response.order_total_paid || 0);
$('#order-total-paid').text(currencySign + ' ' + orderTotalPaid.toFixed(2));
$('#order-total-paid-wrapper').show();
var orderRefundedAmount = parseFloat(response.order_refunded_amount || 0);
$('#order-total-return').text(currencySign + ' ' + orderRefundedAmount.toFixed(2));
$('#order-total-return-wrapper').show();
var slipIds = response.slip_ids || [];
if (slipIds.length) {
var links = slipIds.map(function (id) {
var href = admin_order_slip_tab_link
+ '&order_slipFilter_id_order_slip=' + id
+ '&submitFilterorder_slip=1';
return '<a href="' + href + '">#' + id + '</a>';
});
$('#booking-slip-ids').html(links.join(', '));
$('#booking-slip-ids-wrapper').show();
} else {
$('#booking-slip-ids').html('');
$('#booking-slip-ids-wrapper').hide();
}
$('#credit_slip_amount')
.closest('.input-group')
.find('.input-group-addon, .input-group-text')
.text(currencySign);
var addedRoomTypes = {};
$.each(allBookings, function (_, booking) {
if (!addedRoomTypes[booking.id_product]) {
addedRoomTypes[booking.id_product] = true;
$roomTypeSelect.append($('<option>', {
value: booking.id_product,
text: booking.room_type_name
}));
}
});
$roomTypeSelect.trigger('chosen:updated');
if (restoreRoomTypeId > 0) {
$roomTypeSelect.val(restoreRoomTypeId).trigger('chosen:updated');
restoreRoomTypeId = 0;
}
$roomTypeSelect.trigger('change');
},
error: function (_, status, error) {
console.error('[CreditSlip] AJAX error:', status, error);
}
});
});
$('select[name="id_room_type"]').on('change', function () {
var idProduct = $(this).val();
var $bookingSelect = $('select[name="id_booking_detail"]');
$bookingSelect.empty();
if (!idProduct) {
$bookingSelect.trigger('chosen:updated');
return;
}
var filtered = $.grep(allBookings, function (booking) {
return String(booking.id_product) === String(idProduct);
});
$.each(filtered, function (_, booking) {
$bookingSelect.append($('<option>', {
value: booking.id,
text: booking.room_num + ' | ' + booking.date_from.substring(0, 10) + ' - ' + booking.date_to.substring(0, 10)
}));
});
$bookingSelect.trigger('chosen:updated');
if (restoreBookingDetailId > 0) {
$bookingSelect.val(restoreBookingDetailId).trigger('chosen:updated');
restoreBookingDetailId = 0;
}
$bookingSelect.trigger('change');
});
$('select[name="id_booking_detail"]').on('change', function () {
var idBooking = $(this).val();
var booking = $.grep(allBookings, function (b) {
return String(b.id) === String(idBooking);
})[0];
if (booking) {
var roomCost = parseFloat(booking.total_price_tax_incl);
var serviceCost = parseFloat(booking.extra_service_total_price_tax_incl || 0);
var total = roomCost + serviceCost;
$('#booking-room-amount').text(currencySign + ' ' + roomCost.toFixed(2));
$('#booking-service-amount').text(currencySign + ' ' + serviceCost.toFixed(2));
$('#booking-amount').text(currencySign + ' ' + total.toFixed(2));
} else {
$('#booking-room-amount').text('-');
$('#booking-service-amount').text('-');
$('#booking-amount').text('-');
}
});
if ($('select[name="id_order"]').val()) {
$('select[name="id_order"]').trigger('change');
}
});

View File

@@ -415,19 +415,29 @@ var ajaxCart = {
if (parseInt(booking_product)) {
// get the selected extra demands by customer
if (typeof dateFrom != 'undefined')
req.append('dateFrom', dateFrom);
req.append('date_from', dateFrom);
if (typeof dateTo != 'undefined')
req.append('dateTo', dateTo);
req.append('date_to', dateTo);
if (occupancy_required_for_booking) {
req.append('occupancy', JSON.stringify(occupancy));
if (occupancy_required_for_booking) {
occupancy.forEach(function(room, i) {
req.append('occupancy['+i+'][adults]', room.adults);
req.append('occupancy['+i+'][children]', room.children || 0);
if (room.child_ages && room.child_ages.length) {
room.child_ages.forEach(function(age) {
req.append('occupancy['+i+'][child_ages][]', age);
});
}
});
} else {
req.append('qty', ((occupancy && occupancy != null) ? occupancy : '1'));
}
var roomDemands = getRoomsExtraDemands();
req.append('roomDemands', JSON.stringify(roomDemands) );
req.append('serviceProducts', JSON.stringify(getRoomsServiceProducts()) );
req.append('room_demands', JSON.stringify(roomDemands) );
getRoomsServiceProducts().forEach(function(product) {
req.append('service_product['+product.id_product+'][quantity]', product.quantity);
});
} else {
req.append('qty', ((occupancy && occupancy != null) ? occupancy : '1'));
}
@@ -576,7 +586,7 @@ var ajaxCart = {
async: true,
cache: false,
dataType: "json",
data: 'controller=cart&add=1&op=down&dateFrom=' + dateFrom + '&dateTo=' + dateTo + '&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ((parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination) : '' + '&id_customization=' + ((typeof customizationId !== 'undefined') ? customizationId : 0)),
data: 'controller=cart&add=1&op=down&date_from=' + dateFrom + '&date_to=' + dateTo + '&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ((parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination) : '' + '&id_customization=' + ((typeof customizationId !== 'undefined') ? customizationId : 0)),
success: function(jsonData, textStatus, jqXHR) {
/*by webkul checking and setting availability of rooms*/
/*for product page add to cart quantity management*/
@@ -650,7 +660,7 @@ var ajaxCart = {
async: true,
cache: false,
dataType: "json",
data: 'controller=cart&delete=1&dateFrom=' + dateFrom + '&dateTo=' + dateTo + '&id_product=' + idProduct + '&id_hotel=' + idHotel + '&id_product_option=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
data: 'controller=cart&delete=1&date_from=' + dateFrom + '&date_to=' + dateTo + '&id_product=' + idProduct + '&id_hotel=' + idHotel + '&id_product_option=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
success: function(jsonData) {
if (pagename == 'product') {
disableRoomTypeDemands(0);
@@ -1414,112 +1424,3 @@ function crossselling_serialScroll() {
pager: false
});
}
function resetRoomtypeServices(refresh = true) {
$('.room_demands_container').find('input.id_room_type_demand:checked').prop('checked', false).uniform();
$('#additional_products').empty();
$('#additional_products div')
$('.remove_roomtype_product').text(select_txt).removeClass('btn-danger remove_roomtype_product').addClass('btn-success add_roomtype_product');
if (refresh) {
BookingForm.refresh();
}
}
function disableRoomTypeDemands(show) {
if (show) {
$('.room_demands_container_overlay').show();
$('.room_demands_container').find('input:checkbox.id_room_type_demand').prop('checked', false);
$('.room_demand_block').find('.id_room_type_demand').prop('checked', false).parent().removeClass('checked');
$('.room_demands_container').find('input:checkbox.id_room_type_demand').attr('disabled', 'disabled');
} else {
$('.room_demands_container_overlay').hide();
$('.room_demands_container').find('input:checkbox.id_room_type_demand').removeAttr('disabled');
$('.room_demands_container').find('.checker').removeClass('disabled');
}
}
function disableRoomTypeServices(disable) {
if (disable) {
resetRoomtypeServices(false);
$('#service_products_cont').find('button.add_roomtype_product').attr('disabled', 'disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').attr('disabled', 'disabled');
} else {
$('#service_products_cont').find('button.add_roomtype_product').removeAttr('disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').removeAttr('disabled');
}
}
function getRoomsExtraDemands()
{
var roomDemands = [];
$('input:checkbox.id_room_type_demand:checked').each(function () {
roomDemands.push({
'id_global_demand':$(this).val(),
'id_option': $(this).closest('.room_demand_block').find('.id_option').val()
});
});
return roomDemands;
}
function getRoomsServiceProducts()
{
var serviceProducts = [];
$('#additional_products input.service_product').each(function () {
serviceProducts.push({
'id_product': $(this).data('id_product'),
'quantity':$(this).val(),
});
});
return serviceProducts;
}
function getBookingOccupancyDetails(bookingform, booking_product)
{
let occupancy;
if (booking_product) {
if (occupancy_required_for_booking) {
$('.booking_guest_occupancy_conatiner .dropdown').removeClass('open');
let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected")
if (selected_occupancy.length) {
occupancy = [];
$(selected_occupancy).each(function(ind, element) {
if (parseInt($(element).find('.num_adults').val())) {
let child_ages = [];
$(element).find('.guest_child_age').each(function(index) {
if ($(this).val() > -1) {
child_ages.push($(this).val());
}
});
if ($(element).find('.num_children').val()) {
if (child_ages.length != $(element).find('.num_children').val()) {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
}
occupancy.push({
'adults': $(element).find('.num_adults').val(),
'children': $(element).find('.num_children').val(),
'child_ages': child_ages
});
} else {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
});
} else {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
} else {
occupancy = parseInt($(bookingform).find(".quantity_wanted").val());
}
} else {
occupancy = parseInt($('#service_product_qty').val());
}
return occupancy;
}

View File

@@ -25,6 +25,7 @@ class HotelImage extends ObjectModel
{
public $id;
public $id_hotel;
public $id_htl_image_category;
public $cover;
public $source_index;
public $image_dir;
@@ -37,6 +38,7 @@ class HotelImage extends ObjectModel
'primary' => 'id',
'fields' => array(
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'id_htl_image_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true),
'cover' => array('type' => self::TYPE_BOOL,'validate' => 'isBool')
),
);
@@ -99,7 +101,7 @@ class HotelImage extends ObjectModel
* @param [int] $n [number of images per page for paginated images data]
* @return [array|boolean] [if data found returns array containing information of the images of the hotel which id is passed]
*/
public function getImagesByHotelId($id_hotel, $p = 1, $n = null)
public function getImagesByHotelId($id_hotel, $p = 1, $n = null, $idLang = null)
{
$p = (int) $p;
$n = $n !== null ? (int) $n : $n; // n = null for no pagination
@@ -107,9 +109,16 @@ class HotelImage extends ObjectModel
$p = 1;
}
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'htl_image`
WHERE `id_hotel` = '.(int) $id_hotel.
if (!$idLang) {
$idLang = (int) Context::getContext()->language->id;
}
$sql = 'SELECT hi.*, hicl.`name` AS `category_name`
FROM `'._DB_PREFIX_.'htl_image` hi
LEFT JOIN `'._DB_PREFIX_.'htl_image_category_lang` hicl
ON (hicl.`id_htl_image_category` = hi.`id_htl_image_category`
AND hicl.`id_lang` = '.(int) $idLang.')
WHERE hi.`id_hotel` = '.(int) $id_hotel.
($n ? ' LIMIT '.(int) (($p - 1) * $n).', '.(int) ($n) : '');
return Db::getInstance()->executeS($sql);
@@ -174,107 +183,80 @@ class HotelImage extends ObjectModel
);
}
public function uploadHotelImages($images, $idHotel)
public function uploadHotelImages($images, $idHotel, $idHtlImageCategory = 0, $objCategory = null)
{
if (isset($images) && $idHotel) {
$objHotelHelper = new HotelHelper();
$hotelImages = $images['tmp_name'];
if (is_array($images['tmp_name'])) {
foreach ($hotelImages as $image) {
$objHtlImage = new HotelImage();
$objHtlImage->id_hotel = $idHotel;
if ($coverImgExist = HotelImage::getCover($idHotel)) {
$objHtlImage->cover = 0;
} else {
$objHtlImage->cover = 1;
}
if ($objHtlImage->save()) {
if ($path = $objHtlImage->getPathForCreation()) {
if (ImageManager::resize(
$image,
$path.$objHtlImage->id.'.'.$objHtlImage->image_format
)) {
// add hotel images in all required sizes
$imagesTypes = ImageType::getImagesTypes('hotels');
$generate_hight_dpi_images = (bool)Configuration::get('PS_HIGHT_DPI');
if (!isset($images['tmp_name']) || !$idHotel) {
return false;
}
foreach ($imagesTypes as $imageType) {
if (!ImageManager::resize(
$image,
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
$imageType['width'],
$imageType['height']
)) {
continue;
}
$isMultiple = is_array($images['tmp_name']);
$tmpFiles = $isMultiple ? $images['tmp_name'] : array($images['tmp_name']);
if ($generate_hight_dpi_images) {
if (!ImageManager::resize(
$image,
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
(int)$imageType['width']*2,
(int)$imageType['height']*2
)) {
continue;
}
}
}
$generateHighDpiImages = (bool) Configuration::get('PS_HIGHT_DPI');
$imagesTypes = ImageType::getImagesTypes('hotels');
$addedImage = false;
$allSucceeded = true;
}
}
}
foreach ($tmpFiles as $tmpFile) {
if (!is_string($tmpFile) || $tmpFile === '') {
$allSucceeded = false;
continue;
}
$objHtlImage = new HotelImage();
$objHtlImage->id_hotel = $idHotel;
$objHtlImage->id_htl_image_category = $idHtlImageCategory ?: null;
$objHtlImage->cover = self::getCover($idHotel) ? 0 : 1;
if (!$objHtlImage->save()
|| !($path = $objHtlImage->getPathForCreation())
|| !ImageManager::resize($tmpFile, $path.$objHtlImage->id.'.'.$objHtlImage->image_format)
) {
$allSucceeded = false;
continue;
}
foreach ($imagesTypes as $imageType) {
if (!ImageManager::resize(
$tmpFile,
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
$imageType['width'],
$imageType['height']
)) {
continue;
}
} else {
$objHtlImage = new HotelImage();
$objHtlImage->id_hotel = $idHotel;
if ($coverImgExist = HotelImage::getCover($idHotel)) {
$objHtlImage->cover = 0;
} else {
$objHtlImage->cover = 1;
}
if ($objHtlImage->save()) {
if ($path = $objHtlImage->getPathForCreation()) {
if (ImageManager::resize(
$hotelImages,
$path.$objHtlImage->id.'.'.$objHtlImage->image_format
)) {
$imagesTypes = ImageType::getImagesTypes('hotels');
$generate_hight_dpi_images = (bool)Configuration::get('PS_HIGHT_DPI');
foreach ($imagesTypes as $imageType) {
if (!ImageManager::resize(
$hotelImages,
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
$imageType['width'],
$imageType['height']
)) {
continue;
}
if ($generate_hight_dpi_images) {
if (!ImageManager::resize(
$hotelImages,
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
(int)$imageType['width']*2,
(int)$imageType['height']*2
)) {
continue;
}
}
}
$addedImage = array(
'id' => $objHtlImage->id,
'cover' => $objHtlImage->cover,
'image_link' => Context::getContext()->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id)),
);
return $addedImage;
}
}
if ($generateHighDpiImages) {
ImageManager::resize(
$tmpFile,
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
(int) $imageType['width'] * 2,
(int) $imageType['height'] * 2
);
}
}
return true;
if (!$isMultiple) {
if (!$objCategory || (int) $objCategory->id !== $idHtlImageCategory) {
$objCategory = new HotelImageCategory($idHtlImageCategory, Context::getContext()->language->id);
}
$addedImage = array(
'id' => $objHtlImage->id,
'cover' => $objHtlImage->cover,
'id_htl_image_category' => $idHtlImageCategory,
'category_name' => (string) $objCategory->name,
'image_link' => Context::getContext()->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id)),
);
}
}
return false;
if ($isMultiple) {
return $allSucceeded;
}
return $allSucceeded ? $addedImage : false;
}
public function getPathForCreation()

View File

@@ -0,0 +1,63 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class HotelImageCategory extends ObjectModel
{
public $id_htl_image_category;
public $name;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_image_category',
'primary' => 'id_htl_image_category',
'multilang' => true,
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
),
);
public static function getImageCategories($idLang = null)
{
if (!$idLang) {
$idLang = (int) Context::getContext()->language->id;
}
$defaultLangId = (int) Configuration::get('PS_LANG_DEFAULT');
return Db::getInstance()->executeS(
'SELECT hic.`id_htl_image_category`, COALESCE(hicl.`name`, hiclDefault.`name`) AS `name`
FROM `'._DB_PREFIX_.'htl_image_category` hic
LEFT JOIN `'._DB_PREFIX_.'htl_image_category_lang` hicl
ON (hicl.`id_htl_image_category` = hic.`id_htl_image_category`
AND hicl.`id_lang` = '.(int) $idLang.')
LEFT JOIN `'._DB_PREFIX_.'htl_image_category_lang` hiclDefault
ON (hiclDefault.`id_htl_image_category` = hic.`id_htl_image_category`
AND hiclDefault.`id_lang` = '.(int) $defaultLangId.')
WHERE COALESCE(hicl.`name`, hiclDefault.`name`) IS NOT NULL
ORDER BY `name` ASC'
);
}
}

View File

@@ -87,10 +87,27 @@ class HotelReservationSystemDb
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_image` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_hotel` int(10) unsigned NOT NULL,
`id_htl_image_category` int(10) unsigned DEFAULT NULL,
`cover` tinyint(1) NOT NULL DEFAULT '0',
KEY `id_hotel` (`id_hotel`),
KEY `id_htl_image_category` (`id_htl_image_category`),
PRIMARY KEY (`id`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_image_category` (
`id_htl_image_category` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_htl_image_category`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_image_category_lang` (
`id_htl_image_category` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`name` varchar(128) NOT NULL,
PRIMARY KEY (`id_htl_image_category`, `id_lang`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_amenity` (
`id_amenity` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_parent` int(10) unsigned NOT NULL,
@@ -588,6 +605,8 @@ class HotelReservationSystemDb
`'._DB_PREFIX_.'htl_branch_info`,
`'._DB_PREFIX_.'htl_branch_info_lang`,
`'._DB_PREFIX_.'htl_image`,
`'._DB_PREFIX_.'htl_image_category`,
`'._DB_PREFIX_.'htl_image_category_lang`,
`'._DB_PREFIX_.'htl_branch_amenity`,
`'._DB_PREFIX_.'htl_room_type_amenity`,
`'._DB_PREFIX_.'htl_amenity`,

View File

@@ -282,6 +282,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$totalPrice['total_price_tax_excl'] = 0;
$featureImpactPriceTE = 0;
$featureImpactPriceTI = 0;
$productPriceTI = Product::getPriceStatic((int) $id_product, 1, 0, 6, null, 0, $use_reduc, 1, 0, null, null, null, $nothing, 1, 1, null, 1, 0, 0, $id_group);
$productPriceTE = Product::getPriceStatic((int) $id_product, 0, 0, 6, null, 0, $use_reduc, 1, 0, null, null, null, $nothing, 1, 1, null, 1, 0, 0, $id_group);
$id_address = HotelRoomType::getHotelIdAddressByIdProduct($id_product);
@@ -317,6 +318,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$id_guest,
$id_room
))) {
if ($featurePrice['impact_type'] == self::IMPACT_TYPE_PERCENTAGE) {
//percentage
$featureImpactPriceTE = $productPriceTE * ($featurePrice['impact_value'] / 100);
@@ -344,9 +346,16 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$priceWithFeatureTI = 0;
$priceWithFeatureTE = 0;
}
if ((int)$featurePrice['id_cart'] == 0) {
$priceWithFeatureTI = Product::applyGroupDiscount($priceWithFeatureTI, $id_product, $id_group);
$priceWithFeatureTE = Product::applyGroupDiscount($priceWithFeatureTE, $id_product, $id_group);
}
$totalPrice['total_price_tax_incl'] += $priceWithFeatureTI;
$totalPrice['total_price_tax_excl'] += $priceWithFeatureTE;
} else {
$productPriceTI = Product::applyGroupDiscount($productPriceTI, $id_product, $id_group);
$productPriceTE = Product::applyGroupDiscount($productPriceTE, $id_product, $id_group);
$totalPrice['total_price_tax_incl'] += $productPriceTI;
$totalPrice['total_price_tax_excl'] += $productPriceTE;
}
@@ -368,6 +377,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
'occupancy' => $occupancy
)
);
if ($with_auto_room_services) {
if ($id_cart && $id_room) {
$objHotelCartBookingData = new HotelCartBookingData();

View File

@@ -204,6 +204,9 @@ class AdminAddHotelController extends ModuleAdminController
} else {
$idCountry = Tools::getValue('hotel_country');
}
$smartyVars['hotelImageCategories'] = HotelImageCategory::getImageCategories($this->context->language->id);
// manage state option
$stateOptions = null;
if ($idCountry) {
@@ -412,6 +415,18 @@ class AdminAddHotelController extends ModuleAdminController
} elseif (!Validate::isCityName($city)) {
$this->errors[] = $this->l('Enter a valid city name.');
}
if (Tools::getValue('loclatitude') !== '' && (!is_numeric(Tools::getValue('loclatitude')) || !Validate::isCoordinate($latitude))) {
$this->errors[] = $this->l('Latitude is invalid.');
}
if (Tools::getValue('loclongitude') !== '' && (!is_numeric(Tools::getValue('loclongitude')) || !Validate::isCoordinate($longitude))) {
$this->errors[] = $this->l('Longitude is invalid.');
}
if ($map_formated_address && !Validate::isCleanHtml(html_entity_decode($map_formated_address))) {
$this->errors[] = $this->l('Map formatted address is invalid.');
}
if ($map_input_text && !Validate::isString($map_input_text)) {
$this->errors[] = $this->l('Map location text is invalid.');
}
//Since the address for the hotel is saved in the address table. We are validating the hotel address here manually.
$addressValidation = Address::getValidationRules('Address');
@@ -610,8 +625,8 @@ class AdminAddHotelController extends ModuleAdminController
$objHotelBranch->check_in = $check_in;
$objHotelBranch->check_out = $check_out;
$objHotelBranch->rating = $rating;
$objHotelBranch->latitude = Validate::isCoordinate($latitude) ? Tools::ps_round($latitude, 8) : $latitude;
$objHotelBranch->longitude = Validate::isCoordinate($longitude) ? Tools::ps_round($longitude, 8) : $longitude;
$objHotelBranch->latitude = $latitude;
$objHotelBranch->longitude = $longitude;
$objHotelBranch->map_formated_address = $map_formated_address;
$objHotelBranch->map_input_text = $map_input_text;
$objHotelBranch->save();
@@ -816,10 +831,12 @@ class AdminAddHotelController extends ModuleAdminController
$conf = 4;
}
$tabParam = Tools::getValue('htl_active_tab') ? '&htl_active_tab='.urlencode(Tools::getValue('htl_active_tab')) : '';
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
Tools::redirectAdmin(self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf='.$conf.'&token='.$this->token );
Tools::redirectAdmin(self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf='.$conf.'&token='.$this->token.$tabParam);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token.$tabParam);
}
}
@@ -867,38 +884,35 @@ class AdminAddHotelController extends ModuleAdminController
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessUploadHotelImages()
public function ajaxProcessUploadHotelImage()
{
$response = array('success' => false);
$idHotel = Tools::getValue('id_hotel');
$response = array('success' => false, 'errors' => array());
$idHotel = (int) Tools::getValue('id_hotel');
$idHtlImageCategory = (int) Tools::getValue('id_htl_image_category');
$file = isset($_FILES['hotel_image']) ? $_FILES['hotel_image'] : null;
if ($idHotel) {
$invalidImg = ImageManager::validateUpload(
$_FILES['hotel_image'],
Tools::getMaxUploadSize()
);
if (!$invalidImg) {
// Add Hotel images
$objHotelImage = new HotelImage();
$imageDetail = $objHotelImage->uploadHotelImages($_FILES['hotel_image'], $idHotel);
if ($imageDetail) {
$response['success'] = true;
$imageDetail['image_link'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'],ImageType::getFormatedName('large')));
$imageDetail['image_link_small'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'], ImageType::getFormatedName('small')));
$response['data']['image_info'] = $imageDetail;
// get image row
$this->context->smarty->assign(array(
'image' => $imageDetail,
'hotel_info' => array('id' => $idHotel)
));
$response['data']['image_row'] = $this->context->smarty->fetch(
_PS_MODULE_DIR_.$this->module->name.
'/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl'
);
if ($file && $file['size']) {
$objCategory = $idHtlImageCategory ? new HotelImageCategory($idHtlImageCategory, $this->context->language->id) : null;
if ($idHtlImageCategory && !Validate::isLoadedObject($objCategory)) {
$response['errors'][] = $this->l('Selected image category is invalid.');
} elseif ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize())) {
$response['errors'][] = $error;
} else {
$response['errors'][] = $this->l('Unable to uploade image. Please try again');
$objHotelImage = new HotelImage();
$imageDetail = $objHotelImage->uploadHotelImages($file, $idHotel, $idHtlImageCategory, $objCategory);
if ($imageDetail) {
$imageDetail['image_link'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'], ImageType::getFormatedName('large')));
$imageDetail['image_link_small'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'], ImageType::getFormatedName('small')));
$response['success'] = true;
$response['image_row'] = $this->renderHotelImageRow($imageDetail, $idHotel);
} else {
$response['errors'][] = $this->l('Unable to upload image. Please try again');
}
}
} else {
$response['errors'][] = $_FILES['hotel_image']['name'].': '.$invalidImg;
$response['errors'][] = $this->l('No file received.');
}
} else {
$response['errors'][] = $this->l('Hotel info not found. Please try reloading the page');
@@ -908,38 +922,181 @@ class AdminAddHotelController extends ModuleAdminController
public function ajaxProcessChangeCoverImage()
{
$idImage = Tools::getValue('id_image');
$idImage = (int) Tools::getValue('id_image');
$idHotel = (int) Tools::getValue('id_hotel');
$response = array('status' => false);
if ($idImage) {
$idHotel = Tools::getValue('id_hotel');
if ($idImage && $idHotel && Validate::isLoadedObject($objHtlImage = new HotelImage($idImage)) && (int) $objHtlImage->id_hotel === $idHotel) {
$oldCoverId = null;
$affectedCoverImage = null;
if ($coverImg = HotelImage::getCover($idHotel)) {
$objHtlImage = new HotelImage((int) $coverImg['id']);
$objHtlImage->cover = 0;
$objHtlImage->save();
$oldCoverId = (int) $coverImg['id'];
$affectedCoverImage = new HotelImage($oldCoverId);
$affectedCoverImage->cover = 0;
$affectedCoverImage->save();
}
$objHtlImage = new HotelImage((int) $idImage);
$objHtlImage->cover = 1;
if ($objHtlImage->update()) {
$response['status'] = true;
$objHtlImage->update();
$response['status'] = true;
$response['image_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objHtlImage), $idHotel);
if ($oldCoverId) {
$response['old_cover_id'] = $oldCoverId;
$response['old_cover_row'] = $this->renderHotelImageRow(
$this->getHotelImageRowData($affectedCoverImage),
$idHotel
);
}
}
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessEditHotelImage()
{
$response = array('status' => false);
$idImage = (int) Tools::getValue('id_image');
$idHotel = (int) Tools::getValue('id_hotel');
$idHtlImageCategory = (int) Tools::getValue('id_htl_image_category');
$setCover = (bool) Tools::getValue('cover');
if ($idImage && $idHotel && Validate::isLoadedObject($objHtlImage = new HotelImage($idImage)) && (int) $objHtlImage->id_hotel === $idHotel) {
$objCategory = $idHtlImageCategory ? new HotelImageCategory($idHtlImageCategory, $this->context->language->id) : null;
if ($idHtlImageCategory && !Validate::isLoadedObject($objCategory)) {
$response['errors'][] = $this->l('Selected image category is invalid.');
$this->ajaxDie(json_encode($response));
}
$otherImage = null;
if (!$setCover && $objHtlImage->cover) {
foreach ($objHtlImage->getImagesByHotelId($idHotel, 1, 2) as $image) {
if ((int) $image['id'] !== $idImage) {
$otherImage = $image;
break;
}
}
if (!$otherImage) {
$response['errors'][] = $this->l('At least one image must remain marked as cover.');
$this->ajaxDie(json_encode($response));
}
}
$objHtlImage->id_htl_image_category = $idHtlImageCategory ?: null;
$oldCoverId = null;
$affectedCoverImage = null;
if ($setCover && !$objHtlImage->cover) {
if ($coverImg = HotelImage::getCover($idHotel)) {
$oldCoverId = (int) $coverImg['id'];
$affectedCoverImage = new HotelImage($oldCoverId);
$affectedCoverImage->cover = 0;
$affectedCoverImage->save();
}
$objHtlImage->cover = 1;
} elseif ($otherImage) {
$objHtlImage->cover = 0;
$affectedCoverImage = new HotelImage($otherImage['id']);
$affectedCoverImage->cover = 1;
$affectedCoverImage->save();
$oldCoverId = (int) $affectedCoverImage->id;
}
$objHtlImage->update();
$response['status'] = true;
$response['image_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objHtlImage, $objCategory), $idHotel);
if ($oldCoverId) {
$response['old_cover_id'] = $oldCoverId;
$response['old_cover_row'] = $this->renderHotelImageRow(
$this->getHotelImageRowData($affectedCoverImage),
$idHotel
);
}
} else {
$response['errors'][] = $this->l('Image not found.');
}
$this->ajaxDie(json_encode($response));
}
private function getHotelImageRowData($objHtlImage, ?HotelImageCategory $objCategory = null)
{
$idHtlImageCategory = (int) $objHtlImage->id_htl_image_category;
if (!$objCategory || (int) $objCategory->id !== $idHtlImageCategory) {
$objCategory = new HotelImageCategory($idHtlImageCategory, $this->context->language->id);
}
return array(
'id' => $objHtlImage->id,
'cover' => $objHtlImage->cover,
'id_htl_image_category' => $idHtlImageCategory,
'category_name' => (string) $objCategory->name,
'image_link' => $this->context->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id, ImageType::getFormatedName('large'))),
'image_link_small' => $this->context->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id, ImageType::getFormatedName('small'))),
);
}
private function renderHotelImageRow($imageData, $idHotel)
{
$this->context->smarty->assign(array(
'image' => $imageData,
'hotel_info' => array('id' => $idHotel),
));
return $this->context->smarty->fetch(_PS_MODULE_DIR_.$this->module->name.'/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl');
}
public function ajaxProcessBulkUpdateHotelImage()
{
$response = array('status' => false, 'errors' => array());
$idHotel = (int) Tools::getValue('id_hotel');
$idHtlImageCategory = (int) Tools::getValue('id_htl_image_category');
$imageIds = array_filter(array_map('intval', (array) Tools::getValue('image_ids', array())));
if ($idHotel && $imageIds) {
$objCategory = $idHtlImageCategory ? new HotelImageCategory($idHtlImageCategory, $this->context->language->id) : null;
if ($idHtlImageCategory && !Validate::isLoadedObject($objCategory)) {
$response['errors'][] = $this->l('Selected image category is invalid.');
} else {
foreach ($imageIds as $idImage) {
$objHtlImage = new HotelImage($idImage);
if (Validate::isLoadedObject($objHtlImage) && (int) $objHtlImage->id_hotel === $idHotel) {
$objHtlImage->id_htl_image_category = $idHtlImageCategory ?: null;
$objHtlImage->update();
}
}
$response['status'] = true;
$response['image_ids'] = $imageIds;
$response['category_name'] = $objCategory ? (string) $objCategory->name : '';
}
} else {
$response['errors'][] = $this->l('No images selected.');
}
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessDeleteHotelImage()
{
$response = array('status' => false);
if ($idImage = Tools::getValue('id_image')) {
if ($idHotel = Tools::getValue('id_hotel')) {
if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage))) {
if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage)) && (int) $objHtlImage->id_hotel === (int) $idHotel) {
if ($objHtlImage->delete()) {
if (!HotelImage::getCover($idHotel)) {
$images = $objHtlImage->getImagesByHotelId($idHotel);
$images = $objHtlImage->getImagesByHotelId($idHotel, 1, 1);
if ($images) {
$objHtlImage = new HotelImage($images[0]['id']);
$objHtlImage->cover = 1;
$objHtlImage->save();
$objNewCover = new HotelImage($images[0]['id']);
$objNewCover->cover = 1;
$objNewCover->save();
$response['new_cover_id'] = (int) $objNewCover->id;
$response['new_cover_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objNewCover), $idHotel);
}
}
$response['status'] = true;
@@ -950,6 +1107,43 @@ class AdminAddHotelController extends ModuleAdminController
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessBulkDeleteHotelImage()
{
$response = array('status' => false, 'errors' => array());
$idHotel = (int) Tools::getValue('id_hotel');
$imageIds = array_filter(array_map('intval', (array) Tools::getValue('image_ids', array())));
if (!$idHotel || !$imageIds) {
$response['errors'][] = $this->l('No images selected.');
$this->ajaxDie(json_encode($response));
}
$deletedIds = array();
foreach ($imageIds as $idImage) {
$objHtlImage = new HotelImage($idImage);
if (Validate::isLoadedObject($objHtlImage) && (int) $objHtlImage->id_hotel === $idHotel && $objHtlImage->delete()) {
$deletedIds[] = $idImage;
}
}
if (!HotelImage::getCover($idHotel)) {
$objHelper = new HotelImage();
$images = $objHelper->getImagesByHotelId($idHotel, 1, 1);
if ($images) {
$objNewCover = new HotelImage($images[0]['id']);
$objNewCover->cover = 1;
$objNewCover->save();
$response['new_cover_id'] = (int) $objNewCover->id;
$response['new_cover_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objNewCover), $idHotel);
}
}
$response['status'] = true;
$response['deleted_ids'] = $deletedIds;
$this->ajaxDie(json_encode($response));
}
public function ajaxProcessUpdateSlidesPosition()
{
if (($slideIds = Tools::getValue('slides'))

View File

@@ -0,0 +1,153 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
class AdminHotelImageCategoryController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'htl_image_category';
$this->className = 'HotelImageCategory';
$this->identifier = 'id_htl_image_category';
$this->lang = true;
$this->context = Context::getContext();
parent::__construct();
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->fields_list = array(
'id_htl_image_category' => array(
'title' => $this->l('ID'),
'align' => 'center',
'class' => 'fixed-width-xs',
),
'name' => array(
'title' => $this->l('Name'),
'align' => 'center',
),
'date_add' => array(
'title' => $this->l('Created On'),
'type' => 'date',
'align' => 'right'
),
);
$this->bulk_actions = array(
'delete' => array(
'text' => $this->l('Delete selected'),
'icon' => 'icon-trash',
'confirm' => $this->l('Delete selected items?'),
),
);
}
public function initToolbar()
{
parent::initToolbar();
if (!$this->display || $this->display == 'list') {
$this->page_header_toolbar_btn['new'] = array(
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
'desc' => $this->l('Add new category'),
);
}
}
public function renderForm()
{
if (!$this->loadObject(true)) {
return;
}
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Hotel Image Category'),
'icon' => 'icon-tags',
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name'),
'name' => 'name',
'required' => true,
'lang' => true,
'col' => 4,
'hint' => $this->l('Enter the name of the hotel image category.'),
),
),
'submit' => array(
'title' => $this->l('Save'),
),
'buttons' => array(
'save-and-stay' => array(
'title' => $this->l('Save and stay'),
'name' => 'submitAdd'.$this->table.'AndStay',
'type' => 'submit',
'class' => 'btn btn-default pull-right',
'icon' => 'process-icon-save',
),
),
);
return parent::renderForm();
}
public function processSave()
{
if (!$this->loadObject(true)) {
return;
}
$defaultLangId = (int) Configuration::get('PS_LANG_DEFAULT');
$defaultLanguage = Language::getLanguage($defaultLangId);
$languages = Language::getLanguages(false);
if (!trim(Tools::getValue('name_'.$defaultLangId))) {
$this->errors[] = $this->l('Category name is required at least in ').$defaultLanguage['name'];
} else {
foreach ($languages as $lang) {
$langName = trim(Tools::getValue('name_'.$lang['id_lang']));
if ($langName && !Validate::isCatalogName($langName)) {
$this->errors[] = $this->l('Invalid category name in ').$lang['name'];
}
}
}
return parent::processSave();
}
public function initPageHeaderToolbar()
{
if (!$this->display || $this->display == 'list') {
$back = $this->context->link->getAdminLink('AdminAddHotel');
$this->page_header_toolbar_btn['back_to_list'] = array(
'href' => $back,
'desc' => $this->l('Back to hotel list'),
'icon' => 'process-icon-back'
);
}
parent::initPageHeaderToolbar();
}
}

View File

@@ -26,6 +26,7 @@ require_once 'classes/HotelRoomType.php';
require_once 'classes/HotelRoomInformation.php';
require_once 'classes/HotelBranchInformation.php';
require_once 'classes/HotelImage.php';
require_once 'classes/HotelImageCategory.php';
require_once 'classes/HotelAmenities.php';
require_once 'classes/HotelBranchAmenities.php';
require_once 'classes/HotelRoomTypeAmenities.php';

View File

@@ -529,6 +529,7 @@ class HotelReservationSystem extends Module
$this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false);
$this->installTab('AdminRoomTypeGlobalDemand', 'Additional Demand Configuration', 'AdminHotelConfigurationSetting', false);
$this->installTab('AdminBookingDocument', 'Booking Documents', false, false);
$this->installTab('AdminHotelImageCategory', 'Hotel Image Category', false, false);
return true;
}

View File

@@ -258,17 +258,34 @@ var GoogleMapsManager = {
}
},
setFormVars: function(params) {
$('#loclatitude').val(params.lat);
$('#loclongitude').val(params.lng);
$('#loclatitude').val(Number(params.lat).toFixed(8));
$('#loclongitude').val(Number(params.lng).toFixed(8));
$('#locformatedAddr').val(params.formattedAddress);
$('#googleInputField').val(params.inputText);
},
updateMarkerFromInputs: function() {
if (!this.map) {
return;
}
var latitude = Number($('#loclatitude').val());
var longitude = Number($('#loclongitude').val());
if (!latitude || !longitude) {
return;
}
var latLng = {lat: latitude, lng: longitude};
this.map.setCenter(latLng);
this.addMarker(latLng, null, null, false);
},
}
$(document).on('click', 'button.gm-ui-hover-effect', function () {
GoogleMapsManager.clearAllMarkers();
});
$(document).on('change', '#loclatitude, #loclongitude', function () {
GoogleMapsManager.updateMarkerFromInputs();
});
function initGoogleMaps() {
if (typeof enabledDisplayMap != 'undefined'
&& $('#googleMapContainer').length

View File

@@ -21,82 +21,126 @@
*/
$(document).ready(function () {
$('.htl-img-preview').fancybox({
width: 'auto',
height: 'auto',
autoSize : false,
maxWidth: 700,
'hideOnContentClick': false,
});
$("#hotel_images").on("change", function(event) {
const files = Array.from(event.target.files);
uploadSelectedImages(files);
});
function uploadSelectedImages(files)
function initHotelImagePreview()
{
if (files.length == 0) return; // all done
let file = files[0];
files.splice(0, 1);
createImageUploadRequest(file).then((formData) => {
uploadHotelImages(formData).then(() => {
uploadSelectedImages(files)
});
})
$('.htl-img-preview').fancybox({
width: 'auto',
height: 'auto',
autoSize : false,
maxWidth: 700,
'hideOnContentClick': false,
});
}
function createImageUploadRequest(file)
initHotelImagePreview();
function initHotelImageModal(modalId)
{
return new Promise((resolve, reject) => {
if (typeof file != 'undefined') {
if (file.size > maxSizeAllowed) {
reject(filesizeError + '[' + file.name + ']');
} else {
var formData = new FormData();
var idHotel = $("#id-hotel").val();
formData.append('hotel_image', file);
formData.append('id_hotel', idHotel);
formData.append('ajax', true);
formData.append('action', 'uploadHotelImages');
resolve(formData);
}
$('#page-loader').show();
$(modalId).modal('show');
setTimeout(function () {
$('#page-loader').hide();
}, 0);
}
function getCheckedImageIds()
{
return $('.hotel-image-checkbox:checked').map(function () {
return $(this).val();
}).get();
}
function showEmptyRowIfNoImagesLeft()
{
if (!$('#hotel-image-table tbody tr[data-id-image]').length) {
$('.list-empty-tr').show();
}
}
$('#open-add-hotel-images-modal').on('click', function () {
var fileInput = document.getElementById('hotel-images-file-input');
if (fileInput) {
fileInput.value = '';
}
$('#hotel-images-file-name').val('');
initHotelImageModal('#addHotelImagesModal');
});
$('#hotel-images-file-add-btn').on('click', function () {
$('#hotel-images-file-input').trigger('click');
});
$('#hotel-images-file-name').on('click', function () {
$('#hotel-images-file-input').trigger('click');
});
$('#hotel-images-file-input').on('change', function () {
var fileNames = Array.prototype.map.call(this.files, function (file) {
return file.name;
});
$('#hotel-images-file-name').val(fileNames.join(', '));
});
$('#hotel-images-upload-btn').on('click', function () {
var fileInput = document.getElementById('hotel-images-file-input');
var files = fileInput ? Array.prototype.slice.call(fileInput.files) : [];
if (!files.length) {
showErrorMessage(imgSelectErrorMsg);
return;
}
uploadHotelImagesSequentially(files);
});
function uploadHotelImagesSequentially(files)
{
var index = 0;
var idHotel = $('#id-hotel').val();
var idHtlImageCategory = $('#id_htl_image_category').val();
var $btn = $('#hotel-images-upload-btn').prop('disabled', true);
$('#page-loader').show();
function next() {
if (index >= files.length) {
$btn.prop('disabled', false);
$('#page-loader').hide();
$('#addHotelImagesModal').modal('hide');
return;
}
});
}
function uploadHotelImages(formData) {
return new Promise((resolve, reject) => {
var file = files[index++];
var formData = new FormData();
formData.append('hotel_image', file);
formData.append('ajax', true);
formData.append('action', 'UploadHotelImage');
formData.append('id_hotel', idHotel);
formData.append('id_htl_image_category', idHtlImageCategory);
$.ajax({
type:'POST',
dataType:'JSON',
type: 'POST',
url: adminHotelCtrlUrl,
dataType: 'json',
data: formData,
cache:false,
contentType: false,
processData: false,
success:function(response){
if (response.success) {
$('.list-empty-tr').remove();
$("#hotel-image-table tbody").append(response.data.image_row);
contentType: false,
success: function (resp) {
if (resp && resp.success) {
$('.list-empty-tr').hide();
$('#hotel-image-table tbody').append(resp.image_row);
initHotelImagePreview();
showSuccessMessage(imgUploadSuccessMsg);
resolve(imgUploadSuccessMsg);
} else {
if (typeof response.errors != 'undefined') {
showErrorMessage(response.errors);
reject(response.errors);
} else {
showErrorMessage(imgUploadErrorMsg);
reject(imgUploadErrorMsg);
}
showErrorMessage(file.name + ': ' + ((resp && resp.errors && resp.errors.join(', ')) || imgUploadErrorMsg));
}
next();
},
error: function(data) {
showErrorMessage(imgUploadErrorMsg);
reject(imgUploadErrorMsg);
error: function () {
showErrorMessage(file.name + ': ' + imgUploadErrorMsg);
next();
}
});
});
}
next();
}
$('body').on('click', '.changer-cover-image', function(e){
@@ -104,8 +148,8 @@ $(document).ready(function () {
var idHotel = $(this).attr('data-id-hotel');
var idImage = $(this).attr('data-id-image');
var isCover = $(this).attr('data-is-cover');
var triggerElement = $(this);
if (isCover == 0) {
$('#page-loader').show();
$.ajax({
type:'POST',
url: adminHotelCtrlUrl,
@@ -118,15 +162,11 @@ $(document).ready(function () {
},
success: function(result) {
if (result.status) {
// remover cover image identifier from old cover image
var oldCoverImageTr = $("#hotel-image-table tbody tr.cover-image-tr");
oldCoverImageTr.removeClass("cover-image-tr").find("td.cover-image-td").removeClass("cover-image-td").find("a.changer-cover-image").removeClass("text-success").addClass("text-danger").attr("data-is-cover", "0").find("i.icon-check").removeClass("icon-check").addClass("icon-times");
oldCoverImageTr.find("td button.delete-hotel-image").attr("data-is-cover", "0");
// Add classes in new covre image elements
triggerElement.removeClass("text-danger").addClass("text-success").find("i.icon-times").removeClass("icon-times").addClass("icon-check");
triggerElement.parent().addClass("cover-image-td").parent().addClass("cover-image-tr").find("td button.delete-hotel-image").attr("data-is-cover", "1");
$('#hotel-image-table tr[data-id-image="' + idImage + '"]').replaceWith(result.image_row);
if (result.old_cover_row) {
$('#hotel-image-table tr[data-id-image="' + result.old_cover_id + '"]').replaceWith(result.old_cover_row);
}
initHotelImagePreview();
showSuccessMessage(coverImgSuccessMsg);
} else {
showErrorMessage(coverImgErrorMsg);
@@ -135,18 +175,207 @@ $(document).ready(function () {
error: function(data){
showErrorMessage(coverImgErrorMsg);
}
}).always(function () {
$('#page-loader').hide();
});
}
});
$('body').on('click', '.delete-hotel-image', function(e){
$('body').on('click', '.edit-hotel-image', function () {
var idImage = $(this).data('id-image');
var idCategory = parseInt($(this).data('id-htl-image-category'), 10) || 0;
var isCover = parseInt($(this).attr('data-is-cover'), 10) === 1;
var $categorySelect = $('#edit_id_htl_image_category');
$('#edit_hotel_image_id').val(idImage);
$categorySelect.val($categorySelect.find('option[value="' + idCategory + '"]').length ? idCategory : 0);
$('#edit_hotel_image_cover_on').prop('checked', isCover);
$('#edit_hotel_image_cover_off').prop('checked', !isCover);
initHotelImageModal('#editHotelImageModal');
});
$('#save-edit-hotel-image-btn').on('click', function () {
var idImage = $('#edit_hotel_image_id').val();
var idHotel = $('#id-hotel').val();
var $btn = $(this).prop('disabled', true);
$('#page-loader').show();
$.ajax({
type: 'POST',
url: adminHotelCtrlUrl,
dataType: 'json',
data: {
ajax: true,
action: 'EditHotelImage',
id_hotel: idHotel,
id_image: idImage,
id_htl_image_category: $('#edit_id_htl_image_category').val(),
cover: $('input[name="edit_hotel_image_cover"]:checked').val()
},
success: function (resp) {
if (resp && resp.status) {
$('#hotel-image-table tr[data-id-image="' + idImage + '"]').replaceWith(resp.image_row);
if (resp.old_cover_row) {
$('#hotel-image-table tr[data-id-image="' + resp.old_cover_id + '"]').replaceWith(resp.old_cover_row);
}
initHotelImagePreview();
showSuccessMessage(imgUpdateSuccessMsg);
$('#editHotelImageModal').modal('hide');
} else {
showErrorMessage((resp && resp.errors && resp.errors.join('<br>')) || imgUploadErrorMsg);
}
},
error: function () {
showErrorMessage(imgUploadErrorMsg);
}
}).always(function () {
$btn.prop('disabled', false);
$('#page-loader').hide();
});
});
$('#hotel-image-select-all').on('click', function (e) {
e.preventDefault();
var idHotel = $(this).attr('data-id-hotel');
var idImage = $(this).attr('data-id-image');
var isCover = $(this).attr('data-is-cover');
var triggerElement = $(this);
$('.hotel-image-checkbox').prop('checked', true);
});
$('#hotel-image-unselect-all').on('click', function (e) {
e.preventDefault();
$('.hotel-image-checkbox').prop('checked', false);
});
$('#hotel-image-bulk-update').on('click', function (e) {
e.preventDefault();
if (!$('.hotel-image-checkbox:checked').length) {
showErrorMessage(bulkUpdateSelectErrorMsg);
return;
}
$('#bulk_id_htl_image_category').val(0);
initHotelImageModal('#bulkUpdateHotelImageModal');
});
var pendingBulkDeleteImageIds = null;
$('#hotel-image-bulk-delete').on('click', function (e) {
e.preventDefault();
var imageIds = getCheckedImageIds();
if (!imageIds.length) {
showErrorMessage(bulkDeleteSelectErrorMsg);
return;
}
pendingBulkDeleteImageIds = imageIds;
$('#confirmDeleteHotelImageModal').modal('show');
});
$('#save-bulk-hotel-image-btn').on('click', function () {
var idHotel = $('#id-hotel').val();
var idHtlImageCategory = $('#bulk_id_htl_image_category').val();
var imageIds = getCheckedImageIds();
var $btn = $(this).prop('disabled', true);
$('#page-loader').show();
$.ajax({
type: 'POST',
url: adminHotelCtrlUrl,
dataType: 'json',
data: {
ajax: true,
action: 'BulkUpdateHotelImage',
id_hotel: idHotel,
id_htl_image_category: idHtlImageCategory,
image_ids: imageIds
},
success: function (resp) {
if (resp && resp.status) {
$.each(resp.image_ids, function (i, idImage) {
var $row = $('#hotel-image-table tr[data-id-image="' + idImage + '"]');
$row.find('.hotel-image-category-cell').text(resp.category_name || '—');
$row.find('.edit-hotel-image').attr('data-id-htl-image-category', idHtlImageCategory);
});
$('.hotel-image-checkbox').prop('checked', false);
showSuccessMessage(imgUpdateSuccessMsg);
$('#bulkUpdateHotelImageModal').modal('hide');
} else {
showErrorMessage((resp && resp.errors && resp.errors.join('<br>')) || imgUploadErrorMsg);
}
},
error: function () {
showErrorMessage(imgUploadErrorMsg);
}
}).always(function () {
$btn.prop('disabled', false);
$('#page-loader').hide();
});
});
var pendingDeleteHotelImage = null;
$('body').on('click', '.delete-hotel-image', function (e) {
e.preventDefault();
pendingDeleteHotelImage = $(this);
pendingBulkDeleteImageIds = null;
$('#confirmDeleteHotelImageModal').modal('show');
});
$('#confirm-delete-hotel-image-btn').on('click', function () {
$('#confirmDeleteHotelImageModal').modal('hide');
if (pendingBulkDeleteImageIds && pendingBulkDeleteImageIds.length) {
var bulkImageIds = pendingBulkDeleteImageIds;
var bulkIdHotel = $('#id-hotel').val();
pendingBulkDeleteImageIds = null;
$('#page-loader').show();
$.ajax({
type: 'POST',
url: adminHotelCtrlUrl,
dataType: 'json',
data: {
ajax: true,
action: 'BulkDeleteHotelImage',
id_hotel: bulkIdHotel,
image_ids: bulkImageIds
},
success: function (result) {
if (result.status) {
$.each(result.deleted_ids, function (i, idImage) {
$('#hotel-image-table tr[data-id-image="' + idImage + '"]').fadeOut().remove();
});
if (result.new_cover_row) {
$('#hotel-image-table tr[data-id-image="' + result.new_cover_id + '"]').replaceWith(result.new_cover_row);
initHotelImagePreview();
}
showEmptyRowIfNoImagesLeft();
$('.hotel-image-checkbox').prop('checked', false);
showSuccessMessage(deleteImgSuccessMsg);
} else {
showErrorMessage((result.errors && result.errors.join('<br>')) || deleteImgErrorMsg);
}
},
error: function () {
showErrorMessage(deleteImgErrorMsg);
}
}).always(function () {
$('#page-loader').hide();
});
return;
}
var triggerElement = pendingDeleteHotelImage;
if (!triggerElement) {
return;
}
var idHotel = triggerElement.attr('data-id-hotel');
var idImage = triggerElement.attr('data-id-image');
if (parseInt(idHotel) && parseInt(idImage)) {
$('#page-loader').show();
$.ajax({
type:'POST',
url: adminHotelCtrlUrl,
@@ -159,19 +388,16 @@ $(document).ready(function () {
},
success: function(result) {
if (result.status) {
if (parseInt(isCover)) {
location.reload();
} else {
var currentPosition = parseInt(triggerElement.parents('tr').find('td.image-position').text());
var nextAllSiblings = triggerElement.parents('tr').nextAll();
triggerElement.parents('tr').fadeOut().remove();
triggerElement.parents('tr').fadeOut().remove();
// Correct Images Positions
$(nextAllSiblings).each(function(index, element) {
$(this).find('td.image-position').text(parseInt(currentPosition + parseInt(index)));
});
showSuccessMessage(deleteImgSuccessMsg);
if (result.new_cover_row) {
$('#hotel-image-table tr[data-id-image="' + result.new_cover_id + '"]').replaceWith(result.new_cover_row);
initHotelImagePreview();
}
showEmptyRowIfNoImagesLeft();
showSuccessMessage(deleteImgSuccessMsg);
} else {
showErrorMessage(deleteImgErrorMsg);
}
@@ -179,9 +405,11 @@ $(document).ready(function () {
error: function(data){
showErrorMessage(deleteImgErrorMsg);
}
}).always(function () {
$('#page-loader').hide();
});
} else {
showErrorMessage(deleteImgErrorMsg);
}
});
});
});

View File

@@ -20,16 +20,25 @@
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
<tr class="{if $image.cover == 1}cover-image-tr{/if}">
{assign var="isCoverImage" value=$image.cover == 1}
<tr class="{if $isCoverImage}cover-image-tr{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}">
<td class="row-selector text-center"><input type="checkbox" class="noborder hotel-image-checkbox" value="{$image.id|escape:'html':'UTF-8'}"></td>
<td class="text-center">{$image.id|escape:'html':'UTF-8'}</td>
<td class="text-center">
<a class="htl-img-preview" href="{$image.image_link|escape:'html':'UTF-8'}">
<img class="img-thumbnail" width="100" src="{$image.image_link_small|escape:'html':'UTF-8'}"/>
</a>
</td>
<td class="text-center {if $image.cover == 1}cover-image-td{/if}">
<a href="#" class="{if $image.cover == 1}text-success{else}text-danger{/if} changer-cover-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $image.cover == 1}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}">
{if $image.cover == 1}
<td class="text-center hotel-image-category-cell">
{if isset($image.category_name) && $image.category_name}
{$image.category_name|escape:'html':'UTF-8'}
{else}
&mdash;
{/if}
</td>
<td class="text-center {if $isCoverImage}cover-image-td{/if}">
<a href="#" class="{if $isCoverImage}text-success{else}text-danger{/if} changer-cover-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $isCoverImage}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}">
{if $isCoverImage}
<i class="icon-check"></i>
{else}
<i class="icon-times"></i>
@@ -37,6 +46,7 @@
</a>
</td>
<td class="text-center">
<button type="button" class="btn btn-default delete-hotel-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $image.cover == 1}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}"><i class="icon-trash"></i></button>
<button type="button" class="btn btn-default edit-hotel-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-id-image="{$image.id|escape:'html':'UTF-8'}" data-id-htl-image-category="{if isset($image.id_htl_image_category)}{$image.id_htl_image_category|intval}{else}0{/if}" data-is-cover="{if $isCoverImage}1{else}0{/if}"><i class="icon-pencil"></i></button>
<button type="button" class="btn btn-default delete-hotel-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $isCoverImage}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}"><i class="icon-trash"></i></button>
</td>
</tr>
</tr>

View File

@@ -24,8 +24,10 @@
<table class="table" id="hotel-image-table">
<thead>
<tr>
<th class="text-center">&nbsp;</th>
<th class="text-center">{l s='Image Id' mod='hotelreservationsystem'}</th>
<th class="text-center">{l s='Image' mod='hotelreservationsystem'}</th>
<th class="text-center">{l s='Category' mod='hotelreservationsystem'}</th>
<th class="text-center">{l s='Cover' mod='hotelreservationsystem'}</th>
<th class="text-center">{l s='Action' mod='hotelreservationsystem'}</th>
</tr>
@@ -35,16 +37,183 @@
{foreach from=$hotelImages item=image name=hotelImage}
{include file="./htl-images-list-row.tpl"}
{/foreach}
{else}
<tr class="list-empty-tr">
<td class="list-empty" colspan="5">
<div class="list-empty-msg">
<i class="icon-warning-sign list-empty-icon"></i>
{l s='No Image Found' mod='hotelreservationsystem'}
</div>
</td>
</tr>
{/if}
<tr class="list-empty-tr" {if isset($hotelImages) && $hotelImages}style="display:none;"{/if}>
<td class="list-empty" colspan="6">
<div class="list-empty-msg">
<i class="icon-warning-sign list-empty-icon"></i>
{l s='No Image Found' mod='hotelreservationsystem'}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="btn-group bulk-actions dropup">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
{l s='Bulk actions' mod='hotelreservationsystem'} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="#" id="hotel-image-select-all">
<i class="icon-check-sign"></i>&nbsp;{l s='Select all' mod='hotelreservationsystem'}
</a>
</li>
<li>
<a href="#" id="hotel-image-unselect-all">
<i class="icon-check-empty"></i>&nbsp;{l s='Unselect all' mod='hotelreservationsystem'}
</a>
</li>
<li class="divider"></li>
<li>
<a href="#" id="hotel-image-bulk-update">
<i class="icon-edit"></i>&nbsp;{l s='Update selection' mod='hotelreservationsystem'}
</a>
</li>
<li>
<a href="#" id="hotel-image-bulk-delete">
<i class="icon-trash"></i>&nbsp;{l s='Delete selected' mod='hotelreservationsystem'}
</a>
</li>
</ul>
</div>
<div class="modal fade" id="addHotelImagesModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
<h4 class="modal-title"><i class="icon-image"></i> {l s='Add Images' mod='hotelreservationsystem'}</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="control-label col-lg-3">{l s='Images' mod='hotelreservationsystem'}</label>
<div class="col-lg-9">
<input type="file" id="hotel-images-file-input" class="hide" accept="image/gif, image/jpg, image/jpeg, image/png" multiple>
<div class="dummyfile input-group">
<span class="input-group-addon"><i class="icon-file"></i></span>
<input id="hotel-images-file-name" type="text" readonly>
<span class="input-group-btn">
<button type="button" id="hotel-images-file-add-btn" class="btn btn-default">
<i class="icon-folder-open"></i> {l s='Add images' mod='hotelreservationsystem'}
</button>
</span>
</div>
<p class="help-block">{l s='Allowed image formats: .gif, .jpg, .jpeg and .png' mod='hotelreservationsystem'}</p>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-3" for="id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
<div class="col-lg-9">
<select class="form-control" id="id_htl_image_category" name="id_htl_image_category">
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
{if isset($hotelImageCategories) && $hotelImageCategories}
{foreach from=$hotelImageCategories item=hotelImageCategory}
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
{/foreach}
{/if}
</select>
<p class="help-block" style="margin-bottom:2px;">{l s='If not selected, image will be uncategorized.' mod='hotelreservationsystem'} &mdash; <a href="{$link->getAdminLink('AdminHotelImageCategory')|escape:'html':'UTF-8'}&amp;addhtl_image_category" target="_blank" style="white-space:nowrap;">{l s='Create image category' mod='hotelreservationsystem'} <i class="icon-external-link" style="font-size:11px;"></i></a></p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="hotel-images-upload-btn"><i class="icon-upload"></i> {l s='Upload' mod='hotelreservationsystem'}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="confirmDeleteHotelImageModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
<h4 class="modal-title"><i class="icon-exclamation-triangle"></i> {l s='Confirm Delete' mod='hotelreservationsystem'}</h4>
</div>
<div class="modal-body">
<p>{l s='Are you sure you want to delete the selected image(s)? This cannot be undone.' mod='hotelreservationsystem'}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="confirm-delete-hotel-image-btn">{l s='Delete' mod='hotelreservationsystem'}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="editHotelImageModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
<h4 class="modal-title"><i class="icon-image"></i> {l s='Edit Image' mod='hotelreservationsystem'}</h4>
</div>
<div class="modal-body">
<input type="hidden" id="edit_hotel_image_id">
<div class="form-group">
<label class="control-label col-lg-3" for="edit_id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
<div class="col-lg-9">
<select class="form-control" id="edit_id_htl_image_category">
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
{if isset($hotelImageCategories) && $hotelImageCategories}
{foreach from=$hotelImageCategories item=hotelImageCategory}
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
{/foreach}
{/if}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-3">{l s='Cover image' mod='hotelreservationsystem'}</label>
<div class="col-lg-9">
<span class="switch prestashop-switch fixed-width-lg">
<input type="radio" id="edit_hotel_image_cover_on" name="edit_hotel_image_cover" value="1">
<label for="edit_hotel_image_cover_on">{l s='Yes' mod='hotelreservationsystem'}</label>
<input type="radio" id="edit_hotel_image_cover_off" name="edit_hotel_image_cover" value="0">
<label for="edit_hotel_image_cover_off">{l s='No' mod='hotelreservationsystem'}</label>
<a class="slide-button btn"></a>
</span>
<p class="help-block">{l s='Setting this to Yes will make this the cover image, replacing the current one.' mod='hotelreservationsystem'}</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="save-edit-hotel-image-btn">
<i class="icon-save"></i> {l s='Save' mod='hotelreservationsystem'}
</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="bulkUpdateHotelImageModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
<h4 class="modal-title"><i class="icon-edit"></i> {l s='Bulk Update selection' mod='hotelreservationsystem'}</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="control-label col-lg-3" for="bulk_id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
<div class="col-lg-9">
<select class="form-control" id="bulk_id_htl_image_category">
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
{if isset($hotelImageCategories) && $hotelImageCategories}
{foreach from=$hotelImageCategories item=hotelImageCategory}
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
{/foreach}
{/if}
</select>
<p class="help-block">{l s='If not selected, selected images will be uncategorized.' mod='hotelreservationsystem'}</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="save-bulk-hotel-image-btn">
<i class="icon-save"></i> {l s='Save' mod='hotelreservationsystem'}
</button>
</div>
</div>
</div>
</div>

View File

@@ -30,6 +30,7 @@
</div>
<form id="{$table|escape:'htmlall':'UTF-8'}_form" class="defaultForm {$name_controller|escape:'htmlall':'UTF-8'} form-horizontal" action="{$current|escape:'htmlall':'UTF-8'}&{if !empty($submit_action)}{$submit_action|escape:'htmlall':'UTF-8'}{/if}&token={$token|escape:'htmlall':'UTF-8'}" method="post" enctype="multipart/form-data" {if isset($style)}style="{$style|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="htl_active_tab" name="htl_active_tab" value="">
{if isset($edit)}
{assign var=hook_arg_id_hotel value=$hotel_info.id}
{else}
@@ -286,6 +287,18 @@
<input class="form-control" type="" data-validate="" id="hotel_postal_code" name="hotel_postal_code" value="{if isset($smarty.post.hotel_postal_code)}{$smarty.post.hotel_postal_code}{elseif isset($edit)}{$address_info.postcode|escape:'htmlall':'UTF-8'}{/if}" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="loclatitude">{l s='Latitude :' mod='hotelreservationsystem'}</label>
<div class="col-sm-6">
<input class="form-control" type="text" id="loclatitude" name="loclatitude" value="{if isset($smarty.post.loclatitude)}{$smarty.post.loclatitude|escape:'htmlall':'UTF-8'}{elseif isset($edit) && $hotel_info.latitude != 0}{$hotel_info.latitude|escape:'htmlall':'UTF-8'}{/if}" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="loclongitude">{l s='Longitude :' mod='hotelreservationsystem'}</label>
<div class="col-sm-6">
<input class="form-control" type="text" id="loclongitude" name="loclongitude" value="{if isset($smarty.post.loclongitude)}{$smarty.post.loclongitude|escape:'htmlall':'UTF-8'}{elseif isset($edit) && $hotel_info.longitude != 0}{$hotel_info.longitude|escape:'htmlall':'UTF-8'}{/if}" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">
{l s='Hotel Policies :' mod='hotelreservationsystem'}
@@ -308,8 +321,6 @@
<div class="form-group">
<label class="col-sm-3 control-label">{l s='Map:' mod='hotelreservationsystem'}</label>
<div class="col-sm-6" id="googleMapContainer">
<input type="hidden" id="loclatitude" name="loclatitude" value="{if isset($edit)}{$hotel_info.latitude|escape:'htmlall':'UTF-8'}{/if}" />
<input type="hidden" id="loclongitude" name="loclongitude" value="{if isset($edit)}{$hotel_info.longitude|escape:'htmlall':'UTF-8'}{/if}" />
<input type="hidden" id="locformatedAddr" name="locformatedAddr" value="{if isset($edit)}{$hotel_info.map_formated_address}{/if}" />
<input type="hidden" id="googleInputField" name="googleInputField" value="{if isset($edit)}{$hotel_info.map_input_text}{/if}" />
<div id="pac-input" class="controls" type="text"></div>
@@ -423,12 +434,12 @@
show_label_tooltip = false
show_flag = true
inputs = [
'meta_title' => $meta_title_info,
'meta_description' => $meta_description_info,
'link_rewrite' => $link_rewrite_info,
'meta_keywords' => $meta_keywords_info,
'name' => $hotel_info.hotel_name,
'description_short' => $hotel_info.short_description
'meta_title' => $meta_title_info|default:'',
'meta_description' => $meta_description_info|default:'',
'link_rewrite' => $link_rewrite_info|default:'',
'meta_keywords' => $meta_keywords_info|default:'',
'name' => $hotel_info.hotel_name|default:'',
'description_short' => $hotel_info.short_description|default:''
]
}
{hook h='displayAdminAddHotelFormSeoTabAfter' id_hotel=$hook_arg_id_hotel}
@@ -437,19 +448,17 @@
{hook h='displayAdminAddHotelFormImagesTabBefore' id_hotel=$hook_arg_id_hotel}
{if isset($hotel_info.id) && $hotel_info.id}
<div class="form-group row">
<label for="hotel_images" class="col-sm-3 control-label padding-top-0">
{l s='Upload images' mod='hotelreservationsystem'}&nbsp;:&nbsp;&nbsp;
</label>
<div class="col-sm-5">
<input class="form-control-static" type="file" accept="image/gif, image/jpg, image/jpeg, image/png" id="hotel_images" name="hotel_images[]" multiple>
</div>
</div>
<hr>
{* Image table *}
<h4><i class="icon-image"></i> <span>{l s='Hotel Images' mod='hotelreservationsystem'}</span></h4>
<div class="row">
<div class="col-sm-12 text-right">
<a href="{$link->getAdminLink('AdminHotelImageCategory')|escape:'html':'UTF-8'}" class="btn btn-default">
<i class="icon-plus-sign"></i> {l s='ADD CATEGORY' mod='hotelreservationsystem'}
</a>
<button type="button" class="btn btn-primary" id="open-add-hotel-images-modal">
<i class="icon-plus-sign"></i> {l s='Add images' mod='hotelreservationsystem'}
</button>
</div>
<div class="col-sm-12">
<hr>
{include file="../../_partials/htl-images-list.tpl"}
</div>
</div>
@@ -672,10 +681,14 @@
</form>
</div>
{strip}
{addJsDef adminHotelCtrlUrl = $link->getAdminlink('AdminAddHotel')}
{addJsDefL name=imgUploadSuccessMsg}{l s='Image Successfully Uploaded' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=imgUploadErrorMsg}{l s='Something went wrong while uploading images. Please try again later !!' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{strip}
{addJsDef adminHotelCtrlUrl = $link->getAdminlink('AdminAddHotel')}
{addJsDefL name=imgSelectErrorMsg}{l s='Please select at least one image before uploading.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=bulkUpdateSelectErrorMsg}{l s='Please select at least one image to update.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=bulkDeleteSelectErrorMsg}{l s='Please select at least one image to delete.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=imgUploadSuccessMsg}{l s='Image Successfully Uploaded' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=imgUploadErrorMsg}{l s='Something went wrong while uploading images. Please try again later !!' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=imgUpdateSuccessMsg}{l s='Image updated successfully.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=coverImgSuccessMsg}{l s='Cover image changed successfully' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=coverImgErrorMsg}{l s='Error while changing cover image' js=1 mod='hotelreservationsystem'}{/addJsDefL}
@@ -686,8 +699,6 @@
{addJsDef enabledDisplayMap = $enabledDisplayMap}
{addJsDef defaultCountry = $defaultCountry}
{addJsDef statebycountryurl = $link->getAdminLink('AdminAddHotel')}
{addJsDefL name=htlImgDeleteSuccessMsg}{l s='Image removed successfully.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{addJsDefL name=htlImgDeleteErrMsg}{l s='Some error occurred while deleting hotel image.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
{/strip}
{block name=script}
@@ -726,6 +737,17 @@
$(document).on('wk.lang.changed', function(e, idLang) {
$(window).trigger('resize.autosize');
});
// Restore active tab from controller redirect param
var _htlActiveTab = '{if !empty($smarty.get.htl_active_tab)}{$smarty.get.htl_active_tab|escape:'javascript':'UTF-8'}{/if}';
if (/^#[\w-]+$/.test(_htlActiveTab) && $('a[href="' + _htlActiveTab + '"]').length) {
$('a[href="' + _htlActiveTab + '"]').tab('show');
}
// Keep hidden input in sync so active tab survives form submission
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$('#htl_active_tab').val($(e.target).attr('href'));
});
});
$(".textarea-autosize").autosize();
// After full page load, reinit visible textareas so they start at the correct height

View File

@@ -23,7 +23,7 @@
<div class="booking-form card">
<div class="booking_room_fields">
{block name='booking_form_content'}
<form id="booking-form" action="" method="post">
<form id="booking-form" action="{$link->getPageLink('cart')|escape:'html':'UTF-8'}" method="post">
{block name='product_hidden_fields'}
<p class="hidden">
<input type="hidden" name="token" value="{$static_token}" />
@@ -51,8 +51,8 @@
<div class="form-group col-sm-12">
<label class="control-label">{l s='Check In - Check Out'}</label>
<div class="form-control input-date" id="room_date_range" autocomplete="off" placeholder="{l s='Check-in - Check-out'}"><span>{l s='Check-in'} &nbsp;<i class="icon icon-minus"></i>&nbsp; {l s='Check-out'}</span></div>
<input type="hidden" class="input-date" name="room_check_in" id="room_check_in" value="{if isset($date_from)}{$date_from}{/if}" />
<input type="hidden" class="input-date" name="room_check_out" id="room_check_out" value="{if isset($date_to)}{$date_to}{/if}" />
<input type="hidden" class="input-date" name="date_from" id="room_check_in" value="{if isset($date_from)}{$date_from}{/if}" />
<input type="hidden" class="input-date" name="date_to" id="room_check_out" value="{if isset($date_to)}{$date_to}{/if}" />
</div>
{/block}
</div>
@@ -192,7 +192,7 @@
<div id="additional_products" class="hidden">
{if isset($selected_service_product) && $selected_service_product}
{foreach $selected_service_product as $product}
<input type="hidded" id="service_product_{$product['id_product']}" name="service_product[{$product['id_product']}][]" class="service_product" data-id_product="{$product['id_product']}" value="{$product['quantity']}">
<input type="hidden" id="service_product_{$product['id_product']}" name="service_product[{$product['id_product']}][quantity]" class="service_product" data-id_product="{$product['id_product']}" value="{$product['quantity']}">
{/foreach}
{/if}
</div>
@@ -257,7 +257,7 @@
{if isset($associated_hotels) && $associated_hotels}
<div class="form-group">
<label class="control-label">{l s='Select Hotel'}</label>
<select class="chosen input-hotel" name="service_id_hotel" id="service_id_hotel">
<select class="chosen input-hotel" name="id_hotel" id="service_id_hotel">
{foreach $associated_hotels as $hotel}
<option value="{$hotel.id_hotel}" {if isset($service_id_hotel) && $service_id_hotel == $hotel['id_hotel']}selected{elseif $hotel@first}selected{/if}>{$hotel.name}</option>
{/foreach}
@@ -303,7 +303,7 @@
<div class="qty_container">
<input type="hidden" class="stock_qty" id="stock_qty" name="stock_qty" data-id-product="{$product->id}" data-stock_quantity="{$product->quantity}" data-allow_oosp="{$allow_oosp}" >
<input type="hidden" class="service_product_qty" id="service_product_qty" name="service_product_qty" data-id-product="{$product->id}" data-cart_quantity="{if isset($product->cart_quantity) && $product->cart_quantity}{$product->cart_quantity}{else}0{/if}" data-max_quantity="{if isset($product->max_quantity)}{$product->max_quantity|escape:'html':'UTF-8'}{else}{$product->quantity}{/if}" value="{if isset($quantity)}{$quantity|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}">
<input type="hidden" class="service_product_qty" id="service_product_qty" name="qty" data-id-product="{$product->id}" data-cart_quantity="{if isset($product->cart_quantity) && $product->cart_quantity}{$product->cart_quantity}{else}0{/if}" data-max_quantity="{if isset($product->max_quantity)}{$product->max_quantity|escape:'html':'UTF-8'}{else}{$product->quantity}{/if}" value="{if isset($quantity)}{$quantity|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}">
<div class="qty_count pull-left">
<span>{if isset($quantity)}{$quantity|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}</span>
</div>
@@ -319,7 +319,7 @@
<hr class="separator-hr-mg-10">
{/if}
{else}
<input type="hidden" class="service_product_qty" id="service_product_qty" name="service_product_qty" data-id-product="{$product->id}" data-max_quantity="1" value="1">
<input type="hidden" class="service_product_qty" id="service_product_qty" name="qty" data-id-product="{$product->id}" data-max_quantity="1" value="1">
{/if}
{/block}
{block name='booking_form_actions'}

View File

@@ -24,7 +24,10 @@
{if is_array($hotel_images) && count($hotel_images)}
{foreach from=$hotel_images item=hotel_image}
<div class="col-sm-4 image-item">
<a class="hotel-images-fancybox" href="{$hotel_image.link|escape:'html':'UTF-8'}">
<a class="fancybox"
href="{$hotel_image.link|escape:'html':'UTF-8'}"
data-fancybox-group="hotel-images"
title="{if isset($hotel_image.category_name) && $hotel_image.category_name}{$hotel_image.category_name|escape:'html':'UTF-8'}{/if}">
<img class="img img-responsive" src="{$hotel_image.link|escape:'html':'UTF-8'}">
</a>
</div>

View File

@@ -124,7 +124,7 @@
{/if}
{block name='room_type_list_room_book_now_button'}
<div>
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium ajax_add_to_cart_button"><span>{l s='Book Now'}</span></a>
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="{$link->getPageLink('cart')|escape:'html':'UTF-8'}?id_product={$room_v['id_product']}&date_from={$booking_date_from|escape:'htmlall':'UTF-8'}&date_to={$booking_date_to|escape:'htmlall':'UTF-8'}&add=1&token={$static_token}" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium btn_book_now_with_occupancy ajax_add_to_cart_button"><span>{l s='Book Now'}</span></a>
</div>
{/block}
</div>

View File

@@ -216,7 +216,7 @@
<div class="col-xs-8">
<p class="hotel-name"><span>{$hotel['hotel_name']}</span></p>
<p class="hotel-branch-info-value">{$hotel['address']}, {$hotel['city']}, {if {$hotel['state_name']}}{$hotel['state_name']},{/if} {$hotel['country_name']}, {$hotel['postcode']}</p>
{if ($hotel['latitude'] != 0 || $hotel['longitude'] != 0) && $viewOnMap}
{if $hotel['latitude'] != 0 || $hotel['longitude'] != 0}
<p class="hotel-branch-info-value">
<a class="btn htl-map-direction-btn" href="http://maps.google.com/maps?daddr=({$hotel['latitude']},{$hotel['longitude']})" target="_blank">
<span class="">{l s='View on map'}</span>

View File

@@ -44,7 +44,9 @@ a.fancybox-nav {
.pb-left-column #image-block img {
background: #fbfbfb;
border-radius: 4px;
width: 100%; }
width: 100%;
min-height: 420px;
object-fit: cover; }
.pb-left-column #image-block #view_full_size .span_link {
position: absolute;
bottom: 20px;
@@ -1787,4 +1789,4 @@ ul.service-product-nav > li:hover {
#hotel_rating {
display: block;
}
}
}

View File

@@ -62,6 +62,7 @@
{addJsDef is_occupancy_wise_search=$is_occupancy_wise_search|boolval}
{addJsDef occupancy_required_for_booking=$occupancy_required_for_booking|boolval}
{addJsDef max_child_age=$max_child_age}
{addJsDef hasDeliveryAddress=(isset($cart->id_address_delivery) && $cart->id_address_delivery)}
{addJsDefL name='max_occupancy_reached_txt'}{l s='Maximum room occupancy reached' js=1}{/addJsDefL}
{addJsDefL name='max_adults_txt'}{l s='Maximum adult occupancy reached' js=1}{/addJsDefL}

View File

@@ -601,8 +601,8 @@ function deleteRoomFromSummary(el)
+ '&op=down'
+ '&qty='+qty
+ '&id_product='+id_product
+ '&dateFrom='+date_from
+ '&dateTo='+date_to
+ '&date_from='+date_from
+ '&date_to='+date_to
+ '&token=' + static_token
+ '&allow_refresh=1',
success: function(jsonData)
@@ -942,8 +942,8 @@ function updateCartSummary(json)
$('input[name=quantity_' + key_for_blockcart_nocustom + '_hidden]').val(product_list[i].id_customization? product_list[i].quantity_without_customization : product_list[i].cart_quantity);
if (typeof(product_list[i].customizationQuantityTotal) !== 'undefined' && product_list[i].customizationQuantityTotal > 0)
$('#cart_quantity_custom_' + key_for_blockcart).html(product_list[i].customizationQuantityTotal);
nbrProducts += parseInt(product_list[i].quantity);
}
nbrProducts += parseInt(json.total_products_in_cart);
// Update discounts
var discount_count = 0;

View File

@@ -66,4 +66,27 @@ function resizeCatimg()
$( "#check_out_time" ).datepicker( "option", "maxDate", max_order_date_format);
}
});*/
/*End*/
/*End*/
$(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function (e) {
e.preventDefault();
var baseUrl = $(this).attr('href');
var occupancy = getBookingOccupancyDetails($(this).closest('.booking_room_fields'), true);
if ($(this).prop('disabled') != 'disabled' && occupancy) {
var occupancyParams = '';
if (Array.isArray(occupancy)) {
$.each(occupancy, function(i, room) {
occupancyParams += '&occupancy[' + i + '][adults]=' + encodeURIComponent(room.adults);
occupancyParams += '&occupancy[' + i + '][children]=' + encodeURIComponent(room.children);
if (room.child_ages && room.child_ages.length) {
$.each(room.child_ages, function(_, age) {
occupancyParams += '&occupancy[' + i + '][child_ages][]=' + encodeURIComponent(age);
});
}
});
} else {
occupancyParams += '&qty=' + encodeURIComponent(occupancy);
}
window.location.href = baseUrl + occupancyParams;
}
});

View File

@@ -69,8 +69,6 @@ function initMap() {
map = new google.maps.Map(document.getElementById("map"), PS_MAP_ID ? {mapId: PS_MAP_ID} : {});
google.maps.event.trigger(map, 'resize');
map.setTilt(45);
// Display multiple markers on a map
var infoWindow = new google.maps.InfoWindow();
var marker;

View File

@@ -415,19 +415,29 @@ var ajaxCart = {
if (parseInt(booking_product)) {
// get the selected extra demands by customer
if (typeof dateFrom != 'undefined')
req.append('dateFrom', dateFrom);
req.append('date_from', dateFrom);
if (typeof dateTo != 'undefined')
req.append('dateTo', dateTo);
req.append('date_to', dateTo);
if (occupancy_required_for_booking) {
req.append('occupancy', JSON.stringify(occupancy));
occupancy.forEach(function(room, i) {
req.append('occupancy['+i+'][adults]', room.adults);
req.append('occupancy['+i+'][children]', room.children || 0);
if (room.child_ages && room.child_ages.length) {
room.child_ages.forEach(function(age) {
req.append('occupancy['+i+'][child_ages][]', age);
});
}
});
} else {
req.append('qty', ((occupancy && occupancy != null) ? occupancy : '1'));
}
var roomDemands = getRoomsExtraDemands();
req.append('roomDemands', JSON.stringify(roomDemands) );
req.append('serviceProducts', JSON.stringify(getRoomsServiceProducts()) );
req.append('room_demands', JSON.stringify(roomDemands) );
getRoomsServiceProducts().forEach(function(product) {
req.append('service_product['+product.id_product+'][quantity]', product.quantity);
});
} else {
req.append('qty', ((occupancy && occupancy != null) ? occupancy : '1'));
}
@@ -576,7 +586,7 @@ var ajaxCart = {
async: true,
cache: false,
dataType: "json",
data: 'controller=cart&add=1&op=down&dateFrom=' + dateFrom + '&dateTo=' + dateTo + '&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ((parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination) : '' + '&id_customization=' + ((typeof customizationId !== 'undefined') ? customizationId : 0)),
data: 'controller=cart&add=1&op=down&date_from=' + dateFrom + '&date_to=' + dateTo + '&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ((parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination) : '' + '&id_customization=' + ((typeof customizationId !== 'undefined') ? customizationId : 0)),
success: function(jsonData, textStatus, jqXHR) {
/*by webkul checking and setting availability of rooms*/
/*for product page add to cart quantity management*/
@@ -650,7 +660,7 @@ var ajaxCart = {
async: true,
cache: false,
dataType: "json",
data: 'controller=cart&delete=1&dateFrom=' + dateFrom + '&dateTo=' + dateTo + '&id_product=' + idProduct + '&id_hotel=' + idHotel + '&id_product_option=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
data: 'controller=cart&delete=1&date_from=' + dateFrom + '&date_to=' + dateTo + '&id_product=' + idProduct + '&id_hotel=' + idHotel + '&id_product_option=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
success: function(jsonData) {
if (pagename == 'product') {
disableRoomTypeDemands(0);
@@ -1414,112 +1424,3 @@ function crossselling_serialScroll() {
pager: false
});
}
function resetRoomtypeServices(refresh = true) {
$('.room_demands_container').find('input.id_room_type_demand:checked').prop('checked', false).uniform();
$('#additional_products').empty();
$('#additional_products div')
$('.remove_roomtype_product').text(select_txt).removeClass('btn-danger remove_roomtype_product').addClass('btn-success add_roomtype_product');
if (refresh) {
BookingForm.refresh();
}
}
function disableRoomTypeDemands(show) {
if (show) {
$('.room_demands_container_overlay').show();
$('.room_demands_container').find('input:checkbox.id_room_type_demand').prop('checked', false);
$('.room_demand_block').find('.id_room_type_demand').prop('checked', false).parent().removeClass('checked');
$('.room_demands_container').find('input:checkbox.id_room_type_demand').attr('disabled', 'disabled');
} else {
$('.room_demands_container_overlay').hide();
$('.room_demands_container').find('input:checkbox.id_room_type_demand').removeAttr('disabled');
$('.room_demands_container').find('.checker').removeClass('disabled');
}
}
function disableRoomTypeServices(disable) {
if (disable) {
resetRoomtypeServices(false);
$('#service_products_cont').find('button.add_roomtype_product').attr('disabled', 'disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').attr('disabled', 'disabled');
} else {
$('#service_products_cont').find('button.add_roomtype_product').removeAttr('disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').removeAttr('disabled');
}
}
function getRoomsExtraDemands()
{
var roomDemands = [];
$('input:checkbox.id_room_type_demand:checked').each(function () {
roomDemands.push({
'id_global_demand':$(this).val(),
'id_option': $(this).closest('.room_demand_block').find('.id_option').val()
});
});
return roomDemands;
}
function getRoomsServiceProducts()
{
var serviceProducts = [];
$('#additional_products input.service_product').each(function () {
serviceProducts.push({
'id_product': $(this).data('id_product'),
'quantity':$(this).val(),
});
});
return serviceProducts;
}
function getBookingOccupancyDetails(bookingform, booking_product)
{
let occupancy;
if (booking_product) {
if (occupancy_required_for_booking) {
$('.booking_guest_occupancy_conatiner .dropdown').removeClass('open');
let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected")
if (selected_occupancy.length) {
occupancy = [];
$(selected_occupancy).each(function(ind, element) {
if (parseInt($(element).find('.num_adults').val())) {
let child_ages = [];
$(element).find('.guest_child_age').each(function(index) {
if ($(this).val() > -1) {
child_ages.push($(this).val());
}
});
if ($(element).find('.num_children').val()) {
if (child_ages.length != $(element).find('.num_children').val()) {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
}
occupancy.push({
'adults': $(element).find('.num_adults').val(),
'children': $(element).find('.num_children').val(),
'child_ages': child_ages
});
} else {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
});
} else {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
} else {
occupancy = parseInt($(bookingform).find(".quantity_wanted").val());
}
} else {
occupancy = parseInt($('#service_product_qty').val());
}
return occupancy;
}

View File

@@ -19,8 +19,6 @@
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
$(document).ready(function(){
$(document).on('click', '.booking_occupancy_wrapper .remove-room-link', function(e) {
e.preventDefault();
@@ -412,3 +410,51 @@ function resetOccupancyField(booking_occupancy_wrapper)
}
});
}
function getBookingOccupancyDetails(bookingform, booking_product)
{
let occupancy;
if (booking_product) {
if (occupancy_required_for_booking) {
$('.booking_guest_occupancy_conatiner .dropdown').removeClass('open');
let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected")
if (selected_occupancy.length) {
occupancy = [];
$(selected_occupancy).each(function(ind, element) {
if (parseInt($(element).find('.num_adults').val())) {
let child_ages = [];
$(element).find('.guest_child_age').each(function(index) {
if ($(this).val() > -1) {
child_ages.push($(this).val());
}
});
if ($(element).find('.num_children').val()) {
if (child_ages.length != $(element).find('.num_children').val()) {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
}
occupancy.push({
'adults': $(element).find('.num_adults').val(),
'children': $(element).find('.num_children').val(),
'child_ages': child_ages
});
} else {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
});
} else {
$(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open')
occupancy = false;
}
} else {
occupancy = parseInt($(bookingform).find(".quantity_wanted").val());
}
} else {
occupancy = parseInt($('#service_product_qty').val());
}
return occupancy;
}

View File

@@ -26,6 +26,7 @@ $(document).ready(function(){
var idOrder = $(this).data('id_order');
var dateFrom = $(this).data('date_from');
var dateTo = $(this).data('date_to');
var secureKey = $(this).data('secure_key');
var action = $(this).data('action');
$.ajax({
type: 'POST',
@@ -40,6 +41,7 @@ $(document).ready(function(){
date_to: dateTo,
id_product: idProduct,
id_order: idOrder,
secure_key: secureKey,
action: 'getRoomTypeBookingDemands',
method: 'getRoomTypeBookingDemands',
ajax: true,

View File

@@ -37,8 +37,6 @@ function initMap() {
map = new google.maps.Map(document.getElementById("map"), PS_MAP_ID ? {mapId: PS_MAP_ID} : {});
google.maps.event.trigger(map, 'resize');
map.setTilt(45);
// Display multiple markers on a map
var infoWindow = new google.maps.InfoWindow();
var marker;

View File

@@ -205,6 +205,13 @@ $(document).ready(function() {
}
if ($('.room_info_hotel_images_wrap').length) {
if (!!$.prototype.fancybox) {
$('.room_info_hotel_images_wrap .fancybox').fancybox({
'hideOnContentClick': true,
'openEffect': 'elastic',
'closeEffect': 'elastic',
});
}
loadHotelImagesByPage(1);
}
});
@@ -1270,7 +1277,7 @@ function addProductToRoomType(that) {
} else {
$('<input type="hidden">').attr({
id: 'service_product_'+ id_product,
name: 'service_product['+ id_product +'][]',
name: 'service_product['+ id_product +'][quantity]',
class: 'service_product',
'data-id_product': id_product,
value: qty
@@ -1537,7 +1544,6 @@ function loadHotelImagesByPage(page = 1) {
success: function(response) {
if (response.status == true && response.message == 'HTML_OK') {
$('.room_info_hotel_images_wrap .images-wrap').append(response.html);
$('.room_info_hotel_images_wrap .hotel-images-fancybox').fancybox();
$('.room_info_hotel_images_wrap .btn-show-more-images').removeClass('hide');
}

View File

@@ -0,0 +1,86 @@
/*
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
function resetRoomtypeServices(refresh = true) {
$('.room_demands_container').find('input.id_room_type_demand:checked').prop('checked', false).uniform();
$('#additional_products').empty();
$('#additional_products div')
$('.remove_roomtype_product').text(select_txt).removeClass('btn-danger remove_roomtype_product').addClass('btn-success add_roomtype_product');
if (refresh) {
BookingForm.refresh();
}
}
function disableRoomTypeDemands(show) {
if (show) {
$('.room_demands_container_overlay').show();
$('.room_demands_container').find('input:checkbox.id_room_type_demand').prop('checked', false);
$('.room_demand_block').find('.id_room_type_demand').prop('checked', false).parent().removeClass('checked');
$('.room_demands_container').find('input:checkbox.id_room_type_demand').attr('disabled', 'disabled');
} else {
$('.room_demands_container_overlay').hide();
$('.room_demands_container').find('input:checkbox.id_room_type_demand').removeAttr('disabled');
$('.room_demands_container').find('.checker').removeClass('disabled');
}
}
function disableRoomTypeServices(disable) {
if (disable) {
resetRoomtypeServices(false);
$('#service_products_cont').find('button.add_roomtype_product').attr('disabled', 'disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').attr('disabled', 'disabled');
} else {
$('#service_products_cont').find('button.add_roomtype_product').removeAttr('disabled');
$('#service_products_cont').find('.qty_container .qty_direction a').removeAttr('disabled');
}
}
function getRoomsExtraDemands()
{
var roomDemands = [];
$('input:checkbox.id_room_type_demand:checked').each(function () {
roomDemands.push({
'id_global_demand':$(this).val(),
'id_option': $(this).closest('.room_demand_block').find('.id_option').val()
});
});
return roomDemands;
}
function getRoomsServiceProducts()
{
var serviceProducts = [];
$('#additional_products input.service_product').each(function () {
serviceProducts.push({
'id_product': $(this).data('id_product'),
'quantity':$(this).val(),
});
});
return serviceProducts;
}

View File

@@ -136,7 +136,7 @@
<dt class="col-xs-5">{l s='Extra Services'}</dt>
<dd class="col-xs-7">
{if (isset($rm_v['extra_demands']) && $rm_v['extra_demands']) || isset($rm_v['additional_services']) && $rm_v['additional_services']}
<a data-date_from="{$rm_v['data_form']}" data-date_to="{$rm_v['data_to']}" data-id_product="{$data_v['id_product']}" data-id_order="{$data_v['id_order']}" data-action="{$link->getPageLink('order-detail')}" class="open_rooms_extra_services_panel" href="#rooms_type_extra_services_form">
<a data-date_from="{$rm_v['data_form']}" data-date_to="{$rm_v['data_to']}" data-id_product="{$data_v['id_product']}" data-id_order="{$data_v['id_order']}" data-secure_key="{$order->secure_key|escape:'html':'UTF-8'}" data-action="{$link->getPageLink('order-detail')}" class="open_rooms_extra_services_panel" href="#rooms_type_extra_services_form">
{/if}
{if $group_use_tax}
{displayWtPriceWithCurrency price=($rm_v['extra_demands_price_ti'] + $rm_v['additional_services_price_ti']) currency=$objOrderCurrency}

View File

@@ -395,6 +395,8 @@
{addJsDefL name=txtExtraDemandSucc}{l s='Updated Successfully' js=1}{/addJsDefL}
{addJsDefL name=txtMaxQuantityAdded}{l s='Maximum quantity of service added' js=1}{/addJsDefL}
{addJsDefL name=txtExtraDemandErr}{l s='Some error occurred while updating demands' js=1}{/addJsDefL}
{addJsDefL name=freeShippingTranslation}{l s='Free shipping!' mod='blockcart' js=1}{/addJsDefL}
{/strip}
{/block}
{/if}

View File

@@ -75,7 +75,7 @@
</p>
<div class="hotel-branch-info-actions">
<a href="{$hotel['view_rooms_link']}" target="_blank" class="btn btn-primary view_rooms_btn col-sm-6 col-xs-12">{l s='View Property'}</a>
{if ($hotel['latitude'] != 0 || $hotel['longitude'] != 0) && $viewOnMap}
{if $hotel['latitude'] != 0 || $hotel['longitude'] != 0}
<a class="btn htl-map-direction-btn col-sm-6 col-xs-12" href="http://maps.google.com/maps?daddr=({$hotel['latitude']},{$hotel['longitude']})" target="_blank">{l s='View on map'}</a>
{/if}
</div>