diff --git a/README.md b/README.md index 9575aaf7c..477b7062c 100644 --- a/README.md +++ b/README.md @@ -16,18 +16,19 @@

## Topics -- [Introduction](#introduction) -- [Requirements](#requirements) - - [Hosted Server Configurations](#hosted-server-configurations) - - [Local Server Configurations](#local-server-configurations) -- [Installation and Configuration](#installation-and-configuration) -- [License](#license) -- [Security Vulnerabilities](#security-vulnerabilities) -- [Documentation & Demo](#documentation--demo) - - [QloApps Documentation https://qloapps.com/qlo-reservation-system](#qloapps-documentation-httpsqloappscomqlo-reservation-system) - - [QloApps Demo](#qloapps-demo) -- [Contribute](#contribute) -- [Credits](#credits) +- [Topics](#topics) + - [Introduction](#introduction) + - [Requirements](#requirements) + - [Hosted Server Configurations](#hosted-server-configurations) + - [Local Server Configurations](#local-server-configurations) + - [Installation and Configuration](#installation-and-configuration) + - [License](#license) + - [Security Vulnerabilities](#security-vulnerabilities) + - [Documentation & Demo](#documentation--demo) + - [QloApps Documentation https://qloapps.com/qlo-reservation-system](#qloapps-documentation-httpsqloappscomqlo-reservation-system) + - [QloApps Demo](#qloapps-demo) + - [Contribute](#contribute) + - [Credits](#credits) ### Introduction @@ -85,8 +86,7 @@ Please don't disclose security vulnerabilities publicly. If you find any securit #### QloApps Documentation [https://qloapps.com/qlo-reservation-system](https://qloapps.com/qlo-reservation-system) #### QloApps Demo -**FrontEnd** : https://demo.qloapps.com
-**Backend** : https://demo.qloapps.com/adminhtl/index.php
+**Link** : https://demo.qloapps.com
**username** : demo@demo.com
**Password** : demodemo
diff --git a/install/controllers/http/system.php b/install/controllers/http/system.php index d95708b94..69f544b91 100644 --- a/install/controllers/http/system.php +++ b/install/controllers/http/system.php @@ -87,7 +87,7 @@ class InstallControllerHttpSystem extends InstallControllerHttp 'title' => $this->l('Required PHP parameters'), 'success' => 1, 'checks' => array( - 'phpversion' => $this->l('Minimum PHP 5.4.0 or later is required'), + 'phpversion' => $this->l('Minimum PHP 5.6.0 or later is required'), 'upload' => $this->l('Cannot upload files'), 'system' => $this->l('Cannot create new files and folders'), 'gd' => $this->l('GD library is not installed'), @@ -133,7 +133,7 @@ class InstallControllerHttpSystem extends InstallControllerHttp 'title' => $this->l('Recommended PHP parameters'), 'success' => $this->tests['optional']['success'], 'checks' => array( - 'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by QloApps will be PHP 5.4. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.4 now!'), phpversion()), + 'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by QloApps will be PHP 5.6. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.6 now!'), phpversion()), 'register_globals' => $this->l('PHP register_globals option is enabled'), 'gz' => $this->l('GZIP compression is not activated'), 'mcrypt' => $this->l('Mcrypt extension is not enabled'), diff --git a/modules/blockwishlist/blockwishlist.php b/modules/blockwishlist/blockwishlist.php index 5f77967b8..5575c35bb 100644 --- a/modules/blockwishlist/blockwishlist.php +++ b/modules/blockwishlist/blockwishlist.php @@ -24,15 +24,15 @@ * International Registered Trademark & Property of PrestaShop SA */ -if (!defined('_PS_VERSION_')) +if (!defined('_PS_VERSION_')) { exit; +} -include_once(dirname(__FILE__).'/WishList.php'); +include_once (dirname(__FILE__).'/classes/BlockWishlistDb.php'); +include_once (dirname(__FILE__).'/WishList.php'); class BlockWishList extends Module { - const INSTALL_SQL_FILE = 'install.sql'; - private $html = ''; public function __construct() @@ -55,23 +55,11 @@ class BlockWishList extends Module $this->html = ''; } - public function install($delete_params = true) + public function install() { - if ($delete_params) - { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return (false); - else if (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return (false); - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - foreach ($sql as $query) - if ($query) - if (!Db::getInstance()->execute(trim($query))) - return false; - } - + $objBlockWishListDb = new BlockWishlistDb(); if (!parent::install() || + !$objBlockWishListDb->createTables() || !$this->registerHook('rightColumn') || !$this->registerHook('productActions') || !$this->registerHook('cart') || @@ -79,19 +67,24 @@ class BlockWishList extends Module !$this->registerHook('header') || !$this->registerHook('adminCustomers') || !$this->registerHook('displayProductListFunctionalButtons') || - !$this->registerHook('top')) + !$this->registerHook('top') + ) { return false; + } /* This hook is optional */ $this->registerHook('displayMyAccountBlock'); return true; } - public function uninstall($delete_params = true) + public function uninstall($delete_data = true) { - if (($delete_params && !$this->deleteTables()) || !parent::uninstall()) + $objBlockWishListDb = new BlockWishlistDb(); + if (!parent::uninstall() + || ($delete_data && !$objBlockWishListDb->dropTables()) + ) { return false; - + } return true; } @@ -108,11 +101,12 @@ class BlockWishList extends Module public function reset() { - if (!$this->uninstall(false)) + if (!$this->uninstall(false)) { return false; - if (!$this->install(false)) + } + if (!$this->install()) { return false; - + } return true; } diff --git a/modules/blockwishlist/classes/BlockWishlistDb.php b/modules/blockwishlist/classes/BlockWishlistDb.php new file mode 100644 index 000000000..fe5a650bd --- /dev/null +++ b/modules/blockwishlist/classes/BlockWishlistDb.php @@ -0,0 +1,89 @@ +getModuleSql()) { + foreach ($sql as $query) { + if ($query) { + if (!Db::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function dropTables() + { + return Db::getInstance()->execute( + 'DROP TABLE IF EXISTS + `'._DB_PREFIX_.'wishlist`, + `'._DB_PREFIX_.'wishlist_email`, + `'._DB_PREFIX_.'wishlist_product`, + `'._DB_PREFIX_.'wishlist_product_cart`' + ); + } +} diff --git a/modules/blockwishlist/classes/index.php b/modules/blockwishlist/classes/index.php new file mode 100644 index 000000000..5d9e49caf --- /dev/null +++ b/modules/blockwishlist/classes/index.php @@ -0,0 +1,29 @@ +getModuleSql()) { + foreach ($sql as $query) { + if ($query) { + if (!Db::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function dropTables() + { + return Db::getInstance()->execute( + 'DROP TABLE IF EXISTS + `'._DB_PREFIX_.'htl_room_type`, + `'._DB_PREFIX_.'htl_room_information`, + `'._DB_PREFIX_.'htl_branch_info`, + `'._DB_PREFIX_.'htl_branch_info_lang`, + `'._DB_PREFIX_.'htl_image`, + `'._DB_PREFIX_.'htl_branch_features`, + `'._DB_PREFIX_.'htl_features`, + `'._DB_PREFIX_.'htl_features_lang`, + `'._DB_PREFIX_.'htl_cart_booking_data`, + `'._DB_PREFIX_.'htl_booking_detail`, + `'._DB_PREFIX_.'htl_booking_demands`, + `'._DB_PREFIX_.'htl_booking_demands_tax`, + `'._DB_PREFIX_.'htl_room_status`, + `'._DB_PREFIX_.'htl_room_allotment_type`, + `'._DB_PREFIX_.'htl_advance_payment`, + `'._DB_PREFIX_.'htl_order_refund_rules`, + `'._DB_PREFIX_.'htl_order_refund_rules_lang`, + `'._DB_PREFIX_.'htl_branch_refund_rules`, + `'._DB_PREFIX_.'htl_order_restrict_date`, + `'._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_global_demand`, + `'._DB_PREFIX_.'htl_room_type_global_demand_lang`, + `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option`, + `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option_lang`, + `'._DB_PREFIX_.'htl_room_type_demand_price`, + `'._DB_PREFIX_.'htl_room_type_demand`, + `'._DB_PREFIX_.'htl_room_disable_dates`, + `'._DB_PREFIX_.'htl_access`' + ); + } +} diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index 1e90ad144..ad5b54880 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -18,6 +18,7 @@ * @license https://store.webkul.com/license.html */ +require_once 'classes/HotelReservationSystemDb.php'; require_once 'classes/HotelRoomType.php'; require_once 'classes/HotelRoomInformation.php'; require_once 'classes/HotelBranchInformation.php'; diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index 67176e643..d4a4ddde6 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -25,7 +25,6 @@ include_once 'define.php'; class hotelreservationsystem extends Module { - const INSTALL_SQL_FILE = 'install.sql'; public function __construct() { $this->name = 'hotelreservationsystem'; @@ -636,25 +635,19 @@ class hotelreservationsystem extends Module public function install() { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { + $objModuleDb = new HotelReservationSystemDb(); + $objHtlHelper = new HotelHelper(); + if (!parent::install() + || !$objModuleDb->createTables() + || !$this->registerModuleHooks() + || !$this->callInstallTab() + || !$objHtlHelper->insertDefaultHotelEntries() + || !$objHtlHelper->insertHotelRoomAllotmentType() + ) { return false; - } elseif (!$sql = Tools::file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } - - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - - foreach ($sql as $query) { - if ($query) { - if (!Db::getInstance()->execute(trim($query))) { - return false; - } - } } // if module should be populated while installation - $objHtlHelper = new HotelHelper(); if (isset($this->populateData) && $this->populateData) { if (!$objHtlHelper->createHotelRoomDefaultFeatures() || !$objHtlHelper->insertHotelCommonFeatures() @@ -664,16 +657,6 @@ class hotelreservationsystem extends Module } } - if (!parent::install() - || !$this->callInstallTab() - || !$this->registerModuleHooks() - || !$objHtlHelper->insertDefaultHotelEntries() - || !$objHtlHelper->insertHotelRoomAllotmentType() - ) { - return false; - } - - return true; } @@ -704,43 +687,6 @@ class hotelreservationsystem extends Module ); } - public function deleteTables() - { - return Db::getInstance()->execute( - 'DROP TABLE IF EXISTS - `'._DB_PREFIX_.'htl_room_type`, - `'._DB_PREFIX_.'htl_room_information`, - `'._DB_PREFIX_.'htl_branch_info`, - `'._DB_PREFIX_.'htl_branch_info_lang`, - `'._DB_PREFIX_.'htl_image`, - `'._DB_PREFIX_.'htl_branch_features`, - `'._DB_PREFIX_.'htl_features`, - `'._DB_PREFIX_.'htl_features_lang`, - `'._DB_PREFIX_.'htl_cart_booking_data`, - `'._DB_PREFIX_.'htl_booking_detail`, - `'._DB_PREFIX_.'htl_booking_demands`, - `'._DB_PREFIX_.'htl_booking_demands_tax`, - `'._DB_PREFIX_.'htl_room_status`, - `'._DB_PREFIX_.'htl_room_allotment_type`, - `'._DB_PREFIX_.'htl_advance_payment`, - `'._DB_PREFIX_.'htl_order_refund_rules`, - `'._DB_PREFIX_.'htl_order_refund_rules_lang`, - `'._DB_PREFIX_.'htl_branch_refund_rules`, - `'._DB_PREFIX_.'htl_order_restrict_date`, - `'._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_global_demand`, - `'._DB_PREFIX_.'htl_room_type_global_demand_lang`, - `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option`, - `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option_lang`, - `'._DB_PREFIX_.'htl_room_type_demand_price`, - `'._DB_PREFIX_.'htl_room_type_demand`, - `'._DB_PREFIX_.'htl_room_disable_dates`, - `'._DB_PREFIX_.'htl_access`' - ); - } - public function uninstallTab() { $moduleTabs = Tab::getCollectionFromModule($this->name); @@ -783,9 +729,10 @@ class hotelreservationsystem extends Module public function uninstall() { + $objModuleDb = new HotelReservationSystemDb(); if (!parent::uninstall() || !$this->deleteConfigVars() - || !$this->deleteTables() + || !$objModuleDb->dropTables() || !$this->uninstallTab() ) { return false; diff --git a/modules/hotelreservationsystem/install.sql b/modules/hotelreservationsystem/install.sql deleted file mode 100644 index 2f5e6ac07..000000000 --- a/modules/hotelreservationsystem/install.sql +++ /dev/null @@ -1,363 +0,0 @@ -/** -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `adult` smallint(6) NOT NULL, - `children` smallint(6) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_information` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `room_num` varchar(225) NOT NULL, - `id_status` int(11) NOT NULL, - `floor` text NOT NULL, - `comment` text NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_info` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_category` int(10) unsigned NOT NULL, - `phone` varchar(32) DEFAULT NULL, - `email` varchar(128) NOT NULL, - `check_in` varchar(255) DEFAULT NULL, - `check_out` varchar(255) DEFAULT NULL, - `rating` int(2) unsigned NOT NULL, - `city` varchar(64) NOT NULL, - `state_id` int(10) unsigned NOT NULL, - `country_id` int(10) unsigned NOT NULL, - `zipcode` varchar(12) NOT NULL, - `address` text DEFAULT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `latitude` decimal(10,8) NOT NULL, - `longitude` decimal(11,8) NOT NULL, - `map_formated_address` text NOT NULL, - `map_input_text` text NOT NULL, - `active_refund` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_info_lang` ( - `id` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `hotel_name` varchar(255) DEFAULT NULL, - `short_description` text, - `description` text, - `policies` text, - PRIMARY KEY (`id`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_image` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_hotel` int(10) unsigned NOT NULL, - `hotel_image_id` varchar(32) NOT NULL, - `cover` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_features` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_hotel` int(10) unsigned NOT NULL, - `feature_id` varchar(255) DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_features` ( - `id` int(10) unsigned NOT NULL auto_increment, - `parent_feature_id` int(10) unsigned NOT NULL, - `position` int(10) unsigned NOT NULL, - `active` int(2) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_features_lang` ( - `id` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) NOT NULL, - PRIMARY KEY (`id`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_cart_booking_data` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_cart` int(11) NOT NULL, - `id_guest` int(11) NOT NULL, - `id_order` int(11) NOT NULL, - `id_customer` int(11) NOT NULL, - `id_currency` int(11) NOT NULL, - `id_product` int(11) NOT NULL, - `id_room` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `quantity` int(11) NOT NULL, - `booking_type` tinyint(4) NOT NULL, - `comment` text NOT NULL, - `is_back_order` tinyint(4) NOT NULL, - `extra_demands` text NOT NULL, - `date_from` datetime NOT NULL, - `date_to` datetime NOT NULL, - `is_refunded` tinyint(1) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_detail` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `id_order` int(11) NOT NULL, - `id_order_detail` int(11) NOT NULL, - `id_cart` int(11) NOT NULL, - `id_room` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `id_customer` int(11) NOT NULL, - `booking_type` tinyint(4) NOT NULL, - `id_status` int(11) NOT NULL, - `comment` text NOT NULL, - `check_in` datetime NOT NULL, - `check_out` datetime NOT NULL, - `date_from` datetime NOT NULL, - `date_to` datetime NOT NULL, - `total_price_tax_excl` decimal(20,6) NOT NULL, - `total_price_tax_incl` decimal(20,6) NOT NULL, - `total_paid_amount` decimal(20,6) NOT NULL DEFAULT '0.000000', - `is_back_order` tinyint(4) NOT NULL, - `hotel_name` varchar(255) DEFAULT NULL, - `room_type_name` varchar(255) DEFAULT NULL, - `city` varchar(255) NOT NULL, - `state` varchar(255) DEFAULT NULL, - `country` varchar(255) DEFAULT NULL, - `zipcode` varchar(12) DEFAULT NULL, - `phone` varchar(32) DEFAULT NULL, - `email` varchar(128) DEFAULT NULL, - `check_in_time` varchar(32) DEFAULT NULL, - `check_out_time` varchar(32) DEFAULT NULL, - `room_num` varchar(225) DEFAULT NULL, - `adult` smallint(6) NOT NULL DEFAULT '0', - `children` smallint(6) NOT NULL DEFAULT '0', - `is_refunded` tinyint(1) NOT NULL DEFAULT '0', - -- `available_for_order` tinyint(1) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_demands` ( - `id_booking_demand` int(11) NOT NULL AUTO_INCREMENT, - `id_htl_booking` int(11) NOT NULL, - `name` varchar(255) character set utf8 NOT NULL, - `unit_price_tax_excl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `unit_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `total_price_tax_excl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `total_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `price_calc_method` int(11) unsigned DEFAULT '0', - `id_tax_rules_group` int(11) unsigned DEFAULT '0', - `tax_computation_method` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_booking_demand`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_demands_tax` ( - `id_booking_demand` int(11) NOT NULL AUTO_INCREMENT, - `id_tax` int(11) NOT NULL, - `unit_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', - `total_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', - PRIMARY KEY (`id_booking_demand`, `id_tax`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_status` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `status` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_allotment_type` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `type` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_advance_payment` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `payment_type` tinyint(4) NOT NULL, - `value` decimal(20,6) NOT NULL, - `id_currency` int(11) NOT NULL, - `tax_include` tinyint(4) NOT NULL, - `calculate_from` tinyint(4) NOT NULL, - `active` tinyint(4) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_refund_rules` ( - `id_refund_rule` int(11) NOT NULL AUTO_INCREMENT, - `payment_type` int(2) unsigned NOT NULL, - `deduction_value_full_pay` decimal(20,6) NOT NULL, - `deduction_value_adv_pay` decimal(20,6) NOT NULL, - `days` decimal(35,0) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_refund_rule`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_refund_rules_lang` ( - `id_refund_rule` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) DEFAULT NULL, - `description` text, - PRIMARY KEY (`id_refund_rule`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_refund_rules` ( - `id_hotel_refund_rule` int(11) NOT NULL AUTO_INCREMENT, - `id_refund_rule` int(10) unsigned NOT NULL, - `id_hotel` int(10) unsigned NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_hotel_refund_rule`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_restrict_date` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_hotel` int(11) NOT NULL, - `max_order_date` datetime NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_feature_pricing` ( - `id_feature_price` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `date_from` date NOT NULL, - `date_to` date NOT NULL, - `is_special_days_exists` tinyint(1) NOT NULL, - `date_selection_type` tinyint(1) NOT NULL, - `special_days` text, - `impact_way` tinyint(1) NOT NULL, - `impact_type` tinyint(1) NOT NULL, - `impact_value` decimal(20,6) NOT NULL DEFAULT '0.000000', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_feature_price`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_feature_pricing_lang` ( - `id_feature_price` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `feature_price_name` varchar(255) character set utf8 NOT NULL, - PRIMARY KEY (`id_feature_price`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE `PREFIX_htl_room_type_feature_pricing_group` ( - `id_feature_price` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_feature_price`,`id_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand` ( - `id_global_demand` int(11) NOT NULL AUTO_INCREMENT, - `price` decimal(20,6) NOT NULL DEFAULT '0.000000', - `id_tax_rules_group` int(10) unsigned NOT NULL DEFAULT '0', - `price_calc_method` tinyint(1) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_global_demand`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_lang` ( - `id_global_demand` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) character set utf8 NOT NULL, - PRIMARY KEY (`id_global_demand`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_advance_option` ( - `id_option` int(11) NOT NULL AUTO_INCREMENT, - `id_global_demand` int(11) NOT NULL, - `price` decimal(20,6) NOT NULL DEFAULT '0.000000', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_option`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_advance_option_lang` ( - `id_option` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) character set utf8 NOT NULL, - PRIMARY KEY (`id_option`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_demand_price` ( - `id_room_type_demand_price` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(10) unsigned NOT NULL, - `id_global_demand` int(10) unsigned NOT NULL, - `id_option` int(10) unsigned NOT NULL, - `price` decimal(20,6) NOT NULL DEFAULT '0.000000', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_room_type_demand_price`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_demand` ( - `id_room_type_demand` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(10) unsigned NOT NULL, - `id_global_demand` int(10) unsigned NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_room_type_demand`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_disable_dates` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_room_type` int(11) NOT NULL, - `id_room` int(11) NOT NULL, - `date_from` date NOT NULL, - `date_to` date NOT NULL, - `reason` text, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_access` ( - `id_profile` int(10) unsigned NOT NULL, - `id_hotel` int(10) unsigned NOT NULL, - `access` int(11) NOT NULL, - PRIMARY KEY (`id_profile`, `id_hotel`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; diff --git a/modules/productcomments/classes/ProductCommentsDb.php b/modules/productcomments/classes/ProductCommentsDb.php new file mode 100644 index 000000000..8958f0336 --- /dev/null +++ b/modules/productcomments/classes/ProductCommentsDb.php @@ -0,0 +1,131 @@ +getModuleSql()) { + foreach ($sql as $query) { + if ($query) { + if (!Db::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function dropTables() + { + return Db::getInstance()->execute( + 'DROP TABLE IF EXISTS + `'._DB_PREFIX_.'product_comment`, + `'._DB_PREFIX_.'product_comment_criterion`, + `'._DB_PREFIX_.'product_comment_criterion_product`, + `'._DB_PREFIX_.'product_comment_criterion_lang`, + `'._DB_PREFIX_.'product_comment_criterion_category`, + `'._DB_PREFIX_.'product_comment_grade`, + `'._DB_PREFIX_.'product_comment_usefulness`, + `'._DB_PREFIX_.'product_comment_report`' + ); + } +} diff --git a/modules/productcomments/classes/index.php b/modules/productcomments/classes/index.php new file mode 100644 index 000000000..5d9e49caf --- /dev/null +++ b/modules/productcomments/classes/index.php @@ -0,0 +1,29 @@ +description = $this->l('Allows users to post reviews and rate products on specific criteria.'); } - public function install($keep = true) + public function install() { - if ($keep) - { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return false; - else if (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return false; - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", trim($sql)); - - foreach ($sql as $query) - if (!Db::getInstance()->execute(trim($query))) - return false; - - } - + $objProductCommentsDb = new ProductCommentsDb(); if (parent::install() == false || + !$objProductCommentsDb->createTables() || !$this->registerHook('productTab') || !$this->registerHook('extraProductComparison') || !$this->registerHook('productTabContent') || @@ -83,14 +71,17 @@ class ProductComments extends Module !$this->registerHook('displayProductListReviews') || !Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', 30) || !Configuration::updateValue('PRODUCT_COMMENTS_ALLOW_GUESTS', 0) || - !Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', 1)) + !Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', 1) + ) { return false; + } return true; } - public function uninstall($keep = true) + public function uninstall($delete_data = true) { - if (!parent::uninstall() || ($keep && !$this->deleteTables()) || + $objProductCommentsDb = new ProductCommentsDb(); + if (!parent::uninstall() || ($delete_data && !$objProductCommentsDb->dropTables()) || !Configuration::deleteByName('PRODUCT_COMMENTS_MODERATE') || !Configuration::deleteByName('PRODUCT_COMMENTS_ALLOW_GUESTS') || !Configuration::deleteByName('PRODUCT_COMMENTS_MINIMAL_TIME') || @@ -100,34 +91,24 @@ class ProductComments extends Module !$this->unregisterHook('header') || !$this->unregisterHook('productTab') || !$this->unregisterHook('top') || - !$this->unregisterHook('displayProductListReviews')) + !$this->unregisterHook('displayProductListReviews') + ) { return false; + } return true; } public function reset() { - if (!$this->uninstall(false)) + if (!$this->uninstall(false)) { return false; - if (!$this->install(false)) + } + if (!$this->install()) { return false; + } return true; } - public function deleteTables() - { - return Db::getInstance()->execute(' - DROP TABLE IF EXISTS - `'._DB_PREFIX_.'product_comment`, - `'._DB_PREFIX_.'product_comment_criterion`, - `'._DB_PREFIX_.'product_comment_criterion_product`, - `'._DB_PREFIX_.'product_comment_criterion_lang`, - `'._DB_PREFIX_.'product_comment_criterion_category`, - `'._DB_PREFIX_.'product_comment_grade`, - `'._DB_PREFIX_.'product_comment_usefulness`, - `'._DB_PREFIX_.'product_comment_report`'); - } - public function getCacheId($id_product = null) { return parent::getCacheId().'|'.(int)$id_product; @@ -496,7 +477,6 @@ class ProductComments extends Module return $helper->generateList($comments, $fields_list); } - public function getConfigFieldsValues() { return array( diff --git a/modules/wkabouthotelblock/classes/WkAboutHotelBlockDb.php b/modules/wkabouthotelblock/classes/WkAboutHotelBlockDb.php new file mode 100644 index 000000000..745200fc4 --- /dev/null +++ b/modules/wkabouthotelblock/classes/WkAboutHotelBlockDb.php @@ -0,0 +1,60 @@ +getModuleSqls()) { + foreach ($sqls as $query) { + if ($query) { + if (!DB::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function getModuleSqls() + { + return array( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_interior_image` ( + `id_interior_image` int(11) NOT NULL AUTO_INCREMENT, + `name` text NOT NULL, + `display_name` text NOT NULL, + `active` tinyint(1) NOT NULL, + `position` int(11) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_interior_image`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + ); + } + + public function dropTables() + { + return DB::getInstance()->execute(' + DROP TABLE IF EXISTS + `'._DB_PREFIX_.'htl_interior_image`; + '); + } +} diff --git a/modules/wkabouthotelblock/define.php b/modules/wkabouthotelblock/define.php index 5f063f18b..b010a43e9 100644 --- a/modules/wkabouthotelblock/define.php +++ b/modules/wkabouthotelblock/define.php @@ -18,4 +18,5 @@ * @license https://store.webkul.com/license.html */ +require_once 'classes/WkAboutHotelBlockDb.php'; require_once 'classes/WkHotelInteriorImage.php'; diff --git a/modules/wkabouthotelblock/install.sql b/modules/wkabouthotelblock/install.sql deleted file mode 100644 index 35c2aec12..000000000 --- a/modules/wkabouthotelblock/install.sql +++ /dev/null @@ -1,29 +0,0 @@ -/** -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_interior_image` ( - `id_interior_image` int(11) NOT NULL AUTO_INCREMENT, - `name` text NOT NULL, - `display_name` text NOT NULL, - `active` tinyint(1) NOT NULL, - `position` int(11) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_interior_image`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; \ No newline at end of file diff --git a/modules/wkabouthotelblock/wkabouthotelblock.php b/modules/wkabouthotelblock/wkabouthotelblock.php index 9877b85df..5b3b5a0c1 100644 --- a/modules/wkabouthotelblock/wkabouthotelblock.php +++ b/modules/wkabouthotelblock/wkabouthotelblock.php @@ -26,13 +26,12 @@ require_once dirname(__FILE__).'/define.php'; class WkAboutHotelBlock extends Module { - const INSTALL_SQL_FILE = 'install.sql'; public function __construct() { $this->name = 'wkabouthotelblock'; $this->tab = 'front_office_features'; $this->version = '1.1.7'; - $this->author = 'webkul'; + $this->author = 'Webkul'; $this->need_instance = 0; $this->bootstrap = true; @@ -90,24 +89,10 @@ class WkAboutHotelBlock extends Module public function install() { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } elseif (!$sql = Tools::file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } - - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - - foreach ($sql as $query) { - if ($query) { - if (!Db::getInstance()->execute(trim($query))) { - return false; - } - } - } + $objAboutHotelBlockDb = new WkAboutHotelBlockDb(); $objHtlInteriorImg = new WkHotelInteriorImage(); if (!parent::install() + || !$objAboutHotelBlockDb->createTables() || !$this->registerModuleHooks() || !$this->callInstallTab() || !$objHtlInteriorImg->insertModuleDemoData() @@ -161,9 +146,10 @@ class WkAboutHotelBlock extends Module public function uninstall() { + $objAboutHotelBlockDb = new WkAboutHotelBlockDb(); if (!parent::uninstall() || !$this->deleteHotelInterierImg() - || !$this->deleteTables() + || !$objAboutHotelBlockDb->dropTables() || !$this->deleteConfigKeys() || !$this->uninstallTab() ) { @@ -207,12 +193,4 @@ class WkAboutHotelBlock extends Module } return true; } - - public function deleteTables() - { - return Db::getInstance()->execute( - 'DROP TABLE IF EXISTS - `'._DB_PREFIX_.'htl_interior_image`' - ); - } } diff --git a/modules/wkfooterpaymentblock/classes/WkFooterPaymentBlockDb.php b/modules/wkfooterpaymentblock/classes/WkFooterPaymentBlockDb.php new file mode 100644 index 000000000..2c13d9e3b --- /dev/null +++ b/modules/wkfooterpaymentblock/classes/WkFooterPaymentBlockDb.php @@ -0,0 +1,59 @@ +getModuleSqls()) { + foreach ($sqls as $query) { + if ($query) { + if (!DB::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function getModuleSqls() + { + return array( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_footer_payment_block_info` ( + `id_payment_block` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `active` tinyint(1) NOT NULL, + `position` int(10) unsigned NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_payment_block`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + ); + } + + public function dropTables() + { + return DB::getInstance()->execute(' + DROP TABLE IF EXISTS + `'._DB_PREFIX_.'htl_footer_payment_block_info`; + '); + } +} diff --git a/modules/wkfooterpaymentblock/install.sql b/modules/wkfooterpaymentblock/install.sql deleted file mode 100644 index a116fbe80..000000000 --- a/modules/wkfooterpaymentblock/install.sql +++ /dev/null @@ -1,28 +0,0 @@ -/** -* 2010-2018 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2018 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_footer_payment_block_info` ( - `id_payment_block` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `active` tinyint(1) NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_payment_block`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; \ No newline at end of file diff --git a/modules/wkfooterpaymentblock/wkfooterpaymentblock.php b/modules/wkfooterpaymentblock/wkfooterpaymentblock.php index 1ea861932..4ee7f9ed3 100644 --- a/modules/wkfooterpaymentblock/wkfooterpaymentblock.php +++ b/modules/wkfooterpaymentblock/wkfooterpaymentblock.php @@ -22,18 +22,17 @@ if (!defined('_PS_VERSION_')) { exit; } +require_once dirname(__FILE__).'/classes/WkFooterPaymentBlockDb.php'; require_once dirname(__FILE__).'/classes/WkFooterPaymentBlockInfo.php'; class WkFooterPaymentBlock extends Module { - const INSTALL_SQL_FILE = 'install.sql'; - public function __construct() { $this->name = 'wkfooterpaymentblock'; $this->tab = 'front_office_features'; $this->version = '1.1.4'; - $this->author = 'webkul'; + $this->author = 'Webkul'; $this->need_instance = 0; $this->bootstrap = true; @@ -99,23 +98,9 @@ class WkFooterPaymentBlock extends Module public function install() { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } elseif (!$sql = Tools::file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } - - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - - foreach ($sql as $query) { - if ($query) { - if (!Db::getInstance()->execute(trim($query))) { - return false; - } - } - } + $objFooterPaymentBlockDb = new WkFooterPaymentBlockDb(); if (!parent::install() + || !$objFooterPaymentBlockDb->createTables() ||!$this->registerHook('displayFooterPaymentInfo') ||!$this->registerHook('displayAddModuleSettingLink') || !$this->callInstallTab() @@ -128,13 +113,13 @@ class WkFooterPaymentBlock extends Module public function uninstall() { + $objFooterPaymentBlockDb = new WkFooterPaymentBlockDb(); if (!parent::uninstall() || !$this->uninstallTab() - || !$this->dropTables() + || !$objFooterPaymentBlockDb->dropTables() ) { return false; } - return true; } @@ -150,13 +135,6 @@ class WkFooterPaymentBlock extends Module return true; } - private function dropTables() - { - return Db::getInstance()->execute( - 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'htl_footer_payment_block_info`' - ); - } - public function insertDefaultModuleData() { $paymentNames = array( diff --git a/modules/wkhotelfeaturesblock/classes/WkHotelFeaturesBlockDb.php b/modules/wkhotelfeaturesblock/classes/WkHotelFeaturesBlockDb.php new file mode 100644 index 000000000..26d9c6946 --- /dev/null +++ b/modules/wkhotelfeaturesblock/classes/WkHotelFeaturesBlockDb.php @@ -0,0 +1,67 @@ +getModuleSqls()) { + foreach ($sqls as $query) { + if ($query) { + if (!DB::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function getModuleSqls() + { + return array( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_features_block_data` ( + `id_features_block` int(11) NOT NULL AUTO_INCREMENT, + `active` tinyint(1) NOT NULL, + `position` int(11) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_features_block`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_features_block_data_lang` ( + `id_features_block` int(11) NOT NULL, + `id_lang` int(11) NOT NULL, + `feature_title` text NOT NULL, + `feature_description` text NOT NULL, + PRIMARY KEY (`id_features_block`, `id_lang`) + ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;" + ); + } + + public function dropTables() + { + return DB::getInstance()->execute( + 'DROP TABLE IF EXISTS + `'._DB_PREFIX_.'htl_features_block_data`, + `'._DB_PREFIX_.'htl_features_block_data_lang`; + '); + } +} diff --git a/modules/wkhotelfeaturesblock/install.sql b/modules/wkhotelfeaturesblock/install.sql deleted file mode 100644 index 659abcf60..000000000 --- a/modules/wkhotelfeaturesblock/install.sql +++ /dev/null @@ -1,35 +0,0 @@ -/** -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_features_block_data` ( - `id_features_block` int(11) NOT NULL AUTO_INCREMENT, - `active` tinyint(1) NOT NULL, - `position` int(11) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_features_block`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_features_block_data_lang` ( - `id_features_block` int(11) NOT NULL, - `id_lang` int(11) NOT NULL, - `feature_title` text NOT NULL, - `feature_description` text NOT NULL, - PRIMARY KEY (`id_features_block`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 ; diff --git a/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php b/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php index e671a17d5..b7550193a 100644 --- a/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php +++ b/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php @@ -23,17 +23,17 @@ if (!defined('_PS_VERSION_')) { } require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; +require_once dirname(__FILE__).'/../wkhotelfeaturesblock/classes/WkHotelFeaturesBlockDb.php'; require_once dirname(__FILE__).'/../wkhotelfeaturesblock/classes/WkHotelFeaturesData.php'; class WkHotelFeaturesBlock extends Module { - const INSTALL_SQL_FILE = 'install.sql'; public function __construct() { $this->name = 'wkhotelfeaturesblock'; $this->tab = 'front_office_features'; $this->version = '2.0.5'; - $this->author = 'webkul'; + $this->author = 'Webkul'; $this->bootstrap = true; parent::__construct(); @@ -121,24 +121,10 @@ class WkHotelFeaturesBlock extends Module public function install() { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } elseif (!$sql = Tools::file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } - - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - - foreach ($sql as $query) { - if ($query) { - if (!Db::getInstance()->execute(trim($query))) { - return false; - } - } - } + $objHotelFeaturesBlockDb = new WkHotelFeaturesBlockDb(); $objFeaturesData = new WkHotelFeaturesData(); if (!parent::install() + || !$objHotelFeaturesBlockDb->createTables() || !$this->registerModuleHooks() || !$this->callInstallTab() || !$objFeaturesData->insertModuleDemoData() @@ -162,10 +148,11 @@ class WkHotelFeaturesBlock extends Module public function uninstall() { + $objHotelFeaturesBlockDb = new WkHotelFeaturesBlockDb(); if (!parent::uninstall() || !$this->deleteHotelAmenityImg() || !$this->uninstallTab() - || !$this->deleteTables() + || !$objHotelFeaturesBlockDb->dropTables() || !$this->deleteConfigKeys() ) { return false; @@ -200,16 +187,7 @@ class WkHotelFeaturesBlock extends Module } return true; } - - public function deleteTables() - { - return Db::getInstance()->execute( - 'DROP TABLE IF EXISTS - `'._DB_PREFIX_.'htl_features_block_data`, - `'._DB_PREFIX_.'htl_features_block_data_lang`' - ); - } - + public function uninstallTab() { $moduleTabs = Tab::getCollectionFromModule($this->name); diff --git a/modules/wkhotelroom/classes/WkHotelRoomDb.php b/modules/wkhotelroom/classes/WkHotelRoomDb.php new file mode 100644 index 000000000..a21f82dae --- /dev/null +++ b/modules/wkhotelroom/classes/WkHotelRoomDb.php @@ -0,0 +1,59 @@ +getModuleSqls()) { + foreach ($sqls as $query) { + if ($query) { + if (!DB::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function getModuleSqls() + { + return array( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_block_data` ( + `id_room_block` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `active` tinyint(4) NOT NULL, + `position` int(11) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_room_block`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;" + ); + } + + public function dropTables() + { + return DB::getInstance()->execute( + 'DROP TABLE IF EXISTS + `'._DB_PREFIX_.'htl_room_block_data`; + '); + } +} diff --git a/modules/wkhotelroom/define.php b/modules/wkhotelroom/define.php index c100cb59c..2ca63f9d7 100644 --- a/modules/wkhotelroom/define.php +++ b/modules/wkhotelroom/define.php @@ -19,4 +19,5 @@ */ require_once _PS_MODULE_DIR_.'/hotelreservationsystem/define.php'; +require_once 'classes/WkHotelRoomDb.php'; require_once 'classes/WkHotelRoomDisplay.php'; diff --git a/modules/wkhotelroom/install.sql b/modules/wkhotelroom/install.sql deleted file mode 100644 index 975d3c2e6..000000000 --- a/modules/wkhotelroom/install.sql +++ /dev/null @@ -1,28 +0,0 @@ -/** -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_block_data` ( - `id_room_block` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `active` tinyint(4) NOT NULL, - `position` int(11) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_room_block`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; \ No newline at end of file diff --git a/modules/wkhotelroom/wkhotelroom.php b/modules/wkhotelroom/wkhotelroom.php index c088c6350..9f8723c1a 100644 --- a/modules/wkhotelroom/wkhotelroom.php +++ b/modules/wkhotelroom/wkhotelroom.php @@ -21,18 +21,17 @@ if (!defined('_PS_VERSION_')) { exit; } + require_once dirname(__FILE__).'/define.php'; class WkHotelRoom extends Module { - const INSTALL_SQL_FILE = 'install.sql'; - public function __construct() { $this->name = 'wkhotelroom'; $this->tab = 'front_office_features'; $this->version = '1.1.7'; - $this->author = 'webkul'; + $this->author = 'Webkul'; $this->bootstrap = true; parent::__construct(); @@ -179,24 +178,9 @@ class WkHotelRoom extends Module public function install() { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } elseif (!$sql = Tools::file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } - - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - - foreach ($sql as $query) { - if ($query) { - if (!Db::getInstance()->execute(trim($query))) { - return false; - } - } - } - + $objHotelRoomDb = new WkHotelRoomDb(); if (!parent::install() + || !$objHotelRoomDb->createTables() || !$this->registerModuleHooks() || !$this->callInstallTab() ) { @@ -230,24 +214,17 @@ class WkHotelRoom extends Module public function uninstall() { + $objHotelRoomDb = new WkHotelRoomDb(); if (!parent::uninstall() || !$this->uninstallTab() - || !$this->deleteTables() + || !$objHotelRoomDb->dropTables() || !$this->deleteConfigKeys() ) { return false; } return true; } - - public function deleteTables() - { - return Db::getInstance()->execute( - 'DROP TABLE IF EXISTS - `'._DB_PREFIX_.'htl_room_block_data`' - ); - } - + public function deleteConfigKeys() { $configVars = array( diff --git a/modules/wktestimonialblock/classes/WkTestimonialBlockDb.php b/modules/wktestimonialblock/classes/WkTestimonialBlockDb.php new file mode 100644 index 000000000..5c3b1a17e --- /dev/null +++ b/modules/wktestimonialblock/classes/WkTestimonialBlockDb.php @@ -0,0 +1,68 @@ +getModuleSqls()) { + foreach ($sqls as $query) { + if ($query) { + if (!DB::getInstance()->execute(trim($query))) { + return false; + } + } + } + } + return true; + } + + public function getModuleSqls() + { + return array( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_testimonials_block_data` ( + `id_testimonial_block` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `designation` text NOT NULL, + `active` tinyint(1) NOT NULL, + `position` int(10) unsigned NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_testimonial_block`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_testimonials_block_data_lang` ( + `id_testimonial_block` int(11) NOT NULL, + `id_lang` int(11) NOT NULL, + `testimonial_content` text NOT NULL, + PRIMARY KEY (`id_testimonial_block`, `id_lang`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;" + ); + } + + public function dropTables() + { + return DB::getInstance()->execute( + 'DROP TABLE IF EXISTS + `'._DB_PREFIX_.'htl_testimonials_block_data`, + `'._DB_PREFIX_.'htl_testimonials_block_data_lang` + '); + } +} diff --git a/modules/wktestimonialblock/install.sql b/modules/wktestimonialblock/install.sql deleted file mode 100644 index 9f5d011aa..000000000 --- a/modules/wktestimonialblock/install.sql +++ /dev/null @@ -1,36 +0,0 @@ -/** -* 2010-2020 Webkul. -* -* NOTICE OF LICENSE -* -* All right is reserved, -* Please go through this link for complete license : https://store.webkul.com/license.html -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to newer -* versions in the future. If you wish to customize this module for your -* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. -* -* @author Webkul IN -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_testimonials_block_data` ( - `id_testimonial_block` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `designation` text NOT NULL, - `active` tinyint(1) NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_testimonial_block`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_testimonials_block_data_lang` ( - `id_testimonial_block` int(11) NOT NULL, - `id_lang` int(11) NOT NULL, - `testimonial_content` text NOT NULL, - PRIMARY KEY (`id_testimonial_block`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 ; diff --git a/modules/wktestimonialblock/wktestimonialblock.php b/modules/wktestimonialblock/wktestimonialblock.php index 1edd4993c..de379ea38 100644 --- a/modules/wktestimonialblock/wktestimonialblock.php +++ b/modules/wktestimonialblock/wktestimonialblock.php @@ -22,12 +22,12 @@ if (!defined('_PS_VERSION_')) { exit; } +require_once dirname(__FILE__).'/../wktestimonialblock/classes/WkTestimonialBlockDb.php'; require_once dirname(__FILE__).'/../wktestimonialblock/classes/WkHotelTestimonialData.php'; require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; class WkTestimonialBlock extends Module { - const INSTALL_SQL_FILE = 'install.sql'; public function __construct() { $this->name = 'wktestimonialblock'; @@ -113,23 +113,10 @@ class WkTestimonialBlock extends Module public function install() { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } elseif (!$sql = Tools::file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) { - return false; - } - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - - foreach ($sql as $query) { - if ($query) { - if (!Db::getInstance()->execute(trim($query))) { - return false; - } - } - } + $objTestimonialBlockDb = new WkTestimonialBlockDb(); $objTestimonialData = new WkHotelTestimonialData(); if (!parent::install() + || !$objTestimonialBlockDb->createTables() || !$this->registerModuleHooks() || !$this->callInstallTab() || !$objTestimonialData->insertModuleDemoData() @@ -192,15 +179,6 @@ class WkTestimonialBlock extends Module return true; } - public function deleteTables() - { - return Db::getInstance()->execute( - 'DROP TABLE IF EXISTS - `'._DB_PREFIX_.'htl_testimonials_block_data`, - `'._DB_PREFIX_.'htl_testimonials_block_data_lang`' - ); - } - public function uninstallTab() { $moduleTabs = Tab::getCollectionFromModule($this->name); @@ -215,9 +193,10 @@ class WkTestimonialBlock extends Module public function uninstall() { + $objTestimonialBlockDb = new WkTestimonialBlockDb(); if (!parent::uninstall() || !$this->deleteTestimonialUserImage() - || !$this->deleteTables() + || !$objTestimonialBlockDb->dropTables() || !$this->uninstallTab() || !$this->deleteConfigKeys() ) {