diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 3e89319f2..6ceac9edf 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -1237,25 +1237,27 @@ abstract class PaymentModuleCore extends Module } if (Configuration::get('PS_ORDER_CONF_MAIL_TO_SUPERADMIN')){ // send superadmin information - if (Validate::isLoadedObject($superAdmin = new Employee(_PS_ADMIN_PROFILE_))) { - if (Validate::isEmail($superAdmin->email)) { - $data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname; - $data['{customer_email}'] = $this->context->customer->email; - $data['{firstname}'] = $superAdmin->firstname; - $data['{lastname}'] = $superAdmin->lastname; - $data['{email}'] = $superAdmin->email; - Mail::Send( - (int)$order->id_lang, - 'order_conf_admin', - Mail::l('Order confirmation', (int)$order->id_lang), - $data, - $superAdmin->email, - $superAdmin->firstname.' '.$superAdmin->lastname, - null, - null, - $file_attachement, - null, _PS_MAIL_DIR_, false, (int)$order->id_shop - ); + if ($superAdminEmployees = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true)) { + foreach ($superAdminEmployees as $superAdminEmployee) { + if (Validate::isEmail($superAdminEmployee['email'])) { + $data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname; + $data['{customer_email}'] = $this->context->customer->email; + $data['{firstname}'] = $superAdminEmployee['firstname']; + $data['{lastname}'] = $superAdminEmployee['lastname']; + $data['{email}'] = $superAdminEmployee['email']; + Mail::Send( + (int)$order->id_lang, + 'order_conf_admin', + Mail::l('Order confirmation', (int)$order->id_lang), + $data, + $superAdminEmployee['email'], + $superAdminEmployee['firstname'].' '.$superAdminEmployee['lastname'], + null, + null, + $file_attachement, + null, _PS_MAIL_DIR_, false, (int)$order->id_shop + ); + } } } } @@ -1289,7 +1291,7 @@ abstract class PaymentModuleCore extends Module $data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname; $data['{customer_email}'] = $this->context->customer->email; foreach ($htlAccesses as $access) { - if ($access['id_profile'] != _PS_ADMIN_PROFILE_) { + if ($access['access'] && $access['id_profile'] != _PS_ADMIN_PROFILE_) { if ($htlEmployees = Employee::getEmployeesByProfile($access['id_profile'])) { foreach ($htlEmployees as $empl) { if (Validate::isEmail($empl['email'])) { diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index f9dc27eca..36614990c 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -510,29 +510,31 @@ class OrderReturnCore extends ObjectModel // send mail to the super admin if ($objOrderReturnState->send_email_to_superadmin) { - // send superadmin information - if (Validate::isLoadedObject($superAdmin = new Employee(_PS_ADMIN_PROFILE_))) { - if (Validate::isEmail($superAdmin->email)) { - $data['{customer_name}'] = $objCustomer->firstname.' '.$objCustomer->lastname; - $data['{customer_email}'] = $objCustomer->email; - $data['{firstname}'] = $superAdmin->firstname; - $data['{lastname}'] = $superAdmin->lastname; + // Get all the employees with super admin profile + if ($superAdminEmployees = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true)) { + foreach ($superAdminEmployees as $superAdminEmployee) { + if (Validate::isEmail($superAdminEmployee['email'])) { + $data['{customer_name}'] = $objCustomer->firstname.' '.$objCustomer->lastname; + $data['{customer_email}'] = $objCustomer->email; + $data['{firstname}'] = $superAdminEmployee['firstname']; + $data['{lastname}'] = $superAdminEmployee['lastname']; - Mail::Send( - (int)$idLang, - $objOrderReturnState->admin_template, - $objOrderReturnState->name, - $data, - $superAdmin->email, - $superAdmin->firstname.' '.$superAdmin->lastname, - null, - null, - null, - null, - _PS_MAIL_DIR_, - false, - (int)$objOrder->id_shop - ); + Mail::Send( + (int)$idLang, + $objOrderReturnState->admin_template, + $objOrderReturnState->name, + $data, + $superAdminEmployee['email'], + $superAdminEmployee['firstname'].' '.$superAdminEmployee['lastname'], + null, + null, + null, + null, + _PS_MAIL_DIR_, + false, + (int)$objOrder->id_shop + ); + } } } } @@ -570,7 +572,7 @@ class OrderReturnCore extends ObjectModel $data['{customer_name}'] = $objCustomer->firstname.' '.$objCustomer->lastname; $data['{customer_email}'] = $objCustomer->email; foreach ($htlAccesses as $access) { - if ($access['id_profile'] != _PS_ADMIN_PROFILE_) { + if ($access['access'] && $access['id_profile'] != _PS_ADMIN_PROFILE_) { if ($htlEmployees = Employee::getEmployeesByProfile($access['id_profile'])) { foreach ($htlEmployees as $empl) { if (Validate::isEmail($empl['email'])) {