diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 0d7259b1d..53bc90754 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -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'] diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 413eae55a..5a136f66c 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -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 diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index f7708bfa8..d2819efca 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -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)), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 5e6953f8c..2f48dbce9 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -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 diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 9a4a03745..81d23c6c4 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -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 diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 4396ffe78..bcb120674 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -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 diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 5ae782bb0..d103e1576 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -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`, diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php index 1cf30e7ab..26ffaf3c4 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php @@ -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; diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricingRule.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricingRestriction.php similarity index 81% rename from modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricingRule.php rename to modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricingRestriction.php index c2505d3ad..a1c0b9011 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricingRule.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricingRestriction.php @@ -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(); } } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php index 3fcabe368..237cf880a 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php @@ -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'); diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index e6631fc70..4d63a19a2 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -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'; diff --git a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css index 32debf8aa..6855c96d2 100644 --- a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css +++ b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css @@ -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;} diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index f7903eb0e..7b7af7a43 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -709,49 +709,47 @@ $(document).ready(function() { let panelElem = $('
').addClass('panel advanced_price_rule').attr('data-advanced_price_rule_index', panelIndex); let idElem = $('').attr('type', 'hidden').attr('name', 'advance_price_rule['+panelIndex+'][id]') let headerElem = $('
').addClass('row advance_price_rule_header_container advance_price_rule_collapse').attr({'data-toggle':"collapse", 'data-target':"#advanced_price_rule_"+panelIndex}) - .append($('
').addClass('col-xs-8 advance_price_rule_header')) - .append($('
').addClass('col-xs-4') - .append($('
').addClass('col-xs-7')) - .append($('
').addClass('col-xs-2') + .append($('
').addClass('col-xs-9 advance_price_rule_header')) + .append($('
').addClass('col-xs-3') + .append($('
').addClass('col-xs-offset-7 col-xs-2') .append($('').addClass('btn btn-default remove_advanced_price_rule') .append($('').append($('').addClass('icon-trash'))))) - .append($('
').addClass('col-xs-1')) - .append($('
').addClass('col-xs-2') + .append($('
').addClass('col-xs-offset-1 col-xs-2') .append($('').addClass('btn btn-default') .append($('').addClass('icon-caret-down'))))); let dateSelectionElem = $('
').addClass('form-group') - .append($('
').addClass('col-xs-5') .append($(dateSeletionOptions).attr({'name': 'advance_price_rule['+panelIndex+'][date_selection_type]', 'id': 'date_selection_type_'+panelIndex}))) .append($('
').addClass('col-xs-3 advanced_price_rule_body_actions') - .append($('
').addClass('col-xs-offset-4 col-xs-4') + .append($('
').addClass('col-xs-offset-7 col-xs-2') .append($('').addClass('btn btn-default remove_advanced_price_rule') .append($('').append($('').addClass('icon-trash'))))) - .append($('
').addClass('col-xs-4') + .append($('
').addClass('col-xs-offset-1 col-xs-2') .append($('').addClass('btn btn-default').attr({'data-toggle':"collapse", 'data-target':"#advanced_price_rule_"+panelIndex}) .append($('').addClass('icon-caret-up'))))); let specificDateElem = $('
').addClass('form-group specific_date_type_'+panelIndex).css('display', 'none') - .append($('
').addClass('col-xs-5') .append($('').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 = $('
').addClass('form-group date_range_type_'+panelIndex) - .append($('
').addClass('col-xs-5') .append($('').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 = $('
').addClass('form-group date_range_type_'+panelIndex) - .append($('
').addClass('col-xs-5') .append($('').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 = $('
').addClass('form-group special_days_content_'+panelIndex) - .append($('
').addClass('col-xs-5') .append($('').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 = $('
').addClass('form-group week_days week_days_'+panelIndex) - .append($('
').addClass('col-xs-8 checkboxes-wrap').append($(weekDaysOptions).html())) let bodyElem = $('
').attr('id', 'advanced_price_rule_'+panelIndex).addClass('in advanced_price_rule_body') diff --git a/modules/hotelreservationsystem/views/templates/admin/_partials/feature_price_rules.tpl b/modules/hotelreservationsystem/views/templates/admin/_partials/feature_price_rules.tpl index eeb9b470e..9948c7bfa 100644 --- a/modules/hotelreservationsystem/views/templates/admin/_partials/feature_price_rules.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/_partials/feature_price_rules.tpl @@ -23,16 +23,14 @@
-
-
-
-
+
+
+ -
-
+
@@ -41,7 +39,7 @@
-
-
+ -
+
@@ -69,7 +67,7 @@
-