Skip to content

Commit

Permalink
email refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ClicShopping committed Sep 9, 2022
1 parent 4746c38 commit e999ed7
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use ClicShopping\Sites\ClicShoppingAdmin\HTMLOverrideAdmin;

use ClicShopping\Apps\Catalog\Suppliers\Classes\ClicShoppingAdmin\SupplierAdmin;

$CLICSHOPPING_SupplierAdmin = Registry::get('SupplierAdmin');
$CLICSHOPPING_ProductsAdmin = Registry::get('ProductsAdmin');
$CLICSHOPPING_Language = Registry::get('Language');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,43 @@ public function execute()
$message_info_admin = '';
}

$message_to_admin = $email_subject . ' ' . STORE_NAME . "\n\n" . $message_info_admin . "\n\n" . $CLICSHOPPING_PageManager->getDef('entry_date') . ' ' . $today . "\n" . $num_customer_id . "\n" . $CLICSHOPPING_PageManager->getDef('entry_order') . ' ' . $order_id . "\n" . $CLICSHOPPING_PageManager->getDef('entry_name') . ' ' . $name . "\n" . $CLICSHOPPING_PageManager->getDef('entry_email') . ' ' . $email_address . "\n" . $CLICSHOPPING_PageManager->getDef('entry_enquiry_customer_information') . ' ' . $enquiry . "\n\n" . $CLICSHOPPING_PageManager->getDef('entry_admin_read_message') . "\n\n";
$CLICSHOPPING_Mail->clicMail($email_address_department, STORE_OWNER, $email_subject, $message_to_admin, $name, $email_address);
$message_to_admin = $email_subject . ' ' . STORE_NAME . "\n\n" .
$message_info_admin . "\n\n" . $CLICSHOPPING_PageManager->getDef('entry_date') . ' ' . $today . "\n" .
$num_customer_id . "\n" .
$CLICSHOPPING_PageManager->getDef('entry_order') . ' ' . $order_id . "\n" .
$CLICSHOPPING_PageManager->getDef('entry_name') . ' ' . $name . "\n" .
$CLICSHOPPING_PageManager->getDef('entry_email') . ' ' . $email_address . "\n" . $CLICSHOPPING_PageManager->getDef('entry_enquiry_customer_information') . ' ' . $enquiry . "\n\n" .
$CLICSHOPPING_PageManager->getDef('entry_admin_read_message') . "\n\n";
// aadmin
$to_addr = $email_address_department;
$from_name = STORE_NAME;
$from_addr = $email_address;
$to_name = $name;
$subject = $email_subject;

$CLICSHOPPING_Mail->addHtml($message_to_admin);
$CLICSHOPPING_Mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);

// send information to customer
$message_to_customer = $email_subject . ' ' . STORE_NAME . "\n\n" . $CLICSHOPPING_PageManager->getDef('entry_date') . ' ' . $today . "\n" . $num_customer_id . "\n\n" . $CLICSHOPPING_PageManager->getDef('entry_order') . ' ' . $order_id . "\n" . $CLICSHOPPING_PageManager->getDef('entry_name') . ' ' . $name . "\n" . $CLICSHOPPING_PageManager->getDef('entry_customers_phone') . ' ' . $customers_telephone . "\n" . $CLICSHOPPING_PageManager->getDef('entry_email') . ' ' . $email_address . "\n" . $CLICSHOPPING_PageManager->getDef('entry_enquiry_customer') . ' ' . $enquiry . "\n\n" . $CLICSHOPPING_PageManager->getDef('entry_additional_information') . "\n\n" . $template_email_footer;
$CLICSHOPPING_Mail->clicMail($email_address, STORE_OWNER, $CLICSHOPPING_PageManager->getDef('entry_email_object_customer'), $message_to_customer, $name, STORE_OWNER_EMAIL_ADDRESS);
$message_to_customer = $email_subject . ' ' . STORE_NAME . "\n\n" .
$CLICSHOPPING_PageManager->getDef('entry_date') . ' ' . $today . "\n" .
$num_customer_id . "\n\n" .
$CLICSHOPPING_PageManager->getDef('entry_order') . ' ' . $order_id . "\n" .
$CLICSHOPPING_PageManager->getDef('entry_name') . ' ' . $name . "\n" .
$CLICSHOPPING_PageManager->getDef('entry_customers_phone') . ' ' . $customers_telephone . "\n" .
$CLICSHOPPING_PageManager->getDef('entry_email') . ' ' . $email_address . "\n" .
$CLICSHOPPING_PageManager->getDef('entry_enquiry_customer') . ' ' . $enquiry . "\n\n" .
$CLICSHOPPING_PageManager->getDef('entry_additional_information') . "\n\n" .
$template_email_footer;

