From 5eb3a31470deff0c1fa04f6ffc61a735c9b16f73 Mon Sep 17 00:00:00 2001 From: lakshya chauhan Date: Thu, 13 Jan 2022 14:25:01 +0530 Subject: [PATCH] solved pscleaner issues --- modules/pscleaner/CHANGELOG.txt | 17 +++++ modules/pscleaner/pscleaner.php | 73 +++++++++---------- .../admin/databases_cleaning_conf.tpl | 28 +++++++ .../admin/functional_integrity_conf.tpl | 30 ++++++++ .../templates/admin/pscleaner_script.tpl | 43 +++++++++++ 5 files changed, 152 insertions(+), 39 deletions(-) create mode 100755 modules/pscleaner/views/templates/admin/databases_cleaning_conf.tpl create mode 100755 modules/pscleaner/views/templates/admin/functional_integrity_conf.tpl create mode 100755 modules/pscleaner/views/templates/admin/pscleaner_script.tpl diff --git a/modules/pscleaner/CHANGELOG.txt b/modules/pscleaner/CHANGELOG.txt index e985ac36e..089ac7419 100644 --- a/modules/pscleaner/CHANGELOG.txt +++ b/modules/pscleaner/CHANGELOG.txt @@ -14,3 +14,20 @@ ____________________________________________________________________________________________________ ChangeLog : QloApps Data Cleaner 1.0.0 | COMPATIBLE:: QloApps V1.x.x | Added in QloApps V1.3.2 ____________________________________________________________________________________________________ + + +----------------------------- +# V1.0.1 to V1.0.2 +----------------------------- + +## Improved/changed features + +[*] CO : upgrade Delete Catalog. +[*] CO : upgrade Delete Orders and Customers. +[*] CO : upgrade Delete Check and fix. +[*] CO : upgrade Delete clean and optimize. +____________________________________________________________________________________________________ + +ChangeLog : QloApps Data Cleaner 1.0.2 | COMPATIBLE:: QloApps V1.x.x | Added in QloApps V1.6.0 +____________________________________________________________________________________________________ + diff --git a/modules/pscleaner/pscleaner.php b/modules/pscleaner/pscleaner.php index 5d55073de..dfc96d390 100644 --- a/modules/pscleaner/pscleaner.php +++ b/modules/pscleaner/pscleaner.php @@ -36,7 +36,7 @@ class PSCleaner extends Module { $this->name = 'pscleaner'; $this->tab = 'administration'; - $this->version = '1.0.1'; + $this->version = '1.0.2'; $this->author = 'PrestaShop'; $this->need_instance = 0; if (version_compare(_PS_VERSION_, '1.6.0.0 ', '>=')) { @@ -75,60 +75,30 @@ class PSCleaner extends Module if (Tools::isSubmit('submitCheckAndFix')) { $logs = self::checkAndFix(); if (count($logs)) { - $conf = $this->l('The following queries successfuly fixed broken data:').'
'; + $this->context->smarty->assign('logs', $logs); + $conf = $this->context->smarty->fetch(_PS_MODULE_DIR_.$this->name.'/views/templates/admin/functional_integrity_conf.tpl'); } else { - $conf = $this->l('Nothing that need to be fixed'); + $conf = $this->l('Nothing that need to be fixed please run database cleaning to clean your database'); } $html .= $this->displayConfirmation($conf); } elseif (Tools::isSubmit('submitCleanAndOptimize')) { $logs = self::cleanAndOptimize(); if (count($logs)) { - $conf = $this->l('The following queries successfuly cleaned your database:').'
'; + $this->context->smarty->assign('logs', $logs); + $conf = $this->context->smarty->fetch(_PS_MODULE_DIR_.$this->name.'/views/templates/admin/databases_cleaning_conf.tpl'); } else { $conf = $this->l('Nothing that need to be cleaned'); } $html .= $this->displayConfirmation($conf); } elseif (Tools::getValue('submitTruncateCatalog') && Tools::getValue('checkTruncateCatalog')) { self::truncate('catalog'); - $html .= $this->displayConfirmation($this->l('Catalog truncated')); + $html .= $this->displayConfirmation($this->l('Catalog truncated successfuly please run functional Integrity constraints. to make integrity in data tables')); } elseif (Tools::getValue('submitTruncateSales') && Tools::getValue('checkTruncateSales')) { self::truncate('sales'); - $html .= $this->displayConfirmation($this->l('Orders and customers truncated')); + $html .= $this->displayConfirmation($this->l('Orders and customers truncated successfuly please run functional Integrity constraints. to make integrity in data tables')); } - $html .= ' - '; + $html .= $this->context->smarty->fetch(_PS_MODULE_DIR_.$this->name.'/views/templates/admin/pscleaner_script.tpl'); return $html.$this->renderForm(); } @@ -363,6 +333,13 @@ class PSCleaner extends Module } } + $query = 'DELETE FROM `'._DB_PREFIX_.'htl_order_refund_rules_lang`'; + if (Db::getInstance()->Execute($query)) { + if ($affected_rows = Db::getInstance()->Affected_Rows()) { + $logs[$query] = $affected_rows; + } + } + $parents = Db::getInstance()->ExecuteS('SELECT DISTINCT id_parent FROM '._DB_PREFIX_.'tab'); foreach ($parents as $parent) { $children = Db::getInstance()->ExecuteS('SELECT id_tab FROM '._DB_PREFIX_.'tab WHERE id_parent = '.(int)$parent['id_parent'].' ORDER BY IF(class_name IN ("AdminHome", "AdminDashboard"), 1, 2), position ASC'); @@ -486,6 +463,7 @@ class PSCleaner extends Module 'title' => $this->l('Functional integrity constraints'), 'icon' => 'icon-cogs' ), + 'description' => $this->l('integrity constraint is used to protect the database from accidental damage.'), 'submit' => array( 'title' => $this->l('Check & fix'), 'class' => 'btn btn-default pull-right', @@ -499,6 +477,7 @@ class PSCleaner extends Module 'title' => $this->l('Database Cleaning'), 'icon' => 'icon-cogs' ), + 'description' => $this->l('Cleaning your database will reclaim unused space in your tables, reducing storage space and improving table access efficiency.'), 'submit' => array( 'title' => $this->l('Clean & Optimize'), 'class' => 'btn btn-default pull-right', @@ -681,6 +660,17 @@ class PSCleaner extends Module array('warehouse_carrier', 'id_carrier', 'carrier', 'id_carrier'), array('warehouse_product_location', 'id_product', 'product', 'id_product'), array('warehouse_product_location', 'id_warehouse', 'warehouse', 'id_warehouse'), + array('product_comment', 'id_product', 'product', 'id_product'), + array('specific_price', 'id_product', 'customer', 'id_customer'), + array('specific_price', 'id_group', 'group', 'id_group'), + array('htl_features_block_data_lang', 'id_features_block', 'htl_features_block_data', 'id_features_block'), + array('cart_rule', 'id_customer', 'customer', 'id_customer'), + array('htl_testimonials_block_data_lang', 'id_testimonial_block', 'htl_testimonials_block_data', 'id_testimonial_block'), + array('htl_room_type_global_demand_advance_option', 'id_global_demand', 'htl_room_type_global_demand', 'id_global_demand'), + array('htl_room_type_global_demand_advance_option_lang', 'id_option', 'htl_room_type_global_demand_advance_option', 'id_option'), + array('htl_room_type_global_demand_lang', 'id_global_demand', 'htl_room_type_global_demand', 'id_global_demand'), + + ) ); } @@ -780,6 +770,11 @@ class PSCleaner extends Module 'htl_room_type_demand_price', 'htl_room_type_demand', 'htl_room_disable_dates', + 'htl_interior_image', + 'htl_room_block_data', + 'htl_features_block_data', + 'htl_testimonials_block_data', + 'htl_room_type_global_demand' ) ); } diff --git a/modules/pscleaner/views/templates/admin/databases_cleaning_conf.tpl b/modules/pscleaner/views/templates/admin/databases_cleaning_conf.tpl new file mode 100755 index 000000000..86dd0de8d --- /dev/null +++ b/modules/pscleaner/views/templates/admin/databases_cleaning_conf.tpl @@ -0,0 +1,28 @@ +{* +* 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 +*} + +

