Updated the price rules to restrictions and some code optimization
This commit is contained in:
@@ -85,8 +85,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
'groups' => array('resource' => 'group'),
|
||||
'restrictions' => array(
|
||||
'resource' => 'price_rule',
|
||||
'getter' => 'getWsAdvancePriceRestriction',
|
||||
'setter' => 'setWsAdvancePriceRestriction',
|
||||
'getter' => 'getWsFeaturePriceRestriction',
|
||||
'setter' => 'setWsFeaturePriceRestriction',
|
||||
'fields' => array(
|
||||
'id' => array(),
|
||||
'date_from' => array(),
|
||||
@@ -127,47 +127,50 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
// first call to delete all the group entries
|
||||
$this->cleanGroups();
|
||||
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction();
|
||||
if ($oldFeaturePriceRestrictions = $objFeaturePriceRestriction->getRestrictionsByIdFeaturePrice($this->id)) {
|
||||
$oldFeaturePriceRestrictions = array_column($oldFeaturePriceRestrictions, 'id_feature_price_restriction', 'id_feature_price_restriction');
|
||||
$objFeaturePriceRestriction->deleteFeaturePriceRestrictionsById($oldFeaturePriceRestrictions);
|
||||
if ($existingFeaturePrices = $objFeaturePriceRestriction->getRestrictionsByIdFeaturePrice($this->id)) {
|
||||
$existingFeaturePrices = array_column($existingFeaturePrices, 'id_feature_price_restriction', 'id_feature_price_restriction');
|
||||
$objFeaturePriceRestriction->deleteFeaturePriceRestrictionsById($existingFeaturePrices);
|
||||
}
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
public function getExistingFeaturePriceRules(
|
||||
public function getFeaturePrices(
|
||||
$idRoomType,
|
||||
$groups,
|
||||
$idFeaturePrice,
|
||||
$featurePriceRules
|
||||
$restrictions = array(),
|
||||
$groups = array(),
|
||||
$skipFeaturePriceId = null,
|
||||
$active = null
|
||||
) {
|
||||
$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
|
||||
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';
|
||||
ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price` '.($groups ? ' AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')' : ' ' ).')
|
||||
WHERE 1 '.( !is_null($active) ? ' AND rtfp.`active`= '.(int) $active: ' ').' ' .(!is_null($skipFeaturePriceId) ? ' AND rtfpr.`id_feature_price`!='.(int) $skipFeaturePriceId : ' ');
|
||||
$sqlWhere = '';
|
||||
foreach ($featurePriceRules as $featurePriceRule) {
|
||||
if ($sqlWhere != '') {
|
||||
$sqlWhere .= ' OR ';
|
||||
}
|
||||
if ($restrictions && is_array($restrictions)) {
|
||||
foreach ($restrictions as $restriction) {
|
||||
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).'\')';
|
||||
$dateFrom = date('Y-m-d', strtotime($restriction['date_from']));
|
||||
$dateTo = date('Y-m-d', strtotime($restriction['date_to']));
|
||||
if ($restriction['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 ($restriction['date_selection_type'] == self::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($restriction['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).'\')';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,19 +184,19 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
public function saveFeaturePriceRestrictions($idFeaturePrice, $featurePriceRules)
|
||||
public function saveFeaturePriceRestrictions($idFeaturePrice, $restrictions)
|
||||
{
|
||||
$res = true;
|
||||
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction();
|
||||
if ($oldFeaturePriceRestrictions = $objFeaturePriceRestriction->getRestrictionsByIdFeaturePrice($idFeaturePrice)) {
|
||||
$oldFeaturePriceRestrictions = array_column($oldFeaturePriceRestrictions, 'id_feature_price_restriction', 'id_feature_price_restriction');
|
||||
if ($existingFeaturePrices = $objFeaturePriceRestriction->getRestrictionsByIdFeaturePrice($idFeaturePrice)) {
|
||||
$existingFeaturePrices = array_column($existingFeaturePrices, 'id_feature_price_restriction', 'id_feature_price_restriction');
|
||||
}
|
||||
|
||||
if ($featurePriceRules) {
|
||||
foreach ($featurePriceRules as $featurePriceRule) {
|
||||
if (isset($featurePriceRule['id']) && in_array($featurePriceRule['id'], $oldFeaturePriceRestrictions)) {
|
||||
if ($restrictions) {
|
||||
foreach ($restrictions as $featurePriceRule) {
|
||||
if (isset($featurePriceRule['id']) && in_array($featurePriceRule['id'], $existingFeaturePrices)) {
|
||||
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction($featurePriceRule['id']);
|
||||
unset($oldFeaturePriceRestrictions[$featurePriceRule['id']]);
|
||||
unset($existingFeaturePrices[$featurePriceRule['id']]);
|
||||
} else {
|
||||
$objFeaturePriceRestriction = new HotelRoomTypeFeaturePricingRestriction();
|
||||
}
|
||||
@@ -222,14 +225,13 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldFeaturePriceRestrictions) {
|
||||
$res &= $objFeaturePriceRestriction->deleteFeaturePriceRestrictionsById($oldFeaturePriceRestrictions);
|
||||
if ($existingFeaturePrices) {
|
||||
$res &= $objFeaturePriceRestriction->deleteFeaturePriceRestrictionsById($existingFeaturePrices);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [countFeaturePriceSpecialDays returns number of special days between a date range]
|
||||
* @param [array] $specialDays [array containing special days to be counted]
|
||||
@@ -638,7 +640,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getWsAdvancePriceRestriction()
|
||||
public function getWsFeaturePriceRestriction()
|
||||
{
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT *, id_feature_price_restriction AS `id` FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing_restriction`
|
||||
@@ -647,55 +649,56 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
|
||||
}
|
||||
|
||||
public function setWsAdvancePriceRestriction($priceRules)
|
||||
public function setWsFeaturePriceRestriction($restrictions)
|
||||
{
|
||||
foreach ($priceRules as $ruleKey => $priceRule) {
|
||||
if ($priceRule['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE
|
||||
&& $priceRule['is_special_days_exists']
|
||||
foreach ($restrictions as $restrictionKey => $restriction) {
|
||||
if ($restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE
|
||||
&& $restriction['is_special_days_exists']
|
||||
) {
|
||||
$specialDays = json_decode($priceRule['special_days'], true);
|
||||
$priceRules[$ruleKey]['special_days'] = $specialDays;
|
||||
$specialDays = json_decode($restriction['special_days'], true);
|
||||
$restrictions[$restrictionKey]['special_days'] = $specialDays;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->saveFeaturePriceRestrictions($this->id, $priceRules);
|
||||
return $this->saveFeaturePriceRestrictions($this->id, $restrictions);
|
||||
}
|
||||
|
||||
public function validateExistingFeaturePrice(
|
||||
public function getDuplicateRestrictions(
|
||||
$roomTypeId,
|
||||
$group,
|
||||
$idFeaturePrice,
|
||||
$featurePriceRules
|
||||
$groups,
|
||||
$skipFeaturePriceId,
|
||||
$restrictions
|
||||
) {
|
||||
$duplicateRules = array();
|
||||
if ($oldPriceRules = $this->getExistingFeaturePriceRules(
|
||||
$duplicateRestrictions = array();
|
||||
if ($existingFeturePrices = $this->getFeaturePrices(
|
||||
$roomTypeId,
|
||||
$group,
|
||||
$idFeaturePrice,
|
||||
$featurePriceRules
|
||||
$restrictions,
|
||||
$groups,
|
||||
$skipFeaturePriceId,
|
||||
true
|
||||
)) {
|
||||
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'])) {
|
||||
foreach ($existingFeturePrices as $existingFeturePrice) {
|
||||
foreach ($restrictions as $restrictionKey => $restriction) {
|
||||
if ($restriction['date_selection_type'] == $existingFeturePrice['date_selection_type']) {
|
||||
if ($restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if (strtotime($restriction['date_from']) != strtotime($existingFeturePrice['date_from'])) {
|
||||
continue;
|
||||
} else {
|
||||
$duplicateRules[] = $ruleKey;
|
||||
$duplicateRestrictions[] = $restrictionKey;
|
||||
}
|
||||
} 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'])))) {
|
||||
} else if ($restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if (((strtotime($existingFeturePrice['date_from']) < strtotime($restriction['date_from'])) && (strtotime($existingFeturePrice['date_to']) <= strtotime($restriction['date_from']))) || ((strtotime($existingFeturePrice['date_from']) > strtotime($restriction['date_from'])) && (strtotime($existingFeturePrice['date_from']) >= strtotime($restriction['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;
|
||||
if ($existingFeturePrice['is_special_days_exists'] && $restriction['is_special_days_exists']) {
|
||||
if (!empty($existingFeturePrice['special_days']) && !empty($restriction['special_days'])) {
|
||||
$existingDays = json_decode($existingFeturePrice['special_days'], true);
|
||||
if (array_intersect($existingDays, $restriction['special_days'])) {
|
||||
$duplicateRestrictions[] = $restrictionKey;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$duplicateRules[] = $ruleKey;
|
||||
$duplicateRestrictions[] = $restrictionKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -704,13 +707,13 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
return $duplicateRules;
|
||||
return $duplicateRestrictions;
|
||||
}
|
||||
|
||||
public function validateFields($die = true, $error_return = false)
|
||||
{
|
||||
if (isset($this->webservice_validation) && $this->webservice_validation) {
|
||||
$priceRules = array();
|
||||
$restrictions = array();
|
||||
$idGroups = array();
|
||||
if (isset($this->associations)) {
|
||||
foreach ($this->associations->children() as $association) {
|
||||
@@ -724,7 +727,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$entry[$fieldName] = (string)$fieldValue;
|
||||
}
|
||||
|
||||
$priceRules[] = $entry;
|
||||
$restrictions[] = $entry;
|
||||
}
|
||||
} else if ($association->getName() == 'groups') {
|
||||
$assocItems = $association->children();
|
||||
@@ -745,15 +748,15 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$idGroups = array_column($idGroups, 'id');
|
||||
}
|
||||
|
||||
if ($priceRules) {
|
||||
if ($restrictions) {
|
||||
$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;
|
||||
foreach ($restrictions as $restrictionKey => $restriction) {
|
||||
if ($restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($restriction['is_special_days_exists']) {
|
||||
$specialDays = json_decode($restriction['special_days'], true);
|
||||
$restrictions[$restrictionKey]['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);
|
||||
@@ -771,25 +774,25 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
|
||||
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'])) {
|
||||
foreach ($restrictions as $restrictionKey => $restriction) {
|
||||
foreach ($restrictions as $priceRestrictionKey => $priceRestriction) {
|
||||
if ($priceRestrictionKey != $restrictionKey) {
|
||||
if ($priceRestriction['date_selection_type'] == $restriction['date_selection_type']) {
|
||||
if ($priceRestriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if (strtotime($priceRestriction['date_from']) != strtotime($restriction['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'])))) {
|
||||
} else if ($priceRestriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if (((strtotime($restriction['date_from']) < strtotime($priceRestriction['date_from'])) && (strtotime($restriction['date_to']) <= strtotime($priceRestriction['date_from']))) || ((strtotime($restriction['date_from']) > strtotime($priceRestriction['date_from'])) && (strtotime($restriction['date_from']) >= strtotime($priceRestriction['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'])) {
|
||||
if ($restriction['is_special_days_exists'] && $priceRestriction['is_special_days_exists']) {
|
||||
if (!empty($restriction['special_days']) && !empty($priceRestriction['special_days'])) {
|
||||
if (array_intersect($restriction['special_days'], $priceRestriction['special_days'])) {
|
||||
$message = Tools::displayError('You can not add conflicting days for similar date ranges.', true);
|
||||
$hasError = true;
|
||||
break;
|
||||
@@ -810,11 +813,11 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
}
|
||||
|
||||
if (!$hasError) {
|
||||
$hasDuplicate = $this->validateExistingFeaturePrice(
|
||||
$hasDuplicate = $this->getDuplicateRestrictions(
|
||||
$this->id_product,
|
||||
$idGroups,
|
||||
$this->id,
|
||||
$priceRules
|
||||
$restrictions
|
||||
);
|
||||
|
||||
if ($hasDuplicate) {
|
||||
|
||||
@@ -176,7 +176,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$objFeaturePricing = $this->loadObject();
|
||||
$objFeaturePriceRule = new HotelRoomTypeFeaturePricingRestriction();
|
||||
if (!$objFeaturePricing->active) {
|
||||
if ($this->object->validateExistingFeaturePrice(
|
||||
if ($this->object->getDuplicateRestrictions(
|
||||
$objFeaturePricing->id_product,
|
||||
$objFeaturePricing->getGroups($objFeaturePricing->id),
|
||||
$objFeaturePricing->id,
|
||||
@@ -243,19 +243,19 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$smartyVars['edit'] = 1;
|
||||
|
||||
$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'];
|
||||
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);
|
||||
if ($restrictions = $objFeaturePriceRule->getRestrictionsByIdFeaturePrice($objFeaturePrice->id)) {
|
||||
foreach ($restrictions as $restrictionKey => $restriction) {
|
||||
if ($restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
$restrictions[$restrictionKey]['specific_date'] = $restriction['date_from'];
|
||||
unset($restrictions[$restrictionKey]['date_from']);
|
||||
unset($restrictions[$restrictionKey]['date_to']);
|
||||
} else if ($restriction['is_special_days_exists']) {
|
||||
$restrictions[$restrictionKey]['special_days'] = json_decode($restriction['special_days'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$smartyVars['advancePriceRules'] = $advancePriceRules;
|
||||
$smartyVars['restrictions'] = $restrictions;
|
||||
$smartyVars['feature_price_groups'] = $objFeaturePrice->getGroups($idFeaturePrice);
|
||||
} else {
|
||||
$tree = new HelperTree('hotels-tree');
|
||||
@@ -349,7 +349,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
|
||||
$createMultiple = Tools::getValue('create_multiple');
|
||||
|
||||
$priceRules = Tools::getValue('advance_price_rule', array());
|
||||
$restrictions = Tools::getValue('restriction', array());
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
if ($priceImpactWay == HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE) {
|
||||
$priceImpactType = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
@@ -426,35 +426,35 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
}
|
||||
|
||||
$rowsToHighlight = [];
|
||||
if (!$priceRules) {
|
||||
if (!$restrictions) {
|
||||
$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']) {
|
||||
unset($priceRules[$priceRuleKey]['special_days']);
|
||||
foreach ($restrictions as $restrictionKey => $restriction) {
|
||||
if (!$restriction['is_special_days_exists']) {
|
||||
unset($restrictions[$restrictionKey]['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'])));
|
||||
if ($restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if ($restriction['specific_date']) {
|
||||
$restrictions[$restrictionKey]['date_from'] = $restriction['specific_date'];
|
||||
$restrictions[$restrictionKey]['date_to'] = date('Y-m-d', strtotime("+1 day", strtotime($restriction['specific_date'])));
|
||||
} else {
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
$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;
|
||||
} else if ($restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($restriction['date_from'] == '') {
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
$this->errors[] = $this->l('Dates are invalid in price rule restriction.');
|
||||
} else if ($priceRule['date_to'] == '') {
|
||||
} else if ($restriction['date_to'] == '') {
|
||||
$this->errors[] = $this->l('Dates are invalid in price rule restriction');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
}
|
||||
|
||||
$dateFrom = date('Y-m-d', strtotime($priceRule['date_from']));
|
||||
$dateTo = date('Y-m-d', strtotime($priceRule['date_to']));
|
||||
$dateFrom = date('Y-m-d', strtotime($restriction['date_from']));
|
||||
$dateTo = date('Y-m-d', strtotime($restriction['date_to']));
|
||||
if (!Validate::isDate($dateFrom)) {
|
||||
$this->errors[] = $this->l('Dates are invalid in price rule restriction');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
}
|
||||
if (!Validate::isDate($dateTo)) {
|
||||
$this->errors[] = $this->l('Dates are invalid in price rule restriction');
|
||||
@@ -462,46 +462,48 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
if ($dateTo < $dateFrom) {
|
||||
$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']) {
|
||||
if ($restriction['is_special_days_exists']) {
|
||||
if (!isset($restriction['special_days']) || !$restriction['special_days']) {
|
||||
$this->errors[] = $this->l('Special days are missing for price rule having restrict to week days');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
}
|
||||
}
|
||||
unset($priceRules[$priceRuleKey]['specific_date']);
|
||||
unset($restrictions[$restrictionKey]['specific_date']);
|
||||
} else {
|
||||
unset($priceRules[$priceRuleKey]);
|
||||
unset($restrictions[$restrictionKey]);
|
||||
}
|
||||
|
||||
if ($priceRule['is_special_days_exists'] && empty($priceRule['special_days'])) {
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
if ($restriction['is_special_days_exists'] && empty($restriction['special_days'])) {
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
$this->errors[] = $this->l('Please select at least one day for week days restriction.');
|
||||
}
|
||||
}
|
||||
|
||||
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['specific_date']) != strtotime($priceRule['specific_date'])) {
|
||||
foreach ($restrictions as $restrictionKey => $restriction) {
|
||||
foreach ($restrictions as $priceRestrictionKey => $priceRestriction) {
|
||||
if ($restrictionKey != $priceRestrictionKey) {
|
||||
if ($priceRestriction['date_selection_type'] == $restriction['date_selection_type']) {
|
||||
if ($priceRestriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
if (strtotime($priceRestriction['specific_date']) != strtotime($restriction['specific_date'])) {
|
||||
continue;
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some dates are conflicting. Please check and reselect the dates.');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
}
|
||||
} 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'])))) {
|
||||
} else if ($priceRestriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if (((strtotime($restriction['date_from']) < strtotime($priceRestriction['date_from'])) && (strtotime($restriction['date_to']) <= strtotime($priceRestriction['date_from']))) || ((strtotime($restriction['date_from']) > strtotime($priceRestriction['date_from'])) && (strtotime($restriction['date_from']) >= strtotime($priceRestriction['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'])) {
|
||||
if ($restriction['is_special_days_exists'] && $priceRestriction['is_special_days_exists']) {
|
||||
if (!empty($restriction['special_days']) && !empty($priceRestriction['special_days'])) {
|
||||
if (array_intersect($restriction['special_days'], $priceRestriction['special_days'])) {
|
||||
$this->errors[] = $this->l('Some days are conflicting. Please check and update the special days.');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some dates are conflicting. Please check and reselect the date ranges.');
|
||||
$rowsToHighlight[] = $priceRuleKey;
|
||||
$rowsToHighlight[] = $restrictionKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -521,19 +523,19 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$this->errors[] = $this->l('Please select at least one group for the group access');
|
||||
}
|
||||
|
||||
$duplicatePriceRuleKey = 0;
|
||||
$duplicateRestrictionKey = 0;
|
||||
if (empty($this->errors) && $enableFeaturePrice) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
foreach ($roomTypeIds as $idRoomType) {
|
||||
$duplicatePriceRuleKey = $this->object->validateExistingFeaturePrice(
|
||||
$duplicateRestrictionKey = $this->object->getDuplicateRestrictions(
|
||||
$idRoomType,
|
||||
$groups,
|
||||
$idFeaturePrice,
|
||||
$priceRules
|
||||
$restrictions
|
||||
);
|
||||
|
||||
if ($duplicatePriceRuleKey) {
|
||||
$rowsToHighlight = array_merge($duplicatePriceRuleKey, $rowsToHighlight);
|
||||
if ($duplicateRestrictionKey) {
|
||||
$rowsToHighlight = array_merge($duplicateRestrictionKey, $rowsToHighlight);
|
||||
$objProduct = new Product((int) $idRoomType, false, $this->context->language->id);
|
||||
$this->errors[] = sprintf($this->l('An advanced price rule already exists for "%s". Please update the restrictions to avoid duplication.'), $objProduct->name);
|
||||
}
|
||||
@@ -561,7 +563,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$objFeaturePricing->id_product = $idRoomType;
|
||||
$objFeaturePricing->feature_price_name = $featurePricingName[$idRoomType];
|
||||
$objFeaturePricing->add();
|
||||
$objFeaturePricing->saveFeaturePriceRestrictions($objFeaturePricing->id, $priceRules);
|
||||
$objFeaturePricing->saveFeaturePriceRestrictions($objFeaturePricing->id, $restrictions);
|
||||
}
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token);
|
||||
@@ -571,7 +573,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
|
||||
$conf = $idFeaturePrice ? 4 : 3;
|
||||
if ($objFeaturePricing->save()) {
|
||||
$objFeaturePricing->saveFeaturePriceRestrictions($objFeaturePricing->id, $priceRules);
|
||||
$objFeaturePricing->saveFeaturePriceRestrictions($objFeaturePricing->id, $restrictions);
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(
|
||||
self::$currentIndex.'&id_feature_price='.(int) $objFeaturePricing->id.
|
||||
|
||||
@@ -617,7 +617,9 @@ body.adminhotelroomsbooking .ui-tooltip {
|
||||
}
|
||||
|
||||
#advanced_price_rule_group .panel.advanced_price_rule {
|
||||
padding: 10px 15px;}
|
||||
padding: 10px 0px;}
|
||||
#advanced_price_rule_group .advance_price_rule_header_container, .advanced_price_rule_body {
|
||||
padding: 0px 20px;}
|
||||
#advanced_price_rule_group .advance_price_rule_header_container:hover {
|
||||
cursor: pointer;}
|
||||
.advance_price_rule_header_container {
|
||||
@@ -625,13 +627,6 @@ body.adminhotelroomsbooking .ui-tooltip {
|
||||
.advance_price_rule_header_container.shown{
|
||||
align-items: center;
|
||||
display: flex;}
|
||||
.advanced_price_rule_body .advanced_price_rule_body_actions{
|
||||
display: none;
|
||||
}
|
||||
.advanced_price_rule_body.in .advanced_price_rule_body_actions,
|
||||
.advanced_price_rule_body.in .advanced_price_rule_body_actions{
|
||||
display: block;
|
||||
}
|
||||
.special_days_heading{
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
@@ -586,14 +586,14 @@ $(document).ready(function() {
|
||||
$(".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())) {
|
||||
if (parseInt($('[name="restriction['+panelIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
$('.week_days_'+panelIndex).show(200);
|
||||
}
|
||||
} else {
|
||||
$(".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())) {
|
||||
if (parseInt($('[name="restriction['+panelIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
$('.week_days_'+panelIndex).show(200);
|
||||
}
|
||||
}
|
||||
@@ -602,7 +602,7 @@ $(document).ready(function() {
|
||||
|
||||
$(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())) {
|
||||
if (parseInt($('[name="restriction['+panelIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
$('.week_days_'+panelIndex).show(200);
|
||||
} else {
|
||||
$('.week_days_'+panelIndex).hide(200);
|
||||
@@ -642,6 +642,7 @@ $(document).ready(function() {
|
||||
let elem = $(e.target).closest('.advanced_price_rule');
|
||||
udpateCollapseHeading(elem);
|
||||
$(elem).find('.advance_price_rule_header_container').addClass('shown');
|
||||
$(elem).find('.advanced_price_rule_body .advanced_price_rule_body_actions').hide();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -653,9 +654,9 @@ $(document).ready(function() {
|
||||
let dateFrom = $('#feature_plan_date_from_'+rowIndex).val();
|
||||
let dateTo = $('#feature_plan_date_to_'+rowIndex).val();
|
||||
priceRuleHeadingText = date_selection_types.range.title + ' ('+ dateFrom+ ' - '+ dateTo +')'
|
||||
if (parseInt($('[name="advance_price_rule['+rowIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
if (parseInt($('[name="restriction['+rowIndex+'][is_special_days_exists]"]:checked').val())) {
|
||||
let special_days = [];
|
||||
$('[name="advance_price_rule['+rowIndex+'][special_days][]"]').each(function(){
|
||||
$('[name="restriction['+rowIndex+'][special_days][]"]').each(function(){
|
||||
if ($(this).prop('checked')) {
|
||||
special_days.push($(this).parent().text().trim());
|
||||
}
|
||||
@@ -684,6 +685,7 @@ $(document).ready(function() {
|
||||
$(document).on('show.bs.collapse', function(e) {
|
||||
if ($(e.target).hasClass('advanced_price_rule_body')) {
|
||||
$(e.target).closest('.advanced_price_rule').find('.advance_price_rule_header_container').removeClass('shown');
|
||||
$(e.target).closest('.advanced_price_rule').find('.advanced_price_rule_body .advanced_price_rule_body_actions').show();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -707,7 +709,7 @@ $(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 idElem = $('<input>').attr('type', 'hidden').attr('name', 'restriction['+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-9 advance_price_rule_header'))
|
||||
.append($('<div>').addClass('col-xs-3')
|
||||
@@ -719,9 +721,9 @@ $(document).ready(function() {
|
||||
.append($('<i>').addClass('icon-caret-down')))));
|
||||
|
||||
let dateSelectionElem = $('<div>').addClass('form-group')
|
||||
.append($('<label>').addClass('control-label col-xs-4').attr('for', 'advance_price_rule['+panelIndex+'][date_selection_type]').text(' ' + dateSelectionTitle))
|
||||
.append($('<label>').addClass('control-label col-xs-4').attr('for', 'restriction['+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($(dateSeletionOptions).attr({'name': 'restriction['+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-7 col-xs-2')
|
||||
.append($('<a>').addClass('btn btn-default remove_advanced_price_rule')
|
||||
@@ -731,37 +733,37 @@ $(document).ready(function() {
|
||||
.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-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][specific_date]').text(' ' + specificDateText))
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'restriction['+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'})));
|
||||
.attr({type:'text', id: 'specific_date_'+panelIndex, name: 'restriction['+panelIndex+'][specific_date]', value: dateToday, readonly: 'readonly'})));
|
||||
|
||||
let dateFromElem = $('<div>').addClass('form-group date_range_type_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][date_from]').text(' ' + dateFromText))
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'restriction['+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'})));
|
||||
.attr({type:'text', id: 'feature_plan_date_from_'+panelIndex, name: 'restriction['+panelIndex+'][date_from]', value: dateToday, readonly: 'readonly'})));
|
||||
|
||||
let dateToElem = $('<div>').addClass('form-group date_range_type_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][date_to]').text(' ' + dateToText))
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'restriction['+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'})));
|
||||
.attr({type:'text', id: 'feature_plan_date_to_'+panelIndex, name: 'restriction['+panelIndex+'][date_to]', value: dateTomorrow, readonly: 'readonly'})));
|
||||
|
||||
let specialDaysElement = $('<div>').addClass('form-group special_days_content_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][is_special_days_exists]')
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'restriction['+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')
|
||||
.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($('<input>').attr({'type': 'radio', 'value': 1, 'name': 'restriction['+panelIndex+'][is_special_days_exists]', 'id': 'restriction['+panelIndex+'][is_special_days_exists_on]'}).addClass('is_special_days_exists'))
|
||||
.append($('<label>').attr({'for': 'restriction['+panelIndex+'][is_special_days_exists_on]'}).text(yesText))
|
||||
.append($('<input>').attr({'type': 'radio', 'value': 0, 'name': 'restriction['+panelIndex+'][is_special_days_exists]', 'id': 'restriction['+panelIndex+'][is_special_days_exists_off]', 'checked':'checked'}).addClass('is_special_days_exists'))
|
||||
.append($('<label>').attr({'for': 'restriction['+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][]');
|
||||
$(weekDaysOptions).find('input[type="checkbox"]').attr('name', 'restriction['+panelIndex+'][special_days][]');
|
||||
let specialDaysCheckBoxElem = $('<div>').addClass('form-group week_days week_days_'+panelIndex)
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'advance_price_rule['+panelIndex+'][special_days]').text(' ' +weekDaysText))
|
||||
.append($('<label>').addClass('control-label col-xs-4 required').attr('for', 'restriction['+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')
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*}
|
||||
|
||||
<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}">
|
||||
<input type="hidden" name="restriction[{$key}][id]" value="{if isset($restriction['id'])}{$restriction['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-9 advance_price_rule_header"></div>
|
||||
<div class="col-xs-3">
|
||||
@@ -39,15 +39,15 @@
|
||||
</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-xs-4">
|
||||
<label for="restriction[{$key}][date_selection_type]" class="control-label col-xs-4">
|
||||
{l s='Date Selection type' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-5">
|
||||
<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}>
|
||||
<select class="form-control date_selection_type" name="restriction[{$key}][date_selection_type]" id="date_selection_type_{$key}">
|
||||
<option value="{HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}" {if isset($restriction['date_selection_type']) && $restriction['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}>
|
||||
<option value="{HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC}" {if isset($restriction['date_selection_type']) && $restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC}selected="seleted"{/if}>
|
||||
{l s='Specific Date' mod='hotelreservationsystem'}
|
||||
</option>
|
||||
</select>
|
||||
@@ -66,57 +66,57 @@
|
||||
</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-xs-4 control-label required" for="advance_price_rule[{$key}][specific_date]" >
|
||||
<div class="form-group specific_date_type_{$key}" {if !isset($restriction['date_selection_type']) || $restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="col-xs-4 control-label required" for="restriction[{$key}][specific_date]" >
|
||||
{l s='Specific Date' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-5">
|
||||
<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/>
|
||||
<input type="text" id="specific_date_{$key}" name="restriction[{$key}][specific_date]" class="specific_date form-control datepicker-input" value="{if isset($restriction['specific_date'])}{$restriction['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-xs-4 control-label required" for="advance_price_rule[{$key}][date_from]" >
|
||||
<div class="form-group date_range_type_{$key}" {if isset($restriction['date_selection_type']) && $restriction['date_selection_type'] != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="col-xs-4 control-label required" for="restriction[{$key}][date_from]" >
|
||||
{l s='Date From' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-5">
|
||||
<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/>
|
||||
<input type="text" id="feature_plan_date_from_{$key}" name="restriction[{$key}][date_from]" class="feature_plan_date_from form-control datepicker-input" value="{if isset($restriction['date_from'])}{$restriction['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-xs-4 control-label required" for="advance_price_rule[{$key}][date_to]" >
|
||||
<div class="form-group date_range_type_{$key}" {if isset($restriction['date_selection_type']) && $restriction['date_selection_type'] != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="col-xs-4 control-label required" for="restriction[{$key}][date_to]" >
|
||||
{l s='Date To' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-xs-5">
|
||||
<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/>
|
||||
<input type="text" id="feature_plan_date_to_{$key}" name="restriction[{$key}][date_to]" class="feature_plan_date_to form-control datepicker-input" value="{if isset($restriction['date_to'])}{$restriction['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-xs-4" for="advance_price_rule[{$key}][is_special_days_exists]">
|
||||
<div class="form-group special_days_content_{$key}" {if isset($restriction['date_selection_type']) && $restriction['date_selection_type'] != HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:none;"{/if}>
|
||||
<label class="control-label col-xs-4" for="restriction[{$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>
|
||||
<div class="col-xs-5">
|
||||
<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>
|
||||
<input type="radio" value="1" id="restriction[{$key}][is_special_days_exists_on]" name="restriction[{$key}][is_special_days_exists]" class="is_special_days_exists" {if isset($restriction['is_special_days_exists']) && $restriction['is_special_days_exists']}checked="checked"{/if}>
|
||||
<label for="restriction[{$key}][is_special_days_exists_on]">{l s='Yes' mod='hotelreservationsystem'}</label>
|
||||
<input type="radio" value="0" id="restriction[{$key}][is_special_days_exists_off]" name="restriction[{$key}][is_special_days_exists]" class="is_special_days_exists" {if !isset($restriction['is_special_days_exists']) || !$restriction['is_special_days_exists']}checked="checked"{/if}>
|
||||
<label for="restriction[{$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'] && 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-xs-4">
|
||||
<div class="form-group week_days week_days_{$key}" {if isset($restriction['special_days']) && is_array($restriction['special_days']) && isset($restriction['is_special_days_exists']) && $restriction['is_special_days_exists'] && isset($restriction['date_selection_type']) && $restriction['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}style="display:block;"{/if}>
|
||||
<label for="restriction[{$key}][special_days]" class="control-label col-xs-4">
|
||||
{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}/>
|
||||
<input type="checkbox" name="restriction[{$key}][special_days][]" value="{$dayVal}" {if (isset($restriction['special_days']) && is_array($restriction['special_days']) && in_array($dayVal, $restriction['special_days']))}checked="checked" {/if}/>
|
||||
<p>{$day}</p>
|
||||
</div>
|
||||
{/foreach}
|
||||
|
||||
@@ -119,11 +119,11 @@
|
||||
<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 isset($smarty.post.restrictions) && $smarty.post.restrictions}
|
||||
{assign var='restrictions' value=$smarty.post.restrictions}
|
||||
{/if}
|
||||
{if isset($advancePriceRules) && $advancePriceRules}
|
||||
{foreach $advancePriceRules as $key => $rule}
|
||||
{if isset($restrictions) && $restrictions}
|
||||
{foreach $restrictions as $key => $restriction}
|
||||
{include file="../../../_partials/feature_price_rules.tpl" key=$key advancePriceRule=$rule}
|
||||
{/foreach}
|
||||
{else}
|
||||
|
||||
Reference in New Issue
Block a user