$to_addr = $email_address;
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = $name;
$subject = $CLICSHOPPING_PageManager->getDef('entry_email_object_customer');

$CLICSHOPPING_Mail->addHtml($message_to_customer);
$CLICSHOPPING_Mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);
}
} else {
$message_to_admin = $email_subject . ' ' . STORE_NAME . "\n\n" .
Expand Down Expand Up @@ -183,7 +214,7 @@ public function execute()

$CLICSHOPPING_Mail->addHtmlCkeditor($message_to_customer);
$to_addr = $email_address;
$from_name = STORE_OWNER;
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = $name;
$subject = $CLICSHOPPING_PageManager->getDef('entry_email_object_customer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public function execute()
$_SESSION['admin']['access'] = $access;
}

$this->app->db->save('administrators', ['user_name' => $username,
$sql_array = ['user_name' => $username,
'name' => $name,
'first_name' => $first_name,
'access' => $access
],
['id' => (int)$_GET['aID']]
);
];

$this->app->db->save('administrators', $sql_array, ['id' => (int)$_GET['aID']]);

if (!empty($password)) {
$this->app->db->save('administrators', [
Expand All @@ -77,7 +77,14 @@ public function execute()
}

// mail report
$CLICSHOPPING_Mail->clicMail(STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER, $this->app->getDef('report_password_change_subject', ['username' => $username]), $this->app->getDef('report_password_change_text', ['username' => $username]), STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);
$to_addr = STORE_OWNER_EMAIL_ADDRESS;
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = STORE_OWNER_EMAIL_ADDRESS;
$subject = $this->app->getDef('report_password_change_subject', ['username' => $username]);

$CLICSHOPPING_Mail->addHtml($this->app->getDef('report_password_change_text', ['username' => $username]));
$CLICSHOPPING_Mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);

$this->app->redirect('Administrators&aID=' . (int)$_GET['aID']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public function execute()
$text_password_body .= '<br />' . TemplateEmailAdmin::getTemplateEmailSignature();
$text_password_body .= '<br />' . TemplateEmailAdmin::getTemplateEmailTextFooter();

$to_name = $QcheckCustomer->value('customers_firstname') . ' ' . $QcheckCustomer->value('customers_lastname');
$to_email_address = $QcheckCustomer->value('customers_email_address');
$email_subject = $CLICSHOPPING_Customer->getDef('email_password_reminder_subject', ['store_name' => STORE_NAME]);
$email_body = sprintf($text_password_body, $QcheckCustomer->value('customers_email_address'), $newpass);
$to_addr = $QcheckCustomer->value('customers_email_address');;
$from_name = STORE_NAME;
$from_email_address = STORE_OWNER_EMAIL_ADDRESS;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = $QcheckCustomer->value('customers_firstname') . ' ' . $QcheckCustomer->value('customers_lastname');
$subject = $CLICSHOPPING_Customer->getDef('email_password_reminder_subject', ['store_name' => STORE_NAME]);

$CLICSHOPPING_Mail->clicMail($to_email_address, $to_name, $email_subject, nl2br($email_body), $from_name, $from_email_address);
$CLICSHOPPING_Mail->addHtml(sprintf($text_password_body, $QcheckCustomer->value('customers_email_address'), $newpass));
$CLICSHOPPING_Mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);

$CLICSHOPPING_MessageStack->add($CLICSHOPPING_Customer->getDef('text_new_password') . '&nbsp;' . ($QcheckCustomer->value('customers_firstname') . ' ' . $QcheckCustomer->value('customers_lastname')), 'success');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,28 @@ public function sendEmail()
$CLICSHOPPING_Mail = Registry::get('Mail');

if (REVIEW_COMMENT_SEND_EMAIL == 'true') {
$email_subject = CLICSHOPPING::getDef('email_subject_customer', ['store_name' => STORE_NAME]);
$email_text = CLICSHOPPING::getDef('email_text_customer', ['store_name' => STORE_NAME]);

$CLICSHOPPING_Mail->clicMail($this->customer->getEmailAddress(), $this->customer->getLastName(), $email_subject, $email_text, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);
$to_addr = $this->customer->getEmailAddress();
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = $this->customer->getLastName();
$subject = CLICSHOPPING::getDef('email_subject_customer', ['store_name' => STORE_NAME]);

$email_subject = CLICSHOPPING::getDef('email_subject', ['store_name' => STORE_NAME]);
$CLICSHOPPING_Mail->addHtml($email_text);
$CLICSHOPPING_Mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);

//admin
$email_text = CLICSHOPPING::getDef('email_text', ['store_name' => STORE_NAME]);

$CLICSHOPPING_Mail->clicMail(STORE_OWNER_EMAIL_ADDRESS, STORE_NAME, $email_subject, $email_text, $this->productsCommon->getProductsName(), STORE_OWNER_EMAIL_ADDRESS);
$to_addr = STORE_OWNER_EMAIL_ADDRESS;
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = STORE_NAME;
$subject = CLICSHOPPING::getDef('email_subject', ['store_name' => STORE_NAME]);

$CLICSHOPPING_Mail->addHtml($email_text .'<br />' . $this->productsCommon->getProductsName());
$CLICSHOPPING_Mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);
}
}

