optimized the multiple price rules creation flow
This commit is contained in:
@@ -202,11 +202,6 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
{
|
||||
parent::initToolbar();
|
||||
if (empty($this->display) || $this->display == 'list') {
|
||||
$this->page_header_toolbar_btn['bulk_add'] = array(
|
||||
'href' => self::$currentIndex.'&bulkAdd'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Bulk create rules'),
|
||||
'imgclass' => 'new'
|
||||
);
|
||||
$this->page_header_toolbar_btn['new'] = array(
|
||||
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Add new rule'),
|
||||
@@ -216,34 +211,6 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$this->toolbar_btn = array();
|
||||
}
|
||||
|
||||
public function initToolbarTitle()
|
||||
{
|
||||
parent::initToolbarTitle();
|
||||
if (Tools::isSubmit('bulkAdd'.$this->table)) {
|
||||
$this->toolbar_title[] = $this->l('Bulk Create', null, null, false);
|
||||
$this->addMetaTitle($this->l('Bulk Create', null, null, false));
|
||||
}
|
||||
}
|
||||
|
||||
public function initProcess()
|
||||
{
|
||||
parent::initProcess();
|
||||
if (Tools::isSubmit('bulkAdd'.$this->table)) {
|
||||
self::$currentIndex = self::$currentIndex.'&bulkAdd'.$this->table.'';
|
||||
$this->action = 'new';
|
||||
$this->display = 'add';
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitBulkAdd'.$this->table)) {
|
||||
if ($this->tabAccess['add'] === '1') {
|
||||
$this->action = 'bulkSave';
|
||||
$this->display = 'list';
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to add this.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->addRowAction('edit');
|
||||
@@ -281,15 +248,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$smartyVars['edit'] = 1;
|
||||
|
||||
$smartyVars['feature_price_groups'] = $objFeaturePrice->getGroups($idFeaturePrice);
|
||||
}
|
||||
|
||||
$smartyVars['defaultcurrency_sign'] = $currencySign;
|
||||
$smartyVars['date_from'] = $dateFrom;
|
||||
$smartyVars['date_to'] = $dateTo;
|
||||
$smartyVars['groups'] = Group::getGroups($this->context->language->id);
|
||||
if (Tools::isSubmit('bulkAdd'.$this->table)) {
|
||||
$this->submit_action = 'submitBulkAdd'.$this->table;
|
||||
$smartyVars['bulk_add'] = true;
|
||||
} else {
|
||||
$tree = new HelperTree('hotels-tree');
|
||||
if ($treeData = HotelHelper::generateTreeData([
|
||||
'rootNode' => HotelHelper::NODE_HOTEL,
|
||||
@@ -313,12 +272,18 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$smartyVars['hotel_tree'] = $tree->render();
|
||||
}
|
||||
|
||||
$smartyVars['defaultcurrency_sign'] = $currencySign;
|
||||
$smartyVars['date_from'] = $dateFrom;
|
||||
$smartyVars['date_to'] = $dateTo;
|
||||
$smartyVars['groups'] = Group::getGroups($this->context->language->id);
|
||||
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
$this->fields_form = array(
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
@@ -406,38 +371,66 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$groups = Tools::getValue('groupBox');
|
||||
$jsonSpecialDays = json_encode($specialDays);
|
||||
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
|
||||
$createMultiple = Tools::getValue('create_multiple');
|
||||
if (!$createMultiple) {
|
||||
$roomTypeIds = array($roomTypeId);
|
||||
} else {
|
||||
$roomTypeIds = Tools::getValue('room_type_box');
|
||||
}
|
||||
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
|
||||
if ($priceImpactWay == HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE) {
|
||||
$priceImpactType = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
}
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
$objDefaultLang = new language($defaultLangId);
|
||||
|
||||
if (!Tools::getValue('feature_price_name_'.$defaultLangId)) {
|
||||
if (!($priceRuleNameDefault = Tools::getValue('feature_price_name_'.$defaultLangId))) {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('Advanced price rule name is required at least in %s'),
|
||||
$objDefaultLang->name
|
||||
);
|
||||
} else {
|
||||
if (preg_match('{room_type_name}', $priceRuleNameDefault)) {
|
||||
$priceRuleNameDefault = str_replace('{room_type_name}', '%s', $priceRuleNameDefault);
|
||||
}
|
||||
}
|
||||
|
||||
$validateRules = call_user_func(
|
||||
array('HotelRoomTypeFeaturePricing', 'getValidationRules'),
|
||||
'HotelRoomTypeFeaturePricing'
|
||||
);
|
||||
foreach ($languages as $language) {
|
||||
if (!Validate::isCatalogName(Tools::getValue('feature_price_name_'.$language['id_lang']))) {
|
||||
$this->errors[] = $this->l('Advanced price rule name is invalid in ').$language['name'];
|
||||
} elseif (Tools::strlen(Tools::getValue('feature_price_name_'.$language['id_lang'])) > $validateRules['sizeLang']['feature_price_name']) {
|
||||
sprintf(
|
||||
$this->l('Advanced price rule Name field is too long (%2$d chars max).'),
|
||||
$validateRules['sizeLang']['feature_price_name']
|
||||
);
|
||||
$featurePricingName = array();
|
||||
if ($roomTypeIds) {
|
||||
foreach ($roomTypeIds as $idRoomType) {
|
||||
$objProduct = new Product((int) $idRoomType);
|
||||
foreach ($languages as $lang) {
|
||||
$priceRuleName = Tools::getValue('feature_price_name_'.$lang['id_lang']);
|
||||
if ($priceRuleName) {
|
||||
if (preg_match('{room_type_name}', $priceRuleName)) {
|
||||
$priceRuleName = str_replace('{room_type_name}', $objProduct->name[$lang['id_lang']], $priceRuleName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Validate::isCatalogName($priceRuleName)) {
|
||||
$this->errors[] = $this->l('Advanced price rule name is invalid in ').$lang['name'];
|
||||
} elseif (Tools::strlen($priceRuleName) > $validateRules['sizeLang']['feature_price_name']) {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('Advanced price rule Name field is too long (%d chars max).'),
|
||||
$validateRules['sizeLang']['feature_price_name']
|
||||
);
|
||||
}
|
||||
|
||||
if ($priceRuleName) {
|
||||
$featurePricingName[$idRoomType][$lang['id_lang']] = $priceRuleName;
|
||||
} else {
|
||||
$featurePricingName[$idRoomType][$lang['id_lang']] = $priceRuleNameDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$roomTypeId) {
|
||||
if (!$roomTypeId && !$createMultiple) {
|
||||
$this->errors[] = $this->l('Room is not selected. Please try again.');
|
||||
}
|
||||
|
||||
@@ -460,7 +453,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
$this->errors[] = $this->l('Invalid Date To.');
|
||||
}
|
||||
if ($dateTo < $dateFrom) {
|
||||
$this->errors[] = $this->l('Date To must be a date after Date From.');
|
||||
$this->errors[] = $this->l('Date To cannot be smaller than Date From.');
|
||||
}
|
||||
if ($isSpecialDaysExists) {
|
||||
if (!isset($specialDays) || !$specialDays) {
|
||||
@@ -479,81 +472,87 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
|
||||
if (!$impactValue) {
|
||||
$this->errors[] = $this->l('Please enter a valid impact value.');
|
||||
} else {
|
||||
if (!Validate::isPrice($impactValue)) {
|
||||
$this->errors[] = $this->l('Invalid value of impact value.');
|
||||
} else if ($priceImpactType == HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE
|
||||
&& $impactValue > 100 // check if percentage added is greater then 100
|
||||
) {
|
||||
$this->errors[] = $this->l('Invalid value of impact value.');
|
||||
}
|
||||
} else if (!Validate::isPrice($impactValue)) {
|
||||
$this->errors[] = $this->l('Invalid value of impact value.');
|
||||
} else if ($priceImpactType == HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE
|
||||
&& $impactValue > 100 // check if percentage added is greater then 100
|
||||
) {
|
||||
$this->errors[] = $this->l('Invalid value of impact value.');
|
||||
}
|
||||
|
||||
if (!(bool)$groups) {
|
||||
$this->errors[] = $this->l('Please select at least one group for the group access');
|
||||
}
|
||||
|
||||
|
||||
$isPlanTypeExists = 0;
|
||||
if ($isSpecialDaysExists && $jsonSpecialDays == 'false') {
|
||||
$this->errors[] = $this->l('Please select at least one day for week days restriction.');
|
||||
} else if (empty($this->errors)) {
|
||||
$isPlanTypeExists = $this->validateExistingFeaturePrice(
|
||||
$dateSelectionType,
|
||||
$roomTypeId,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$groups,
|
||||
$idFeaturePrice,
|
||||
$isSpecialDaysExists,
|
||||
$jsonSpecialDays
|
||||
);
|
||||
}
|
||||
if ($isPlanTypeExists) {
|
||||
$this->errors[] = $this->l('An advanced price rule already exists in which some dates are common with this plan. Please select a different date range.');
|
||||
} else {
|
||||
if (!count($this->errors)) {
|
||||
if ($idFeaturePrice) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing($idFeaturePrice);
|
||||
}
|
||||
$objFeaturePricing->id_product = $roomTypeId;
|
||||
// lang fields
|
||||
foreach ($languages as $language) {
|
||||
if (Tools::getValue('feature_price_name_'.$language['id_lang'])) {
|
||||
$objFeaturePricing->feature_price_name[$language['id_lang']] = Tools::getValue(
|
||||
'feature_price_name_'.$language['id_lang']
|
||||
);
|
||||
} else {
|
||||
$objFeaturePricing->feature_price_name[$language['id_lang']] = Tools::getValue(
|
||||
'feature_price_name_'.$defaultLangId
|
||||
);
|
||||
}
|
||||
}
|
||||
$objFeaturePricing->date_selection_type = $dateSelectionType;
|
||||
$objFeaturePricing->date_from = $dateFrom;
|
||||
$objFeaturePricing->date_to = $dateTo;
|
||||
$objFeaturePricing->impact_way = $priceImpactWay;
|
||||
$objFeaturePricing->is_special_days_exists = $isSpecialDaysExists;
|
||||
$objFeaturePricing->special_days = $jsonSpecialDays;
|
||||
$objFeaturePricing->impact_type = $priceImpactType;
|
||||
$objFeaturePricing->impact_value = $impactValue;
|
||||
$objFeaturePricing->active = $enableFeaturePrice;
|
||||
|
||||
// set the values of the groups for this feature price
|
||||
$objFeaturePricing->groupBox = $groups;
|
||||
if ($createMultiple && empty($roomTypeIds)) {
|
||||
$this->errors[] = $this->l('Please select at least one room type for creating multiple price rules.');
|
||||
} else if (empty($this->errors)) {
|
||||
foreach ($roomTypeIds as $idRoomType) {
|
||||
$isPlanTypeExists = $this->validateExistingFeaturePrice(
|
||||
$dateSelectionType,
|
||||
$idRoomType,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$groups,
|
||||
$idFeaturePrice,
|
||||
$isSpecialDaysExists,
|
||||
$jsonSpecialDays
|
||||
);
|
||||
|
||||
if ($objFeaturePricing->save()) {
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(
|
||||
self::$currentIndex.'&id_feature_price='.(int) $objFeaturePricing->id.
|
||||
'&update'.$this->table.'&conf=4&token='.$this->token
|
||||
);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
if ($isPlanTypeExists) {
|
||||
$objProduct = new Product((int) $idRoomType, false, $this->context->language->id);
|
||||
$this->errors[] = sprintf($this->l('An advanced price rule already exists for "%s" for the selected date range. Please select a different date range.'), $objProduct->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isPlanTypeExists && !count($this->errors)) {
|
||||
if ($idFeaturePrice) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing($idFeaturePrice);
|
||||
}
|
||||
|
||||
// lang fields
|
||||
$objFeaturePricing->date_selection_type = $dateSelectionType;
|
||||
$objFeaturePricing->date_from = $dateFrom;
|
||||
$objFeaturePricing->date_to = $dateTo;
|
||||
$objFeaturePricing->impact_way = $priceImpactWay;
|
||||
$objFeaturePricing->is_special_days_exists = $isSpecialDaysExists;
|
||||
$objFeaturePricing->special_days = $jsonSpecialDays;
|
||||
$objFeaturePricing->impact_type = $priceImpactType;
|
||||
$objFeaturePricing->impact_value = $impactValue;
|
||||
$objFeaturePricing->active = $enableFeaturePrice;
|
||||
|
||||
// set the values of the groups for this feature price
|
||||
$objFeaturePricing->groupBox = $groups;
|
||||
$objFeaturePricing->id_product = $roomTypeId;
|
||||
if ($createMultiple) {
|
||||
foreach ($roomTypeIds as $idRoomType) {
|
||||
$objFeaturePricing->id_product = $idRoomType;
|
||||
$objFeaturePricing->feature_price_name = $featurePricingName[$idRoomType];
|
||||
$objFeaturePricing->add();
|
||||
}
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token);
|
||||
} else {
|
||||
$objFeaturePricing->feature_price_name = $featurePricingName[$roomTypeId];
|
||||
}
|
||||
|
||||
if ($objFeaturePricing->save()) {
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(
|
||||
self::$currentIndex.'&id_feature_price='.(int) $objFeaturePricing->id.
|
||||
'&update'.$this->table.'&conf=4&token='.$this->token
|
||||
);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured while saving advanced price rule.');
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured while saving advanced price rule.');
|
||||
}
|
||||
}
|
||||
if (isset($idFeaturePrice) && $idFeaturePrice) {
|
||||
@@ -563,167 +562,6 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function processBulkSave()
|
||||
{
|
||||
$enableFeaturePrice = Tools::getValue('enable_feature_price');
|
||||
$roomTypeIds = Tools::getValue('room_type_box');
|
||||
$dateFrom = Tools::getValue('date_from');
|
||||
$dateTo = Tools::getValue('date_to');
|
||||
$isSpecialDaysExists = Tools::getValue('is_special_days_exists');
|
||||
$specialDays = Tools::getValue('special_days');
|
||||
$priceImpactWay = Tools::getValue('price_impact_way');
|
||||
$priceImpactType = Tools::getValue('price_impact_type');
|
||||
$impactValue = Tools::getValue('impact_value');
|
||||
$dateSelectionType = Tools::getValue('date_selection_type');
|
||||
$specificDate = date('Y-m-d', strtotime(Tools::getValue('specific_date')));
|
||||
$groups = Tools::getValue('groupBox');
|
||||
$jsonSpecialDays = json_encode($specialDays);
|
||||
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
|
||||
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
|
||||
if ($priceImpactWay == HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE) {
|
||||
$priceImpactType = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
|
||||
}
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
$objDefaultLang = new language($defaultLangId);
|
||||
$featurePricingName = array();
|
||||
if (!Tools::getValue('feature_price_name_'.$defaultLangId)) {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('Advanced price rule name is required at least in %s'),
|
||||
$objDefaultLang->name
|
||||
);
|
||||
}
|
||||
|
||||
$validateRules = call_user_func(
|
||||
array('HotelRoomTypeFeaturePricing', 'getValidationRules'),
|
||||
'HotelRoomTypeFeaturePricing'
|
||||
);
|
||||
foreach ($languages as $language) {
|
||||
if (!Validate::isCatalogName(Tools::getValue('feature_price_name_'.$language['id_lang']))) {
|
||||
$this->errors[] = $this->l('Advanced price rule name is invalid in ').$language['name'];
|
||||
} elseif (Tools::strlen(Tools::getValue('feature_price_name_'.$language['id_lang'])) > $validateRules['sizeLang']['feature_price_name']) {
|
||||
sprintf(
|
||||
$this->l('Advanced price rule Name field is too long (%2$d chars max).'),
|
||||
$validateRules['sizeLang']['feature_price_name']
|
||||
);
|
||||
}
|
||||
|
||||
if (Tools::getValue('feature_price_name_'.$language['id_lang'])) {
|
||||
$featurePricingName[$language['id_lang']] = Tools::getValue('feature_price_name_'.$language['id_lang']);
|
||||
} else {
|
||||
$featurePricingName[$language['id_lang']] = Tools::getValue('feature_price_name_'.$defaultLangId);
|
||||
}
|
||||
}
|
||||
if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
|
||||
$dateFrom = $specificDate;
|
||||
$dateTo = date('Y-m-d', strtotime("+1 day", strtotime($specificDate)));
|
||||
} else if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
|
||||
if ($dateFrom == '') {
|
||||
$this->errors[] = $this->l('Please choose Date from for the advanced price rule.');
|
||||
}
|
||||
if ($dateTo == '') {
|
||||
$this->errors[] = $this->l('Please choose Date to for the advanced price rule.');
|
||||
}
|
||||
$dateFrom = date('Y-m-d', strtotime($dateFrom));
|
||||
$dateTo = date('Y-m-d', strtotime($dateTo));
|
||||
if (!Validate::isDate($dateFrom)) {
|
||||
$this->errors[] = $this->l('Invalid Date From.');
|
||||
}
|
||||
if (!Validate::isDate($dateTo)) {
|
||||
$this->errors[] = $this->l('Invalid Date To.');
|
||||
}
|
||||
if ($dateTo < $dateFrom) {
|
||||
$this->errors[] = $this->l('Date To must be a date after Date From.');
|
||||
}
|
||||
if ($isSpecialDaysExists) {
|
||||
if (!isset($specialDays) || !$specialDays) {
|
||||
$this->errors[] = $this->l('Please select at least one day for week days restriction.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($specificDate == '') {
|
||||
$this->errors[] = $this->l('Please choose Date from for the advanced price rule.');
|
||||
}
|
||||
$specificDate = date('Y-m-d', strtotime($specificDate));
|
||||
if (!Validate::isDate($specificDate)) {
|
||||
$this->errors[] = $this->l('Invalid Date From.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$impactValue) {
|
||||
$this->errors[] = $this->l('Please enter a valid impact value.');
|
||||
} else {
|
||||
if (!Validate::isPrice($impactValue)) {
|
||||
$this->errors[] = $this->l('Invalid value of impact value.');
|
||||
} else if ($priceImpactType == HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE
|
||||
&& $impactValue > 100 // check if percentage added is greater then 100
|
||||
) {
|
||||
$this->errors[] = $this->l('Invalid value of impact value.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!(bool)$groups) {
|
||||
$this->errors[] = $this->l('Please select at least one group for the group access');
|
||||
}
|
||||
|
||||
$isPlanTypeExists = 0;
|
||||
if (empty($roomTypeIds)) {
|
||||
$this->errors[] = $this->l('Please select at least one room type for bulk creation process.');
|
||||
} else if (empty($this->errors)) {
|
||||
if ($isSpecialDaysExists && $jsonSpecialDays == 'false') {
|
||||
$this->errors[] = $this->l('Please select at least one day for week days restriction.');
|
||||
} else {
|
||||
foreach ($roomTypeIds as $roomTypeId) {
|
||||
$isPlanTypeExists = $this->validateExistingFeaturePrice(
|
||||
$dateSelectionType,
|
||||
$roomTypeId,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$groups,
|
||||
0,
|
||||
$isSpecialDaysExists,
|
||||
$jsonSpecialDays
|
||||
);
|
||||
|
||||
if ($isPlanTypeExists) {
|
||||
$objProduct = new Product((int) $roomTypeId, false, $this->context->language->id);
|
||||
$this->errors[] = sprintf($this->l('An advanced price rule already exists for "%s" for the selected date range. Please select a different date range.'), $objProduct->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->errors)) {
|
||||
$res = true;
|
||||
foreach ($roomTypeIds as $roomTypeId) {
|
||||
$objFeaturePricing = new HotelRoomTypeFeaturePricing();
|
||||
$objFeaturePricing->id_product = $roomTypeId;
|
||||
$objFeaturePricing->feature_price_name = $featurePricingName;
|
||||
$objFeaturePricing->date_selection_type = $dateSelectionType;
|
||||
$objFeaturePricing->date_from = $dateFrom;
|
||||
$objFeaturePricing->date_to = $dateTo;
|
||||
$objFeaturePricing->impact_way = $priceImpactWay;
|
||||
$objFeaturePricing->is_special_days_exists = $isSpecialDaysExists;
|
||||
$objFeaturePricing->special_days = $jsonSpecialDays;
|
||||
$objFeaturePricing->impact_type = $priceImpactType;
|
||||
$objFeaturePricing->impact_value = $impactValue;
|
||||
$objFeaturePricing->active = $enableFeaturePrice;
|
||||
|
||||
// set the values of the groups for this feature price
|
||||
$objFeaturePricing->groupBox = $groups;
|
||||
$res &= $objFeaturePricing->save();
|
||||
}
|
||||
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelFeaturePricesSettings').'&conf=4&token='.$this->token);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->errors)) {
|
||||
$this->display = 'add';
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessSearchProductByName()
|
||||
{
|
||||
$response = array('status' => 'failed');
|
||||
|
||||
@@ -569,6 +569,28 @@ $(document).ready(function() {
|
||||
|
||||
/* ---- AdminHotelFeaturePricesSettingsController Admin ---- */
|
||||
|
||||
if ($('input[name="create_multiple"]:checked').val() == 1) {
|
||||
$('.room-type-name').hide();
|
||||
$('.room-type-name-tree').show();
|
||||
$('[name="submitAddhtl_room_type_feature_pricingAndStay"]').hide();
|
||||
} else {
|
||||
$('.room-type-name').show();
|
||||
$('[name="submitAddhtl_room_type_feature_pricingAndStay"]').show();
|
||||
$('.room-type-name-tree').hide();
|
||||
}
|
||||
|
||||
$(document).on('change', 'input[name="create_multiple"]', function() {
|
||||
if ($('input[name="create_multiple"]:checked').val() == 1) {
|
||||
$('.room-type-name').hide();
|
||||
$('.room-type-name-tree').show();
|
||||
$('[name="submitAddhtl_room_type_feature_pricingAndStay"]').hide();
|
||||
} else {
|
||||
$('.room-type-name').show();
|
||||
$('[name="submitAddhtl_room_type_feature_pricingAndStay"]').show();
|
||||
$('.room-type-name-tree').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#date_selection_type').on('change', function() {
|
||||
if ($('#date_selection_type').val() == date_selection_types.specific) {
|
||||
$(".specific_date_type").show(200);
|
||||
|
||||
@@ -57,36 +57,57 @@
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="col-xs-3 col-xs-offset-3 help-block">
|
||||
{l s='Use {room_type_name} to generate dynamic feature price names.' mod='hotelreservationsystem'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if isset($bulk_add)}
|
||||
<div class="form-group room-type-name">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
{l s='Select Room Types:' mod='hotelreservationsystem'}
|
||||
{if !isset($objFeaturePrice) || !$objFeaturePrice->id}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">
|
||||
<span class="label-tooltip" data-toggle="tooltip" data-html="true" title="" data-original-title="{l s='Enable this option to create advance price rules for multiple room types.' mod='hotelreservationsystem'}">
|
||||
{l s='Create for multiple room types' mod='hotelreservationsystem'}
|
||||
</span>
|
||||
</label>
|
||||
<div class="col-sm-7">
|
||||
{$hotel_tree}
|
||||
<div class="col-lg-9 ">
|
||||
<span class="switch prestashop-switch fixed-width-lg">
|
||||
<input type="radio" {if isset($smarty.post.create_multiple) && $smarty.post.create_multiple == 1}checked="checked" {/if} value="1" id="create_multiple_on" name="create_multiple">
|
||||
<label for="create_multiple_on">{l s='Yes' mod='hotelreservationsystem'}</label>
|
||||
<input {if !isset($smarty.post.create_multiple) || isset($smarty.post.create_multiple) && $smarty.post.create_multiple == 0} checked="checked" {/if} type="radio" value="0" id="create_multiple_off" name="create_multiple">
|
||||
<label for="create_multiple_off">{l s='No' mod='hotelreservationsystem'}</label>
|
||||
<a class="slide-button btn"></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<div class="form-group room-type-name">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
{l s='Room Type :' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-3">
|
||||
<input autocomplete="off" type="text" id="room_type_name" name="room_type_name" class="form-control" placeholder= "{l s='Enter room type name' mod='hotelreservationsystem'}" value="{if isset($productName)}{$productName}{/if}"/>
|
||||
<input type="hidden" id="room_type_id" name="room_type_id" class="form-control" value="{if isset($objFeaturePrice->id_product)}{$objFeaturePrice->id_product}{else}0{/if}"/>
|
||||
<div class="dropdown">
|
||||
<ul class="room_type_search_results_ul"></ul>
|
||||
</div>
|
||||
<p class="error-block" style="display:none; color: #CD5D5D;">{l s='No match found for this search. Please try with an existing name.' mod='hotelreservationsystem'}</p>
|
||||
<div class="help-block">
|
||||
{l s='Enter room type name and select the room for which you are going to create this advanced price rule.' mod='hotelreservationsystem'}
|
||||
{if isset($hotel_tree)}
|
||||
<div class="form-group room-type-name-tree">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
{l s='Room Types:' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-7">
|
||||
{$hotel_tree}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<div class="form-group room-type-name">
|
||||
<label class="col-sm-3 control-label required" for="feature_price_name" >
|
||||
{l s='Room Type :' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-3">
|
||||
<input autocomplete="off" type="text" id="room_type_name" name="room_type_name" class="form-control" placeholder= "{l s='Enter room type name' mod='hotelreservationsystem'}" value="{if isset($productName)}{$productName}{/if}"/>
|
||||
<input type="hidden" id="room_type_id" name="room_type_id" class="form-control" value="{if isset($objFeaturePrice->id_product)}{$objFeaturePrice->id_product}{else}0{/if}"/>
|
||||
<div class="dropdown">
|
||||
<ul class="room_type_search_results_ul"></ul>
|
||||
</div>
|
||||
<p class="error-block" style="display:none; color: #CD5D5D;">{l s='No match found for this search. Please try with an existing name.' mod='hotelreservationsystem'}</p>
|
||||
<div class="help-block">
|
||||
{l s='Enter room type name and select the room for which you are going to create this advanced price rule.' mod='hotelreservationsystem'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="date_selection_type" class="control-label col-lg-3">
|
||||
{l s='Date Selection type :' mod='hotelreservationsystem'}
|
||||
|
||||
Reference in New Issue
Block a user