Updated the flow for feature prices, added multiple date wise rules in a feature price for a room type
This commit is contained in:
@@ -390,7 +390,7 @@ $(document).ready(function () {
|
||||
<a target="_blank" href="{$link->getAdminLink('AdminHotelFeaturePricesSettings')}">{l s='create advanced price rules.'}</a>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#{l s='Id'}</th>
|
||||
|
||||
@@ -1487,6 +1487,10 @@ class WebserviceRequestCore
|
||||
|
||||
if (!$this->hasErrors()) {
|
||||
$object->webservice_validation = 1;
|
||||
if (isset($attributes->associations)) {
|
||||
$object->associations = $attributes->associations;
|
||||
}
|
||||
|
||||
if ($i18n && ($retValidateFieldsLang = $object->validateFieldsLang(false, true)) !== true) {
|
||||
$this->setError(400, 'Validation error: "'.$retValidateFieldsLang.'"', 84);
|
||||
return false;
|
||||
|
||||
@@ -2930,38 +2930,19 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
|
||||
*/
|
||||
public function createFeaturePrice($params)
|
||||
{
|
||||
$feature_price_name = array();
|
||||
foreach (Language::getIDs(true) as $idLang) {
|
||||
$feature_price_name[$idLang] = 'Api-Booking-Price';
|
||||
}
|
||||
|
||||
$numDays = HotelHelper::getNumberOfDays($params['date_from'], $params['date_to']);
|
||||
if (!$numDays) {
|
||||
$numDays = 1;
|
||||
}
|
||||
|
||||
$objRoomTypeFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
$objRoomTypeFeaturePricing->id_product = (int) $params['id_product'];
|
||||
$objRoomTypeFeaturePricing->id_cart = (int) $params['id_cart'];
|
||||
$objRoomTypeFeaturePricing->id_guest = (int) $params['id_guest'];
|
||||
$objRoomTypeFeaturePricing->id_room = (int) $params['id_room'];
|
||||
$objRoomTypeFeaturePricing->feature_price_name = $feature_price_name;
|
||||
$objRoomTypeFeaturePricing->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
|
||||
$objRoomTypeFeaturePricing->date_from = $params['date_from'];
|
||||
$objRoomTypeFeaturePricing->date_to = $params['date_to'];
|
||||
$objRoomTypeFeaturePricing->is_special_days_exists = 0;
|
||||
$objRoomTypeFeaturePricing->special_days = json_encode(false);
|
||||
$objRoomTypeFeaturePricing->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
|
||||
$objRoomTypeFeaturePricing->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
$objRoomTypeFeaturePricing->impact_value = $params['price']/$numDays;
|
||||
$objRoomTypeFeaturePricing->active = 1;
|
||||
$objRoomTypeFeaturePricing->groupBox = array_column(Group::getGroups(Configuration::get('PS_LANG_DEFAULT')), 'id_group');
|
||||
$params['name'] = 'Api-Booking-Price';
|
||||
$params['date_selection_type'] = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
|
||||
$params['impact_type'] = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
$params['price'] /= $numDays;
|
||||
$params['is_special_days_exists'] = 0;
|
||||
$params['special_days'] = json_encode(false);
|
||||
|
||||
if ($objRoomTypeFeaturePricing->add()) {
|
||||
return $objRoomTypeFeaturePricing->id;
|
||||
}
|
||||
|
||||
return false;
|
||||
return HotelRoomTypeFeaturePricing::createRoomTypeFeaturePrice($params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -978,28 +978,22 @@ class AdminCartsControllerCore extends AdminController
|
||||
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
HotelRoomTypeFeaturePricing::deleteFeaturePrices($id_cart, $id_product, $id_room, $date_from, $date_to);
|
||||
$feature_price_name = array();
|
||||
foreach (Language::getIDs(true) as $id_lang) {
|
||||
$feature_price_name[$id_lang] = 'Auto-generated';
|
||||
}
|
||||
HotelRoomTypeFeaturePricing::createRoomTypeFeaturePrice(
|
||||
array(
|
||||
'id_product' => $id_product,
|
||||
'id_cart' => $id_cart,
|
||||
'id_guest' => (int) $this->context->cookie->id_guest,
|
||||
'id_room' => $id_room,
|
||||
'date_selection_type' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE,
|
||||
'date_from' => $date_from,
|
||||
'date_to' => $date_to,
|
||||
'is_special_days_exists' => 0,
|
||||
'impact_way' => HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE,
|
||||
'impact_type' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE,
|
||||
'impact_value' => $price
|
||||
)
|
||||
);
|
||||
|
||||
$hrt_feature_price = new HotelRoomTypeFeaturePricing();
|
||||
$hrt_feature_price->id_product = $id_product;
|
||||
$hrt_feature_price->id_cart = $id_cart;
|
||||
$hrt_feature_price->id_guest = (int) $this->context->cookie->id_guest;
|
||||
$hrt_feature_price->id_room = $id_room;
|
||||
$hrt_feature_price->feature_price_name = $feature_price_name;
|
||||
$hrt_feature_price->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
|
||||
$hrt_feature_price->date_from = $date_from;
|
||||
$hrt_feature_price->date_to = $date_to;
|
||||
$hrt_feature_price->is_special_days_exists = 0;
|
||||
$hrt_feature_price->special_days = json_encode(false);
|
||||
$hrt_feature_price->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
|
||||
$hrt_feature_price->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
$hrt_feature_price->impact_value = $price;
|
||||
$hrt_feature_price->active = 1;
|
||||
$hrt_feature_price->groupBox = array_column(Group::getGroups($this->context->language->id), 'id_group');
|
||||
$hrt_feature_price->add();
|
||||
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$bookingsInfo = $objHotelCartBookingData->getCartFormatedBookinInfoByIdCart($id_cart);
|
||||
|
||||
@@ -2615,7 +2615,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->context->cart->id_guest
|
||||
);
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
if ($idRooms = $objHotelCartBookingData->getCustomerIdRoomsByIdCartIdProduct(
|
||||
if ($bookingCartData = $objHotelCartBookingData->getCustomerIdRoomsByIdCartIdProduct(
|
||||
$this->context->cart->id,
|
||||
$orderProduct['id_product'],
|
||||
date('Y-m-d', strtotime($dateFrom)),
|
||||
@@ -2632,28 +2632,23 @@ class AdminImportControllerCore extends AdminController
|
||||
$taxRateM = $taxRate/100;
|
||||
if (isset($orderProduct['amount'])) {
|
||||
$orderProduct['amount'] = (float)$orderProduct['amount']/(1+$taxRateM);
|
||||
foreach ($idRooms as $idRoom) {
|
||||
$objRoomFeaturePrice = new HotelRoomTypeFeaturePricing();
|
||||
$objRoomFeaturePrice->id_product = (int) $orderProduct['id_product'];
|
||||
$objRoomFeaturePrice->id_cart = (int) $this->context->cart->id;
|
||||
$objRoomFeaturePrice->id_guest = (int) $this->context->cart->id_guest;
|
||||
foreach(Language::getLanguages(true) as $lang) {
|
||||
$objRoomFeaturePrice->feature_price_name[$lang['id_lang']] = 'csvprice';
|
||||
}
|
||||
|
||||
$objRoomFeaturePrice->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
|
||||
$objRoomFeaturePrice->date_from = date('Y-m-d', strtotime($dateFrom));
|
||||
$objRoomFeaturePrice->date_to = date('Y-m-d', strtotime($dateTo));
|
||||
$objRoomFeaturePrice->is_special_days_exists = 0;
|
||||
$objRoomFeaturePrice->id_room = $idRoom['id_room'];
|
||||
$objRoomFeaturePrice->special_days = json_encode(false);
|
||||
$objRoomFeaturePrice->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
|
||||
$objRoomFeaturePrice->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
$objRoomFeaturePrice->impact_value = $orderProduct['amount'];
|
||||
$objRoomFeaturePrice->active = 1;
|
||||
$objRoomFeaturePrice->groupBox = array_column(Group::getGroups($this->context->language->id), 'id_group');
|
||||
$objRoomFeaturePrice->add();
|
||||
$featurePrices[] = $objRoomFeaturePrice->id;
|
||||
foreach ($bookingCartData as $bookingCart) {
|
||||
$featurePrices[] = HotelRoomTypeFeaturePricing::createRoomTypeFeaturePrice(
|
||||
array(
|
||||
'name' => 'csvprice',
|
||||
'id_product' => (int) $orderProduct['id_product'],
|
||||
'id_cart' => (int) $this->context->cart->id,
|
||||
'id_guest' => (int) $this->context->cart->id_guest,
|
||||
'date_selection_type' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE,
|
||||
'date_from' => date('Y-m-d', strtotime($dateFrom)),
|
||||
'date_to' => date('Y-m-d', strtotime($dateTo)),
|
||||
'is_special_days_exists' => 0,
|
||||
'id_room' => $bookingCart['id_room'],
|
||||
'impact_way' => HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE,
|
||||
'impact_type' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE,
|
||||
'impact_value' => $orderProduct['amount'],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4824,7 +4824,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if ($createFeaturePrice) {
|
||||
$featurePriceParams['id_room'] = $room_info['id_room'];
|
||||
$featurePriceParams = array_merge($featurePriceParams, array('date_from' => $date_from, 'date_to' => $date_to));
|
||||
HotelRoomTypeFeaturePricing::createAutoFeaturePrice($featurePriceParams);
|
||||
HotelRoomTypeFeaturePricing::createRoomTypeFeaturePrice($featurePriceParams);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -5663,7 +5663,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'date_from' => $new_date_from,
|
||||
'date_to' => $new_date_to
|
||||
);
|
||||
HotelRoomTypeFeaturePricing::createAutoFeaturePrice($params);
|
||||
HotelRoomTypeFeaturePricing::createRoomTypeFeaturePrice($params);
|
||||
|
||||
$roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$id_product,
|
||||
|
||||
@@ -1998,7 +1998,7 @@ class HotelBookingDetail extends ObjectModel
|
||||
$featurePriceParams,
|
||||
array('date_from' => $objOldHotelBooking->date_from, 'date_to' => $objOldHotelBooking->date_to)
|
||||
);
|
||||
HotelRoomTypeFeaturePricing::createAutoFeaturePrice($featurePriceParams);
|
||||
HotelRoomTypeFeaturePricing::createRoomTypeFeaturePrice($featurePriceParams);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1443,7 +1443,7 @@ class HotelCartBookingData extends ObjectModel
|
||||
* @param [int] $id_group [id_group for which price is need (if available for the passed group)]
|
||||
* @return [array|false] [returns array containg info of the feature plan if foung otherwise returns false]
|
||||
*/
|
||||
public function getProductFeaturePricePlanByDateByPriority(
|
||||
public static function getProductFeaturePricePlanByDateByPriority(
|
||||
$id_product,
|
||||
$date,
|
||||
$id_group,
|
||||
@@ -1453,10 +1453,12 @@ class HotelCartBookingData extends ObjectModel
|
||||
) {
|
||||
if ($id_cart && $id_room) {
|
||||
if ($featurePrice = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` fpr
|
||||
ON (fpr.`id_feature_price` = fp.`id_feature_price`)
|
||||
WHERE fp.`id_product` = '.(int) $id_product.' AND fp.`id_cart` = '.(int) $id_cart.'
|
||||
AND fp.`id_guest` = '.(int) $id_guest.' AND fp.`id_room` = '.(int) $id_room.'
|
||||
AND fp.`active` = 1 AND fp.`date_from` <= \''.pSQL($date).'\'
|
||||
AND fp.`date_to` >= \''.pSQL($date).'\'')
|
||||
AND fp.`active` = 1 AND fpr.`date_from` <= \''.pSQL($date).'\'
|
||||
AND fpr.`date_to` >= \''.pSQL($date).'\'')
|
||||
) {
|
||||
return $featurePrice;
|
||||
}
|
||||
@@ -1472,8 +1474,10 @@ class HotelCartBookingData extends ObjectModel
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
|
||||
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
|
||||
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` fpr
|
||||
ON (fpr.`id_feature_price` = fp.`id_feature_price`)
|
||||
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`active`=1
|
||||
AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fp.`date_from` = \''.pSQL($date).'\''
|
||||
AND fpr.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fpr.`date_from` = \''.pSQL($date).'\''
|
||||
)) {
|
||||
return $featurePrice;
|
||||
}
|
||||
@@ -1482,9 +1486,11 @@ class HotelCartBookingData extends ObjectModel
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
|
||||
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
|
||||
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` fpr
|
||||
ON (fpr.`id_feature_price` = fp.`id_feature_price`)
|
||||
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.'
|
||||
AND fp.`is_special_days_exists`=1 AND fp.`active`=1 AND fp.`date_from` <= \''.pSQL($date).'\'
|
||||
AND fp.`date_to` >= \''.pSQL($date).'\''
|
||||
AND fpr.`is_special_days_exists`=1 AND fp.`active`=1 AND fpr.`date_from` <= \''.pSQL($date).'\'
|
||||
AND fpr.`date_to` >= \''.pSQL($date).'\''
|
||||
)) {
|
||||
foreach ($featurePrice as $fRow) {
|
||||
$specialDays = json_decode($fRow['special_days']);
|
||||
@@ -1498,9 +1504,11 @@ class HotelCartBookingData extends ObjectModel
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
|
||||
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
|
||||
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
|
||||
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE.'
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` fpr
|
||||
ON (fpr.`id_feature_price` = fp.`id_feature_price`)
|
||||
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fpr.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE.'
|
||||
AND `is_special_days_exists`=0 AND `active`=1
|
||||
AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\''
|
||||
AND fpr.`date_from` <= \''.pSQL($date).'\' AND fpr.`date_to` >= \''.pSQL($date).'\''
|
||||
)) {
|
||||
return $featurePrice;
|
||||
}
|
||||
|
||||
@@ -284,11 +284,6 @@ class HotelReservationSystemDb
|
||||
`id_cart` int(11) NOT NULL DEFAULT '0',
|
||||
`id_guest` int(11) NOT NULL DEFAULT '0',
|
||||
`id_room` int(11) NOT NULL DEFAULT '0',
|
||||
`date_from` date NOT NULL,
|
||||
`date_to` date NOT NULL,
|
||||
`is_special_days_exists` tinyint(1) NOT NULL,
|
||||
`date_selection_type` tinyint(1) NOT NULL,
|
||||
`special_days` text,
|
||||
`impact_way` tinyint(1) NOT NULL,
|
||||
`impact_type` tinyint(1) NOT NULL,
|
||||
`impact_value` decimal(20,6) NOT NULL DEFAULT '0.000000',
|
||||
@@ -298,6 +293,19 @@ class HotelReservationSystemDb
|
||||
PRIMARY KEY (`id_feature_price`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
|
||||
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_feature_pricing_rule` (
|
||||
`id_feature_price_rule` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_feature_price` int(11) NOT NULL,
|
||||
`is_special_days_exists` tinyint(1) NOT NULL,
|
||||
`date_selection_type` tinyint(1) NOT NULL,
|
||||
`special_days` text,
|
||||
`date_from` date NOT NULL,
|
||||
`date_to` date NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_feature_price_rule`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
|
||||
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_feature_pricing_lang` (
|
||||
`id_feature_price` int(10) unsigned NOT NULL,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
@@ -582,6 +590,7 @@ class HotelReservationSystemDb
|
||||
`'._DB_PREFIX_.'htl_room_type_feature_pricing`,
|
||||
`'._DB_PREFIX_.'htl_room_type_feature_pricing_lang`,
|
||||
`'._DB_PREFIX_.'htl_room_type_feature_pricing_group`,
|
||||
`'._DB_PREFIX_.'htl_room_type_feature_pricing_rule`,
|
||||
`'._DB_PREFIX_.'htl_room_type_global_demand`,
|
||||
`'._DB_PREFIX_.'htl_room_type_global_demand_lang`,
|
||||
`'._DB_PREFIX_.'htl_room_type_global_demand_advance_option`,
|
||||
|
||||
@@ -25,11 +25,6 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
public $id_guest = 0;
|
||||
public $id_room = 0;
|
||||
public $feature_price_name;
|
||||
public $date_selection_type;
|
||||
public $date_from;
|
||||
public $date_to;
|
||||
public $is_special_days_exists;
|
||||
public $special_days;
|
||||
public $impact_way;
|
||||
public $impact_type;
|
||||
public $impact_value;
|
||||
@@ -60,12 +55,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_room' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
|
||||
'date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'impact_way' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'is_special_days_exists' => array('type' => self::TYPE_INT, 'required' => true),
|
||||
'date_selection_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'special_days' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
||||
'impact_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'impact_value' => array('type' => self::TYPE_FLOAT, 'required' => true),
|
||||
'active' => array('type' => self::TYPE_INT),
|
||||
@@ -93,6 +83,19 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
),
|
||||
'associations' => array(
|
||||
'groups' => array('resource' => 'group'),
|
||||
'price_rules' => array(
|
||||
'resource' => 'price_rule',
|
||||
'getter' => 'getWsAdvancePriceRule',
|
||||
'setter' => 'setWsAdvancePriceRule',
|
||||
'fields' => array(
|
||||
'id' => array(),
|
||||
'date_from' => array(),
|
||||
'date_to' => array(),
|
||||
'date_selection_type' => array(),
|
||||
'is_special_days_exists' => array(),
|
||||
'special_days' => array(),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -123,119 +126,109 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
{
|
||||
// first call to delete all the group entries
|
||||
$this->cleanGroups();
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
|
||||
if ($oldFeaturePriceRules = $objFeaturePriceRule->getRulesByIdFeaturePrice($this->id)) {
|
||||
$objFeaturePriceRule->deleteFeaturePriceRules($oldFeaturePriceRules);
|
||||
}
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
public function getFeaturePriceInfo($idFeaturePrice)
|
||||
{
|
||||
if (!$idFeaturePrice) {
|
||||
return false;
|
||||
}
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` WHERE `id_feature_price`='.
|
||||
(int) $idFeaturePrice
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* [getRoomTypeActiveFeaturePrices returns room type active feature price plans]
|
||||
* @param [int] $id_product [id of the product]
|
||||
* @return [array|false] [returns array of all active feature plans of the room type if found else returns false]
|
||||
*/
|
||||
public static function getRoomTypeActiveFeaturePrices($id_product)
|
||||
{
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing`
|
||||
WHERE `id_product`='.(int) $id_product.' AND `active`=1'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* [getRoomTypeActiveFeaturePricesByDateRange returns room type active feature price plans by supplied date Range]
|
||||
* @param [int] $id_product [id of the product]
|
||||
* @param [date] $date_from [start date of the date range]
|
||||
* @param [date] $date_to [end date of the date range]
|
||||
* @return [array|false] [returns array of all active feature plans of the room type if found else returns false]
|
||||
*/
|
||||
public static function getRoomTypeActiveFeaturePricesByDateRange($id_product, $date_from, $date_to)
|
||||
{
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing`
|
||||
WHERE (`id_product`=0 OR `id_product`='.(int) $id_product.')
|
||||
AND `active`=1 AND `date_from` <= \''.$date_to.'\' AND `date_to` >= \''.$date_from.'\''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* [checkRoomTypeFeaturePriceExistance returns room type active feature price plan by supplied date Range and supplied feature price plan type else returns false]
|
||||
* @param [int] $id_product [id of the product]
|
||||
* @param [date] $date_from [start date of the date range]
|
||||
* @param [date] $date_to [end date of the date range]
|
||||
* @param [type] $type [Type of the feature price plan must be among 'specific_date', 'special_day' and 'date_range']
|
||||
* @return [array|false] [returns room type active feature price plan by supplied date Range and supplied feature price plan type else returns false]
|
||||
*/
|
||||
public function checkRoomTypeFeaturePriceExistance(
|
||||
$id_product,
|
||||
$date_from,
|
||||
$date_to,
|
||||
public function getExistingFeaturePriceRules(
|
||||
$idRoomType,
|
||||
$groups,
|
||||
$type = 'date_range',
|
||||
$current_Special_days = false,
|
||||
$id_feature_price = 0
|
||||
$idFeaturePrice,
|
||||
$featurePriceRules
|
||||
) {
|
||||
$date_from = date('Y-m-d', strtotime($date_from));
|
||||
$date_to = date('Y-m-d', strtotime($date_to));
|
||||
if ($type == 'specific_date') {
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg
|
||||
ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price`)
|
||||
WHERE rtfp.`id_product`='.(int) $id_product.' AND rtfp.`active`=1
|
||||
AND rtfp.`date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_SPECIFIC.'
|
||||
AND rtfp.`date_from` = \''.pSQL($date_from).'\'
|
||||
AND rtfp.`id_feature_price`!='.(int) $id_feature_price.'
|
||||
AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')'
|
||||
);
|
||||
} elseif ($type == 'special_day') {
|
||||
$featurePrices = Db::getInstance()->executeS(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg
|
||||
ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price`)
|
||||
WHERE rtfp.`id_product`='.(int) $id_product.'
|
||||
AND rtfp.`is_special_days_exists`=1 AND `active`=1
|
||||
AND rtfp.`date_from` < \''.pSQL($date_to).'\'
|
||||
AND rtfp.`date_to` > \''.pSQL($date_from).'\'
|
||||
AND rtfp.`id_feature_price`!='.(int) $id_feature_price.'
|
||||
AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')'
|
||||
);
|
||||
if ($featurePrices) {
|
||||
foreach ($featurePrices as $featurePrice) {
|
||||
$specialDays = json_decode($featurePrice['special_days']);
|
||||
$currentSpecialDays = json_decode($current_Special_days);
|
||||
$commonValues = array_intersect($specialDays, $currentSpecialDays);
|
||||
if ($commonValues) {
|
||||
return $featurePrice;
|
||||
}
|
||||
$sql = 'SELECT *, GROUP_CONCAT(rtfpg.`id_group`) AS id_group FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` rtfpr
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp
|
||||
ON (rtfpr.`id_feature_price` = rtfp.`id_feature_price` AND rtfp.`id_product`='.(int) $idRoomType.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg
|
||||
ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price` AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).'))
|
||||
WHERE rtfpr.`id_feature_price`!='.(int) $idFeaturePrice.' AND rtfp.`active`= 1';
|
||||
$sqlWhere = '';
|
||||
foreach ($featurePriceRules as $featurePriceRule) {
|
||||
if ($sqlWhere != '') {
|
||||
$sqlWhere .= ' OR ';
|
||||
}
|
||||
|
||||
$dateFrom = date('Y-m-d', strtotime($featurePriceRule['date_from']));
|
||||
$dateTo = date('Y-m-d', strtotime($featurePriceRule['date_to']));
|
||||
if ($featurePriceRule['date_selection_type'] == self::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
$sqlWhere .= ' (rtfpr.`date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_SPECIFIC.'
|
||||
AND rtfpr.`date_from` = \''.pSQL($dateFrom).'\')';
|
||||
} else if ($featurePriceRule['date_selection_type'] == self::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($featurePriceRule['is_special_days_exists']) {
|
||||
$sqlWhere .= ' (rtfpr.`is_special_days_exists`=1
|
||||
AND rtfpr.`date_from` < \''.pSQL($dateTo).'\'
|
||||
AND rtfpr.`date_to` > \''.pSQL($dateFrom).'\')';
|
||||
} else {
|
||||
$sqlWhere .= ' (rtfpr.`date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_RANGE.'
|
||||
AND rtfpr.`is_special_days_exists`=0
|
||||
AND rtfpr.`date_from` <= \''.pSQL($dateTo).'\'
|
||||
AND rtfpr.`date_to` >= \''.pSQL($dateFrom).'\')';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} elseif ($type == 'date_range') {
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg
|
||||
ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price`)
|
||||
WHERE rtfp.`id_product`='.(int) $id_product.' AND rtfp.`active`=1
|
||||
AND rtfp.`date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_RANGE.'
|
||||
AND rtfp.`is_special_days_exists`=0
|
||||
AND rtfp.`date_from` <= \''.pSQL($date_to).'\'
|
||||
AND rtfp.`date_to` >= \''.pSQL($date_from).'\'
|
||||
AND rtfp.`id_feature_price`!='.(int) $id_feature_price.'
|
||||
AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')'
|
||||
);
|
||||
}
|
||||
return false;
|
||||
|
||||
if ($sqlWhere != '') {
|
||||
$sqlWhere = ' AND ('.$sqlWhere.')';
|
||||
}
|
||||
|
||||
$sql .= $sqlWhere.' GROUP BY rtfpr.`id_feature_price`';
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
public function saveUpdateFeaturePrices($idFeaturePrice, $featurePriceRules)
|
||||
{
|
||||
$res = true;
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
|
||||
if ($oldFeaturePriceRules = $objFeaturePriceRule->getRulesByIdFeaturePrice($idFeaturePrice)) {
|
||||
$oldFeaturePriceRules = array_column($oldFeaturePriceRules, 'id_feature_price_rule', 'id_feature_price_rule');
|
||||
}
|
||||
|
||||
if ($featurePriceRules) {
|
||||
foreach ($featurePriceRules as $featurePriceRule) {
|
||||
if (isset($featurePriceRule['id']) && in_array($featurePriceRule['id'], $oldFeaturePriceRules)) {
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule($featurePriceRule['id']);
|
||||
unset($oldFeaturePriceRules[$featurePriceRule['id']]);
|
||||
} else {
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
|
||||
}
|
||||
|
||||
$objFeaturePriceRule->id_feature_price = $idFeaturePrice;
|
||||
$objFeaturePriceRule->date_from = $featurePriceRule['date_from'];
|
||||
$objFeaturePriceRule->date_to = $featurePriceRule['date_to'];
|
||||
$objFeaturePriceRule->date_selection_type = isset($featurePriceRule['date_selection_type']) ? $featurePriceRule['date_selection_type'] : HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
|
||||
$objFeaturePriceRule->special_days = json_encode(array());
|
||||
if ($objFeaturePriceRule->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE
|
||||
&& $featurePriceRule['is_special_days_exists']
|
||||
) {
|
||||
$objFeaturePriceRule->is_special_days_exists = isset($featurePriceRule['is_special_days_exists']) ? $featurePriceRule['is_special_days_exists'] : 0;
|
||||
if (isset($featurePriceRule['is_special_days_exists'])
|
||||
&& $featurePriceRule['is_special_days_exists']
|
||||
&& isset($featurePriceRule['special_days'])
|
||||
&& $featurePriceRule['special_days']
|
||||
) {
|
||||
$objFeaturePriceRule->special_days = json_encode($featurePriceRule['special_days']);
|
||||
}
|
||||
} else {
|
||||
$objFeaturePriceRule->is_special_days_exists = 0;
|
||||
}
|
||||
|
||||
$res &= $objFeaturePriceRule->save();
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldFeaturePriceRules) {
|
||||
$res &= $objFeaturePriceRule->deleteFeaturePriceRules($oldFeaturePriceRules);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [countFeaturePriceSpecialDays returns number of special days between a date range]
|
||||
* @param [array] $specialDays [array containing special days to be counted]
|
||||
@@ -309,9 +302,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$context = Context::getContext();
|
||||
$id_currency = Validate::isLoadedObject($context->currency) ? (int)$context->currency->id : (int)Configuration::get('PS_CURRENCY_DEFAULT');
|
||||
|
||||
$hotelCartBookingData = new HotelCartBookingData();
|
||||
for($currentDate = date('Y-m-d', strtotime($date_from)); $currentDate < date('Y-m-d', strtotime($date_to)); $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))) {
|
||||
if ($use_reduc && ($featurePrice = $hotelCartBookingData->getProductFeaturePricePlanByDateByPriority(
|
||||
if ($use_reduc && ($featurePrice = HotelCartBookingData::getProductFeaturePricePlanByDateByPriority(
|
||||
$id_product,
|
||||
$currentDate,
|
||||
$id_group,
|
||||
@@ -492,9 +484,12 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
{
|
||||
$idLang = Context::getContext()->language->id;
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT hrfp.*, hrfpl.`feature_price_name` FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` hrfp
|
||||
'SELECT hrfp.*, hrfpr.`date_from`, hrfpr.`date_to`, hrfpr.`date_selection_type`, hrfpr.`is_special_days_exists`, hrfpr.`special_days`, hrfpl.`feature_price_name`
|
||||
FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` hrfp
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_lang` hrfpl
|
||||
ON(hrfp.`id_feature_price` = hrfpl.`id_feature_price` AND hrfpl.`id_lang` = '.(int)$idLang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` hrfpr
|
||||
ON (hrfpr.`id_feature_price` = hrfp.`id_feature_price`)
|
||||
WHERE `id_product` = '.(int)$id_product.' AND `id_cart` = '.(int)$id_cart.' AND `id_guest` = '.(int)$id_guest.' AND `id_room` = '.(int)$id_room
|
||||
);
|
||||
}
|
||||
@@ -545,13 +540,15 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
}
|
||||
|
||||
$idfeaturePrices = Db::getInstance()->executeS(
|
||||
'SELECT `id_feature_price` FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing`
|
||||
'SELECT hrfp.`id_feature_price` FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` hrfp
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` hrfpr
|
||||
ON (hrfpr.`id_feature_price` = hrfp.`id_feature_price`)
|
||||
WHERE 1'.
|
||||
($id_cart ? ' AND `id_cart` = '.(int) $id_cart : '').
|
||||
($id_product ? ' AND `id_product` = '.(int) $id_product : '').
|
||||
($id_room ? ' AND `id_room` = '.(int) $id_room : '').
|
||||
($date_from ? ' AND `date_from` = "'.pSQL($date_from) .'"' : '').
|
||||
($date_to ? ' AND `date_to` = "'.pSQL($date_to) .'"' : '')
|
||||
($id_cart ? ' AND hrfp.`id_cart` = '.(int) $id_cart : '').
|
||||
($id_product ? ' AND hrfp.`id_product` = '.(int) $id_product : '').
|
||||
($id_room ? ' AND hrfp.`id_room` = '.(int) $id_room : '').
|
||||
($date_from ? ' AND hrfpr.`date_from` = "'.pSQL($date_from) .'"' : '').
|
||||
($date_to ? ' AND hrfpr.`date_to` = "'.pSQL($date_to) .'"' : '')
|
||||
);
|
||||
$res = true;
|
||||
foreach ($idfeaturePrices as $featurePrice) {
|
||||
@@ -640,25 +637,192 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getWsAdvancePriceRule()
|
||||
{
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT *, id_feature_price_rule AS `id` FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule`
|
||||
WHERE `id_feature_price` ='.(int)$this->id.' ORDER BY `id_feature_price` ASC'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function setWsAdvancePriceRule($priceRules)
|
||||
{
|
||||
foreach ($priceRules as $ruleKey => $priceRule) {
|
||||
if ($priceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE
|
||||
&& $priceRule['is_special_days_exists']
|
||||
) {
|
||||
$specialDays = json_decode($priceRule['special_days'], true);
|
||||
$priceRules[$ruleKey]['special_days'] = $specialDays;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->saveUpdateFeaturePrices($this->id, $priceRules);
|
||||
}
|
||||
|
||||
public function validateExistingFeaturePrice(
|
||||
$roomTypeId,
|
||||
$group,
|
||||
$idFeaturePrice,
|
||||
$featurePriceRules
|
||||
) {
|
||||
$duplicateRules = array();
|
||||
if ($oldPriceRules = $this->getExistingFeaturePriceRules(
|
||||
$roomTypeId,
|
||||
$group,
|
||||
$idFeaturePrice,
|
||||
$featurePriceRules
|
||||
)) {
|
||||
foreach ($oldPriceRules as $oldPriceRule) {
|
||||
foreach ($featurePriceRules as $ruleKey => $rule) {
|
||||
if ($rule['date_selection_type'] == $oldPriceRule['date_selection_type']) {
|
||||
if ($rule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if (strtotime($rule['date_from']) != strtotime($oldPriceRule['date_from'])) {
|
||||
continue;
|
||||
} else {
|
||||
$duplicateRules[] = $ruleKey;
|
||||
}
|
||||
} else if ($rule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if (((strtotime($oldPriceRule['date_from']) < strtotime($rule['date_from'])) && (strtotime($oldPriceRule['date_to']) <= strtotime($rule['date_from']))) || ((strtotime($oldPriceRule['date_from']) > strtotime($rule['date_from'])) && (strtotime($oldPriceRule['date_from']) >= strtotime($rule['date_to'])))) {
|
||||
continue;
|
||||
} else {
|
||||
if ($oldPriceRule['is_special_days_exists'] && $rule['is_special_days_exists']) {
|
||||
if (!empty($oldPriceRule['special_days']) && !empty($rule['special_days'])) {
|
||||
$existingDays = json_decode($oldPriceRule['special_days'], true);
|
||||
if (array_intersect($existingDays, $rule['special_days'])) {
|
||||
$duplicateRules[] = $ruleKey;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$duplicateRules[] = $ruleKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $duplicateRules;
|
||||
}
|
||||
|
||||
public function validateFields($die = true, $error_return = false)
|
||||
{
|
||||
if (isset($this->webservice_validation) && $this->webservice_validation) {
|
||||
$weekDays = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
||||
if($this->is_special_days_exists) {
|
||||
if ($this->special_days
|
||||
&& ($specialDays = json_decode($this->special_days, true))
|
||||
) {
|
||||
if (is_array($specialDays) && $specialDays) {
|
||||
if (count(array_diff($specialDays, $weekDays))) {
|
||||
$message = Tools::displayError('Invalid special days. format must match with : ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]', false);
|
||||
$priceRules = array();
|
||||
$idGroups = array();
|
||||
if (isset($this->associations)) {
|
||||
foreach ($this->associations->children() as $association) {
|
||||
if ($association->getName() == 'price_rules') {
|
||||
$assocItems = $association->children();
|
||||
foreach ($assocItems as $assocItem) {
|
||||
/** @var SimpleXMLElement $assocItem */
|
||||
$fields = $assocItem->children();
|
||||
$entry = array();
|
||||
foreach ($fields as $fieldName => $fieldValue) {
|
||||
$entry[$fieldName] = (string)$fieldValue;
|
||||
}
|
||||
|
||||
$priceRules[] = $entry;
|
||||
}
|
||||
} else if ($association->getName() == 'groups') {
|
||||
$assocItems = $association->children();
|
||||
foreach ($assocItems as $assocItem) {
|
||||
/** @var SimpleXMLElement $assocItem */
|
||||
$fields = $assocItem->children();
|
||||
$entry = array();
|
||||
foreach ($fields as $fieldName => $fieldValue) {
|
||||
$entry[$fieldName] = (string)$fieldValue;
|
||||
}
|
||||
|
||||
$idGroups[] = $entry;
|
||||
}
|
||||
} else {
|
||||
$message = Tools::displayError('Invalid special days. format must match with : ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]', false);
|
||||
}
|
||||
} else {
|
||||
$message = Tools::displayError('Invalid special days. format must match with : ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]', false);
|
||||
}
|
||||
}
|
||||
if ($idGroups) {
|
||||
$idGroups = array_column($idGroups, 'id');
|
||||
}
|
||||
|
||||
if ($priceRules) {
|
||||
$hasError = false;
|
||||
$weekDays = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
||||
// check for invalid special days
|
||||
foreach ($priceRules as $ruleKey => $priceRule) {
|
||||
if ($priceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($priceRule['is_special_days_exists']) {
|
||||
$specialDays = json_decode($priceRule['special_days'], true);
|
||||
$priceRules[$ruleKey]['special_days'] = $specialDays;
|
||||
if (is_array($specialDays) && $specialDays) {
|
||||
if (count(array_diff($specialDays, $weekDays))) {
|
||||
$message = Tools::displayError('Invalid special days. format must match with : ["mon", "tue", "wed", "thu", "fri", "sat", "sun"].', true);
|
||||
$hasError = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$message = Tools::displayError('Invalid special days. format must match with : ["mon", "tue", "wed", "thu", "fri", "sat", "sun"].', true);
|
||||
$hasError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasError) {
|
||||
// check for conflicting dates in the rules.
|
||||
foreach ($priceRules as $priceRuleKey => $priceRule) {
|
||||
foreach ($priceRules as $ruleKey => $rule) {
|
||||
if ($priceRuleKey != $ruleKey) {
|
||||
if ($rule['date_selection_type'] == $priceRule['date_selection_type']) {
|
||||
if ($rule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if (strtotime($rule['date_from']) != strtotime($priceRule['date_from'])) {
|
||||
continue;
|
||||
} else {
|
||||
$message = Tools::displayError('You can not add conflicting dates.', true);
|
||||
$hasError = true;
|
||||
break;
|
||||
}
|
||||
} else if ($rule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if (((strtotime($priceRule['date_from']) < strtotime($rule['date_from'])) && (strtotime($priceRule['date_to']) <= strtotime($rule['date_from']))) || ((strtotime($priceRule['date_from']) > strtotime($rule['date_from'])) && (strtotime($priceRule['date_from']) >= strtotime($rule['date_to'])))) {
|
||||
continue;
|
||||
} else {
|
||||
if ($priceRule['is_special_days_exists'] && $rule['is_special_days_exists']) {
|
||||
if (!empty($priceRule['special_days']) && !empty($rule['special_days'])) {
|
||||
if (array_intersect($priceRule['special_days'], $rule['special_days'])) {
|
||||
$message = Tools::displayError('You can not add conflicting days for similar date ranges.', true);
|
||||
$hasError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = Tools::displayError('You can not add conflicting date ranges.', true);
|
||||
$hasError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasError) {
|
||||
$hasDuplicate = $this->validateExistingFeaturePrice(
|
||||
$this->id_product,
|
||||
$idGroups,
|
||||
$this->id,
|
||||
$priceRules
|
||||
);
|
||||
|
||||
if ($hasDuplicate) {
|
||||
$message = Tools::displayError('An advanced price rule already exists with overlapping conditions.', false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = Tools::displayError('Price rules are required.', false);
|
||||
}
|
||||
|
||||
if (isset($message) && $message != '') {
|
||||
if ($die) {
|
||||
@@ -671,30 +835,39 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
|
||||
return parent::validateFields($die, $error_return);
|
||||
}
|
||||
public static function createAutoFeaturePrice($params)
|
||||
|
||||
public static function createRoomTypeFeaturePrice($params)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$featurePriceName = array();
|
||||
foreach (Language::getIDs(true) as $idLang) {
|
||||
$featurePriceName[$idLang] = 'Auto-generated';
|
||||
if (isset($params['name']) && $params['name']) {
|
||||
$featurePriceName[$idLang] = $params['name'];
|
||||
} else {
|
||||
$featurePriceName[$idLang] = 'Auto-generated';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['id']) && $params['id']) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing($params['id']);
|
||||
} else {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
}
|
||||
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
$objFeaturePricing->id_product = (int) $params['id_product'];
|
||||
$objFeaturePricing->id_cart = (int) $params['id_cart'];
|
||||
$objFeaturePricing->id_guest = (int) $params['id_guest'];
|
||||
$objFeaturePricing->id_room = (int) $params['id_room'];
|
||||
$objFeaturePricing->id_cart = (int) isset($params['id_cart']) ? $params['id_cart'] : 0;
|
||||
$objFeaturePricing->id_guest = (int) isset($params['id_guest']) ? $params['id_guest'] : 0;
|
||||
$objFeaturePricing->id_room = (int) isset($params['id_room']) ? $params['id_room'] : 0;
|
||||
$objFeaturePricing->feature_price_name = $featurePriceName;
|
||||
$objFeaturePricing->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
|
||||
$objFeaturePricing->date_from = date('Y-m-d', strtotime($params['date_from']));
|
||||
$objFeaturePricing->date_to = date('Y-m-d', strtotime($params['date_to']));
|
||||
$objFeaturePricing->is_special_days_exists = 0;
|
||||
$objFeaturePricing->special_days = json_encode(false);
|
||||
$objFeaturePricing->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
|
||||
$objFeaturePricing->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
$objFeaturePricing->impact_value = $params['price'];
|
||||
$objFeaturePricing->active = 1;
|
||||
$objFeaturePricing->groupBox = array_column(Group::getGroups($context->language->id), 'id_group');
|
||||
$objFeaturePricing->add();
|
||||
$objFeaturePricing->impact_way = isset($params['impact_way']) ? $params['impact_way'] : HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
|
||||
$objFeaturePricing->impact_type = isset($params['impact_type']) ? $params['impact_type'] : HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
$objFeaturePricing->impact_value = isset($params['price']) ? $params['price'] : 0;
|
||||
$objFeaturePricing->active = isset($params['active']) ? $params['active'] : 1;
|
||||
$objFeaturePricing->groupBox = !empty($params['groupBox']) ? $params['groupBox'] : array_column(Group::getGroups($context->language->id), 'id_group');
|
||||
if ($objFeaturePricing->add()) {
|
||||
$objFeaturePricing->saveUpdateFeaturePrices($objFeaturePricing->id, $params['price_rules']);
|
||||
}
|
||||
|
||||
return $objFeaturePricing->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2020 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2020 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class HotelRoomTypeFeaturePricingRule extends ObjectModel
|
||||
{
|
||||
public $id_feature_price;
|
||||
public $date_selection_type;
|
||||
public $date_from;
|
||||
public $date_to;
|
||||
public $is_special_days_exists;
|
||||
public $special_days;
|
||||
public $date_add;
|
||||
public $date_upd;
|
||||
public static $definition = array(
|
||||
'table' => 'htl_room_type_feature_pricing_rule',
|
||||
'primary' => 'id_feature_price_rule',
|
||||
'multilang' => false,
|
||||
'fields' => array(
|
||||
'id_feature_price' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
|
||||
'date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'is_special_days_exists' => array('type' => self::TYPE_INT, 'required' => true),
|
||||
'date_selection_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'special_days' => 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')
|
||||
)
|
||||
);
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectsNodeName' => 'price_rules',
|
||||
'objectNodeName' => 'price_rule',
|
||||
'fields' => array(
|
||||
'id_feature_price' => array(
|
||||
'xlink_resource' => array(
|
||||
'resourceName' => 'feature_prices',
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
public function getRulesByIdFeaturePrice($idFeaturePrice)
|
||||
{
|
||||
$sql = 'SELECT *, id_feature_price_rule AS `id` FROM `'._DB_PREFIX_.$this->table.'`
|
||||
WHERE `id_feature_price` ='.(int) $idFeaturePrice;
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
public function deleteFeaturePriceRules($featurePriceRules)
|
||||
{
|
||||
$res = true;
|
||||
if ($featurePriceRules) {
|
||||
foreach ($featurePriceRules as $idFeaturePriceRules) {
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule($idFeaturePriceRules);
|
||||
$res &= $objFeaturePriceRule->delete();
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
$this->_new_list_header_design = true;
|
||||
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang`='.(int) $this->context->language->id.')';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_lang` fpl ON (a.id_feature_price = fpl.id_feature_price AND fpl.`id_lang` = '.(int) $this->context->language->id.')';
|
||||
@@ -57,8 +58,16 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
|
||||
$this->_where = ' AND a.`id_cart` = 0 AND a.`id_guest` = 0 AND a.`id_room` = 0';
|
||||
|
||||
$impactWays = array(1 => $this->l('Decrease'), 2 => $this->l('Increase'), 3 => $this->l('Fix'));
|
||||
$impactTypes = array(1 => $this->l('Percentage'), 2 => $this->l('Fixed Price'));
|
||||
$impactWays = array(
|
||||
HotelRoomTypeFeaturePricing::IMPACT_WAY_DECREASE => $this->l('Decrease'),
|
||||
HotelRoomTypeFeaturePricing::IMPACT_WAY_INCREASE => $this->l('Increase'),
|
||||
HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE => $this->l('Fix')
|
||||
);
|
||||
|
||||
$impactTypes = array(
|
||||
HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE => $this->l('Percentage'),
|
||||
HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE => $this->l('Fixed Price')
|
||||
);
|
||||
|
||||
$priorities = Configuration::get('HTL_FEATURE_PRICING_PRIORITY');
|
||||
$this->context->smarty->assign('featurePricePriority', explode(';', $priorities));
|
||||
@@ -111,17 +120,6 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
'callback' => 'setGroupAccessLabel',
|
||||
'search' => false,
|
||||
),
|
||||
'date_from' => array(
|
||||
'title' => $this->l('Date From'),
|
||||
'align' => 'center',
|
||||
'type' => 'date',
|
||||
),
|
||||
'date_to' => array(
|
||||
'title' => $this->l('Date To'),
|
||||
'align' => 'center',
|
||||
'type' => 'date',
|
||||
'callback' => 'getDateToValue',
|
||||
),
|
||||
'active' => array(
|
||||
'align' => 'center',
|
||||
'title' => $this->l('Status'),
|
||||
@@ -176,20 +174,15 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
public function processStatus()
|
||||
{
|
||||
$objFeaturePricing = $this->loadObject();
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
|
||||
if (!$objFeaturePricing->active) {
|
||||
if ($this->validateExistingFeaturePrice(
|
||||
$objFeaturePricing->date_selection_type,
|
||||
if ($this->object->validateExistingFeaturePrice(
|
||||
$objFeaturePricing->id_product,
|
||||
$objFeaturePricing->date_from,
|
||||
$objFeaturePricing->date_to,
|
||||
$objFeaturePricing->getGroups($objFeaturePricing->id),
|
||||
$objFeaturePricing->id,
|
||||
$objFeaturePricing->is_special_days_exists,
|
||||
$objFeaturePricing->special_days
|
||||
|
||||
|
||||
$objFeaturePriceRule->getRulesByIdFeaturePrice($objFeaturePricing->id)
|
||||
)) {
|
||||
$this->errors[] = $this->l('An advanced price rule already exists in which some dates are common with this plan. Please select a different date range.');
|
||||
$this->errors[] = $this->l('An advanced price rule already exists with overlapping conditions. Please update the existing rule to activate this one.');
|
||||
return ;
|
||||
}
|
||||
}
|
||||
@@ -221,17 +214,21 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
if (!$this->loadObject(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$smartyVars = array();
|
||||
$objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$currencySign = $objCurrency->sign;
|
||||
$dateFrom = date('d-m-Y');
|
||||
$dateTo = date('d-m-Y', strtotime($dateFrom) + 86400);
|
||||
$dateFrom = date('Y-m-d');
|
||||
$dateTo = date('Y-m-d', strtotime($dateFrom) + 86400);
|
||||
$currentLangId = $this->default_form_language ? $this->default_form_language : Configuration::get('PS_LANG_DEFAULT');
|
||||
|
||||
$smartyVars['languages'] = Language::getLanguages(false);
|
||||
$smartyVars['currentLang'] = Language::getLanguage((int) $currentLangId);
|
||||
|
||||
if ($this->display == 'edit') {
|
||||
if ($this->display == 'edit' && $this->object->id) {
|
||||
$idFeaturePrice = Tools::getValue('id_feature_price');
|
||||
if (Validate::isLoadedObject(
|
||||
$objFeaturePrice = new HotelRoomTypeFeaturePricing($idFeaturePrice)
|
||||
@@ -241,12 +238,24 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$smartyVars['productName'] = $product->name;
|
||||
}
|
||||
}
|
||||
if ($objFeaturePrice->special_days) {
|
||||
$smartyVars['special_days'] = (array)json_decode($objFeaturePrice->special_days);
|
||||
}
|
||||
|
||||
$smartyVars['objFeaturePrice'] = $objFeaturePrice;
|
||||
$smartyVars['edit'] = 1;
|
||||
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
|
||||
if ($advancePriceRules = $objFeaturePriceRule->getRulesByIdFeaturePrice($objFeaturePrice->id)) {
|
||||
foreach ($advancePriceRules as $priceRuleKey => $advancePriceRule) {
|
||||
if ($advancePriceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
$advancePriceRules[$priceRuleKey]['specific_date'] = $advancePriceRule['date_from'];
|
||||
unset($advancePriceRules[$priceRuleKey]['date_from']);
|
||||
unset($advancePriceRules[$priceRuleKey]['date_to']);
|
||||
} else if ($advancePriceRule['is_special_days_exists']) {
|
||||
$advancePriceRules[$priceRuleKey]['special_days'] = json_decode($advancePriceRule['special_days'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$smartyVars['advancePriceRules'] = $advancePriceRules;
|
||||
$smartyVars['feature_price_groups'] = $objFeaturePrice->getGroups($idFeaturePrice);
|
||||
} else {
|
||||
$tree = new HelperTree('hotels-tree');
|
||||
@@ -272,6 +281,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$smartyVars['hotel_tree'] = $tree->render();
|
||||
}
|
||||
|
||||
$smartyVars['week_days'] = $this->getWeekDays();
|
||||
$smartyVars['defaultcurrency_sign'] = $currencySign;
|
||||
$smartyVars['date_from'] = $dateFrom;
|
||||
$smartyVars['date_to'] = $dateTo;
|
||||
@@ -287,6 +297,19 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function getWeekDays()
|
||||
{
|
||||
return array(
|
||||
'mon' => $this->l('Mon'),
|
||||
'tue' => $this->l('Tue'),
|
||||
'wed' => $this->l('Wed'),
|
||||
'thu' => $this->l('Thu'),
|
||||
'fri' => $this->l('Fri'),
|
||||
'sat' => $this->l('Sat'),
|
||||
'sun' => $this->l('Sun')
|
||||
);
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitAddFeaturePricePriority')) {
|
||||
@@ -307,72 +330,26 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function validateExistingFeaturePrice(
|
||||
$dateSelectionType,
|
||||
$roomTypeId,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$group,
|
||||
$idFeaturePrice,
|
||||
$isSpecialDaysExists = false,
|
||||
$jsonSpecialDays = "false"
|
||||
) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
return $objFeaturePricing->checkRoomTypeFeaturePriceExistance(
|
||||
$roomTypeId,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$group,
|
||||
'specific_date',
|
||||
false,
|
||||
$idFeaturePrice
|
||||
);
|
||||
} elseif (isset($isSpecialDaysExists) && $isSpecialDaysExists && $jsonSpecialDays != "false") {
|
||||
return $objFeaturePricing->checkRoomTypeFeaturePriceExistance(
|
||||
$roomTypeId,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$group,
|
||||
'special_day',
|
||||
$jsonSpecialDays,
|
||||
$idFeaturePrice
|
||||
);
|
||||
} else {
|
||||
return $objFeaturePricing->checkRoomTypeFeaturePriceExistance(
|
||||
$roomTypeId,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$group,
|
||||
'date_range',
|
||||
false,
|
||||
$idFeaturePrice
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSave()
|
||||
{
|
||||
if (!$this->loadObject(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$idFeaturePrice = Tools::getValue('id_feature_price');
|
||||
if (!isset($idFeaturePrice) || !$idFeaturePrice) {
|
||||
$idFeaturePrice = 0;
|
||||
}
|
||||
$enableFeaturePrice = Tools::getValue('enable_feature_price');
|
||||
$roomTypeId = Tools::getValue('room_type_id');
|
||||
$dateFrom = Tools::getValue('date_from');
|
||||
$dateTo = Tools::getValue('date_to');
|
||||
$isSpecialDaysExists = Tools::getValue('is_special_days_exists');
|
||||
$specialDays = Tools::getValue('special_days');
|
||||
$priceImpactWay = Tools::getValue('price_impact_way');
|
||||
$priceImpactType = Tools::getValue('price_impact_type');
|
||||
$impactValue = Tools::getValue('impact_value');
|
||||
$dateSelectionType = Tools::getValue('date_selection_type');
|
||||
$specificDate = date('Y-m-d', strtotime(Tools::getValue('specific_date')));
|
||||
$groups = Tools::getValue('groupBox');
|
||||
$jsonSpecialDays = json_encode($specialDays);
|
||||
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
|
||||
$createMultiple = Tools::getValue('create_multiple');
|
||||
|
||||
$priceRules = Tools::getValue('advance_price_rule', array());
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
if ($priceImpactWay == HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE) {
|
||||
$priceImpactType = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
@@ -448,39 +425,90 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
$dateFrom = $specificDate;
|
||||
$dateTo = date('Y-m-d', strtotime("+1 day", strtotime($specificDate)));
|
||||
} else if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($dateFrom == '') {
|
||||
$this->errors[] = $this->l('Please choose Date from for the advanced price rule.');
|
||||
}
|
||||
if ($dateTo == '') {
|
||||
$this->errors[] = $this->l('Please choose Date to for the advanced price rule.');
|
||||
}
|
||||
$dateFrom = date('Y-m-d', strtotime($dateFrom));
|
||||
$dateTo = date('Y-m-d', strtotime($dateTo));
|
||||
if (!Validate::isDate($dateFrom)) {
|
||||
$this->errors[] = $this->l('Invalid Date From.');
|
||||
}
|
||||
if (!Validate::isDate($dateTo)) {
|
||||
$this->errors[] = $this->l('Invalid Date To.');
|
||||
}
|
||||
if ($dateTo < $dateFrom) {
|
||||
$this->errors[] = $this->l('Date To cannot be smaller than Date From.');
|
||||
}
|
||||
if ($isSpecialDaysExists) {
|
||||
if (!isset($specialDays) || !$specialDays) {
|
||||
$rowsToHighlight = [];
|
||||
if (!$priceRules) {
|
||||
$this->errors[] = $this->l('Atleast one rule is required while creating advance price rule.');
|
||||
} else {
|
||||
foreach ($priceRules as $priceRuleKey => $priceRule) {
|
||||
if (!$priceRule['is_special_days_exists']) {
|
||||
unset($priceRules[$priceRuleKey]['special_days']);
|
||||
}
|
||||
if ($priceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if ($priceRule['specific_date']) {
|
||||
$priceRules[$priceRuleKey]['date_from'] = $priceRule['specific_date'];
|
||||
$priceRules[$priceRuleKey]['date_to'] = date('Y-m-d', strtotime("+1 day", strtotime($priceRule['specific_date'])));
|
||||
unset($priceRules[$priceRuleKey]['specific_date']);
|
||||
} else {
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$this->errors = $this->l('Specific Date is missing for advance price rule');
|
||||
}
|
||||
} else if ($priceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($priceRule['date_from'] == '') {
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$this->errors[] = $this->l('Dates are invalid in some rules');
|
||||
} else if ($priceRule['date_to'] == '') {
|
||||
$this->errors[] = $this->l('Dates are invalid in some rules');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
}
|
||||
|
||||
$dateFrom = date('Y-m-d', strtotime($priceRule['date_from']));
|
||||
$dateTo = date('Y-m-d', strtotime($priceRule['date_to']));
|
||||
if (!Validate::isDate($dateFrom)) {
|
||||
$this->errors[] = $this->l('Dates are invalid in some rules');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
}
|
||||
if (!Validate::isDate($dateTo)) {
|
||||
$this->errors[] = $this->l('Dates are invalid in some rules');
|
||||
}
|
||||
if ($dateTo < $dateFrom) {
|
||||
$this->errors[] = $this->l('Dates are invalid in some rules');
|
||||
}
|
||||
if ($priceRule['is_special_days_exists']) {
|
||||
if (!isset($priceRule['special_days']) || !$priceRule['special_days']) {
|
||||
$this->errors[] = $this->l('Special days are missing for price rule having restrict to week days');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
}
|
||||
}
|
||||
unset($priceRules[$priceRuleKey]['specific_date']);
|
||||
} else {
|
||||
unset($priceRules[$priceRuleKey]);
|
||||
}
|
||||
|
||||
if ($priceRule['is_special_days_exists'] && empty($priceRule['special_days'])) {
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$this->errors[] = $this->l('Please select at least one day for week days restriction.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($specificDate == '') {
|
||||
$this->errors[] = $this->l('Please choose Date from for the advanced price rule.');
|
||||
}
|
||||
$specificDate = date('Y-m-d', strtotime($specificDate));
|
||||
if (!Validate::isDate($specificDate)) {
|
||||
$this->errors[] = $this->l('Invalid Date From.');
|
||||
|
||||
foreach ($priceRules as $ruleKey => $rule) {
|
||||
if ($priceRuleKey != $ruleKey) {
|
||||
if ($rule['date_selection_type'] == $priceRule['date_selection_type']) {
|
||||
if ($rule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if (strtotime($rule['date_from']) != strtotime($priceRule['date_from'])) {
|
||||
continue;
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some dates are conflicting. Please check and reselect the dates.');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
}
|
||||
} else if ($rule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if (((strtotime($priceRule['date_from']) < strtotime($rule['date_from'])) && (strtotime($priceRule['date_to']) <= strtotime($rule['date_from']))) || ((strtotime($priceRule['date_from']) > strtotime($rule['date_from'])) && (strtotime($priceRule['date_from']) >= strtotime($rule['date_to'])))) {
|
||||
continue;
|
||||
} else {
|
||||
if ($priceRule['is_special_days_exists'] && $rule['is_special_days_exists']) {
|
||||
if (!empty($priceRule['special_days']) && !empty($rule['special_days'])) {
|
||||
if (array_intersect($priceRule['special_days'], $rule['special_days'])) {
|
||||
$this->errors[] = $this->l('Some days are conflicting. Please check and update the special days.');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some dates are conflicting. Please check and reselect the date ranges.');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,43 +522,34 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$this->errors[] = $this->l('Please select at least one group for the group access');
|
||||
}
|
||||
|
||||
$isPlanTypeExists = 0;
|
||||
if ($isSpecialDaysExists && $jsonSpecialDays == 'false') {
|
||||
$this->errors[] = $this->l('Please select at least one day for week days restriction.');
|
||||
}
|
||||
|
||||
if (empty($this->errors)) {
|
||||
foreach ($roomTypeIds as $idRoomType) {
|
||||
$isPlanTypeExists = $this->validateExistingFeaturePrice(
|
||||
$dateSelectionType,
|
||||
$duplicatePriceRuleKey = 0;
|
||||
if (empty($this->errors) && $enableFeaturePrice) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
foreach ($roomTypeIds as $idRoomType) {
|
||||
$duplicatePriceRuleKey = $this->object->validateExistingFeaturePrice(
|
||||
$idRoomType,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$groups,
|
||||
$idFeaturePrice,
|
||||
$isSpecialDaysExists,
|
||||
$jsonSpecialDays
|
||||
$priceRules
|
||||
);
|
||||
|
||||
if ($isPlanTypeExists) {
|
||||
if ($duplicatePriceRuleKey) {
|
||||
$rowsToHighlight = array_merge($duplicatePriceRuleKey, $rowsToHighlight);
|
||||
$objProduct = new Product((int) $idRoomType, false, $this->context->language->id);
|
||||
$this->errors[] = sprintf($this->l('An advanced price rule already exists for "%s" for the selected date range. Please select a different date range.'), $objProduct->name);
|
||||
$this->errors[] = sprintf($this->l('An advanced price rule already exists for "%s". Please update the restrictions to avoid duplication.'), $objProduct->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isPlanTypeExists && !count($this->errors)) {
|
||||
$rowsToHighlight = array_values($rowsToHighlight);
|
||||
$this->context->smarty->assign('rowsToHighlight', $rowsToHighlight);
|
||||
if (!($this->errors)) {
|
||||
if ($idFeaturePrice) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing($idFeaturePrice);
|
||||
}
|
||||
|
||||
// lang fields
|
||||
$objFeaturePricing->date_selection_type = $dateSelectionType;
|
||||
$objFeaturePricing->date_from = $dateFrom;
|
||||
$objFeaturePricing->date_to = $dateTo;
|
||||
$objFeaturePricing->impact_way = $priceImpactWay;
|
||||
$objFeaturePricing->is_special_days_exists = $isSpecialDaysExists;
|
||||
$objFeaturePricing->special_days = $jsonSpecialDays;
|
||||
$objFeaturePricing->impact_type = $priceImpactType;
|
||||
$objFeaturePricing->impact_value = $impactValue;
|
||||
$objFeaturePricing->active = $enableFeaturePrice;
|
||||
@@ -543,6 +562,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$objFeaturePricing->id_product = $idRoomType;
|
||||
$objFeaturePricing->feature_price_name = $featurePricingName[$idRoomType];
|
||||
$objFeaturePricing->add();
|
||||
$objFeaturePricing->saveUpdateFeaturePrices($objFeaturePricing->id, $priceRules);
|
||||
}
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token);
|
||||
@@ -550,14 +570,16 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$objFeaturePricing->feature_price_name = $featurePricingName[$roomTypeId];
|
||||
}
|
||||
|
||||
$conf = $idFeaturePrice ? 4 : 3;
|
||||
if ($objFeaturePricing->save()) {
|
||||
$objFeaturePricing->saveUpdateFeaturePrices($objFeaturePricing->id, $priceRules);
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(
|
||||
self::$currentIndex.'&id_feature_price='.(int) $objFeaturePricing->id.
|
||||
'&update'.$this->table.'&conf=4&token='.$this->token
|
||||
'&update'.$this->table.'&conf='.$conf.'&token='.$this->token
|
||||
);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured while saving advanced price rule.');
|
||||
@@ -607,8 +629,14 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
|
||||
Media::addJsDef(array(
|
||||
'date_selection_types' => array(
|
||||
'range' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE,
|
||||
'specific' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC,
|
||||
'range' => array(
|
||||
'value' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE,
|
||||
'title' => $this->l('Date Range', null, true)
|
||||
),
|
||||
'specific' => array(
|
||||
'value' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC,
|
||||
'title' => $this->l('Specific Date', null, true)
|
||||
),
|
||||
),
|
||||
'impact_ways' => array(
|
||||
'decrease' => HotelRoomTypeFeaturePricing::IMPACT_WAY_DECREASE,
|
||||
@@ -619,6 +647,17 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
'percentage' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE,
|
||||
'fixed' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE,
|
||||
),
|
||||
'week_days' => $this->getWeekDays(),
|
||||
'priceRuleHeadingText' => $this->l('Price rule restriction', null, true),
|
||||
'dateSelectionTitle' => $this->l('Date Selection type', null, true),
|
||||
'specificDateText' => $this->l('Specific Date', null, true),
|
||||
'dateFromText' => $this->l('Date From', null, true),
|
||||
'dateToText' => $this->l('Date to', null, true),
|
||||
'yesText' => $this->l('Yes', null, true),
|
||||
'noText' => $this->l('No', null, true),
|
||||
'specialDaysText' => $this->l('Restrict to Week Days', null, true),
|
||||
'weekDaysText' => $this->l('Select Week Days', null, true),
|
||||
'specialDaysTooltipText' => $this->l('Enable this option to restrict this rule to specific week days (for example, weekends) of the selected date range. If disabled, rule will be applicable to all week days.', null, true)
|
||||
));
|
||||
|
||||
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
|
||||
|
||||
@@ -32,6 +32,7 @@ require_once 'classes/HotelOrderRefundRules.php';
|
||||
require_once 'classes/HotelOrderRestrictDate.php';
|
||||
require_once 'classes/HotelHelper.php';
|
||||
require_once 'classes/HotelRoomTypeFeaturePricing.php';
|
||||
require_once 'classes/HotelRoomTypeFeaturePricingRule.php';
|
||||
require_once 'classes/ChannelOrderPayment.php';
|
||||
|
||||
require_once 'classes/HotelBookingDemands.php';
|
||||
|
||||
@@ -398,8 +398,7 @@ class HotelReservationSystem extends Module
|
||||
}
|
||||
|
||||
// delete the feature prices of the room type
|
||||
$objRoomTypeFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
$objRoomTypeFeaturePricing->deleteFeaturePriceByIdProduct($idProduct);
|
||||
HotelRoomTypeFeaturePricing::deleteFeaturePrices(false, $idProduct);
|
||||
|
||||
// delete the disable dates (temporary inactive status) of the room type
|
||||
$objRoomDisableDates = new HotelRoomDisableDates();
|
||||
|
||||
@@ -614,4 +614,27 @@ body.adminhotelroomsbooking .ui-tooltip {
|
||||
#room-reallocation-modal .modal-body, #room-reallocation-modal .tab-content {
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd
|
||||
}
|
||||
}
|
||||
|
||||
a.remove_advanced_price_rule {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: -8px;}
|
||||
#advanced_price_rule_group .panel.advanced_price_rule {
|
||||
padding: 0px;}
|
||||
#advanced_price_rule_group .advance_price_rule_header {
|
||||
padding: 15px;}
|
||||
#advanced_price_rule_group .advance_price_rule_header:hover {
|
||||
cursor: pointer;}
|
||||
.advance_price_rule_header i.icon-caret-down,
|
||||
.advance_price_rule_header.collapsed i.icon-caret-up{
|
||||
display: none;}
|
||||
.advance_price_rule_header.collapsed i.icon-caret-down{
|
||||
display: block;}
|
||||
.advanced_price_rule_body {
|
||||
border-top: 1px solid #d3d3d3;}
|
||||
.advanced_price_rule_body .form-group:first-child {
|
||||
margin-top: 15px;}
|
||||
.error-border {
|
||||
outline: rgb(210, 124, 130) solid 1px;
|
||||
border-radius: 2px;}
|
||||
|
||||
@@ -575,28 +575,37 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$('#date_selection_type').on('change', function() {
|
||||
if ($('#date_selection_type').val() == date_selection_types.specific) {
|
||||
$(".specific_date_type").show(200);
|
||||
$(".date_range_type").hide(200);
|
||||
$(".special_days_content").hide(200);
|
||||
} else if ($('#date_selection_type').val() == date_selection_types.range) {
|
||||
$(".specific_date_type").hide(200);
|
||||
$(".date_range_type").show(200);
|
||||
$(".special_days_content").show(200);
|
||||
$(document).on('change', '.date_selection_type', function() {
|
||||
let panelIndex = $(this).closest('.advanced_price_rule').data('advanced_price_rule_index');
|
||||
if ($('#date_selection_type_'+panelIndex).val() == date_selection_types.specific.value) {
|
||||
$(".specific_date_type_"+panelIndex).show(200);
|
||||
$(".date_range_type_"+panelIndex).hide(200);
|
||||
$(".special_days_content_"+panelIndex).hide(200);
|
||||
$('.week_days_'+panelIndex).hide(200);
|
||||
} else if ($('#date_selection_type_'+panelIndex).val() == date_selection_types.range.value) {
|
||||
$(".specific_date_type_"+panelIndex).hide(200);
|
||||
$(".date_range_type_"+panelIndex).show(200);
|
||||
$(".special_days_content_"+panelIndex).show(200);
|
||||
if (parseInt($('[name="advance_price_rule['+panelIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
$('.week_days_'+panelIndex).show(200);
|
||||
}
|
||||
} else {
|
||||
$(".specific_date_type").hide(200);
|
||||
$(".date_range_type").show(200);
|
||||
$(".special_days_content").show(200);
|
||||
$(".specific_date_type_"+panelIndex).hide(200);
|
||||
$(".date_range_type_"+panelIndex).show(200);
|
||||
$(".special_days_content_"+panelIndex).show(200);
|
||||
if (parseInt($('[name="advance_price_rule['+panelIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
$('.week_days_'+panelIndex).show(200);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('[name="is_special_days_exists"]').on('change', function() {
|
||||
if (parseInt($('[name="is_special_days_exists"]:checked').val())) {
|
||||
$('.week_days').show(200);
|
||||
$(document).on('change', '.is_special_days_exists', function() {
|
||||
let panelIndex = $(this).closest('.advanced_price_rule').data('advanced_price_rule_index');
|
||||
if (parseInt($('[name="advance_price_rule['+panelIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
$('.week_days_'+panelIndex).show(200);
|
||||
} else {
|
||||
$('.week_days').hide(200);
|
||||
$('.week_days_'+panelIndex).hide(200);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -621,6 +630,95 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
const dateToday = $.datepicker.formatDate('yy-mm-dd', new Date());
|
||||
$(document).on('click', '#add_more_dates_button', function() {
|
||||
let dateSeletionOptions = $('<select>').addClass('form-control date_selection_type');
|
||||
$.each(date_selection_types, function(dateSelectionIndex, date_selection_type) {
|
||||
dateSeletionOptions.append($('<option>').attr('value', date_selection_type.value).text(date_selection_type.title))
|
||||
});
|
||||
|
||||
let weekDaysOptions = $('<div>');
|
||||
$.each(week_days, function(weekDayIndex, weekDay) {
|
||||
weekDaysOptions.append($('<div>').addClass('day-wrap')
|
||||
.append($('<input>').attr({'type':'checkbox', 'value': weekDayIndex, 'name': 'special_days'}))
|
||||
.append($('<p>').text(weekDay)))
|
||||
});
|
||||
let panelIndex = parseInt($('.advanced_price_rule').last().data('advanced_price_rule_index'));
|
||||
if (isNaN(panelIndex)) {
|
||||
panelIndex = 0;
|
||||
} else {
|
||||
panelIndex++;
|
||||
}
|
||||
|
||||
let panelElem = $('<div>').addClass('panel advanced_price_rule').attr('data-advanced_price_rule_index', panelIndex);
|
||||
let idElem = $('<input>').attr('type', 'hidden').attr('name', 'advance_price_rule['+panelIndex+'][id]')
|
||||
let headerElem = $('<div>').addClass('row advance_price_rule_header collapsed').attr({'data-toggle':"collapse", 'data-target':"#advanced_price_rule_"+panelIndex})
|
||||
.append($('<div>').addClass('col-xs-8 col-sm-10').text(priceRuleHeadingText))
|
||||
.append($('<div>').addClass('col-xs-1 pull-right')
|
||||
.append($('<div>').addClass('col-xs-8')
|
||||
.append($('<a>').addClass('btn btn-default remove_advanced_price_rule')
|
||||
.append($('<span>').append($('<i>').addClass('icon-trash')))))
|
||||
.append($('<div>').addClass('col-xs-4')
|
||||
.append($('<i>').addClass('icon-caret-down'))
|
||||
.append($('<i>').addClass('icon-caret-up'))));
|
||||
|
||||
let dateSelectionElem = $('<div>').addClass('form-group')
|
||||
.append($('<label>').addClass('control-label col-sm-4 col-xs-3').attr('for', 'advance_price_rule['+panelIndex+'][date_selection_type]').text(dateSelectionTitle))
|
||||
.append($('<div>').addClass('col-xs-6')
|
||||
.append($(dateSeletionOptions).attr({'name': 'advance_price_rule['+panelIndex+'][date_selection_type]', 'id': 'date_selection_type_'+panelIndex})));
|
||||
|
||||
let specificDateElem = $('<div>').addClass('form-group specific_date_type_'+panelIndex).css('display', 'none')
|
||||
.append($('<label>').addClass('control-label col-sm-4 col-xs-3 required').attr('for', 'advance_price_rule['+panelIndex+'][specific_date]').text(specificDateText))
|
||||
.append($('<div>').addClass('col-xs-6')
|
||||
.append($('<input>').addClass('specific_date form-control datepicker-input')
|
||||
.attr({type:'text', id: 'specific_date_'+panelIndex, name: 'advance_price_rule['+panelIndex+'][specific_date]', value: dateToday, readonly: 'readonly'})));
|
||||
|
||||
let dateFromElem = $('<div>').addClass('form-group date_range_type_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-sm-4 col-xs-3 required').attr('for', 'advance_price_rule['+panelIndex+'][date_from]').text(dateFromText))
|
||||
.append($('<div>').addClass('col-xs-6')
|
||||
.append($('<input>').addClass('feature_plan_date_from form-control datepicker-input')
|
||||
.attr({type:'text', id: 'feature_plan_date_from_'+panelIndex, name: 'advance_price_rule['+panelIndex+'][date_from]', value: dateToday, readonly: 'readonly'})));
|
||||
|
||||
let dateToElem = $('<div>').addClass('form-group date_range_type_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-sm-4 col-xs-3 required').attr('for', 'advance_price_rule['+panelIndex+'][date_to]').text(dateToText))
|
||||
.append($('<div>').addClass('col-xs-6')
|
||||
.append($('<input>').addClass('feature_plan_date_to form-control datepicker-input')
|
||||
.attr({type:'text', id: 'feature_plan_date_to_'+panelIndex, name: 'advance_price_rule['+panelIndex+'][date_to]', value: dateToday, readonly: 'readonly'})));
|
||||
|
||||
let specialDaysElement = $('<div>').addClass('form-group special_days_content_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-sm-4 col-xs-3 required').attr('for', 'advance_price_rule['+panelIndex+'][is_special_days_exists]')
|
||||
.append($('<span>').addClass('label-tooltip').attr({'data-toggle': 'tooltip', 'data-html':'true', 'title': '', 'data-original-title': specialDaysTooltipText}).text(specialDaysText)))
|
||||
.append($('<div>').addClass('col-xs-6')
|
||||
.append($('<span>').addClass('switch prestashop-switch fixed-width-lg')
|
||||
.append($('<input>').attr({'type': 'radio', 'value': 1, 'name': 'advance_price_rule['+panelIndex+'][is_special_days_exists]', 'id': 'advance_price_rule['+panelIndex+'][is_special_days_exists_on]'}).addClass('is_special_days_exists'))
|
||||
.append($('<label>').attr({'for': 'advance_price_rule['+panelIndex+'][is_special_days_exists_on]'}).text(yesText))
|
||||
.append($('<input>').attr({'type': 'radio', 'value': 0, 'name': 'advance_price_rule['+panelIndex+'][is_special_days_exists]', 'id': 'advance_price_rule['+panelIndex+'][is_special_days_exists_off]', 'checked':'checked'}).addClass('is_special_days_exists'))
|
||||
.append($('<label>').attr({'for': 'advance_price_rule['+panelIndex+'][is_special_days_exists_off]'}).text(noText))
|
||||
.append($('<a>').addClass('slide-button btn'))))
|
||||
|
||||
$(weekDaysOptions).find('input[type="checkbox"]').attr('name', 'advance_price_rule['+panelIndex+'][special_days][]');
|
||||
let specialDaysCheckBoxElem = $('<div>').addClass('form-group week_days week_days_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-sm-4 col-xs-3 required').attr('for', 'advance_price_rule['+panelIndex+'][special_days]').text(weekDaysText))
|
||||
.append($('<div>').addClass('col-xs-8 checkboxes-wrap').append($(weekDaysOptions).html()))
|
||||
|
||||
let bodyElem = $('<div>').attr('id', 'advanced_price_rule_'+panelIndex).addClass('collapse advanced_price_rule_body')
|
||||
.append(dateSelectionElem)
|
||||
.append(specificDateElem)
|
||||
.append(dateFromElem)
|
||||
.append(dateToElem)
|
||||
.append(specialDaysElement)
|
||||
.append(specialDaysCheckBoxElem);
|
||||
|
||||
panelElem.append(idElem).append(headerElem).append(bodyElem);
|
||||
$('#advanced_price_rule_group').append($(panelElem).prop('outerHTML'));
|
||||
$('#advanced_price_rule_group').find('.advanced_price_rule').last().find('.label-tooltip').tooltip();
|
||||
initDatePicker($('#advanced_price_rule_group').find('.advanced_price_rule').last())
|
||||
});
|
||||
|
||||
$(document).on('click', '.remove_advanced_price_rule', function(){
|
||||
$(this).closest('.advanced_price_rule').remove();
|
||||
});
|
||||
|
||||
var ajax_pre_check_var = '';
|
||||
$('.room_type_search_results_ul').hide();
|
||||
|
||||
@@ -676,49 +774,48 @@ $(document).ready(function() {
|
||||
$('.room_type_search_results_ul').empty().hide();
|
||||
});
|
||||
|
||||
$("#feature_plan_date_from").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'dd-mm-yy',
|
||||
minDate: 0,
|
||||
//for calender Css
|
||||
beforeShowDay: function (date) {
|
||||
return highlightDateBorder($("#feature_plan_date_from").val(), date);
|
||||
},
|
||||
onSelect: function(selectedDate) {
|
||||
let objDateToMin = $.datepicker.parseDate('dd-mm-yy', selectedDate);
|
||||
objDateToMin.setDate(objDateToMin.getDate());
|
||||
|
||||
$('#feature_plan_date_to').datepicker('option', 'minDate', objDateToMin);
|
||||
},
|
||||
$('.advanced_price_rule').each(function(){
|
||||
initDatePicker($(this));
|
||||
});
|
||||
function initDatePicker(elem) {
|
||||
$(elem).find(".feature_plan_date_from").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'yy-mm-dd',
|
||||
minDate: 0,
|
||||
onSelect: function(selectedDate) {
|
||||
let objDateToMin = $.datepicker.parseDate('yy-mm-dd', selectedDate);
|
||||
objDateToMin.setDate(objDateToMin.getDate());
|
||||
$(elem).find(".feature_plan_date_to").datepicker('option', 'minDate', objDateToMin);
|
||||
},
|
||||
});
|
||||
|
||||
$("#specific_date").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'dd-mm-yy',
|
||||
minDate: 0,
|
||||
});
|
||||
$(elem).find(".specific_date").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'yy-mm-dd',
|
||||
minDate: 0,
|
||||
});
|
||||
|
||||
$("#feature_plan_date_to").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'dd-mm-yy',
|
||||
beforeShow: function () {
|
||||
let dateFrom = $('#feature_plan_date_from').val();
|
||||
$(elem).find(".feature_plan_date_to").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'yy-mm-dd',
|
||||
beforeShow: function () {
|
||||
let dateFrom = $(elem).find(".feature_plan_date_from").val();
|
||||
let objDateToMin = null;
|
||||
if (typeof dateFrom != 'undefined' && dateFrom != '') {
|
||||
objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom);
|
||||
} else {
|
||||
objDateToMin = new Date();
|
||||
}
|
||||
|
||||
let objDateToMin = null;
|
||||
if (typeof dateFrom != 'undefined' && dateFrom != '') {
|
||||
objDateToMin = $.datepicker.parseDate('dd-mm-yy', dateFrom);
|
||||
} else {
|
||||
objDateToMin = new Date();
|
||||
objDateToMin.setDate(objDateToMin.getDate());
|
||||
$(elem).find(".feature_plan_date_to").datepicker('option', 'minDate', objDateToMin);
|
||||
},
|
||||
//for calender Css
|
||||
beforeShowDay: function (date) {
|
||||
return highlightDateBorder($("#feature_plan_date_to").val(), date);
|
||||
}
|
||||
|
||||
objDateToMin.setDate(objDateToMin.getDate());
|
||||
$('#feature_plan_date_to').datepicker('option', 'minDate', objDateToMin);
|
||||
},
|
||||
//for calender Css
|
||||
beforeShowDay: function (date) {
|
||||
return highlightDateBorder($("#feature_plan_date_to").val(), date);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function highlightDateBorder(elementVal, date)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
|
||||
<div class="panel advanced_price_rule {if isset($rowsToHighlight) && in_array($key, $rowsToHighlight)}error-border{/if}" data-advanced_price_rule_index="{$key}">
|
||||
<input type="hidden" name="advance_price_rule[{$key}][id]" value="{if isset($advancePriceRule['id'])}{$advancePriceRule['id']}{/if}">
|
||||
<div class="row advance_price_rule_header {if $key}collapsed{/if}" data-toggle="collapse" data-target="#advanced_price_rule_{$key}">
|
||||
<div class="col-xs-10">
|
||||
{l s='Price rule restriction' mod='hotelreservationsystem'}
|
||||
</div>
|
||||
<div class="col-xs-1 pull-right">
|
||||
<div class="col-xs-8">
|
||||
<a class="btn btn-default remove_advanced_price_rule">
|
||||
<i class="icon-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<i class="icon-caret-down"></i>
|
||||
<i class="icon-caret-up"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="advanced_price_rule_{$key}" class="collapse advanced_price_rule_body {if !$key}in{/if}">
|
||||
<div class="form-group">
|
||||
<label for="advance_price_rule[{$key}][date_selection_type]" class="control-label col-sm-4 col-xs-3">
|
||||
{l s='Date Selection type' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-6">
|
||||
<select class="form-control date_selection_type" name="advance_price_rule[{$key}][date_selection_type]" id="date_selection_type_{$key}">
|
||||
<option value="{HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}" {if isset($advancePriceRule['date_selection_type']) && $advancePriceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}selected="seleted"{/if}>
|
||||
{l s='Date Range' mod='hotelreservationsystem'}
|
||||
</option>
|
||||
<option value="{HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC}" {if isset($advancePriceRule['date_selection_type']) && $advancePriceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC}selected="seleted"{/if}>
|
||||
{l s='Specific Date' mod='hotelreservationsystem'}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group specific_date_type_{$key}" {if !isset($advancePriceRule['date_selection_type']) || $advancePriceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="col-sm-4 col-xs-3 control-label required" for="advance_price_rule[{$key}][specific_date]" >
|
||||
{l s='Specific Date' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-6">
|
||||
<input type="text" id="specific_date_{$key}" name="advance_price_rule[{$key}][specific_date]" class="specific_date form-control datepicker-input" value="{if isset($advancePriceRule['specific_date'])}{$advancePriceRule['specific_date']}{else}{$date_from}{/if}" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group date_range_type_{$key}" {if isset($advancePriceRule['date_selection_type']) && $advancePriceRule['date_selection_type'] != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="col-sm-4 col-xs-3 control-label required" for="advance_price_rule[{$key}][date_from]" >
|
||||
{l s='Date From' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-6">
|
||||
<input type="text" id="feature_plan_date_from_{$key}" name="advance_price_rule[{$key}][date_from]" class="feature_plan_date_from form-control datepicker-input" value="{if isset($advancePriceRule['date_from'])}{$advancePriceRule['date_from']}{else}{$date_from}{/if}" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group date_range_type_{$key}" {if isset($advancePriceRule['date_selection_type']) && $advancePriceRule['date_selection_type'] != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="col-sm-4 col-xs-3 control-label required" for="advance_price_rule[{$key}][date_to]" >
|
||||
{l s='Date To' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-6">
|
||||
<input type="text" id="feature_plan_date_to_{$key}" name="advance_price_rule[{$key}][date_to]" class="feature_plan_date_to form-control datepicker-input" value="{if isset($advancePriceRule['date_to'])}{$advancePriceRule['date_to']}{else}{$date_to}{/if}" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group special_days_content_{$key}" {if isset($advancePriceRule['date_selection_type']) && $advancePriceRule['date_selection_type'] != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="control-label col-sm-4 col-xs-3" for="advance_price_rule[{$key}][is_special_days_exists]">
|
||||
<span class="label-tooltip" data-toggle="tooltip" data-html="true" title="" data-original-title="{l s='Enable this option to restrict this rule to specific week days (for example, weekends) of the selected date range. If disabled, rule will be applicable to all week days.' mod='hotelreservationsystem'}">
|
||||
{l s='Restrict to Week Days' mod='hotelreservationsystem'}
|
||||
</span>
|
||||
</label>
|
||||
<div class="col-xs-6">
|
||||
<span class="switch prestashop-switch fixed-width-lg">
|
||||
<input type="radio" value="1" id="advance_price_rule[{$key}][is_special_days_exists_on]" name="advance_price_rule[{$key}][is_special_days_exists]" class="is_special_days_exists" {if isset($advancePriceRule['is_special_days_exists']) && $advancePriceRule['is_special_days_exists']}checked="checked"{/if}>
|
||||
<label for="advance_price_rule[{$key}][is_special_days_exists_on]">{l s='Yes' mod='hotelreservationsystem'}</label>
|
||||
<input type="radio" value="0" id="advance_price_rule[{$key}][is_special_days_exists_off]" name="advance_price_rule[{$key}][is_special_days_exists]" class="is_special_days_exists" {if !isset($advancePriceRule['is_special_days_exists']) || !$advancePriceRule['is_special_days_exists']}checked="checked"{/if}>
|
||||
<label for="advance_price_rule[{$key}][is_special_days_exists_off]">{l s='No' mod='hotelreservationsystem'}</label>
|
||||
<a class="slide-button btn"></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group week_days week_days_{$key}" {if isset($advancePriceRule['special_days']) && is_array($advancePriceRule['special_days']) && isset($advancePriceRule['is_special_days_exists']) && $advancePriceRule['is_special_days_exists']}style="display:block;"{/if}>
|
||||
<label for="advance_price_rule[{$key}][special_days]" class="control-label col-sm-4 col-xs-3">
|
||||
{l s='Select Week Days' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-8 checkboxes-wrap">
|
||||
{foreach $week_days as $dayVal => $day}
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="advance_price_rule[{$key}][special_days][]" value="{$dayVal}" {if (isset($advancePriceRule['special_days']) && is_array($advancePriceRule['special_days']) && in_array($dayVal, $advancePriceRule['special_days']))}checked="checked" {/if}/>
|
||||
<p>{$day}</p>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -81,7 +81,7 @@
|
||||
</div>
|
||||
{if isset($hotel_tree)}
|
||||
<div class="form-group room-type-name-tree" style="display:none;">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
<label class="col-sm-3 control-label required" for="room_types">
|
||||
<span class="label-tooltip" data-toggle="tooltip" data-html="true" title="" data-original-title="{l s='Select the room types for which you are going to create this advanced price rule.' mod='hotelreservationsystem'}">
|
||||
{l s='Room Types' mod='hotelreservationsystem'}
|
||||
</span>
|
||||
@@ -94,12 +94,12 @@
|
||||
{/if}
|
||||
|
||||
<div class="form-group room-type-name">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
<label class="col-sm-3 control-label required" for="room_type_name" >
|
||||
{l s='Room Type' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-3">
|
||||
<input autocomplete="off" type="text" id="room_type_name" name="room_type_name" class="form-control" placeholder= "{l s='Enter room type name' mod='hotelreservationsystem'}" value="{if isset($productName)}{$productName}{/if}"/>
|
||||
<input type="hidden" id="room_type_id" name="room_type_id" class="form-control" value="{if isset($objFeaturePrice->id_product)}{$objFeaturePrice->id_product}{else}0{/if}"/>
|
||||
<input autocomplete="off" type="text" id="room_type_name" name="room_type_name" class="form-control" placeholder= "{l s='Enter room type name' mod='hotelreservationsystem'}" value="{if isset($smarty.post.room_type_name)}{$smarty.post.room_type_name}{elseif isset($productName)}{$productName}{/if}"/>
|
||||
<input type="hidden" id="room_type_id" name="room_type_id" class="form-control" value="{if isset($smarty.post.room_type_id)}{$smarty.post.room_type_id}{elseif isset($objFeaturePrice->id_product)}{$objFeaturePrice->id_product}{else}0{/if}"/>
|
||||
<div class="dropdown">
|
||||
<ul class="room_type_search_results_ul"></ul>
|
||||
</div>
|
||||
@@ -112,125 +112,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="date_selection_type" class="control-label col-lg-3">
|
||||
{l s='Date Selection type' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-lg-3">
|
||||
<select class="form-control" name="date_selection_type" id="date_selection_type">
|
||||
<option value="{HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}" {if (isset($smarty.post.date_selection_type) && $smarty.post.date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) || (isset($objFeaturePrice->date_selection_type) && $objFeaturePrice->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE)}selected = "selected"{/if}>
|
||||
{l s='Date Range' mod='hotelreservationsystem'}
|
||||
</option>
|
||||
<option value="{HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC}" {if (isset($smarty.post.date_selection_type) && $smarty.post.date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) || (isset($objFeaturePrice->date_selection_type) && $objFeaturePrice->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC)}selected = "selected"{/if}>
|
||||
{l s='Specific Date' mod='hotelreservationsystem'}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group specific_date_type" {if (isset($smarty.post.date_selection_type) && $smarty.post.date_selection_type != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) || (isset($objFeaturePrice->date_selection_type) && $objFeaturePrice->date_selection_type != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC)}style="display:none;"{else if !isset($edit) && !isset($smarty.post.date_selection_type)}style="display:none;"{/if}>
|
||||
<label class="col-sm-3 control-label required" for="specific_date" >
|
||||
{l s='Specific Date' mod='hotelreservationsystem'}
|
||||
<div class="row">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
{l s='Advanced Price Rules' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" id="specific_date" name="specific_date" class="form-control datepicker-input" value="{if isset($objFeaturePrice->date_from)}{$objFeaturePrice->date_from}{else}{$date_from}{/if}" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group date_range_type" {if (isset($objFeaturePrice->date_selection_type) && $objFeaturePrice->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) || (isset($smarty.post.date_selection_type) && $smarty.post.date_selection_type != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE)}style="display:none;"{/if}>
|
||||
<label class="col-sm-3 control-label required" for="date_form" >
|
||||
{l s='Date From' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" id="feature_plan_date_from" name="date_from" class="form-control datepicker-input" value="{if isset($smarty.post.date_from) && $smarty.post.date_from}{$smarty.post.date_from}{elseif isset($objFeaturePrice->date_from)}{$objFeaturePrice->date_from|date_format:'%d-%m-%Y'}{else}{$date_from|date_format:'%d-%m-%Y'}{/if}" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group date_range_type" {if (isset($objFeaturePrice->date_selection_type) && $objFeaturePrice->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) || (isset($smarty.post.date_selection_type) && $smarty.post.date_selection_type != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE)}style="display:none;"{/if}>
|
||||
<label class="col-sm-3 control-label required" for="date_to" >
|
||||
{l s='Date To' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" id="feature_plan_date_to" name="date_to" class="form-control datepicker-input" value="{if isset($smarty.post.date_to) && $smarty.post.date_to}{$smarty.post.date_to}{elseif isset($objFeaturePrice->date_to)}{$objFeaturePrice->date_to|date_format:'%d-%m-%Y'}{else}{$date_to|date_format:'%d-%m-%Y'}{/if}" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group special_days_content" {if (isset($objFeaturePrice->date_selection_type) && $objFeaturePrice->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) || (isset($smarty.post.date_selection_type) && $smarty.post.date_selection_type != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE)}style="display:none;"{/if}>
|
||||
<label class="control-label col-lg-3">
|
||||
<span class="label-tooltip" data-toggle="tooltip" data-html="true" title="" data-original-title="{l s='Enable this option to restrict this rule to specific week days (for example, weekends) of the selected date range. If disabled, rule will be applicable to all week days.' mod='hotelreservationsystem'}">
|
||||
{l s='Restrict to Week Days' mod='hotelreservationsystem'}
|
||||
</span>
|
||||
</label>
|
||||
<div class="col-lg-9 ">
|
||||
<span class="switch prestashop-switch fixed-width-lg">
|
||||
<input type="radio" {if isset($smarty.post.is_special_days_exists) && $smarty.post.is_special_days_exists == 1}checked="checked"{elseif isset($edit) && $objFeaturePrice->is_special_days_exists == 1}checked="checked"{/if} value="1" id="is_special_days_exists_on" name="is_special_days_exists">
|
||||
<label for="is_special_days_exists_on">{l s='Yes' mod='hotelreservationsystem'}</label>
|
||||
<input {if isset($smarty.post.is_special_days_exists) && $smarty.post.is_special_days_exists == 0} checked="checked" {elseif (isset($edit) && $objFeaturePrice->is_special_days_exists == 0) || !isset($edit)} checked="checked"{/if} type="radio" value="0" id="is_special_days_exists_off" name="is_special_days_exists">
|
||||
<label for="is_special_days_exists_off">{l s='No' mod='hotelreservationsystem'}</label>
|
||||
<a class="slide-button btn"></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group week_days" {if (isset($smarty.post.is_special_days_exists) && $smarty.post.is_special_days_exists) || (isset($objFeaturePrice->is_special_days_exists) && $objFeaturePrice->is_special_days_exists)}style="display:block;"{/if}>
|
||||
<label for="special_days" class="control-label col-lg-3">
|
||||
{l s='Select Week Days' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-lg-3 checkboxes-wrap">
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="special_days[]" value="mon"
|
||||
{if (isset($smarty.post.special_days) && in_array('mon', $smarty.post.special_days))
|
||||
|| (isset($special_days) && $special_days && in_array('mon', $special_days))}
|
||||
checked="checked"
|
||||
{/if}/>
|
||||
<p>{l s='Mon' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="special_days[]" value="tue"
|
||||
{if (isset($smarty.post.special_days) && in_array('tue', $smarty.post.special_days))
|
||||
|| (isset($special_days) && $special_days && in_array('tue', $special_days))}
|
||||
checked="checked"
|
||||
{/if}/>
|
||||
<p>{l s='Tue' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="special_days[]" value="wed"
|
||||
{if (isset($smarty.post.special_days) && in_array('wed', $smarty.post.special_days))
|
||||
|| (isset($special_days) && $special_days && in_array('wed', $special_days))}
|
||||
checked="checked"
|
||||
{/if}/>
|
||||
<p>{l s='Wed' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="special_days[]" value="thu"
|
||||
{if (isset($smarty.post.special_days) && in_array('thu', $smarty.post.special_days))
|
||||
|| (isset($special_days) && $special_days && in_array('thu', $special_days))}
|
||||
checked="checked"
|
||||
{/if}/>
|
||||
<p>{l s='Thu' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="special_days[]" value="fri"
|
||||
{if (isset($smarty.post.special_days) && in_array('fri', $smarty.post.special_days))
|
||||
|| (isset($special_days) && $special_days && in_array('fri', $special_days))}
|
||||
checked="checked"
|
||||
{/if}/>
|
||||
<p>{l s='Fri' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="special_days[]" value="sat"
|
||||
{if (isset($smarty.post.special_days) && in_array('sat', $smarty.post.special_days))
|
||||
|| (isset($special_days) && $special_days && in_array('sat', $special_days))}
|
||||
checked="checked"
|
||||
{/if}/>
|
||||
<p>{l s='Sat' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
<div class="day-wrap">
|
||||
<input type="checkbox" name="special_days[]" value="sun"
|
||||
{if (isset($smarty.post.special_days) && in_array('sun', $smarty.post.special_days))
|
||||
|| (isset($special_days) && $special_days && in_array('sun', $special_days))}
|
||||
checked="checked"
|
||||
{/if}/>
|
||||
<p>{l s='Sun' mod='hotelreservationsystem'}</p>
|
||||
<div class="col-sm-6 col-xs-9">
|
||||
<div class="panel">
|
||||
<div id="advanced_price_rule_group">
|
||||
{if isset($smarty.post.advance_price_rule) && $smarty.post.advance_price_rule}
|
||||
{assign var='advancePriceRules' value=$smarty.post.advance_price_rule}
|
||||
{/if}
|
||||
{if isset($advancePriceRules) && $advancePriceRules}
|
||||
{foreach $advancePriceRules as $key => $rule}
|
||||
{include file="../../../_partials/feature_price_rules.tpl" key=$key advancePriceRule=$rule}
|
||||
{/foreach}
|
||||
{else}
|
||||
{include file="../../../_partials/feature_price_rules.tpl" key=0}
|
||||
{/if}
|
||||
</div>
|
||||
<a id="add_more_dates_button" class="btn btn-default">
|
||||
<i class="icon icon-plus"></i> {l s='Add More Restrictions' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -271,14 +173,13 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
<label class="col-sm-3 control-label required" for="impact_value" >
|
||||
{l s='Impact Value' mod='hotelreservationsystem'}({l s='tax excl.' mod='hotelreservationsystem'})
|
||||
</label>
|
||||
<div class="col-lg-3">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon payment_type_icon">{if isset($edit)} {if $objFeaturePrice->impact_type == HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE}{$defaultcurrency_sign}{else}%{/if}{else}%{/if}</span>
|
||||
<input type="text" id="impact_value" name="impact_value"
|
||||
value="{if isset($smarty.post.impact_value) && $smarty.post.impact_value}{$smarty.post.impact_value}{elseif isset($objFeaturePrice->impact_value)}{$objFeaturePrice->impact_value}{/if}"/>
|
||||
<input type="text" id="impact_value" name="impact_value" value="{if isset($smarty.post.impact_value) && $smarty.post.impact_value}{$smarty.post.impact_value}{elseif isset($objFeaturePrice->impact_value)}{$objFeaturePrice->impact_value}{/if}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -291,9 +192,9 @@
|
||||
</label>
|
||||
<div class="col-lg-9 ">
|
||||
<span class="switch prestashop-switch fixed-width-lg">
|
||||
<input type="radio" {if isset($edit) && $objFeaturePrice->active==1} checked="checked" {else}checked="checked"{/if} value="1" id="enable_feature_price_on" name="enable_feature_price">
|
||||
<input type="radio" {if isset($smarty.post.enable_feature_price)} {if $smarty.post.enable_feature_price} checked="checked" {/if}{elseif isset($edit) && $objFeaturePrice->active==1} checked="checked" {else}checked="checked"{/if} value="1" id="enable_feature_price_on" name="enable_feature_price">
|
||||
<label for="enable_feature_price_on">{l s='Yes' mod='hotelreservationsystem'}</label>
|
||||
<input {if isset($edit) && $objFeaturePrice->active==0} checked="checked" {/if} type="radio" value="0" id="enable_feature_price_off" name="enable_feature_price">
|
||||
<input {if isset($smarty.post.enable_feature_price)} {if !$smarty.post.enable_feature_price} checked="checked"{/if} {elseif isset($edit) && $objFeaturePrice->active==0} checked="checked" {/if} type="radio" value="0" id="enable_feature_price_off" name="enable_feature_price">
|
||||
<label for="enable_feature_price_off">{l s='No' mod='hotelreservationsystem'}</label>
|
||||
<a class="slide-button btn"></a>
|
||||
</span>
|
||||
|
||||
@@ -683,6 +683,8 @@ class QloCleaner extends Module
|
||||
array('htl_room_type_demand', 'id_global_demand', 'htl_room_type_global_demand', 'id_global_demand'),
|
||||
array('htl_room_type_demand', 'id_product', 'product', 'id_product'),
|
||||
array('htl_room_type_demand_price', 'id_product', 'product', 'id_product'),
|
||||
array('htl_room_type_feature_pricing', 'id_product', 'product', 'id_product'),
|
||||
array('htl_room_type_feature_pricing_rule', 'id_feature_price', 'htl_room_type_feature_pricing', 'id_feature_price'),
|
||||
array('htl_room_type_feature_pricing_group', 'id_group', 'group', 'id_group'),
|
||||
array('htl_booking_demands_tax', 'id_tax', 'tax', 'id_tax'),
|
||||
array('htl_booking_detail', 'id_product', 'product', 'id_product'),
|
||||
@@ -804,6 +806,7 @@ class QloCleaner extends Module
|
||||
'htl_branch_refund_rules',
|
||||
'htl_order_restrict_date',
|
||||
'htl_room_type_feature_pricing',
|
||||
'htl_room_type_feature_pricing_rule',
|
||||
'htl_room_type_feature_pricing_lang',
|
||||
'htl_room_type_feature_pricing_group',
|
||||
'htl_room_type_demand_price',
|
||||
|
||||
Reference in New Issue
Block a user