Expand Down
70 changes: 59 additions & 11 deletions includes/ClicShopping/Apps/Orders/Orders/Classes/Shop/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -1326,10 +1326,24 @@ public function sendCustomerEmail(int $order_id) :void

if (\is_array($email)) {
foreach ($email as $key => $value) {
$this->mail->clicMail($value[$key], null, $email_text_subject, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$to_addr = $value[$key];
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = null;
$subject = $email_text_subject;

$this->mail->addHtml($email_order);
$this->mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);
}
} else {
$this->mail->clicMail($email, null, $email_text_subject, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$to_addr = $email;
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = null;
$subject = $email_text_subject;

$this->mail->addHtml($email_order);
$this->mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);
}
}
}
Expand Down Expand Up @@ -1373,9 +1387,19 @@ public function sendEmailAlertProductsSoldOut(int $insert_id) :void
if (($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') && (STOCK_CHECK == 'true')) {
$email_text_subject_stock = stripslashes(CLICSHOPPING::getDef('email_text_subject_stock', ['store_name' => STORE_NAME]));
$email_product_sold_out_stock = stripslashes(CLICSHOPPING::getDef('email_text_stock'));
$email_product_sold_out_stock .= "\n" . CLICSHOPPING::getDef('email_text_date_alert') . ' ' . strftime(CLICSHOPPING::getDef('date_format_long')) . "\n" . CLICSHOPPING::getDef('email_text_model') . ' ' . $Qproducts->value('products_model') . "\n" . CLICSHOPPING::getDef('email_text_products_name') . ' ' . $Qproducts->value('products_name') . "\n" . CLICSHOPPING::getDef('email_text_id_product') . ' ' . $CLICSHOPPING_Prod::getProductID($Qproducts->value('products_id')) . "\n";

$this->mail->clicMail(STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER, $email_text_subject_stock, $email_product_sold_out_stock, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$email_product_sold_out_stock .= "\n" . CLICSHOPPING::getDef('email_text_date_alert') . ' ' . strftime(CLICSHOPPING::getDef('date_format_long')) . "\n" .
CLICSHOPPING::getDef('email_text_model') . ' ' . $Qproducts->value('products_model') . "\n" .
CLICSHOPPING::getDef('email_text_products_name') . ' ' . $Qproducts->value('products_name') . "\n" .
CLICSHOPPING::getDef('email_text_id_product') . ' ' . $CLICSHOPPING_Prod::getProductID($Qproducts->value('products_id')) . "\n";

$to_addr = STORE_OWNER_EMAIL_ADDRESS;
$from_name = STORE_NAME;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = STORE_OWNER_EMAIL_ADDRESS;
$subject = $email_text_subject_stock;

$this->mail->addHtml($email_product_sold_out_stock);
$this->mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);
}
} // end stock alert
} // end while
Expand Down Expand Up @@ -1424,18 +1448,42 @@ public function sendEmailAlertStockWarning(int $insert_id) :void
$email_text_subject_stock = stripslashes(CLICSHOPPING::getDef('email_text_suject_stock', ['store_name' => STORE_NAME]));

$reorder_stock_email = stripslashes(CLICSHOPPING::getDef('email_reorder_level_text_alert_stock'));
$reorder_stock_email .= "\n" . CLICSHOPPING::getDef('email_text_date_alert') . ' ' . strftime(CLICSHOPPING::getDef('date_format_long')) . "\n" . CLICSHOPPING::getDef('email_text_model') . ' ' . $Qproducts->value('products_model') . "\n" . CLICSHOPPING::getDef('email_text_products_name') . ' ' . $Qproducts->value('products_name') . "\n" . CLICSHOPPING::getDef('email_text_id_product') . ' ' . $CLICSHOPPING_Prod::getProductID($Qproducts->value('products_id')) . "\n" . '<strong>' . CLICSHOPPING::getDef('email_text_product_url') . ' </strong>' . HTTP::getShopUrlDomain() . 'index.php?Products&Description&products_id=' . $Qproducts->value('products_id') . "\n" . '<strong>' . CLICSHOPPING::getDef('email_text_product_stock') . ' ' . $stock_products_quantity_alert . '</strong>';

