Updated: The database structure, optimized design and updated the text

This commit is contained in:
vishalsingh.qlo325
2025-06-18 13:01:28 +05:30
parent 7d53afca51
commit 16d4b22dd3
15 changed files with 108 additions and 115 deletions

View File

@@ -2937,10 +2937,10 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
$params['name'] = 'Api-Booking-Price';
$params['impact_type'] = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
$params['price'] /= $numDays;
$params['impact_value'] /= $numDays;
$params['is_special_days_exists'] = 0;
$params['special_days'] = json_encode(false);
$params['price_rules'] = array(
$params['restrictions'] = array(
array(
'date_from' => $params['date_from'],
'date_to' => $params['date_to']

View File

@@ -1018,7 +1018,7 @@ class AdminCartsControllerCore extends AdminController
'impact_way' => HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE,
'impact_type' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE,
'impact_value' => $price,
'price_rules' => array(
'restrictions' => array(
array(
'date_from' => $date_from,
'date_to' => $date_to

View File

@@ -2644,7 +2644,7 @@ class AdminImportControllerCore extends AdminController
'impact_way' => HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE,
'impact_type' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE,
'impact_value' => $orderProduct['amount'],
'price_rules' => array(
'restrictions' => array(
array(
'date_from' => date('Y-m-d', strtotime($dateFrom)),
'date_to' => date('Y-m-d', strtotime($dateTo)),

View File

@@ -4808,7 +4808,7 @@ class AdminOrdersControllerCore extends AdminController
$featurePriceParams = array(
'id_cart' => $this->context->cart->id,
'id_guest' => $this->context->cookie->id_guest,
'price' => $product_informations['product_price_tax_excl'],
'impact_value' => $product_informations['product_price_tax_excl'],
'id_product' => $product->id,
);
}
@@ -4862,7 +4862,7 @@ class AdminOrdersControllerCore extends AdminController
// create feature price if needed
if ($createFeaturePrice) {
$featurePriceParams['id_room'] = $room_info['id_room'];
$featurePriceParams['price_rules'] = array(
$featurePriceParams['restrictions'] = array(
array(
'date_from' => $date_from,
'date_to' => $date_to
@@ -5717,8 +5717,8 @@ class AdminOrdersControllerCore extends AdminController
'id_guest' => $cart->id_guest,
'id_product' => $id_product,
'id_room' => $id_room,
'price' => $room_unit_price,
'price_rules' => array(
'impact_value' => $room_unit_price,
'restrictions' => array(
array(
'date_from' => $new_date_from,
'date_to' => $new_date_to

View File

@@ -1955,13 +1955,11 @@ class HotelBookingDetail extends ObjectModel
$featurePriceParams = array(
'id_cart' => $context->cart->id,
'id_guest' => $context->cookie->id_guest,
'price' => $newRoomPriceTaxExcl,
'impact_value' => $newRoomPriceTaxExcl,
'id_product' => $idNewRoomType,
);
}
$objServiceProductCartDetail = new ServiceProductCartDetail();
$bookingParams = array(
'date_from' => $objOldHotelBooking->date_from,
'date_to' => $objOldHotelBooking->date_to,
@@ -1994,7 +1992,7 @@ class HotelBookingDetail extends ObjectModel
// create feature price if needed
if ($createFeaturePrice) {
$featurePriceParams['id_room'] = $roomInfo['id_room'];
$featurePriceParams['price_rules'] = array(
$featurePriceParams['restrictions'] = array(
array(
'date_from' => $objOldHotelBooking->date_from,
'date_to' => $objOldHotelBooking->date_to

View File

@@ -1444,7 +1444,7 @@ 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
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction` 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.'
@@ -1465,7 +1465,7 @@ 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
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction` 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 fpr.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fpr.`date_from` = \''.pSQL($date).'\''
@@ -1477,7 +1477,7 @@ 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
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction` fpr
ON (fpr.`id_feature_price` = fp.`id_feature_price`)
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.'
AND fpr.`is_special_days_exists`=1 AND fp.`active`=1 AND fpr.`date_from` <= \''.pSQL($date).'\'
@@ -1495,7 +1495,7 @@ 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
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction` 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

View File

@@ -293,8 +293,8 @@ 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,
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_feature_pricing_restriction` (
`id_feature_price_restriction` 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,
@@ -303,7 +303,7 @@ class HotelReservationSystemDb
`date_to` date NOT NULL,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_feature_price_rule`)
PRIMARY KEY (`id_feature_price_restriction`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_feature_pricing_lang` (
@@ -590,7 +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_feature_pricing_restriction`,
`'._DB_PREFIX_.'htl_room_type_global_demand`,
`'._DB_PREFIX_.'htl_room_type_global_demand_lang`,
`'._DB_PREFIX_.'htl_room_type_global_demand_advance_option`,

View File

@@ -83,10 +83,10 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
),
'associations' => array(
'groups' => array('resource' => 'group'),
'price_rules' => array(
'restrictions' => array(
'resource' => 'price_rule',
'getter' => 'getWsAdvancePriceRule',
'setter' => 'setWsAdvancePriceRule',
'getter' => 'getWsAdvancePriceRestriction',
'setter' => 'setWsAdvancePriceRestriction',
'fields' => array(
'id' => array(),
'date_from' => array(),
@@ -126,10 +126,10 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
{
// first call to delete all the group entries
$this->cleanGroups();
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
if ($oldFeaturePriceRules = $objFeaturePriceRule->getRulesByIdFeaturePrice($this->id)) {
$oldFeaturePriceRules = array_column($oldFeaturePriceRules, 'id_feature_price_rule', 'id_feature_price_rule');
$objFeaturePriceRule->deleteFeaturePriceRulesById($oldFeaturePriceRules);
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction();
if ($oldFeaturePriceRestrictions = $objFeaturePriceRestriction->getRestrictionsByIdFeaturePrice($this->id)) {
$oldFeaturePriceRestrictions = array_column($oldFeaturePriceRestrictions, 'id_feature_price_restriction', 'id_feature_price_restriction');
$objFeaturePriceRestriction->deleteFeaturePriceRestrictionsById($oldFeaturePriceRestrictions);
}
return parent::delete();
@@ -141,7 +141,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$idFeaturePrice,
$featurePriceRules
) {
$sql = 'SELECT *, GROUP_CONCAT(rtfpg.`id_group`) AS id_group FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule` rtfpr
$sql = 'SELECT *, GROUP_CONCAT(rtfpg.`id_group`) AS id_group FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction` 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
@@ -181,49 +181,49 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
return Db::getInstance()->executeS($sql);
}
public function saveFeaturePricesRules($idFeaturePrice, $featurePriceRules)
public function saveFeaturePriceRestrictions($idFeaturePrice, $featurePriceRules)
{
$res = true;
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
if ($oldFeaturePriceRules = $objFeaturePriceRule->getRulesByIdFeaturePrice($idFeaturePrice)) {
$oldFeaturePriceRules = array_column($oldFeaturePriceRules, 'id_feature_price_rule', 'id_feature_price_rule');
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction();
if ($oldFeaturePriceRestrictions = $objFeaturePriceRestriction->getRestrictionsByIdFeaturePrice($idFeaturePrice)) {
$oldFeaturePriceRestrictions = array_column($oldFeaturePriceRestrictions, 'id_feature_price_restriction', 'id_feature_price_restriction');
}
if ($featurePriceRules) {
foreach ($featurePriceRules as $featurePriceRule) {
if (isset($featurePriceRule['id']) && in_array($featurePriceRule['id'], $oldFeaturePriceRules)) {
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule($featurePriceRule['id']);
unset($oldFeaturePriceRules[$featurePriceRule['id']]);
if (isset($featurePriceRule['id']) && in_array($featurePriceRule['id'], $oldFeaturePriceRestrictions)) {
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction($featurePriceRule['id']);
unset($oldFeaturePriceRestrictions[$featurePriceRule['id']]);
} else {
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction();
}
$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
$objFeaturePriceRestriction->id_feature_price = $idFeaturePrice;
$objFeaturePriceRestriction->date_from = $featurePriceRule['date_from'];
$objFeaturePriceRestriction->date_to = $featurePriceRule['date_to'];
$objFeaturePriceRestriction->date_selection_type = isset($featurePriceRule['date_selection_type']) ? $featurePriceRule['date_selection_type'] : HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
$objFeaturePriceRestriction->special_days = json_encode(array());
if ($objFeaturePriceRestriction->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE
&& isset($featurePriceRule['is_special_days_exists']) && $featurePriceRule['is_special_days_exists']
) {
$objFeaturePriceRule->is_special_days_exists = $featurePriceRule['is_special_days_exists'];
$objFeaturePriceRestriction->is_special_days_exists = $featurePriceRule['is_special_days_exists'];
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']);
$objFeaturePriceRestriction->special_days = json_encode($featurePriceRule['special_days']);
}
} else {
$objFeaturePriceRule->is_special_days_exists = 0;
$objFeaturePriceRestriction->is_special_days_exists = 0;
}
$res &= $objFeaturePriceRule->save();
$res &= $objFeaturePriceRestriction->save();
}
}
if ($oldFeaturePriceRules) {
$res &= $objFeaturePriceRule->deleteFeaturePriceRulesById($oldFeaturePriceRules);
if ($oldFeaturePriceRestrictions) {
$res &= $objFeaturePriceRestriction->deleteFeaturePriceRestrictionsById($oldFeaturePriceRestrictions);
}
return $res;
@@ -489,7 +489,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
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
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction` 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
);
@@ -542,7 +542,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$idfeaturePrices = Db::getInstance()->executeS(
'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
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction` hrfpr
ON (hrfpr.`id_feature_price` = hrfp.`id_feature_price`)
WHERE 1'.
($id_cart ? ' AND hrfp.`id_cart` = '.(int) $id_cart : '').
@@ -638,16 +638,16 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
return true;
}
public function getWsAdvancePriceRule()
public function getWsAdvancePriceRestriction()
{
return Db::getInstance()->executeS(
'SELECT *, id_feature_price_rule AS `id` FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing_rule`
'SELECT *, id_feature_price_restriction AS `id` FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction`
WHERE `id_feature_price` ='.(int)$this->id.' ORDER BY `id_feature_price` ASC'
);
}
public function setWsAdvancePriceRule($priceRules)
public function setWsAdvancePriceRestriction($priceRules)
{
foreach ($priceRules as $ruleKey => $priceRule) {
if ($priceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE
@@ -658,7 +658,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
}
}
return $this->saveFeaturePricesRules($this->id, $priceRules);
return $this->saveFeaturePriceRestrictions($this->id, $priceRules);
}
public function validateExistingFeaturePrice(
@@ -714,7 +714,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$idGroups = array();
if (isset($this->associations)) {
foreach ($this->associations->children() as $association) {
if ($association->getName() == 'price_rules') {
if ($association->getName() == 'restrictions') {
$assocItems = $association->children();
foreach ($assocItems as $assocItem) {
/** @var SimpleXMLElement $assocItem */
@@ -862,11 +862,11 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$objFeaturePricing->feature_price_name = $featurePriceName;
$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->impact_value = isset($params['impact_value']) ? $params['impact_value'] : 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->saveFeaturePricesRules($objFeaturePricing->id, $params['price_rules']);
$objFeaturePricing->saveFeaturePriceRestrictions($objFeaturePricing->id, $params['restrictions']);
}
return $objFeaturePricing->id;

View File

@@ -18,7 +18,7 @@
* @license https://store.webkul.com/license.html
*/
class HotelRoomTypeFeaturePricingRule extends ObjectModel
class HotelRoomTypeFeaturePricingRestriction extends ObjectModel
{
public $id_feature_price;
public $date_selection_type;
@@ -29,8 +29,8 @@ class HotelRoomTypeFeaturePricingRule extends ObjectModel
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_room_type_feature_pricing_rule',
'primary' => 'id_feature_price_rule',
'table' => 'htl_room_type_feature_pricing_restriction',
'primary' => 'id_feature_price_restriction',
'multilang' => false,
'fields' => array(
'id_feature_price' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
@@ -45,8 +45,8 @@ class HotelRoomTypeFeaturePricingRule extends ObjectModel
);
protected $webserviceParameters = array(
'objectsNodeName' => 'price_rules',
'objectNodeName' => 'price_rule',
'objectsNodeName' => 'restrictions',
'objectNodeName' => 'restriction',
'fields' => array(
'id_feature_price' => array(
'xlink_resource' => array(
@@ -56,20 +56,20 @@ class HotelRoomTypeFeaturePricingRule extends ObjectModel
)
);
public function getRulesByIdFeaturePrice($idFeaturePrice)
public function getRestrictionsByIdFeaturePrice($idFeaturePrice)
{
$sql = 'SELECT *, id_feature_price_rule AS `id` FROM `'._DB_PREFIX_.$this->table.'`
$sql = 'SELECT *, id_feature_price_restriction AS `id` FROM `'._DB_PREFIX_.$this->table.'`
WHERE `id_feature_price` ='.(int) $idFeaturePrice;
return Db::getInstance()->executeS($sql);
}
public function deleteFeaturePriceRulesById($featurePriceRules)
public function deleteFeaturePriceRestrictionsById($featurePriceRules)
{
$res = true;
if ($featurePriceRules) {
foreach ($featurePriceRules as $idFeaturePriceRules) {
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule($idFeaturePriceRules);
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRestriction($idFeaturePriceRules);
$res &= $objFeaturePriceRule->delete();
}
}

View File

@@ -174,13 +174,13 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
public function processStatus()
{
$objFeaturePricing = $this->loadObject();
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRestriction();
if (!$objFeaturePricing->active) {
if ($this->object->validateExistingFeaturePrice(
$objFeaturePricing->id_product,
$objFeaturePricing->getGroups($objFeaturePricing->id),
$objFeaturePricing->id,
$objFeaturePriceRule->getRulesByIdFeaturePrice($objFeaturePricing->id)
$objFeaturePriceRule->getRestrictionsByIdFeaturePrice($objFeaturePricing->id)
)) {
$this->errors[] = $this->l('An advanced price rule already exists with overlapping conditions. Please update the existing rule to activate this one.');
return ;
@@ -242,8 +242,8 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
$smartyVars['objFeaturePrice'] = $objFeaturePrice;
$smartyVars['edit'] = 1;
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRule();
if ($advancePriceRules = $objFeaturePriceRule->getRulesByIdFeaturePrice($objFeaturePrice->id)) {
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRestriction();
if ($advancePriceRules = $objFeaturePriceRule->getRestrictionsByIdFeaturePrice($objFeaturePrice->id)) {
foreach ($advancePriceRules as $priceRuleKey => $advancePriceRule) {
if ($advancePriceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
$advancePriceRules[$priceRuleKey]['specific_date'] = $advancePriceRule['date_from'];
@@ -427,7 +427,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
$rowsToHighlight = [];
if (!$priceRules) {
$this->errors[] = $this->l('Atleast one rule is required while creating advance price rule.');
$this->errors[] = $this->l('Atleast one restriction is required while creating advance price rule.');
} else {
foreach ($priceRules as $priceRuleKey => $priceRule) {
if (!$priceRule['is_special_days_exists']) {
@@ -437,31 +437,30 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
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');
$this->errors = $this->l('Specific Date is missing for price rule restriction.');
}
} 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');
$this->errors[] = $this->l('Dates are invalid in price rule restriction.');
} else if ($priceRule['date_to'] == '') {
$this->errors[] = $this->l('Dates are invalid in some rules');
$this->errors[] = $this->l('Dates are invalid in price rule restriction');
$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');
$this->errors[] = $this->l('Dates are invalid in price rule restriction');
$rowsToHighlight[] = $priceRuleKey;
}
if (!Validate::isDate($dateTo)) {
$this->errors[] = $this->l('Dates are invalid in some rules');
$this->errors[] = $this->l('Dates are invalid in price rule restriction');
}
if ($dateTo < $dateFrom) {
$this->errors[] = $this->l('Dates are invalid in some rules');
$this->errors[] = $this->l('Dates are invalid in price rule restriction');
}
if ($priceRule['is_special_days_exists']) {
if (!isset($priceRule['special_days']) || !$priceRule['special_days']) {
@@ -483,7 +482,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
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'])) {
if (strtotime($rule['specific_date']) != strtotime($priceRule['specific_date'])) {
continue;
} else {
$this->errors[] = $this->l('Some dates are conflicting. Please check and reselect the dates.');
@@ -562,7 +561,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
$objFeaturePricing->id_product = $idRoomType;
$objFeaturePricing->feature_price_name = $featurePricingName[$idRoomType];
$objFeaturePricing->add();
$objFeaturePricing->saveFeaturePricesRules($objFeaturePricing->id, $priceRules);
$objFeaturePricing->saveFeaturePriceRestrictions($objFeaturePricing->id, $priceRules);
}
Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token);
@@ -572,7 +571,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
$conf = $idFeaturePrice ? 4 : 3;
if ($objFeaturePricing->save()) {
$objFeaturePricing->saveFeaturePricesRules($objFeaturePricing->id, $priceRules);
$objFeaturePricing->saveFeaturePriceRestrictions($objFeaturePricing->id, $priceRules);
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
Tools::redirectAdmin(
self::$currentIndex.'&id_feature_price='.(int) $objFeaturePricing->id.
@@ -656,7 +655,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
'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)
'specialDaysTooltipText' => $this->l('Enable this option to add restriction to specific week days (for example, weekends) of the selected date range.', null, true)
));
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');

View File

@@ -32,7 +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/HotelRoomTypeFeaturePricingRestriction.php';
require_once 'classes/ChannelOrderPayment.php';
require_once 'classes/HotelBookingDemands.php';

View File

@@ -618,7 +618,7 @@ body.adminhotelroomsbooking .ui-tooltip {
#advanced_price_rule_group .panel.advanced_price_rule {
padding: 0px;}
#advanced_price_rule_group .advance_price_rule_header_container {
#advanced_price_rule_group .advance_price_rule_header_container, .advanced_price_rule_body {
padding: 15px;}
#advanced_price_rule_group .advance_price_rule_header_container:hover {
cursor: pointer;}

View File

@@ -709,49 +709,47 @@ $(document).ready(function() {
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_container advance_price_rule_collapse').attr({'data-toggle':"collapse", 'data-target':"#advanced_price_rule_"+panelIndex})
.append($('<div>').addClass('col-xs-8 advance_price_rule_header'))
.append($('<div>').addClass('col-xs-4')
.append($('<div>').addClass('col-xs-7'))
.append($('<div>').addClass('col-xs-2')
.append($('<div>').addClass('col-xs-9 advance_price_rule_header'))
.append($('<div>').addClass('col-xs-3')
.append($('<div>').addClass('col-xs-offset-7 col-xs-2')
.append($('<a>').addClass('btn btn-default remove_advanced_price_rule')
.append($('<span>').append($('<i>').addClass('icon-trash')))))
.append($('<div>').addClass('col-xs-1'))
.append($('<div>').addClass('col-xs-2')
.append($('<div>').addClass('col-xs-offset-1 col-xs-2')
.append($('<a>').addClass('btn btn-default')
.append($('<i>').addClass('icon-caret-down')))));
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($('<label>').addClass('control-label col-xs-4').attr('for', 'advance_price_rule['+panelIndex+'][date_selection_type]').text(' ' + dateSelectionTitle))
.append($('<div>').addClass('col-xs-5')
.append($(dateSeletionOptions).attr({'name': 'advance_price_rule['+panelIndex+'][date_selection_type]', 'id': 'date_selection_type_'+panelIndex})))
.append($('<div>').addClass('col-xs-3 advanced_price_rule_body_actions')
.append($('<div>').addClass('col-xs-offset-4 col-xs-4')
.append($('<div>').addClass('col-xs-offset-7 col-xs-2')
.append($('<a>').addClass('btn btn-default remove_advanced_price_rule')
.append($('<span>').append($('<i>').addClass('icon-trash')))))
.append($('<div>').addClass('col-xs-4')
.append($('<div>').addClass('col-xs-offset-1 col-xs-2')
.append($('<a>').addClass('btn btn-default').attr({'data-toggle':"collapse", 'data-target':"#advanced_price_rule_"+panelIndex})
.append($('<i>').addClass('icon-caret-up')))));
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($('<label>').addClass('control-label col-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][specific_date]').text(' ' + specificDateText))
.append($('<div>').addClass('col-xs-5')
.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($('<label>').addClass('control-label col-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][date_from]').text(' ' + dateFromText))
.append($('<div>').addClass('col-xs-5')
.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($('<label>').addClass('control-label col-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][date_to]').text(' ' + dateToText))
.append($('<div>').addClass('col-xs-5')
.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: dateTomorrow, 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($('<label>').addClass('control-label col-xs-4 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-5')
.append($('<span>').addClass('switch prestashop-switch fixed-width-lg')
@@ -763,7 +761,7 @@ $(document).ready(function() {
$(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($('<label>').addClass('control-label col-xs-4 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('in advanced_price_rule_body')

View File

@@ -23,16 +23,14 @@
<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_container {if !isset($collapse)}shown{/if}" data-toggle="collapse" data-target="#advanced_price_rule_{$key}">
<div class="col-xs-8 advance_price_rule_header"></div>
<div class="col-xs-4">
<div class="col-xs-7"></div>
<div class="col-xs-2">
<div class="col-xs-9 advance_price_rule_header"></div>
<div class="col-xs-3">
<div class="col-xs-offset-7 col-xs-2">
<a class="btn btn-default remove_advanced_price_rule">
<i class="icon-trash"></i>
</a>
</div>
<div class="col-xs-1"></div>
<div class="col-xs-2">
<div class="col-xs-offset-1 col-xs-2">
<a class="btn btn-default">
<i class="icon-caret-down"></i>
</a>
@@ -41,7 +39,7 @@
</div>
<div id="advanced_price_rule_{$key}" class="collapse advanced_price_rule_body {if isset($collapse)}in{/if}">
<div class="form-group">
<label for="advance_price_rule[{$key}][date_selection_type]" class="control-label col-sm-4 col-xs-3">
<label for="advance_price_rule[{$key}][date_selection_type]" class="control-label col-xs-4">
{l s='Date Selection type' mod='hotelreservationsystem'}
</label>
<div class="col-xs-5">
@@ -55,12 +53,12 @@
</select>
</div>
<div class="col-xs-3 advanced_price_rule_body_actions">
<div class="col-xs-offset-4 col-xs-4">
<div class="col-xs-offset-7 col-xs-2">
<a class="btn btn-default remove_advanced_price_rule">
<i class="icon-trash"></i>
</a>
</div>
<div class="col-xs-4">
<div class="col-xs-offset-1 col-xs-2">
<a class="btn btn-default" data-toggle="collapse" data-target="#advanced_price_rule_{$key}">
<i class="icon-caret-up"></i>
</a>
@@ -69,7 +67,7 @@
</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]" >
<label class="col-xs-4 control-label required" for="advance_price_rule[{$key}][specific_date]" >
{l s='Specific Date' mod='hotelreservationsystem'}
</label>
<div class="col-xs-5">
@@ -78,7 +76,7 @@
</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]" >
<label class="col-xs-4 control-label required" for="advance_price_rule[{$key}][date_from]" >
{l s='Date From' mod='hotelreservationsystem'}
</label>
<div class="col-xs-5">
@@ -86,7 +84,7 @@
</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]" >
<label class="col-xs-4 control-label required" for="advance_price_rule[{$key}][date_to]" >
{l s='Date To' mod='hotelreservationsystem'}
</label>
<div class="col-xs-5">
@@ -95,8 +93,8 @@
</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'}">
<label class="control-label col-xs-4" 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 add restriction to specific week days (for example, weekends) of the selected date range.' mod='hotelreservationsystem'}">
{l s='Restrict to Week Days' mod='hotelreservationsystem'}
</span>
</label>
@@ -112,7 +110,7 @@
</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'] && isset($advancePriceRule['date_selection_type']) && $advancePriceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:block;"{/if}>
<label for="advance_price_rule[{$key}][special_days]" class="control-label col-sm-4 col-xs-3">
<label for="advance_price_rule[{$key}][special_days]" class="control-label col-xs-4">
{l s='Select Week Days' mod='hotelreservationsystem'}
</label>
<div class="col-xs-8 checkboxes-wrap">

View File

@@ -684,7 +684,7 @@ class QloCleaner extends Module
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_restriction', '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'),
@@ -806,7 +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_restriction',
'htl_room_type_feature_pricing_lang',
'htl_room_type_feature_pricing_group',
'htl_room_type_demand_price',