{l s='The following queries successfuly cleaned your database:' mod='pscleaner'}

+

\ No newline at end of file diff --git a/modules/pscleaner/views/templates/admin/functional_integrity_conf.tpl b/modules/pscleaner/views/templates/admin/functional_integrity_conf.tpl new file mode 100755 index 000000000..3a4c4ae22 --- /dev/null +++ b/modules/pscleaner/views/templates/admin/functional_integrity_conf.tpl @@ -0,0 +1,30 @@ +{* +* 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 +*} +{* {$query|escape:'htmlall':'UTF-8'} *} +

{l s='The following queries successfuly fixed broken data:' mod='pscleaner'}

+

    + {foreach $logs as $query => $entries} +
  • + {$query|escape:'htmlall':'UTF-8'}
    + {l s='%d line(s)' sprintf=[$entries] mod='pscleaner'} +
  • + {/foreach} +
+
+{l s='please run database cleaning to clean your database' mod='pscleaner'} \ No newline at end of file diff --git a/modules/pscleaner/views/templates/admin/pscleaner_script.tpl b/modules/pscleaner/views/templates/admin/pscleaner_script.tpl new file mode 100755 index 000000000..092eeda73 --- /dev/null +++ b/modules/pscleaner/views/templates/admin/pscleaner_script.tpl @@ -0,0 +1,43 @@ +{* +* 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 +*} + + \ No newline at end of file