From 5e4cae78e06cf6740fb6cdeaadb01b56df869e01 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 10 Jul 2024 12:37:51 +0530 Subject: [PATCH] Revert the changes made to the ajaxprocess in the admin address controller --- .../addresses/helpers/form/form.tpl | 16 ++++++++------ .../admin/AdminAddressesController.php | 22 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl b/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl index 7cd7a9ad0..fbcda13d1 100644 --- a/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl @@ -60,22 +60,24 @@ var email = $(this).find('[value="'+id_customer+'"]').text(); $('#email').val(email); var data = {}; - data.id_customer = id_customer; + data.email = email; data.token = "{$token|escape:'html':'UTF-8'}"; data.ajax = 1; data.controller = "AdminAddresses"; - data.action = "loadCustomer"; + data.action = "loadNames"; $.ajax({ type: "POST", url: "ajax-tab.php", data: data, dataType: 'json', async : true, - success: function(response) { - if (response.status) { - $('input[name=firstname]').val(response.firstname); - $('input[name=lastname]').val(response.lastname); - $('input[name=company]').val(response.company); + success: function(msg) { + if (msg) { + var infos = msg.infos.replace("\\'", "'").split('_'); + $('input[name=firstname]').val(infos[0]); + $('input[name=lastname]').val(infos[1]); + $('input[name=company]').val(infos[2]); + $('input[name=id_customer]').val(infos[3]); } else { resetCustomerRelatedAddressFields(); } diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index 8c4033a88..daf71152d 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -527,22 +527,20 @@ class AdminAddressesControllerCore extends AdminController } /** - * Method called when an ajax request is made to load the customer info for the selected email + * Method called when an ajax request is made * @see AdminController::postProcess() */ - public function ajaxProcessLoadCustomer() + public function ajaxProcess() { - $response = array('status' => false); - if (Tools::getValue('id_customer') - && Validate::isLoadedObject($objCustomer = new Customer(Tools::getValue('id_customer'))) - ) { - $response['status'] = true; - $response['firstname'] = $objCustomer->firstname; - $response['lastname'] = $objCustomer->lastname; - $response['company'] = $objCustomer->company; + if (Tools::isSubmit('email')) { + $email = pSQL(Tools::getValue('email')); + $customer = Customer::searchByName($email); + if (!empty($customer)) { + $customer = $customer['0']; + echo json_encode(array('infos' => pSQL($customer['firstname']).'_'.pSQL($customer['lastname']).'_'.pSQL($customer['company']).'_'.pSQL($customer['id_customer']))); + } } - - $this->ajaxDie(json_encode($response)); + die; } /**