From df643828f0a8e5104bea2bcd5c82d273125b3ca0 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 12 Jun 2024 15:21:31 +0530 Subject: [PATCH] updated the customer delete and ban process --- .../customers/helpers/view/view.tpl | 24 ++++++++++++++----- classes/Customer.php | 5 +++- .../admin/AdminCustomersController.php | 10 ++++++-- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl index 88da2734e..294f6dd69 100644 --- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl @@ -146,15 +146,27 @@

- {if $customer->active} - - - {l s='Active'} + {if !$customer->deleted} + {if $customer->active} + + + {l s='Active'} + + {else} + + + {l s='Inactive'} + + {/if} + {else if $customer->deleted == Customer::STATUS_BANNED} + + + {l s='Banned'} - {else} + {else if $customer->deleted == Customer::STATUS_DELETED} - {l s='Inactive'} + {l s='Deleted'} {/if}

diff --git a/classes/Customer.php b/classes/Customer.php index a8c4c3609..fd46a853a 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -135,6 +135,9 @@ class CustomerCore extends ObjectModel public $groupBox; + const STATUS_BANNED = 1; + const STATUS_DELETED = 2; + protected $webserviceParameters = array( 'fields' => array( 'id_default_group' => array('xlink_resource' => 'groups'), @@ -179,7 +182,7 @@ class CustomerCore extends ObjectModel 'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), - 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), + 'deleted' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'note' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000, 'copy_post' => false), 'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false), diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 3344f23a2..58527d92f 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -236,6 +236,11 @@ class AdminCustomersControllerCore extends AdminController $this->context->cookie->{$prefix.$this->table.'Filter_date_add'} = json_encode(array($dateFrom, $dateTo)); } + $this->redirect_after = $this->context->link->getAdminLink('AdminCustomers'); + } else if (Tools::getValue('filterOnlyBannedCustomer')) { + $this->processResetFilters(); + $this->context->cookie->{'submitFilter'.$this->table} = true; + $this->context->cookie->{$prefix.$this->table.'Filter_deleted'} = Customer::STATUS_BANNED; $this->redirect_after = $this->context->link->getAdminLink('AdminCustomers'); } @@ -779,6 +784,7 @@ class AdminCustomersControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Banned Customers', null, null, false); $helper->subtitle = $this->l('All Time', null, null, false); + $helper->href = $this->context->link->getAdminLink('AdminCustomers').'&filterOnlyBannedCustomer=1'; $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_banned_customers'; $helper->tooltip = $this->l('The total number of banned customers.', null, null, false); $kpis[] = $helper; @@ -988,7 +994,7 @@ class AdminCustomersControllerCore extends AdminController if (Validate::isLoadedObject($objCustomer = $this->loadObject())) { if ($this->delete_mode == 'real' && Order::getCustomerOrders($objCustomer->id, true)) { $objCustomer->email = 'anonymous'.'-'.$objCustomer->id.'@'.Tools::getShopDomain(); - $objCustomer->deleted = 1; + $objCustomer->deleted = Customer::STATUS_DELETED; if (!$objCustomer->update()) { $this->errors[] = Tools::displayError('Some error ocurred while deleting the Customer'); return; @@ -1029,7 +1035,7 @@ class AdminCustomersControllerCore extends AdminController // check if customer has orders for email change else customer will be deleted if (Order::getCustomerOrders($objCustomer->id, true)) { $objCustomer->email = 'anonymous'.'-'.$objCustomer->id.'@'.Tools::getShopDomain(); - $objCustomer->deleted = 1; + $objCustomer->deleted = Customer::STATUS_DELETED; if ($objCustomer->update()) { // unset the customer which is processed // not processed customers will be deleted with default process if no errors are there