$this->mail->clicMail(STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER, $email_text_subject_stock, $reorder_stock_email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$reorder_stock_email .= "\n" . CLICSHOPPING::getDef('email_text_date_alert') . ' ' . strftime(CLICSHOPPING::getDef('date_format_long')) . "\n" .
CLICSHOPPING::getDef('email_text_model') . ' ' . $Qproducts->value('products_model') . "\n" .
CLICSHOPPING::getDef('email_text_products_name') . ' ' . $Qproducts->value('products_name') . "\n" .
CLICSHOPPING::getDef('email_text_id_product') . ' ' . $CLICSHOPPING_Prod::getProductID($Qproducts->value('products_id')) . "\n" .
'<strong>' . CLICSHOPPING::getDef('email_text_product_url') . ' </strong>' . HTTP::getShopUrlDomain() . 'index.php?Products&Description&products_id=' . $Qproducts->value('products_id') . "\n" .
'<strong>' . CLICSHOPPING::getDef('email_text_product_stock') . ' ' . $stock_products_quantity_alert . '</strong>';

$to_addr = STORE_OWNER_EMAIL_ADDRESS;
$from_name = STORE_OWNER;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = STORE_OWNER_EMAIL_ADDRESS;
$subject = $email_text_subject_stock;

$this->mail->addHtml($reorder_stock_email);
$this->mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);
}

if ($current_stock <= $warning_stock) {
$email_text_subject_stock = stripslashes(CLICSHOPPING::getDef('email_text_suject_stock', ['store_name' => STORE_NAME]));

$reorder_stock_email = stripslashes(CLICSHOPPING::getDef('email_reorder_level_text_stock'));
$reorder_stock_email .= "\n" . CLICSHOPPING::getDef('email_text_date_alert') . ' ' . strftime(CLICSHOPPING::getDef('date_format_long')) . "\n" . CLICSHOPPING::getDef('email_text_model') . ' ' . $Qproducts->value('products_model') . "\n" . CLICSHOPPING::getDef('email_text_products_name') . ' ' . $Qproducts->value('products_name') . "\n" . CLICSHOPPING::getDef('email_text_id_product') . ' ' . $CLICSHOPPING_Prod::getProductID($Qproducts->value('products_id')) . "\n" . '<strong>' . CLICSHOPPING::getDef('email_text_product_url') . ' </strong>' . HTTP::getShopUrlDomain() . 'index.php?Products&Description&products_id=' . $Qproducts->value('products_id') . "\n" . '<strong>' . CLICSHOPPING::getDef('email_text_product_stock') . ' ' . $stock_products_quantity_alert . '</strong>';

$this->mail->clicMail(STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER, $email_text_subject_stock, $reorder_stock_email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$reorder_stock_email .= "\n" . CLICSHOPPING::getDef('email_text_date_alert') . ' ' . strftime(CLICSHOPPING::getDef('date_format_long')) . "\n" .
CLICSHOPPING::getDef('email_text_model') . ' ' . $Qproducts->value('products_model') . "\n" .
CLICSHOPPING::getDef('email_text_products_name') . ' ' . $Qproducts->value('products_name') . "\n" .
CLICSHOPPING::getDef('email_text_id_product') . ' ' . $CLICSHOPPING_Prod::getProductID($Qproducts->value('products_id')) . "\n" .
'<strong>' . CLICSHOPPING::getDef('email_text_product_url') . ' </strong>' . HTTP::getShopUrlDomain() . 'index.php?Products&Description&products_id=' . $Qproducts->value('products_id') . "\n" .
'<strong>' . CLICSHOPPING::getDef('email_text_product_stock') . ' ' . $stock_products_quantity_alert . '</strong>';

$to_addr = STORE_OWNER_EMAIL_ADDRESS;
$from_name = STORE_OWNER;
$from_addr = STORE_OWNER_EMAIL_ADDRESS;
$to_name = STORE_OWNER_EMAIL_ADDRESS;
$subject = $email_text_subject_stock;

$this->mail->addHtml($reorder_stock_email);
$this->mail->send($to_addr, $from_name, $from_addr, $to_name, $subject);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions includes/ClicShopping/External/vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../../../../',
'aliases' => array(),
'reference' => 'f1cc188259d03fcce1c22f4dae4867c7e558c63e',
'reference' => '4746c38d2ea5ddd54648674500b3db34a5086f1a',
'name' => '__root__',
'dev' => true,
),
Expand All @@ -16,7 +16,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../../../../',
'aliases' => array(),
'reference' => 'f1cc188259d03fcce1c22f4dae4867c7e558c63e',
'reference' => '4746c38d2ea5ddd54648674500b3db34a5086f1a',
'dev_requirement' => false,
),
'darkghosthunter/preloader' => array(
Expand Down
Loading

0 comments on commit e999ed7

Please sign in to comment.