diff --git a/classes/orderCleaner.php b/classes/orderCleaner.php index e0102d5..038a826 100644 --- a/classes/orderCleaner.php +++ b/classes/orderCleaner.php @@ -189,7 +189,13 @@ public function createDummyOrders($nb = 50) { for ($o = 1; $o <= $nb; ++$o) { $customer_id = Db::getInstance()->getValue('SELECT id_customer FROM `' . _DB_PREFIX_ . 'customer` ORDER BY RAND()'); - $address_id = Db::getInstance()->getValue('SELECT id_address FROM `' . _DB_PREFIX_ . 'address` ORDER BY RAND()'); + $sql = new DbQuery(); + $sql->select('a.id_address'); + $sql->from('address', 'a'); + $sql->innerJoin('country', 'c', 'c.id_country = a.id_country'); + $sql->where('c.active = 1'); + $sql->orderBy('RAND()'); + $address_id = Db::getInstance()->getValue($sql); $carrier_id = Db::getInstance()->getValue('SELECT id_carrier FROM `' . _DB_PREFIX_ . 'carrier` ORDER BY RAND()'); $state_id = Db::getInstance()->getValue('SELECT id_order_state FROM `' . _DB_PREFIX_ . 'order_state` ORDER BY RAND()'); @@ -210,7 +216,8 @@ public function createDummyOrders($nb = 50) $new_cart->add(); - for ($p = 1; $p <= 5; ++$p) { + $products = Db::getInstance()->executeS('SELECT id_product FROM ' . _DB_PREFIX_ . 'product ORDER BY RAND() LIMIT 5'); + foreach (array_column($products, 'id_product') as $p) { $result = $new_cart->updateQty(rand(1, 5), $p); } @@ -231,6 +238,7 @@ public function createDummyOrders($nb = 50) $history = new OrderHistory(); $history->id_order = (int) $id_order; + $history->id_order_state = (int) $state_id; $history->changeIdOrderState((int) $state_id, (int) $history->id_order); $history->save(); } diff --git a/logo.png b/logo.png index adbebfd..e22377d 100644 Binary files a/logo.png and b/logo.png differ diff --git a/prestaclean.php b/prestaclean.php index 5e327f8..78ba3ef 100644 --- a/prestaclean.php +++ b/prestaclean.php @@ -39,7 +39,7 @@ public function __construct() { $this->name = 'prestaclean'; $this->tab = 'administration'; - $this->version = '1.0.1'; + $this->version = '1.0.2'; $this->author = 'Spiriit'; $this->need_instance = 0; $this->bootstrap = true; diff --git a/views/js/order.js b/views/js/order.js new file mode 100644 index 0000000..cf8e3d7 --- /dev/null +++ b/views/js/order.js @@ -0,0 +1,38 @@ +/* +* 2013-2022 In Spiriit +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author In Spiriit +* @copyright 2013-2022 In Spiriit +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +document.addEventListener("DOMContentLoaded", function() { + const deleteBtn = document.querySelector('.delete-order'); + + // Confirm delete button click + deleteBtn && deleteBtn.addEventListener('click', function(e) { + if(!confirm(confirmDeleteLang)) { + e.preventDefault(); + e.stopPropagation(); + return; + } + }); + +});