コード例 #1
0
ファイル: invoice.php プロジェクト: wardvanderput/SumoStore
 public function send()
 {
     $this->load->model('sale/invoice');
     $invoiceData = $this->model_sale_invoice->getInvoice($this->request->get['invoice_id']);
     $this->load->model('sale/customer');
     $customerData = $this->model_sale_customer->getCustomer($invoiceData['customer_id']);
     // Save invoice in cache
     $pdf = $this->download(true);
     $handle = fopen(DIR_CACHE . $invoiceData['invoice_no'] . '.pdf', 'w+');
     fwrite($handle, $pdf);
     fclose($handle);
     // Get template
     Mailer::setInvoice($invoiceData);
     Mailer::setCustomer($customerData);
     $template = Mailer::getTemplate('send_invoice');
     Mail::setTo($invoiceData['customer_email']);
     Mail::setSubject($template['title']);
     Mail::setHtml($template['content']);
     Mail::addAttachment(DIR_CACHE . $invoiceData['invoice_no'] . '.pdf');
     Mail::send();
     // Mark invoice as sent
     $this->model_sale_invoice->markSent($invoiceData['invoice_id']);
     // Change status (if necessary)
     if ($invoiceData['status'] == 'CONCEPT') {
         $this->model_sale_invoice->changeStatus($invoiceData['invoice_id'], 'sent');
     }
     // Remove invoice
     @unlink(DIR_CACHE . $invoiceData['invoice_no'] . '.pdf');
     $this->redirect($this->url->link('sale/invoice', 'token=' . $this->session->data['token'], 'SSL'));
 }
コード例 #2
0
 public function confirm($order_id)
 {
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($order_id);
     if ($order_info) {
         $this->load->model('localisation/language');
         $language = new Language($order_info['language_directory']);
         $language->load($order_info['language_filename']);
         $language->load('mail/voucher');
         $voucher_query = $this->db->query("SELECT *, vtd.name AS theme FROM `" . DB_PREFIX . "voucher` v LEFT JOIN " . DB_PREFIX . "voucher_theme vt ON (v.voucher_theme_id = vt.voucher_theme_id) LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) AND vtd.language_id = '" . (int) $order_info['language_id'] . "' WHERE order_id = '" . (int) $order_id . "'");
         foreach ($voucher_query->rows as $voucher) {
             // HTML Mail
             $template = new Template();
             $template->data['title'] = sprintf($language->get('text_subject'), $voucher['from_name']);
             $template->data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']));
             $template->data['text_from'] = sprintf($language->get('text_from'), $voucher['from_name']);
             $template->data['text_message'] = $language->get('text_message');
             $template->data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher['code']);
             $template->data['text_footer'] = $language->get('text_footer');
             if (file_exists(DIR_IMAGE . $voucher['image'])) {
                 $template->data['image'] = 'cid:' . md5(basename($voucher['image']));
             } else {
                 $template->data['image'] = '';
             }
             $template->data['store_name'] = $order_info['store_name'];
             $template->data['store_url'] = $order_info['store_url'];
             $template->data['message'] = nl2br($voucher['message']);
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/voucher.tpl')) {
                 $html = $template->fetch($this->config->get('config_template') . '/template/mail/voucher.tpl');
             } else {
                 $html = $template->fetch('default/template/mail/voucher.tpl');
             }
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($voucher['to_email']);
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_info['store_name']);
             $mail->setSubject(sprintf($language->get('text_subject'), $voucher['from_name']));
             $mail->setHtml($html);
             if (file_exists(DIR_IMAGE . $voucher['image'])) {
                 $mail->addAttachment(DIR_IMAGE . $voucher['image'], md5(basename($voucher['image'])));
             }
             $mail->send();
         }
     }
 }
コード例 #3
0
ファイル: Mailer.php プロジェクト: vincenta/stato
 protected function create($methodName, $args)
 {
     $mail = new Mail($this->date);
     if (is_array($this->from)) {
         $mail->setFrom($this->from[0], $this->from[1]);
     } else {
         $mail->setFrom($this->from);
     }
     if (!is_array($this->recipients)) {
         $this->recipients = array($this->recipients);
     }
     foreach ($this->recipients as $to) {
         if (is_array($to)) {
             $mail->addTo($to[0], $to[1]);
         } else {
             $mail->addTo($to);
         }
     }
     $mail->setSubject($this->subject);
     if (is_array($this->body)) {
         $template = $this->getTemplateName($methodName);
         if (file_exists($this->getTemplatePath($template . '.plain'))) {
             $mail->setText($this->render($template . '.plain', $this->body));
         }
         if (file_exists($this->getTemplatePath($template . '.html'))) {
             $mail->setHtmlText($this->render($template . '.html', $this->body));
         }
     } elseif (is_string($this->body) && !empty($this->body)) {
         $mail->setText($this->body);
     }
     foreach ($this->parts as $p) {
         $p = array_merge(self::$partDefaults, $p);
         $mail->addPart($p['content'], $p['content_type'], $p['encoding'], $p['charset']);
     }
     foreach ($this->attachments as $a) {
         $a = array_merge(self::$attachmentDefaults, $a);
         $mail->addAttachment($a['content'], $a['filename'], $a['content_type'], $a['encoding']);
     }
     $this->reset();
     return $mail;
 }
コード例 #4
0
ファイル: MailTest.php プロジェクト: jrdncchr/merlinleads
 public function testKitchenSinkExample()
 {
     $mail = new Mail();
     $email = new Email("DX", "*****@*****.**");
     $mail->setFrom($email);
     $mail->setSubject("Hello World from the SendGrid PHP Library");
     $personalization = new Personalization();
     $email = new Email("Example User", "*****@*****.**");
     $personalization->addTo($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization->addTo($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization->addCc($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization->addCc($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization->addBcc($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization->addBcc($email);
     $personalization->setSubject("Hello World from the SendGrid PHP Library");
     $personalization->addHeader("X-Test", "test");
     $personalization->addHeader("X-Mock", "true");
     $personalization->addSubstitution("%name%", "Example User");
     $personalization->addSubstitution("%city%", "Denver");
     $personalization->addCustomArg("user_id", "343");
     $personalization->addCustomArg("type", "marketing");
     $personalization->setSendAt(1443636843);
     $mail->addPersonalization($personalization);
     $personalization2 = new Personalization();
     $email = new Email("Example User", "*****@*****.**");
     $personalization2->addTo($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization2->addTo($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization2->addCc($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization2->addCc($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization2->addBcc($email);
     $email = new Email("Example User", "*****@*****.**");
     $personalization2->addBcc($email);
     $personalization2->setSubject("Hello World from the SendGrid PHP Library");
     $personalization2->addHeader("X-Test", "test");
     $personalization2->addHeader("X-Mock", "true");
     $personalization2->addSubstitution("%name%", "Example User");
     $personalization2->addSubstitution("%city%", "Denver");
     $personalization2->addCustomArg("user_id", "343");
     $personalization2->addCustomArg("type", "marketing");
     $personalization2->setSendAt(1443636843);
     $mail->addPersonalization($personalization2);
     $content = new Content("text/plain", "some text here");
     $mail->addContent($content);
     $content = new Content("text/html", "<html><body>some text here</body></html>");
     $mail->addContent($content);
     $attachment = new Attachment();
     $attachment->setContent("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12");
     $attachment->setType("application/pdf");
     $attachment->setFilename("balance_001.pdf");
     $attachment->setDisposition("attachment");
     $attachment->setContentId("Balance Sheet");
     $mail->addAttachment($attachment);
     $attachment2 = new Attachment();
     $attachment2->setContent("BwdW");
     $attachment2->setType("image/png");
     $attachment2->setFilename("banner.png");
     $attachment2->setDisposition("inline");
     $attachment2->setContentId("Banner");
     $mail->addAttachment($attachment2);
     $mail->setTemplateId("439b6d66-4408-4ead-83de-5c83c2ee313a");
     $mail->addSection("%section1%", "Substitution Text for Section 1");
     $mail->addSection("%section2%", "Substitution Text for Section 2");
     $mail->addHeader("X-Test1", "1");
     $mail->addHeader("X-Test2", "2");
     $mail->addCategory("May");
     $mail->addCategory("2016");
     $mail->addCustomArg("campaign", "welcome");
     $mail->addCustomArg("weekday", "morning");
     $mail->setSendAt(1443636842);
     $asm = new ASM();
     $asm->setGroupId(99);
     $asm->setGroupsToDisplay([4, 5, 6, 7, 8]);
     $mail->setASM($asm);
     $mail->setIpPoolName("23");
     $mail_settings = new MailSettings();
     $bcc_settings = new BccSettings();
     $bcc_settings->setEnable(True);
     $bcc_settings->setEmail("*****@*****.**");
     $mail_settings->setBccSettings($bcc_settings);
     $sandbox_mode = new SandBoxMode();
     $sandbox_mode->setEnable(True);
     $mail_settings->setSandboxMode($sandbox_mode);
     $bypass_list_management = new BypassListManagement();
     $bypass_list_management->setEnable(True);
     $mail_settings->setBypassListManagement($bypass_list_management);
     $footer = new Footer();
     $footer->setEnable(true);
     $footer->setText("Footer Text");
     $footer->setHtml("<html><body>Footer Text</body></html>");
     $mail_settings->setFooter($footer);
     $spam_check = new SpamCheck();
     $spam_check->setEnable(True);
     $spam_check->setThreshold(1);
     $spam_check->setPostToUrl("https://spamcatcher.sendgrid.com");
     $mail_settings->setSpamCheck($spam_check);
     $mail->setMailSettings($mail_settings);
     $tracking_settings = new TrackingSettings();
     $click_tracking = new ClickTracking();
     $click_tracking->setEnable(true);
     $click_tracking->setEnableText(True);
     $tracking_settings->setClickTracking($click_tracking);
     $open_tracking = new OpenTracking();
     $open_tracking->setEnable(True);
     $open_tracking->setSubstitutionTag("Optional tag to replace with the open image in the body of the message");
     $tracking_settings->setOpenTracking($open_tracking);
     $subscription_tracking = new SubscriptionTracking();
     $subscription_tracking->setEnable(True);
     $subscription_tracking->setText("text to insert into the text/plain portion of the message");
     $subscription_tracking->setHtml("<html><body>html to insert into the text/html portion of the message</body></html>");
     $subscription_tracking->setSubstitutionTag("Optional tag to replace with the open image in the body of the message");
     $tracking_settings->setSubscriptionTracking($subscription_tracking);
     $ganalytics = new Ganalytics();
     $ganalytics->setEnable(True);
     $ganalytics->setCampaignSource("some source");
     $ganalytics->setCampaignTerm("some term");
     $ganalytics->setCampaignContent("some content");
     $ganalytics->setCampaignName("some name");
     $ganalytics->setCampaignMedium("some medium");
     $tracking_settings->setGanalytics($ganalytics);
     $mail->setTrackingSettings($tracking_settings);
     $reply_to = new ReplyTo("*****@*****.**");
     $mail->setReplyTo($reply_to);
     $json = json_encode($mail);
     $this->assertEquals($json, '{"from":{"name":"DX","email":"*****@*****.**"},"personalizations":[{"to":[{"name":"Example User","email":"*****@*****.**"},{"name":"Example User","email":"*****@*****.**"}],"cc":[{"name":"Example User","email":"*****@*****.**"},{"name":"Example User","email":"*****@*****.**"}],"bcc":[{"name":"Example User","email":"*****@*****.**"},{"name":"Example User","email":"*****@*****.**"}],"subject":"Hello World from the SendGrid PHP Library","headers":{"X-Test":"test","X-Mock":"true"},"substitutions":{"%name%":"Example User","%city%":"Denver"},"custom_args":{"user_id":"343","type":"marketing"},"send_at":1443636843},{"to":[{"name":"Example User","email":"*****@*****.**"},{"name":"Example User","email":"*****@*****.**"}],"cc":[{"name":"Example User","email":"*****@*****.**"},{"name":"Example User","email":"*****@*****.**"}],"bcc":[{"name":"Example User","email":"*****@*****.**"},{"name":"Example User","email":"*****@*****.**"}],"subject":"Hello World from the SendGrid PHP Library","headers":{"X-Test":"test","X-Mock":"true"},"substitutions":{"%name%":"Example User","%city%":"Denver"},"custom_args":{"user_id":"343","type":"marketing"},"send_at":1443636843}],"subject":"Hello World from the SendGrid PHP Library","content":[{"type":"text\\/plain","value":"some text here"},{"type":"text\\/html","value":"<html><body>some text here<\\/body><\\/html>"}],"attachments":[{"content":"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12","type":"application\\/pdf","filename":"balance_001.pdf","disposition":"attachment","content_id":"Balance Sheet"},{"content":"BwdW","type":"image\\/png","filename":"banner.png","disposition":"inline","content_id":"Banner"}],"template_id":"439b6d66-4408-4ead-83de-5c83c2ee313a","sections":{"%section1%":"Substitution Text for Section 1","%section2%":"Substitution Text for Section 2"},"headers":{"X-Test1":"1","X-Test2":"2"},"categories":["May","2016"],"custom_args":{"campaign":"welcome","weekday":"morning"},"send_at":1443636842,"asm":{"group_id":99,"groups_to_display":[4,5,6,7,8]},"ip_pool_name":"23","mail_settings":{"bcc":{"enable":true,"email":"*****@*****.**"},"bypass_list_management":{"enable":true},"footer":{"enable":true,"text":"Footer Text","html":"<html><body>Footer Text<\\/body><\\/html>"},"sandbox_mode":{"enable":true},"spam_check":{"enable":true,"threshold":1,"post_to_url":"https:\\/\\/spamcatcher.sendgrid.com"}},"tracking_settings":{"click_tracking":{"enable":true,"enable_text":true},"open_tracking":{"enable":true,"substitution_tag":"Optional tag to replace with the open image in the body of the message"},"subscription_tracking":{"enable":true,"text":"text to insert into the text\\/plain portion of the message","html":"<html><body>html to insert into the text\\/html portion of the message<\\/body><\\/html>","substitution_tag":"Optional tag to replace with the open image in the body of the message"},"ganalytics":{"enable":true,"utm_source":"some source","utm_medium":"some medium","utm_term":"some term","utm_content":"some content","utm_campaign":"some name"}},"reply_to":{"email":"*****@*****.**"}}');
 }
コード例 #5
0
ファイル: bitpay.php プロジェクト: keramist/opencart-plugin
 /**
  * Sends a support request to BitPay.
  * @return void
  */
 public function sendSupportRequest()
 {
     $this->load->library('mail');
     $mail = new Mail(array('protocol' => $this->config->get('config_mail')['protocol'], 'parameter' => $this->config->get('config_mail')['parameter'], 'hostname' => $this->config->get('config_mail')['smtp_hostname'], 'username' => $this->config->get('config_mail')['smtp_username'], 'password' => $this->config->get('config_mail')['smtp_password'], 'port' => $this->config->get('config_mail')['smtp_port'], 'timeout' => $this->config->get('config_mail')['smtp_timeout']));
     $mail->setTo('*****@*****.**');
     $mail->setFrom($this->request->post['request_email_address']);
     $mail->setSender($this->request->post['request_name']);
     $mail->setSubject($this->request->post['request_subject']);
     $description = $this->request->post['request_description'];
     // Include server info?
     if ($this->request->post['request_send_server_info'] === "1") {
         $description .= "\n\n" . $this->getServerInfo();
     }
     $mail->setHtml($description);
     // Include BitPay logs?
     if ($this->request->post['request_send_logs'] === "1") {
         $mail->addAttachment(DIR_LOGS . 'bitpay.log');
     }
     $mail->send();
 }
コード例 #6
0
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);
?>



<?php 
include_once 'mail.class.php';
$now = new Mail();
$now->setTo('*****@*****.**');
$now->setFrom('*****@*****.**', 'User name');
$now->setSubject('Temat wiadomoœci');
$now->setContent('Treœæ wiadomoœci');
$now->addAttachment('/path/to/file.txt', 'text/plain');
$now->addAttachment('/path/to/file2.txt', 'text/plain');
echo 'Wysy³anie maila...';
echo $now->sendMail() ? 'OK' : 'FAILED';
?>



<?php 
function sock_mail($to, $subj, $body, $head)
{
    $auth = 0;
    $from = "\"Ktoœ\" <*****@*****.**>";
    $loc_host = "localhost";
    $smtp_acc = "uzytkownik";
    $smtp_pass = "******";
コード例 #7
0
ファイル: order.php プロジェクト: Tambralinga/drupal-opencart
 public function confirm($order_id, $order_status_id, $comment = '', $notify = false)
 {
     $order_info = $this->getOrder($order_id);
     if ($order_info && !$order_info['order_status_id']) {
         $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '1', comment = '" . $this->db->escape($comment && $notify ? $comment : '') . "', date_added = NOW()");
         $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
         foreach ($order_product_query->rows as $order_product) {
             $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_id = '" . (int) $order_product['product_id'] . "' AND subtract = '1'");
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $order_product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "' AND subtract = '1'");
             }
         }
         $this->cache->delete('product');
         $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "'");
         foreach ($order_total_query->rows as $order_total) {
             $this->load->model('total/' . $order_total['code']);
             if (method_exists($this->{'model_total_' . $order_total['code']}, 'confirm')) {
                 $this->{'model_total_' . $order_total['code']}->confirm($order_info, $order_total);
             }
         }
         // Send out any gift voucher mails
         if ($this->config->get('config_complete_status_id') == $order_status_id) {
             $this->load->model('checkout/voucher');
             $this->model_checkout_voucher->confirm($order_id);
         }
         // Send out order confirmation mail
         $language = new Language($order_info['language_directory']);
         $language->load($order_info['language_filename']);
         $language->load('mail/order');
         $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
         if ($order_status_query->num_rows) {
             $order_status = $order_status_query->row['name'];
         } else {
             $order_status = '';
         }
         $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
         $order_total_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC");
         $order_download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "'");
         $subject = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id);
         // HTML Mail
         $template = new Template();
         $template->data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
         $template->data['text_greeting'] = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
         $template->data['text_link'] = $language->get('text_new_link');
         $template->data['text_download'] = $language->get('text_new_download');
         $template->data['text_order_detail'] = $language->get('text_new_order_detail');
         $template->data['text_instruction'] = $language->get('text_new_instruction');
         $template->data['text_order_id'] = $language->get('text_new_order_id');
         $template->data['text_date_added'] = $language->get('text_new_date_added');
         $template->data['text_payment_method'] = $language->get('text_new_payment_method');
         $template->data['text_shipping_method'] = $language->get('text_new_shipping_method');
         $template->data['text_email'] = $language->get('text_new_email');
         $template->data['text_telephone'] = $language->get('text_new_telephone');
         $template->data['text_ip'] = $language->get('text_new_ip');
         $template->data['text_payment_address'] = $language->get('text_new_payment_address');
         $template->data['text_shipping_address'] = $language->get('text_new_shipping_address');
         $template->data['text_product'] = $language->get('text_new_product');
         $template->data['text_model'] = $language->get('text_new_model');
         $template->data['text_quantity'] = $language->get('text_new_quantity');
         $template->data['text_price'] = $language->get('text_new_price');
         $template->data['text_total'] = $language->get('text_new_total');
         $template->data['text_footer'] = $language->get('text_new_footer');
         $template->data['text_powered'] = $language->get('text_new_powered');
         $template->data['logo'] = 'cid:' . md5(basename($this->config->get('config_logo')));
         $template->data['store_name'] = $order_info['store_name'];
         $template->data['store_url'] = $order_info['store_url'];
         $template->data['customer_id'] = $order_info['customer_id'];
         $template->data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
         if ($order_download_query->num_rows) {
             $template->data['download'] = $order_info['store_url'] . 'index.php?route=account/download';
         } else {
             $template->data['download'] = '';
         }
         $template->data['order_id'] = $order_id;
         $template->data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
         $template->data['payment_method'] = $order_info['payment_method'];
         $template->data['shipping_method'] = $order_info['shipping_method'];
         $template->data['email'] = $order_info['email'];
         $template->data['telephone'] = $order_info['telephone'];
         $template->data['ip'] = $order_info['ip'];
         if ($comment && $notify) {
             $template->data['comment'] = nl2br($comment);
         } else {
             $template->data['comment'] = '';
         }
         if ($order_info['shipping_address_format']) {
             $format = $order_info['shipping_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country']);
         $template->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         if ($order_info['payment_address_format']) {
             $format = $order_info['payment_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country']);
         $template->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         $template->data['products'] = array();
         foreach ($order_product_query->rows as $product) {
             $option_data = array();
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 if ($option['type'] != 'file') {
                     $option_data[] = array('name' => $option['name'], 'value' => strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']);
                 } else {
                     $filename = substr($option['value'], 0, strrpos($option['value'], '.'));
                     $option_data[] = array('name' => $option['name'], 'value' => strlen($filename) > 20 ? substr($filename, 0, 20) . '..' : $filename);
                 }
             }
             $template->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']));
         }
         $template->data['totals'] = $order_total_query->rows;
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
             $html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
         } else {
             $html = $template->fetch('default/template/mail/order.tpl');
         }
         // Text Mail
         $text = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n";
         $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
         $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
         $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
         if ($comment && $notify) {
             $text .= $language->get('text_new_instruction') . "\n\n";
             $text .= $comment . "\n\n";
         }
         $text .= $language->get('text_new_products') . "\n";
         foreach ($order_product_query->rows as $result) {
             $text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $text .= chr(9) . '-' . $option['name'] . ' ' . (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
             }
         }
         $text .= "\n";
         $text .= $language->get('text_new_order_total') . "\n";
         foreach ($order_total_query->rows as $result) {
             $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
         }
         $text .= "\n";
         if ($order_info['customer_id']) {
             $text .= $language->get('text_new_link') . "\n";
             $text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n";
         }
         if ($order_download_query->num_rows) {
             $text .= $language->get('text_new_download') . "\n";
             $text .= $order_info['store_url'] . 'index.php?route=account/download' . "\n\n";
         }
         if ($order_info['comment']) {
             $text .= $language->get('text_new_comment') . "\n\n";
             $text .= $order_info['comment'] . "\n\n";
         }
         $text .= $language->get('text_new_footer') . "\n\n";
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($order_info['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($order_info['store_name']);
         $mail->setSubject($subject);
         $mail->setHtml($html);
         $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
         $mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'), md5(basename($this->config->get('config_logo'))));
         $mail->send();
         // Admin Alert Mail
         if ($this->config->get('config_alert_mail')) {
             $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
             // Text
             $text = $language->get('text_new_received') . "\n\n";
             $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
             $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
             $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
             $text .= $language->get('text_new_products') . "\n";
             foreach ($order_product_query->rows as $result) {
                 $text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
                 $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
                 foreach ($order_option_query->rows as $option) {
                     $text .= chr(9) . '-' . $option['name'] . ' ' . (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
                 }
             }
             $text .= "\n";
             $text .= $language->get('text_new_order_total') . "\n";
             foreach ($order_total_query->rows as $result) {
                 $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
             }
             $text .= "\n";
             if ($order_info['comment'] != '') {
                 $comment = $order_info['comment'] . "\n\n" . $comment;
             }
             if ($comment) {
                 $text .= $language->get('text_new_comment') . "\n\n";
                 $text .= $comment . "\n\n";
             }
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($this->config->get('config_email'));
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_info['store_name']);
             $mail->setSubject($subject);
             $mail->setText($text);
             $mail->send();
             // Send to additional alert emails
             $emails = explode(',', $this->config->get('config_alert_emails'));
             foreach ($emails as $email) {
                 if ($email && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
                     $mail->setTo($email);
                     $mail->send();
                 }
             }
         }
     }
 }
コード例 #8
0
ファイル: contact.php プロジェクト: RepublicMaster/opencart
 public function index()
 {
     $this->load->language('customer/contact');
     $this->document->title = $this->language->get('heading_title');
     $this->load->model('customer/customer');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $emails = array();
         if (isset($this->request->post['group'])) {
             switch ($this->request->post['group']) {
                 case 'newsletter':
                     $results = $this->model_customer_customer->getCustomersByNewsletter();
                     foreach ($results as $result) {
                         $emails[$result['customer_id']] = $result['email'];
                     }
                     break;
                 case 'customer':
                     $results = $this->model_customer_customer->getCustomers();
                     foreach ($results as $result) {
                         $emails[$result['customer_id']] = $result['email'];
                     }
                     break;
             }
         }
         if (isset($this->request->post['to']) && $this->request->post['to']) {
             foreach ($this->request->post['to'] as $customer_id) {
                 $customer_info = $this->model_customer_customer->getCustomer($customer_id);
                 if ($customer_info) {
                     $emails[] = $customer_info['email'];
                 }
             }
         }
         if ($emails) {
             $message = '<html dir="ltr" lang="en">' . "\n";
             $message .= '<head>' . "\n";
             $message .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
             $message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
             $message .= '</head>' . "\n";
             $message .= '<body>' . html_entity_decode($this->request->post['message']) . '</body>' . "\n";
             $message .= '</html>' . "\n";
             $attachments = array();
             $pattern = '#(src="([^"]*)")#mis';
             if (preg_match_all($pattern, $message, $matches)) {
                 foreach ($matches[2] as $key => $value) {
                     $attachments[] = str_replace('/image/', DIR_IMAGE, $value);
                     $message = str_replace($value, 'cid:' . basename($value), $message);
                 }
             }
             foreach ($emails as $email) {
                 $mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password')), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
                 $mail->setTo($email);
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setSender($this->config->get('config_store'));
                 $mail->setSubject($this->request->post['subject']);
                 $mail->addAttachment($attachments);
                 $mail->setHtml($message);
                 $mail->send();
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_newsletter'] = $this->language->get('text_newsletter');
     $this->data['text_customer'] = $this->language->get('text_customer');
     $this->data['text_search'] = $this->language->get('text_search');
     $this->data['entry_to'] = $this->language->get('entry_to');
     $this->data['entry_subject'] = $this->language->get('entry_subject');
     $this->data['entry_message'] = $this->language->get('entry_message');
     $this->data['button_send'] = $this->language->get('button_send');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     $this->data['tab_general'] = $this->language->get('tab_general');
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['subject'])) {
         $this->data['error_subject'] = $this->error['subject'];
     } else {
         $this->data['error_subject'] = '';
     }
     if (isset($this->error['message'])) {
         $this->data['error_message'] = $this->error['message'];
     } else {
         $this->data['error_message'] = '';
     }
     $this->document->breadcrumbs = array();
     $this->document->breadcrumbs[] = array('href' => $this->url->https('common/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE);
     $this->document->breadcrumbs[] = array('href' => $this->url->https('customer/contact'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ');
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['action'] = $this->url->https('customer/contact');
     $this->data['cancel'] = $this->url->https('customer/contact');
     $this->data['customers'] = array();
     if (isset($this->request->post['to']) && $this->request->post['to']) {
         foreach ($this->request->post['to'] as $customer_id) {
             $customer_info = $this->model_customer_customer->getCustomer($customer_id);
             if ($customer_info) {
                 $this->data['customers'][] = array('customer_id' => $customer_info['customer_id'], 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname'] . ' (' . $customer_info['email'] . ')');
             }
         }
     }
     if (isset($this->request->post['group'])) {
         $this->data['group'] = $this->request->post['group'];
     } else {
         $this->data['group'] = '';
     }
     if (isset($this->request->post['subject'])) {
         $this->data['subject'] = $this->request->post['subject'];
     } else {
         $this->data['subject'] = '';
     }
     if (isset($this->request->post['message'])) {
         $this->data['message'] = $this->request->post['message'];
     } else {
         $this->data['message'] = '';
     }
     $this->template = 'customer/contact.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
 }
コード例 #9
0
function plugin_filemanager_plugin_actions()
{
    global $myUser, $_, $conf;
    switch ($_['action']) {
        case 'plugin_filemanager_get':
            if (!$myUser->can('file', 'r')) {
                exit('permission denied');
            }
            $files = array();
            echo json_encode($files);
            break;
        case 'plugin_filemanager_edit':
            if (!$myUser->can('file', 'u')) {
                exit('permission denied');
            }
            require_once 'plugins/file/FileUploaded.class.php';
            $current = new FileUploaded();
            $current->date = time();
            $current->user = $myUser->getLogin();
            $current = isset($_['id']) && $_['id'] != '' ? $current->getById($_['id']) : $current;
            $current->save();
            break;
        case "plugin_filemanager_plugin_setting":
            if ($myUser->can('plugin_filemanager_validation', 'u')) {
                // $conf->put("plugin_filemanager_plugin_recipients",$_['mail']); // on enregistre le contenu des champs (adresses mails de destination) dans la bdd
                // $conf->put("plugin_filemanager_plugin_users",json_encode($_['users']));
                echo 'Enregistré.';
            } else {
                echo 'Permissions insuffisantes.';
            }
            break;
        case 'plugin_filemanager_delete':
            header('Content-type: application/json');
            if ($myUser->can('file', 'd')) {
                require_once 'plugins/file/FileUploaded.class.php';
                $response = array();
                try {
                    $current = new FileUploaded();
                    $current = $current->getById($_['id']);
                    @unlink($current->path);
                    if ($_['id'] != 0) {
                        $current->delete(array('id' => $_['id']));
                    }
                    $response['success'] = true;
                } catch (Exception $e) {
                    $response['message'] = 'Erreur : ' . $e->getMessage();
                }
                echo json_encode($response);
            }
            break;
        case 'plugin_filemanager_send_email_form':
            require_once 'plugins/file/FileUploaded.class.php';
            $file = new FileUploaded();
            if (isset($_['id'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        echo '<div class="label label-important">Attention, les permissions de de fichier seront modifiées en "acces public".</div><br/><br/>Destinaire : <input type="text" id="recipient" value=""><br/>

						  Fichier : <a target="_blank" href="' . $file->getUrl() . '">' . $file->name . '</a><br/>
						  <br/>Message<br/><textarea style="width:520px;" id="message">Veuillez trouver en pièce jointe le fichier : ' . $file->name . '</textarea><br/>';
                    }
                }
            }
            break;
        case 'plugin_filemanager_set_permission_form':
            require_once 'plugins/file/FileUploaded.class.php';
            $file = new FileUploaded();
            if (isset($_['id'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        $permissions = $file->getPermissions();
                        echo "\n\t\t\t\t\t<label class='checkbox'><input id='allow_internal' " . (in_array('$', $permissions) ? 'checked=checked' : '') . " type='checkbox'> Autoriser tous les utilisateurs ERP</label>\n\t\t\t\t\t<label class='checkbox'><input id='allow_all' " . (in_array('*', $permissions) ? 'checked=checked' : '') . " type='checkbox'> Autoriser tous le monde (même exterieur a l'erp)</label>\n\t\t\t\t\t<label>Autoriser les utilisateurs suivants (séparés par saut de ligne) </label>\n\n\t\t\t\t\t<textarea  style='width:510px;' placeholder='valentin.carruesco...' id='allow_user'>";
                        foreach ($permissions as $permission) {
                            if ($permission != '*' && $permission != '$') {
                                echo $permission . "\n";
                            }
                        }
                        echo "</textarea>";
                    }
                }
            }
            break;
        case 'plugin_filemanager_set_permission':
            header('Content-type: application/json');
            require_once 'plugins/file/FileUploaded.class.php';
            $response = array();
            $file = new FileUploaded();
            if (isset($_['id'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    $permissions = explode("\n", $_['allow_user']);
                    if ($_['allow_all'] == 'true') {
                        $permissions[] = '*';
                    }
                    if ($_['allow_internal'] == 'true') {
                        $permissions[] = '$';
                    }
                    $file->setPermissions($permissions);
                    $file->save();
                    $response['success'] = true;
                }
            }
            echo json_encode($response);
            break;
        case 'plugin_filemanager_send_mail':
            header('Content-type: application/json');
            require_once 'plugins/file/FileUploaded.class.php';
            $response = array();
            $file = new FileUploaded();
            if (isset($_['id']) && isset($_['recipient'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        $file->addPermission('*');
                        $file->save();
                        $mail = new Mail();
                        $mail->disableBorder();
                        $mail->setExpeditor('"' . $myUser->getFullName() . '" <' . $myUser->getMail() . '>');
                        $mail->setReply('"' . $myUser->getFullName() . '" <' . $myUser->getMail() . '>');
                        $mail->addRecipient($_['recipient']);
                        $mail->addAttachment($file->name . '|' . $file->mime, file_get_contents($file->path));
                        $mail->setTitle("Pièce jointe - " . $file->name, false);
                        $mail->setMessage($_['message']);
                        $mail->send();
                        $response['success'] = true;
                    }
                }
            }
            echo json_encode($response);
            break;
        case 'plugin_filemanager_search':
            require_once 'plugins/file/FileUploaded.class.php';
            $fileManager = new FileUploaded();
            $keyword = isset($_['keyword']) && $_['keyword'] != '' ? $_['keyword'] : '';
            $files = $fileManager->search($keyword);
            foreach ($files as $file) {
                if ($file->checkPermission($myUser)) {
                    ?>
			<div id="file_<?php 
                    echo $file->id;
                    ?>
" class="dz-preview dz-file-preview"> 
			  <div class="dz-details"> 
			    <div class="dz-filename"><a href="<?php 
                    echo $file->getUrl();
                    ?>
"><i class="fa fa-file-text-o"></i> <?php 
                    echo $file->name;
                    ?>
</a></div> - 
			    <div class="dz-size" data-dz-size><strong><?php 
                    echo $file->getSize();
                    ?>
</strong></div> 
			    <div class="dz-options"><ul class="dz-options"><li title="Envoyer par email" onclick="plugin_filemanager_send_mail_form(<?php 
                    echo $file->id;
                    ?>
);"><i class="fa fa-paper-plane-o"></i></li><li onclick="plugin_filemanager_set_permission_form('<?php 
                    echo $file->id;
                    ?>
');" title="Régler les permissions"><i class="fa fa-check-square-o"></i></li><li title="Supprimer" onclick="plugin_filemanager_delete(<?php 
                    echo $file->id;
                    ?>
)"><i class="fa fa-times"></i></li></ul></div> 
			    <div class="dz-tags"><span class="dz-tag label">Tags</span> <span class="dz-tag label label-inverse"><?php 
                    echo implode('</span> <span class="dz-tag label label-inverse">', $file->getTags());
                    ?>
</span></div> 
			  </div> 
			</div>
			<?php 
                }
            }
            break;
        case 'open_file':
            require_once 'plugins/file/FileUploaded.class.php';
            $file = new FileUploaded();
            if (isset($_['file'])) {
                $file = $file->getById($_['file']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        header('Content-type: ' . $file->mime);
                        header('Content-Transfer-Encoding: binary');
                        header('Expires: 0');
                        header('Cache-Control: must-revalidate');
                        header('Pragma: public');
                        ob_clean();
                        flush();
                        echo file_get_contents($file->path);
                    } else {
                        echo 'Acces interdit';
                    }
                }
            }
            break;
        case 'upload':
            require_once 'plugins/file/FileUploaded.class.php';
            header('Content-type: application/json');
            $response = array('error' => array());
            try {
                $max_size = 419430400;
                $allowed_ext = array('jpg', 'png', 'bmp', 'psd', 'doc', 'docx', 'xls', 'xlsx', 'mp3', 'mp4', 'ppt', 'txt', 'sql', 'pptx');
                $file = new FileUploaded($_FILES['file']);
                if (!$file->check('size', $max_size)) {
                    throw new Exception('Taille maximum dépassée, (autorisé : ' . $max_size . ' octets max) ');
                }
                if (!$file->check('extension', $allowed_ext)) {
                    throw new Exception('Extension non permise (autorisé : ' . implode(',', $allowed_ext) . ')');
                }
                $file->user = $myUser->getLogin();
                $file->permissions = '*';
                if (!$file->upload()) {
                    throw new Exception('Erreur lors de l\'envoi, merci de contacter un administrateur');
                }
                $response['file'] = array('id' => $file->id, 'url' => $file->url, 'name' => $file->name, 'ext' => $file->ext, 'tags' => $file->getTags(), 'size' => $file->getSize());
            } catch (Exception $e) {
                $response['error'][] = $e->getMessage();
            }
            echo json_encode($response);
            break;
    }
}
コード例 #10
0
 function sendTemplateMail($to, $templateName, $varList = null, $attachments = array())
 {
     $FROM_MAIL = FROM_MAIL;
     $varList = array_merge($varList, array('FROM_SITE' => FROM_SITE));
     if ($mail = $this->cfg("FROM_MAIL")) {
         $FROM_MAIL = $mail;
     }
     if (isset($varList['from_mail'])) {
         $FROM_MAIL = $varList['from_mail'];
     }
     $mail = new Mail();
     $mail->setTemplate($templateName, $varList);
     $mail->setFromMail($FROM_MAIL);
     foreach ($attachments as $a) {
         $mail->addAttachment($a);
     }
     $mail->xsend($to, $varList);
 }
コード例 #11
0
ファイル: order.php プロジェクト: miechuliv/BeautyCenter
 public function confirm($order_id, $order_status_id, $comment = '', $notify = false)
 {
     $order_info = $this->getOrder($order_id);
     if ($order_info && !$order_info['order_status_id']) {
         // Fraud Detection
         if ($this->config->get('config_fraud_detection')) {
             $this->load->model('checkout/fraud');
             $risk_score = $this->model_checkout_fraud->getFraudScore($order_info);
             if ($risk_score > $this->config->get('config_fraud_score')) {
                 $order_status_id = $this->config->get('config_fraud_status_id');
             }
         }
         // Ban IP
         $status = false;
         $this->load->model('account/customer');
         if ($order_info['customer_id']) {
             $results = $this->model_account_customer->getIps($order_info['customer_id']);
             foreach ($results as $result) {
                 if ($this->model_account_customer->isBanIp($result['ip'])) {
                     $status = true;
                     break;
                 }
             }
         } else {
             $status = $this->model_account_customer->isBanIp($order_info['ip']);
         }
         if ($status) {
             $order_status_id = $this->config->get('config_order_status_id');
         }
         $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '1', comment = '" . $this->db->escape($comment && $notify ? $comment : '') . "', date_added = NOW()");
         $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
         foreach ($order_product_query->rows as $order_product) {
             $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_id = '" . (int) $order_product['product_id'] . "' AND subtract = '1'");
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $order_product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "' AND subtract = '1'");
             }
         }
         if (!isset($passArray) || empty($passArray)) {
             $passArray = null;
         }
         $this->openbay->orderNew((int) $order_id);
         $this->cache->delete('product');
         // Downloads
         $order_download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "'");
         // Gift Voucher
         $this->load->model('checkout/voucher');
         $order_voucher_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int) $order_id . "'");
         foreach ($order_voucher_query->rows as $order_voucher) {
             $voucher_id = $this->model_checkout_voucher->addVoucher($order_id, $order_voucher);
             $this->db->query("UPDATE " . DB_PREFIX . "order_voucher SET voucher_id = '" . (int) $voucher_id . "' WHERE order_voucher_id = '" . (int) $order_voucher['order_voucher_id'] . "'");
         }
         // Send out any gift voucher mails
         if ($this->config->get('config_complete_status_id') == $order_status_id) {
             $this->model_checkout_voucher->confirm($order_id);
         }
         // Order Totals
         $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC");
         foreach ($order_total_query->rows as $order_total) {
             $this->load->model('total/' . $order_total['code']);
             if (method_exists($this->{'model_total_' . $order_total['code']}, 'confirm')) {
                 $this->{'model_total_' . $order_total['code']}->confirm($order_info, $order_total);
             }
         }
         // Send out order confirmation mail
         $language = new Language($order_info['language_directory']);
         $language->load($order_info['language_filename']);
         $language->load('mail/order');
         $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
         if ($order_status_query->num_rows) {
             $order_status = $order_status_query->row['name'];
         } else {
             $order_status = '';
         }
         $subject = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id);
         // HTML Mail
         $template = new Template();
         $template->data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
         $template->data['text_greeting'] = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
         $template->data['text_link'] = $language->get('text_new_link');
         $template->data['text_download'] = $language->get('text_new_download');
         $template->data['text_order_detail'] = $language->get('text_new_order_detail');
         $template->data['text_instruction'] = $language->get('text_new_instruction');
         $template->data['text_order_id'] = $language->get('text_new_order_id');
         $template->data['text_date_added'] = $language->get('text_new_date_added');
         $template->data['text_payment_method'] = $language->get('text_new_payment_method');
         $template->data['text_shipping_method'] = $language->get('text_new_shipping_method');
         $template->data['text_email'] = $language->get('text_new_email');
         $template->data['text_telephone'] = $language->get('text_new_telephone');
         $template->data['text_ip'] = $language->get('text_new_ip');
         $template->data['text_payment_address'] = $language->get('text_new_payment_address');
         $template->data['text_shipping_address'] = $language->get('text_new_shipping_address');
         $template->data['text_product'] = $language->get('text_new_product');
         $template->data['text_model'] = $language->get('text_new_model');
         $template->data['text_quantity'] = $language->get('text_new_quantity');
         $template->data['text_price'] = $language->get('text_new_price');
         $template->data['text_total'] = $language->get('text_new_total');
         $template->data['text_footer'] = $language->get('text_new_footer');
         $template->data['text_powered'] = $language->get('text_new_powered');
         $template->data['logo'] = $this->config->get('config_url') . 'image/' . $this->config->get('config_logo');
         $template->data['store_name'] = $order_info['store_name'];
         $template->data['store_url'] = $order_info['store_url'];
         $template->data['customer_id'] = $order_info['customer_id'];
         $template->data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
         if ($order_download_query->num_rows) {
             $template->data['download'] = $order_info['store_url'] . 'index.php?route=account/download';
         } else {
             $template->data['download'] = '';
         }
         $template->data['order_id'] = $order_id;
         $template->data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
         $template->data['payment_method'] = $order_info['payment_method'];
         $template->data['shipping_method'] = $order_info['shipping_method'];
         $template->data['email'] = $order_info['email'];
         $template->data['telephone'] = $order_info['telephone'];
         $template->data['ip'] = $order_info['ip'];
         if ($comment && $notify) {
             $template->data['comment'] = nl2br($comment);
         } else {
             $template->data['comment'] = '';
         }
         if ($order_info['payment_address_format']) {
             $format = $order_info['payment_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country']);
         $template->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         if ($order_info['shipping_address_format']) {
             $format = $order_info['shipping_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country']);
         $template->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         // Products
         $template->data['products'] = array();
         foreach ($order_product_query->rows as $product) {
             $option_data = array();
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 if ($option['type'] != 'file') {
                     $value = $option['value'];
                 } else {
                     $value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.'));
                 }
                 $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
             }
             $template->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']));
         }
         // Vouchers
         $template->data['vouchers'] = array();
         foreach ($order_voucher_query->rows as $voucher) {
             $template->data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']));
         }
         $template->data['totals'] = $order_total_query->rows;
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
             $html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
         } else {
             $html = $template->fetch('default/template/mail/order.tpl');
         }
         // Can not send confirmation emails for CBA orders as email is unknown
         $this->load->model('payment/amazon_checkout');
         if (!$this->model_payment_amazon_checkout->isAmazonOrder($order_info['order_id'])) {
             // Text Mail
             $text = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n";
             $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
             $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
             $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
             if ($comment && $notify) {
                 $text .= $language->get('text_new_instruction') . "\n\n";
                 $text .= $comment . "\n\n";
             }
             // Products
             $text .= $language->get('text_new_products') . "\n";
             foreach ($order_product_query->rows as $product) {
                 $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
                 $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'");
                 foreach ($order_option_query->rows as $option) {
                     $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
                 }
             }
             foreach ($order_voucher_query->rows as $voucher) {
                 $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']);
             }
             $text .= "\n";
             $text .= $language->get('text_new_order_total') . "\n";
             foreach ($order_total_query->rows as $total) {
                 $text .= $total['title'] . ': ' . html_entity_decode($total['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
             }
             $text .= "\n";
             if ($order_info['customer_id']) {
                 $text .= $language->get('text_new_link') . "\n";
                 $text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n";
             }
             if ($order_download_query->num_rows) {
                 $text .= $language->get('text_new_download') . "\n";
                 $text .= $order_info['store_url'] . 'index.php?route=account/download' . "\n\n";
             }
             // Comment
             if ($order_info['comment']) {
                 $text .= $language->get('text_new_comment') . "\n\n";
                 $text .= $order_info['comment'] . "\n\n";
             }
             $text .= $language->get('text_new_footer') . "\n\n";
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($order_info['email']);
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_info['store_name']);
             $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
             $mail->setHtml($html);
             $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
             /* Blitz code */
             /* send each downloadable product image as attachment if order is complete */
             if ($this->config->get('config_complete_status_id') == $order_status_id) {
                 $res = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "' ");
                 foreach ($res->rows as $row) {
                     if (isset($row['order_download_id']) && $row['order_download_id']) {
                         $order_download_id = $res->row['order_download_id'];
                     } else {
                         $order_download_id = 0;
                     }
                     $this->load->model('account/download');
                     $download_info = $this->model_account_download->getDownloadBefore($order_download_id);
                     if (!$download_info) {
                         $date = new DateTime();
                         $this->log->write(' No download info, cannot send file , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
                     }
                     if ($download_info) {
                         $file = DIR_DOWNLOAD . $download_info['filename'];
                         $movedFile = DIR_IMAGE . $download_info['filename'];
                         // remove ending hash
                         $t = explode('.', $movedFile);
                         array_pop($t);
                         $movedFile = implode('.', $t);
                         copy($file, $movedFile);
                         if (!is_dir(DIR_IMAGE . 'order_images/')) {
                             mkdir(DIR_IMAGE . 'order_images/');
                             chmod(DIR_IMAGE . 'order_images/', 0777);
                         }
                         if (!is_dir(DIR_IMAGE . 'order_images/' . $order_id . '/')) {
                             mkdir(DIR_IMAGE . 'order_images/' . $order_id . '/');
                             chmod(DIR_IMAGE . 'order_images/' . $order_id . '/', 0777);
                         }
                         $modifiedImageFile = DIR_IMAGE . 'order_images/' . $order_id . '/' . $download_info['filename'];
                         // remove ending hash
                         $t = explode('.', $modifiedImageFile);
                         array_pop($t);
                         // also remove extension ( if PDF conversion )
                         array_pop($t);
                         $modifiedImageFile = implode('.', $t) . '.pdf';
                         if (file_exists($movedFile)) {
                             $this->model_account_download->prepareDownloadImagePdf(str_ireplace(DIR_IMAGE, '', $movedFile), str_ireplace(DIR_IMAGE, '', $modifiedImageFile), $order_info['firstname'], $order_info['lastname'], $download_info['name'], $download_info['description'], $order_id, $download_info['date_end']);
                         } else {
                             $this->log->write('Unable to move file: ' . $file . ' to ' . $movedFile . ' , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
                         }
                         if (file_exists($modifiedImageFile)) {
                             $mail->addAttachment($modifiedImageFile);
                         } else {
                             $date = new DateTime();
                             $this->log->write('Unable to locate downloadable file: ' . $file . ' , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
                         }
                     }
                 }
             }
             /* Blitz code end */
             $mail->send();
         }
         // Admin Alert Mail
         if ($this->config->get('config_alert_mail')) {
             $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
             // Text
             $text = $language->get('text_new_received') . "\n\n";
             $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
             $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
             $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
             $text .= $language->get('text_new_products') . "\n";
             foreach ($order_product_query->rows as $product) {
                 $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
                 $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'");
                 foreach ($order_option_query->rows as $option) {
                     if ($option['type'] != 'file') {
                         $value = $option['value'];
                     } else {
                         $value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.'));
                     }
                     $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n";
                 }
             }
             foreach ($order_voucher_query->rows as $voucher) {
                 $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']);
             }
             $text .= "\n";
             $text .= $language->get('text_new_order_total') . "\n";
             foreach ($order_total_query->rows as $total) {
                 $text .= $total['title'] . ': ' . html_entity_decode($total['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
             }
             $text .= "\n";
             if ($order_info['comment']) {
                 $text .= $language->get('text_new_comment') . "\n\n";
                 $text .= $order_info['comment'] . "\n\n";
             }
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($this->config->get('config_email'));
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_info['store_name']);
             $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
             $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
             $mail->send();
             // Send to additional alert emails
             $emails = explode(',', $this->config->get('config_alert_emails'));
             foreach ($emails as $email) {
                 if ($email && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
                     $mail->setTo($email);
                     $mail->send();
                 }
             }
         }
     }
 }
コード例 #12
0
 public function confirm($order_id, $order_status_id, $comment = '')
 {
     $order_query = $this->db->query("SELECT *, l.filename AS filename, l.directory AS directory FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) WHERE o.order_id = '" . (int) $order_id . "' AND o.order_status_id = '0'");
     if ($order_query->num_rows) {
         $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $order_status_id . "' WHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '1', comment = '" . $this->db->escape($comment) . "', date_added = NOW()");
         $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
         foreach ($order_product_query->rows as $product) {
             $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int) $product['quantity'] . ") WHERE product_id = '" . (int) $product['product_id'] . "' AND subtract = '1'");
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int) $product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "' AND subtract = '1'");
             }
             $this->cache->delete('product');
         }
         $language = new Language($order_query->row['directory']);
         $language->load($order_query->row['filename']);
         $language->load('mail/order_confirm');
         $this->load->model('localisation/currency');
         $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_query->row['language_id'] . "'");
         $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
         $order_total_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC");
         $order_download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "'");
         $subject = sprintf($language->get('text_subject'), $order_query->row['store_name'], $order_id);
         // HTML Mail
         $template = new Template();
         $template->data['title'] = sprintf($language->get('text_subject'), html_entity_decode($order_query->row['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
         $template->data['text_greeting'] = sprintf($language->get('text_greeting'), html_entity_decode($order_query->row['store_name'], ENT_QUOTES, 'UTF-8'));
         $template->data['text_order_detail'] = $language->get('text_order_detail');
         $template->data['text_order_id'] = $language->get('text_order_id');
         $template->data['text_invoice'] = $language->get('text_invoice');
         $template->data['text_date_added'] = $language->get('text_date_added');
         $template->data['text_telephone'] = $language->get('text_telephone');
         $template->data['text_email'] = $language->get('text_email');
         $template->data['text_ip'] = $language->get('text_ip');
         $template->data['text_fax'] = $language->get('text_fax');
         $template->data['text_shipping_address'] = $language->get('text_shipping_address');
         $template->data['text_payment_address'] = $language->get('text_payment_address');
         $template->data['text_shipping_method'] = $language->get('text_shipping_method');
         $template->data['text_payment_method'] = $language->get('text_payment_method');
         $template->data['text_comment'] = $language->get('text_comment');
         $template->data['text_powered_by'] = $language->get('text_powered_by');
         $template->data['column_product'] = $language->get('column_product');
         $template->data['column_model'] = $language->get('column_model');
         $template->data['column_quantity'] = $language->get('column_quantity');
         $template->data['column_price'] = $language->get('column_price');
         $template->data['column_total'] = $language->get('column_total');
         $template->data['order_id'] = $order_id;
         $template->data['customer_id'] = $order_query->row['customer_id'];
         $template->data['date_added'] = date($language->get('date_format_short'), strtotime($order_query->row['date_added']));
         $template->data['logo'] = 'cid:' . basename($this->config->get('config_logo'));
         $template->data['store_name'] = $order_query->row['store_name'];
         $template->data['address'] = nl2br($this->config->get('config_address'));
         $template->data['telephone'] = $this->config->get('config_telephone');
         $template->data['fax'] = $this->config->get('config_fax');
         $template->data['email'] = $this->config->get('config_email');
         $template->data['store_url'] = $order_query->row['store_url'];
         $template->data['invoice'] = $order_query->row['store_url'] . 'index.php?route=account/invoice&order_id=' . $order_id;
         $template->data['firstname'] = $order_query->row['firstname'];
         $template->data['lastname'] = $order_query->row['lastname'];
         $template->data['shipping_method'] = $order_query->row['shipping_method'];
         $template->data['payment_method'] = $order_query->row['payment_method'];
         $template->data['customer_email'] = $order_query->row['email'];
         $template->data['customer_telephone'] = $order_query->row['telephone'];
         $template->data['customer_ip'] = $order_query->row['ip'];
         $template->data['comment'] = nl2br($order_query->row['comment']);
         if ($comment) {
             $template->data['comment'] .= '<br /><br />' . nl2br($comment);
         }
         $zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int) $order_query->row['shipping_zone_id'] . "'");
         if ($zone_query->num_rows) {
             $zone_code = $zone_query->row['code'];
         } else {
             $zone_code = '';
         }
         if ($order_query->row['shipping_address_format']) {
             $format = $order_query->row['shipping_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_query->row['shipping_firstname'], 'lastname' => $order_query->row['shipping_lastname'], 'company' => $order_query->row['shipping_company'], 'address_1' => $order_query->row['shipping_address_1'], 'address_2' => $order_query->row['shipping_address_2'], 'city' => $order_query->row['shipping_city'], 'postcode' => $order_query->row['shipping_postcode'], 'zone' => $order_query->row['shipping_zone'], 'zone_code' => $zone_code, 'country' => $order_query->row['shipping_country']);
         $template->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         $zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int) $order_query->row['payment_zone_id'] . "'");
         if ($zone_query->num_rows) {
             $zone_code = $zone_query->row['code'];
         } else {
             $zone_code = '';
         }
         if ($order_query->row['payment_address_format']) {
             $format = $order_query->row['payment_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_query->row['payment_firstname'], 'lastname' => $order_query->row['payment_lastname'], 'company' => $order_query->row['payment_company'], 'address_1' => $order_query->row['payment_address_1'], 'address_2' => $order_query->row['payment_address_2'], 'city' => $order_query->row['payment_city'], 'postcode' => $order_query->row['payment_postcode'], 'zone' => $order_query->row['payment_zone'], 'zone_code' => $zone_code, 'country' => $order_query->row['payment_country']);
         $template->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         $template->data['products'] = array();
         foreach ($order_product_query->rows as $product) {
             $option_data = array();
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $option_data[] = array('name' => $option['name'], 'value' => $option['value']);
             }
             $template->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'], $order_query->row['currency'], $order_query->row['value']), 'total' => $this->currency->format($product['total'], $order_query->row['currency'], $order_query->row['value']));
         }
         $template->data['totals'] = $order_total_query->rows;
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order_confirm.tpl')) {
             $html = $template->fetch($this->config->get('config_template') . '/template/mail/order_confirm.tpl');
         } else {
             $html = $template->fetch('default/template/mail/order_confirm.tpl');
         }
         // Text Mail
         $text = sprintf($language->get('text_greeting'), html_entity_decode($order_query->row['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n";
         $text .= $language->get('text_order_id') . ' ' . $order_id . "\n";
         $text .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_query->row['date_added'])) . "\n";
         $text .= $language->get('text_order_status') . ' ' . $order_status_query->row['name'] . "\n\n";
         $text .= $language->get('text_product') . "\n";
         foreach ($order_product_query->rows as $result) {
             $text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_query->row['currency'], $order_query->row['value']), ENT_NOQUOTES, 'UTF-8') . "\n";
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $text .= chr(9) . '-' . $option['name'] . ' ' . $option['value'] . "\n";
             }
         }
         $text .= "\n";
         $text .= $language->get('text_total') . "\n";
         foreach ($order_total_query->rows as $result) {
             $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
         }
         $order_total = $result['text'];
         $text .= "\n";
         if ($order_query->row['customer_id']) {
             $text .= $language->get('text_invoice') . "\n";
             $text .= $order_query->row['store_url'] . 'index.php?route=account/invoice&order_id=' . $order_id . "\n\n";
         }
         if ($order_download_query->num_rows) {
             $text .= $language->get('text_download') . "\n";
             $text .= $order_query->row['store_url'] . 'index.php?route=account/download' . "\n\n";
         }
         if ($order_query->row['comment'] != '') {
             $comment = $order_query->row['comment'] . "\n\n" . $comment;
         }
         if ($comment) {
             $text .= $language->get('text_comment') . "\n\n";
             $text .= $comment . "\n\n";
         }
         $text .= $language->get('text_footer');
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($order_query->row['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($order_query->row['store_name']);
         $mail->setSubject($subject);
         $mail->setHtml($html);
         $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
         $mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'));
         $mail->send();
         if ($this->config->get('config_alert_mail')) {
             // HTML
             $template->data['text_greeting'] = $language->get('text_received') . "\n\n";
             $template->data['invoice'] = '';
             $template->data['text_invoice'] = '';
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order_confirm.tpl')) {
                 $html = $template->fetch($this->config->get('config_template') . '/template/mail/order_confirm.tpl');
             } else {
                 $html = $template->fetch('default/template/mail/order_confirm.tpl');
             }
             $subject = sprintf($language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id . ' (' . $order_total . ')');
             $mail->setSubject($subject);
             $mail->setTo($this->config->get('config_email'));
             $mail->setHtml($html);
             $mail->send();
             // Send to additional alert emails
             $pattern = '/^[A-Z0-9._%-+]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\\.[A-Z]{2,6}$/i';
             $emails = explode(',', $this->config->get('config_alert_emails'));
             foreach ($emails as $email) {
                 if (strlen($email) > 0 && preg_match($pattern, $email)) {
                     $mail->setTo($email);
                     $mail->send();
                 }
             }
             /*
             // Text
             $text  = $language->get('text_received') . "\n\n";
             $text .= $language->get('text_order_id') . ' ' . $order_id . "\n";
             $text .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_query->row['date_added'])) . "\n";
             $text .= $language->get('text_order_status') . ' ' . $order_status_query->row['name'] . "\n\n";
             $text .= $language->get('text_product') . "\n";
             
             foreach ($order_product_query->rows as $result) {
             	$text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_query->row['currency'], $order_query->row['value']), ENT_NOQUOTES, 'UTF-8') . "\n";
             	$order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
             	foreach ($order_option_query->rows as $option) {
             		$text .= chr(9) . '-' . $option['name'] . ' ' . $option['value'] . "\n";
             	}
             }
             
             $text .= "\n";
             
             $text.= $language->get('text_total') . "\n";
             
             foreach ($order_total_query->rows as $result) {
             	$text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
             }			
             
             $text .= "\n";
             
             if ($order_query->row['comment'] != '') {
             	$comment = ($order_query->row['comment'] .  "\n\n" . $comment);
             }
             
             if ($comment) {
             	$text .= $language->get('text_comment') . "\n\n";
             	$text .= $comment . "\n\n";
             }
             			
             $mail = new Mail(); 
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($this->config->get('config_email'));
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_query->row['store_name']);
             $mail->setSubject($subject);
             $mail->setText($text);
             $mail->send();
             */
         }
     }
 }
コード例 #13
0
ファイル: order.php プロジェクト: miechuliv/BeautyCenter
 public function addOrderHistory($order_id, $data)
 {
     /* Blitz code start */
     $result = 'no_file_sent';
     /* Blitz code end */
     $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $data['order_status_id'] . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'");
     $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $data['order_status_id'] . "', notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', date_added = NOW()");
     $order_info = $this->getOrder($order_id);
     // Send out any gift voucher mails
     if ($this->config->get('config_complete_status_id') == $data['order_status_id']) {
         $this->load->model('sale/voucher');
         $results = $this->getOrderVouchers($order_id);
         foreach ($results as $result) {
             $this->model_sale_voucher->sendVoucher($result['voucher_id']);
         }
     }
     if ($data['notify']) {
         $language = new Language($order_info['language_directory']);
         $language->load($order_info['language_filename']);
         $language->load('mail/order');
         $subject = sprintf($language->get('text_subject'), $order_info['store_name'], $order_id);
         $message = $language->get('text_order') . ' ' . $order_id . "\n";
         $message .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n\n";
         $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $data['order_status_id'] . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
         if ($order_status_query->num_rows) {
             $message .= $language->get('text_order_status') . "\n";
             $message .= $order_status_query->row['name'] . "\n\n";
         }
         if ($order_info['customer_id']) {
             $message .= $language->get('text_link') . "\n";
             $message .= html_entity_decode($order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n";
         }
         if ($data['comment']) {
             $message .= $language->get('text_comment') . "\n\n";
             $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n";
         }
         $message .= $language->get('text_footer');
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($order_info['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($order_info['store_name']);
         $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         /* Blitz code */
         /* send each downloadable product image as attachment if order is complete */
         if ($this->config->get('config_complete_status_id') == $data['order_status_id']) {
             $res = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "' ");
             $result = array('success' => 0, 'failure' => 0);
             foreach ($res->rows as $row) {
                 if (isset($row['order_download_id']) && $row['order_download_id']) {
                     $order_download_id = $res->row['order_download_id'];
                 } else {
                     $order_download_id = 0;
                 }
                 $this->load->model('catalog/download');
                 $download_info = $this->model_catalog_download->getDownloadFrontend($order_download_id);
                 if (!$download_info) {
                     $date = new DateTime();
                     $this->log->write(' No download info, cannot send file , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
                     $result['failure']++;
                 }
                 if ($download_info) {
                     $file = DIR_DOWNLOAD . $download_info['filename'];
                     $movedFile = DIR_IMAGE . $download_info['filename'];
                     // remove ending hash
                     $t = explode('.', $movedFile);
                     array_pop($t);
                     $movedFile = implode('.', $t);
                     copy($file, $movedFile);
                     if (!is_dir(DIR_IMAGE . 'order_images/')) {
                         mkdir(DIR_IMAGE . 'order_images/');
                         chmod(DIR_IMAGE . 'order_images/', 0777);
                     }
                     if (!is_dir(DIR_IMAGE . 'order_images/' . $order_id . '/')) {
                         mkdir(DIR_IMAGE . 'order_images/' . $order_id . '/');
                         chmod(DIR_IMAGE . 'order_images/' . $order_id . '/', 0777);
                     }
                     $modifiedImageFile = DIR_IMAGE . 'order_images/' . $order_id . '/' . $download_info['filename'];
                     // remove ending hash
                     $t = explode('.', $modifiedImageFile);
                     array_pop($t);
                     // also remove extension ( if PDF conversion )
                     array_pop($t);
                     $modifiedImageFile = implode('.', $t) . '.pdf';
                     if (file_exists($movedFile)) {
                         $this->model_catalog_download->prepareDownloadImagePdf(str_ireplace(DIR_IMAGE, '', $movedFile), str_ireplace(DIR_IMAGE, '', $modifiedImageFile), $order_info['firstname'], $order_info['lastname'], $download_info['name'], $download_info['description'], $order_id, $download_info['date_end']);
                     } else {
                         $this->log->write('Unable to move file: ' . $file . ' to ' . $movedFile . ' , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
                         $result['failure']++;
                     }
                     if (file_exists($modifiedImageFile)) {
                         $mail->addAttachment($modifiedImageFile);
                         $result['success']++;
                     } else {
                         $date = new DateTime();
                         $this->log->write('Unable to locate downloadable file: ' . $file . ' , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
                         $result['failure']++;
                     }
                 }
             }
         }
         /* Blitz code end */
         $mail->send();
     }
     $this->load->model('payment/amazon_checkout');
     $this->model_payment_amazon_checkout->orderStatusChange($order_id, $data);
     /* Blitz code */
     return $result;
     /* Blitz code end */
 }
コード例 #14
0
ファイル: nfe.php プロジェクト: luanmpereira/default-store
 public function email()
 {
     $this->load->model('module/nfe');
     $this->load->model('sale/order');
     $result = $this->model_module_nfe->getDataNfeVenda($this->request->post['order_id']);
     $result_order = $this->model_sale_order->getOrder($this->request->post['order_id']);
     $data = array();
     $text_assunt = 'Nfe - Nota Fiscal Eletrônica';
     $data['firstname'] = strtoupper($result_order['firstname']);
     $data['order_id'] = $this->request->post['order_id'];
     $data['chave_nota'] = $result['chave_nota'];
     $data['name_store'] = $this->config->get('config_name');
     $data['url_store'] = $this->config->get('config_url');
     $this->load->model('tool/image');
     if ($this->config->get('config_mail_header') && is_file(DIR_IMAGE . $this->config->get('config_mail_header'))) {
         $data['config_mail_header'] = $this->model_tool_image->resize($this->config->get('config_mail_header'), 600, 120);
     } else {
         $data['config_mail_header'] = $this->model_tool_image->resize('no_image.png', 600, 120);
     }
     if ($this->config->get('config_mail_footer') && is_file(DIR_IMAGE . $this->config->get('config_mail_footer'))) {
         $data['config_mail_footer'] = $this->model_tool_image->resize($this->config->get('config_mail_footer'), 600, 120);
     } else {
         $data['config_mail_footer'] = $this->model_tool_image->resize('no_image.png', 600, 120);
     }
     $mail = new Mail($this->config->get('config_mail'));
     $mail->setTo($result_order['email']);
     $mail->setFrom($this->config->get('config_email'));
     $mail->setSender($this->config->get('config_name'));
     $mail->setSubject(sprintf($text_assunt, $result_order['firstname']));
     $mail->addAttachment(DIR_NFE_FILES . 'enviadas/aprovadas/' . $result['chave_nota'] . '-nfe.xml');
     $mail->addAttachment(DIR_NFE_FILES . 'pdf/' . $result['chave_nota'] . '-nfe.pdf');
     $mail->setHtml($this->load->view('mail/nfe.tpl', $data));
     $mail->send();
     $emails = explode(',', $this->config->get('config_mail_alert_nfe'));
     if ($emails) {
         foreach ($emails as $email) {
             if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                 $mail->setTo($email);
                 $mail->send();
             }
         }
     }
     $this->addOrderHistory($this->request->post['order_id']);
     $this->db->query("UPDATE " . DB_PREFIX . "nfe SET enviada = '1' WHERE codigo_pedido = '" . $this->request->post['order_id'] . "'");
     exit('Email enviado com sucesso!');
 }
コード例 #15
0
 public function addCustomerSupport($data)
 {
     $this->db->query("\n\t\t\tINSERT INTO " . DB_PREFIX . "customer_support\n\t\t\tSET\n\t\t\t\t  customer_support_topic_id = '" . (int) $data['customer_support_topic_id'] . "' \n\t\t\t\t, store_id = '" . (int) $data['store_id'] . "'\n\t\t\t\t, customer_id = '" . (int) $data['customer_id'] . "'\n\t\t\t\t, reference = '" . $data['reference'] . "' \n\t\t\t\t, customer_support_status = '" . $data['customer_support_status'] . "' \n\t\t\t\t, subject = '" . $this->db->escape(strip_tags($data['subject'])) . "'\n\t\t\t\t, enquiry = '" . $this->db->escape(strip_tags($data['enquiry'])) . "'\n\t\t\t\t, date_added = NOW() \n\t\t\t\t, date_updated = NOW() \n\t\t\t\t, customer_support_1st_category_id = '" . (int) $data['customer_support_1st_category_id'] . "' \n\t\t\t\t, customer_support_2nd_category_id = '" . (int) $data['customer_support_2nd_category_id'] . "'\n\t\t");
     $customer_support_id = $this->db->getLastId();
     $this->db->query("\n\t\t\tUPDATE " . DB_PREFIX . "customer_support\n\t\t\tSET\n\t\t\t\tdate_updated = NOW()\n\t\t\t\t, customer_support_status ='" . $data['customer_support_status'] . "'\n\t\t\tWHERE\n\t\t\t\tcustomer_support_id = '" . (int) $data['customer_support_topic_id'] . "'\n\t\t");
     if (isset($data['notify_customer']) && $data['notify_customer'] == 'notify') {
         $data = $this->getCustomerSupport($customer_support_id);
         if (!empty($data)) {
             $parent_data = $this->getCustomerSupport($data['customer_support_topic_id']);
             $language = new Language('english');
             $language->load('mail/customer_support');
             $subject = "[" . $this->config->get('config_name') . "] " . html_entity_decode($data['subject'], ENT_QUOTES, 'UTF-8') . " - " . $language->get('text_answered');
             // HTML Mail
             $template = new Template();
             $template->data['title'] = $language->get('text_subject');
             $template->data['text_greeting'] = sprintf($language->get('text_greeting'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
             $template->data['text_category'] = $language->get('text_category');
             $template->data['text_reference'] = $language->get('text_reference');
             $template->data['text_subject'] = $language->get('text_subject');
             $template->data['text_enquiry'] = $language->get('text_enquiry');
             $template->data['text_lead_url'] = $language->get('text_lead_url');
             $template->data['text_powered_by'] = $language->get('text_powered_by');
             $template->data['store_url'] = $this->config->get('config_url');
             $template->data['store_name'] = $this->config->get('config_name');
             $template->data['subject'] = $data['subject'];
             $template->data['enquiry'] = nl2br(html_entity_decode($data['enquiry'], ENT_QUOTES, 'UTF-8'));
             $template->data['category'] = $data['customer_support_1st_category'] . '/' . $data['customer_support_2nd_category'];
             $template->data['lead_url'] = $this->config->get('config_url') . 'index.php?route=account/customer_support';
             $template->data['logo'] = 'cid:' . basename($this->config->get('config_logo'));
             $html = $template->fetch('/mail/customer_support.tpl');
             // Text Mail
             $text = sprintf($language->get('text_greeting'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')) . "\n\n";
             $text .= $language->get('text_category') . ": " . html_entity_decode($data['customer_support_1st_category'] . '/' . $data['customer_support_2nd_category'], ENT_QUOTES, 'UTF-8') . "\n\n";
             $text .= $language->get('text_reference') . ": " . html_entity_decode($data['reference'], ENT_QUOTES, 'UTF-8') . "\n\n";
             $text .= $language->get('text_subject') . ": " . html_entity_decode($data['subject'], ENT_QUOTES, 'UTF-8') . "\n\n";
             $text .= $language->get('text_enquiry') . ": " . nl2br(html_entity_decode($data['enquiry'], ENT_QUOTES, 'UTF-8')) . "\n\n";
             $text .= $language->get('text_lead_url') . ": " . $this->config->get('config_url') . 'index.php?route=account/customer_support';
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
             $mail->setHtml($html);
             $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
             $mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'));
             $mail->setTo($parent_data['customer_email']);
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($this->config->get('config_name'));
             $mail->send();
             // 	Send to additional alert emails
             $mail->setSubject(html_entity_decode("[ADMIN]" . $subject, ENT_QUOTES, 'UTF-8'));
             $mail->setTo($this->config->get('config_email'));
             $mail->setHtml($html);
             $mail->send();
         }
     }
 }
コード例 #16
0
ファイル: contact.php プロジェクト: riano2010/reg
 public function index()
 {
     $this->load->language('sale/contact');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('sale/customer');
     $this->load->model('sale/customer_group');
     $this->load->model('sale/affiliate');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->load->model('setting/store');
         $store_info = $this->model_setting_store->getStore($this->request->post['store_id']);
         if ($store_info) {
             $store_name = $store_info['name'];
         } else {
             $store_name = $this->config->get('config_name');
         }
         $emails = array();
         switch ($this->request->post['to']) {
             case 'newsletter':
                 $results = $this->model_sale_customer->getCustomersByNewsletter();
                 foreach ($results as $result) {
                     $emails[] = $result['email'];
                 }
                 break;
             case 'customer_all':
                 $results = $this->model_sale_customer->getCustomers();
                 foreach ($results as $result) {
                     $emails[] = $result['email'];
                 }
                 break;
             case 'customer_group':
                 $results = $this->model_sale_customer->getCustomersByCustomerGroupId($this->request->post['customer_group_id']);
                 foreach ($results as $result) {
                     $emails[$result['customer_id']] = $result['email'];
                 }
                 break;
             case 'customer':
                 if (isset($this->request->post['customer'])) {
                     foreach ($this->request->post['customer'] as $customer_id) {
                         $customer_info = $this->model_sale_customer->getCustomer($customer_id);
                         if ($customer_info) {
                             $emails[] = $customer_info['email'];
                         }
                     }
                 }
                 break;
             case 'affiliate_all':
                 $results = $this->model_sale_affiliate->getAffiliates();
                 foreach ($results as $result) {
                     $emails[] = $result['email'];
                 }
                 break;
             case 'affiliate':
                 if (isset($this->request->post['affiliate'])) {
                     foreach ($this->request->post['affiliate'] as $affiliate_id) {
                         $affiliate_info = $this->model_sale_affiliate->getAffiliate($affiliate_id);
                         if ($affiliate_info) {
                             $emails[] = $affiliate_info['email'];
                         }
                     }
                 }
                 break;
             case 'product':
                 if (isset($this->request->post['product'])) {
                     foreach ($this->request->post['product'] as $product_id) {
                         $results = $this->model_sale_customer->getCustomersByProduct($product_id);
                         foreach ($results as $result) {
                             $emails[] = $result['email'];
                         }
                     }
                 }
                 break;
         }
         $emails = array_unique($emails);
         if ($emails) {
             $message = '<html dir="ltr" lang="en">' . "\n";
             $message .= '<head>' . "\n";
             $message .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
             $message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
             $message .= '</head>' . "\n";
             $message .= '<body>' . html_entity_decode($this->request->post['message'], ENT_QUOTES, 'UTF-8') . '</body>' . "\n";
             $message .= '</html>' . "\n";
             $attachments = array();
             if (preg_match_all('#(src="([^"]*)")#mis', $message, $matches)) {
                 foreach ($matches[2] as $key => $value) {
                     $filename = md5(basename($value)) . strrchr($value, '.');
                     $path = rtrim($this->request->server['DOCUMENT_ROOT'], '/') . parse_url($value, PHP_URL_PATH);
                     $attachments[] = array('filename' => $filename, 'path' => $path);
                     $message = str_replace($value, 'cid:' . $filename, $message);
                 }
             }
             foreach ($emails as $email) {
                 $mail = new Mail();
                 $mail->protocol = $this->config->get('config_mail_protocol');
                 $mail->parameter = $this->config->get('config_mail_parameter');
                 $mail->hostname = $this->config->get('config_smtp_host');
                 $mail->username = $this->config->get('config_smtp_username');
                 $mail->password = $this->config->get('config_smtp_password');
                 $mail->port = $this->config->get('config_smtp_port');
                 $mail->timeout = $this->config->get('config_smtp_timeout');
                 $mail->setTo($email);
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setSender($store_name);
                 $mail->setSubject($this->request->post['subject']);
                 foreach ($attachments as $attachment) {
                     $mail->addAttachment($attachment['path'], $attachment['filename']);
                 }
                 $mail->setHtml($message);
                 $mail->send();
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_default'] = $this->language->get('text_default');
     $this->data['text_newsletter'] = $this->language->get('text_newsletter');
     $this->data['text_customer_all'] = $this->language->get('text_customer_all');
     $this->data['text_customer'] = $this->language->get('text_customer');
     $this->data['text_customer_group'] = $this->language->get('text_customer_group');
     $this->data['text_affiliate_all'] = $this->language->get('text_affiliate_all');
     $this->data['text_affiliate'] = $this->language->get('text_affiliate');
     $this->data['text_product'] = $this->language->get('text_product');
     $this->data['entry_store'] = $this->language->get('entry_store');
     $this->data['entry_to'] = $this->language->get('entry_to');
     $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
     $this->data['entry_customer'] = $this->language->get('entry_customer');
     $this->data['entry_affiliate'] = $this->language->get('entry_affiliate');
     $this->data['entry_product'] = $this->language->get('entry_product');
     $this->data['entry_subject'] = $this->language->get('entry_subject');
     $this->data['entry_message'] = $this->language->get('entry_message');
     $this->data['button_send'] = $this->language->get('button_send');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     $this->data['tab_general'] = $this->language->get('tab_general');
     $this->data['token'] = $this->session->data['token'];
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['subject'])) {
         $this->data['error_subject'] = $this->error['subject'];
     } else {
         $this->data['error_subject'] = '';
     }
     if (isset($this->error['message'])) {
         $this->data['error_message'] = $this->error['message'];
     } else {
         $this->data['error_message'] = '';
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('sale/contact', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['action'] = $this->url->link('sale/contact', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['cancel'] = $this->url->link('sale/contact', 'token=' . $this->session->data['token'], 'SSL');
     if (isset($this->request->post['store_id'])) {
         $this->data['store_id'] = $this->request->post['store_id'];
     } else {
         $this->data['store_id'] = '';
     }
     $this->load->model('setting/store');
     $this->data['stores'] = $this->model_setting_store->getStores();
     if (isset($this->request->post['to'])) {
         $this->data['to'] = $this->request->post['to'];
     } else {
         $this->data['to'] = '';
     }
     if (isset($this->request->post['customer_group_id'])) {
         $this->data['customer_group_id'] = $this->request->post['customer_group_id'];
     } else {
         $this->data['customer_group_id'] = '';
     }
     $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups(0);
     $this->data['customers'] = array();
     if (isset($this->request->post['customer'])) {
         foreach ($this->request->post['customer'] as $customer_id) {
             $customer_info = $this->model_sale_customer->getCustomer($customer_id);
             if ($customer_info) {
                 $this->data['customers'][] = array('customer_id' => $customer_info['customer_id'], 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']);
             }
         }
     }
     $this->data['affiliates'] = array();
     if (isset($this->request->post['affiliate'])) {
         foreach ($this->request->post['affiliate'] as $affiliate_id) {
             $affiliate_info = $this->model_sale_affiliate->getAffiliate($affiliate_id);
             if ($affiliate_info) {
                 $this->data['affiliates'][] = array('affiliate_id' => $affiliate_info['affiliate_id'], 'name' => $affiliate_info['firstname'] . ' ' . $affiliate_info['lastname']);
             }
         }
     }
     $this->load->model('catalog/product');
     $this->data['products'] = array();
     if (isset($this->request->post['product'])) {
         foreach ($this->request->post['product'] as $product_id) {
             $product_info = $this->model_catalog_product->getProduct($product_id);
             if ($product_info) {
                 $this->data['products'][] = array('product_id' => $product_info['product_id'], 'name' => $product_info['name']);
             }
         }
     }
     if (isset($this->request->post['subject'])) {
         $this->data['subject'] = $this->request->post['subject'];
     } else {
         $this->data['subject'] = '';
     }
     if (isset($this->request->post['message'])) {
         $this->data['message'] = $this->request->post['message'];
     } else {
         $this->data['message'] = '';
     }
     $this->template = 'sale/contact.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
コード例 #17
0
ファイル: copu.php プロジェクト: prismsquare/OC2COPU
 public function addUpload($data)
 {
     $this->load->language('myoc/copu');
     $mask = myoc_basename(substr($data['filename'], 0, strrpos($data['filename'], '.')));
     //$this->db->query("INSERT INTO " . DB_PREFIX . "myoc_upload SET filename = '" . $this->db->escape($data['filename']) . "', mask = '" . $this->db->escape($mask) . "', date_added = NOW();");
     //$upload_id = $this->db->getLastId();
     $upload_id = $data['upload_id'];
     $email_attachment = false;
     if (isset($data['customer_id'])) {
         $this->db->query("INSERT INTO " . DB_PREFIX . "myoc_customer_upload SET customer_id = '" . (int) $data['customer_id'] . "', upload_id = '" . (int) $upload_id . "';");
         if ($this->config->get('copu_customer_email_alert')) {
             $this->load->model('account/customer');
             $customer_info = $this->model_account_customer->getCustomer($data['customer_id']);
             $subject = sprintf($this->language->get('text_new_upload_title'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $this->language->get('text_customer'), $customer_info['firstname'] . ' ' . $customer_info['lastname']);
             $text = sprintf($this->language->get('text_new_upload_body'), $this->language->get('text_customer'), $customer_info['firstname'] . ' ' . $customer_info['lastname'] . ' (' . $customer_info['email'] . ')') . "\n\n";
             if ($this->config->get('copu_customer_email_attachment')) {
                 $email_attachment = true;
             }
         }
     }
     if (isset($data['order_id'])) {
         $this->db->query("INSERT INTO " . DB_PREFIX . "myoc_order_upload SET order_id = '" . (int) $data['order_id'] . "', upload_id = '" . (int) $upload_id . "';");
         $order_info_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int) $data['order_id'] . "'");
         if ($this->config->get('copu_order_history_modify_email_alert') && $order_info_query->row['order_status_id']) {
             $subject = sprintf($this->language->get('text_new_upload_title'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $this->language->get('text_order'), $data['order_id']);
             $text = sprintf($this->language->get('text_new_upload_body'), $this->language->get('text_order'), $data['order_id']) . "\n\n";
             if ($this->config->get('copu_order_email_attachment')) {
                 $email_attachment = true;
             }
         }
     }
     if (isset($subject)) {
         $text .= sprintf($this->language->get('text_new_upload_file'), $mask) . "\n";
         $text .= sprintf($this->language->get('text_new_upload_date'), date($this->language->get('date_format_long') . ' ' . $this->language->get('time_format'))) . "\n";
         // Admin Alert Mail
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         if ($email_attachment) {
             copy(DIR_UPLOAD . $data['filename'], DIR_UPLOAD . $mask);
             $mail->addAttachment(DIR_UPLOAD . $mask);
         }
         $mail->setTo($this->config->get('config_email'));
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
         $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         // Send to additional alert emails
         $emails = explode(',', $this->config->get('config_alert_emails'));
         foreach ($emails as $email) {
             if ($email && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
                 $mail->setTo($email);
                 $mail->send();
             }
         }
         if (file_exists(DIR_UPLOAD . $mask)) {
             unlink(DIR_UPLOAD . $mask);
         }
     }
     return $upload_id;
 }
コード例 #18
0
ファイル: example.php プロジェクト: ATCS-BCA/bca-apps
function kitchenSink()
{
    $mail = new Mail();
    $email = new Email("DX", "*****@*****.**");
    $mail->setFrom($email);
    $mail->setSubject("Hello World from the SendGrid PHP Library");
    $personalization = new Personalization();
    $email = new Email("Example User", "*****@*****.**");
    $personalization->addTo($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization->addTo($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization->addCc($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization->addCc($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization->addBcc($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization->addBcc($email);
    $personalization->setSubject("Hello World from the SendGrid PHP Library");
    $personalization->addHeader("X-Test", "test");
    $personalization->addHeader("X-Mock", "true");
    $personalization->addSubstitution("%name%", "Example User");
    $personalization->addSubstitution("%city%", "Denver");
    $personalization->addCustomArg("user_id", "343");
    $personalization->addCustomArg("type", "marketing");
    $personalization->setSendAt(1443636843);
    $mail->addPersonalization($personalization);
    $personalization2 = new Personalization();
    $email = new Email("Example User", "*****@*****.**");
    $personalization2->addTo($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization2->addTo($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization2->addCc($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization2->addCc($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization2->addBcc($email);
    $email = new Email("Example User", "*****@*****.**");
    $personalization2->addBcc($email);
    $personalization2->setSubject("Hello World from the SendGrid PHP Library");
    $personalization2->addHeader("X-Test", "test");
    $personalization2->addHeader("X-Mock", "true");
    $personalization2->addSubstitution("%name%", "Example User");
    $personalization2->addSubstitution("%city%", "Denver");
    $personalization2->addCustomArg("user_id", "343");
    $personalization2->addCustomArg("type", "marketing");
    $personalization2->setSendAt(1443636843);
    $mail->addPersonalization($personalization2);
    $content = new Content("text/plain", "some text here");
    $mail->addContent($content);
    $content = new Content("text/html", "<html><body>some text here</body></html>");
    $mail->addContent($content);
    $attachment = new Attachment();
    $attachment->setContent("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12");
    $attachment->setType("application/pdf");
    $attachment->setFilename("balance_001.pdf");
    $attachment->setDisposition("attachment");
    $attachment->setContentId("Balance Sheet");
    $mail->addAttachment($attachment);
    $attachment2 = new Attachment();
    $attachment2->setContent("BwdW");
    $attachment2->setType("image/png");
    $attachment2->setFilename("banner.png");
    $attachment2->setDisposition("inline");
    $attachment2->setContentId("Banner");
    $mail->addAttachment($attachment2);
    $mail->setTemplateId("439b6d66-4408-4ead-83de-5c83c2ee313a");
    # This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) to work
    # $mail->setBatchID("sengrid_batch_id");
    $mail->addSection("%section1%", "Substitution Text for Section 1");
    $mail->addSection("%section2%", "Substitution Text for Section 2");
    $mail->addHeader("X-Test1", "1");
    $mail->addHeader("X-Test2", "2");
    $mail->addCategory("May");
    $mail->addCategory("2016");
    $mail->addCustomArg("campaign", "welcome");
    $mail->addCustomArg("weekday", "morning");
    $mail->setSendAt(1443636842);
    $asm = new ASM();
    $asm->setGroupId(99);
    $asm->setGroupsToDisplay([4, 5, 6, 7, 8]);
    $mail->setASM($asm);
    $mail->setIpPoolName("23");
    $mail_settings = new MailSettings();
    $bcc_settings = new BccSettings();
    $bcc_settings->setEnable(true);
    $bcc_settings->setEmail("*****@*****.**");
    $mail_settings->setBccSettings($bcc_settings);
    $sandbox_mode = new SandBoxMode();
    $sandbox_mode->setEnable(true);
    $mail_settings->setSandboxMode($sandbox_mode);
    $bypass_list_management = new BypassListManagement();
    $bypass_list_management->setEnable(true);
    $mail_settings->setBypassListManagement($bypass_list_management);
    $footer = new Footer();
    $footer->setEnable(true);
    $footer->setText("Footer Text");
    $footer->setHtml("<html><body>Footer Text</body></html>");
    $mail_settings->setFooter($footer);
    $spam_check = new SpamCheck();
    $spam_check->setEnable(true);
    $spam_check->setThreshold(1);
    $spam_check->setPostToUrl("https://spamcatcher.sendgrid.com");
    $mail_settings->setSpamCheck($spam_check);
    $mail->setMailSettings($mail_settings);
    $tracking_settings = new TrackingSettings();
    $click_tracking = new ClickTracking();
    $click_tracking->setEnable(true);
    $click_tracking->setEnableText(true);
    $tracking_settings->setClickTracking($click_tracking);
    $open_tracking = new OpenTracking();
    $open_tracking->setEnable(true);
    $open_tracking->setSubstitutionTag("Optional tag to replace with the open image in the body of the message");
    $tracking_settings->setOpenTracking($open_tracking);
    $subscription_tracking = new SubscriptionTracking();
    $subscription_tracking->setEnable(true);
    $subscription_tracking->setText("text to insert into the text/plain portion of the message");
    $subscription_tracking->setHtml("<html><body>html to insert into the text/html portion of the message</body></html>");
    $subscription_tracking->setSubstitutionTag("Optional tag to replace with the open image in the body of the message");
    $tracking_settings->setSubscriptionTracking($subscription_tracking);
    $ganalytics = new Ganalytics();
    $ganalytics->setEnable(true);
    $ganalytics->setCampaignSource("some source");
    $ganalytics->setCampaignTerm("some term");
    $ganalytics->setCampaignContent("some content");
    $ganalytics->setCampaignName("some name");
    $ganalytics->setCampaignMedium("some medium");
    $tracking_settings->setGanalytics($ganalytics);
    $mail->setTrackingSettings($tracking_settings);
    $reply_to = new ReplyTo("*****@*****.**");
    $mail->setReplyTo($reply_to);
    //echo json_encode($mail, JSON_PRETTY_PRINT), "\n";
    return $mail;
}
コード例 #19
0
ファイル: invoice.php プロジェクト: cdsalmons/arastta
 public function email()
 {
     $url = '';
     if (isset($this->request->get['filter_invoice_number'])) {
         $url .= '&filter_invoice_number=' . urlencode(html_entity_decode($this->request->get['filter_invoice_number'], ENT_QUOTES, 'UTF-8'));
     }
     if (isset($this->request->get['filter_order_id'])) {
         $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
     }
     if (isset($this->request->get['filter_customer'])) {
         $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
     }
     if (isset($this->request->get['filter_total'])) {
         $url .= '&filter_total=' . $this->request->get['filter_total'];
     }
     if (isset($this->request->get['filter_invoice_date'])) {
         $url .= '&filter_invoice_date=' . $this->request->get['filter_invoice_date'];
     }
     if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
     }
     if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
     }
     if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
     }
     if (!$this->validate()) {
         $this->response->redirect($this->url->link('sale/invoice', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     }
     $this->load->language('sale/order');
     $this->load->language('sale/invoice');
     $this->load->model('sale/order');
     $this->load->model('sale/invoice');
     if (isset($this->request->get['invoice_id'])) {
         $invoice_id = $this->request->get['invoice_id'];
     } else {
         $invoice_id = 0;
     }
     $invoice_info = $this->model_sale_invoice->getInvoice($invoice_id);
     if (!$invoice_info) {
         $this->session->data['error'] = $this->language->get('error_invoice_not_found');
         $this->response->redirect($this->url->link('sale/invoice', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     }
     // Generate the invoice file, temporary
     $this->pdf('F');
     // Send Email
     $invoice_data = $this->model_sale_order->getOrder($invoice_info['order_id']);
     $invoice_data['invoice_id'] = $invoice_info['invoice_id'];
     $invoice_data['invoice_date'] = $invoice_info['invoice_date'];
     $invoice_file = DIR_UPLOAD . $invoice_data['invoice_prefix'] . $invoice_data['invoice_no'] . '.pdf';
     $subject = $this->emailtemplate->getSubject('Invoice', 'invoice_1', $invoice_data);
     $message = $this->emailtemplate->getMessage('Invoice', 'invoice_1', $invoice_data);
     $mail = new Mail($this->config->get('config_mail'));
     $mail->setTo($invoice_data['email']);
     $mail->setFrom($this->config->get('config_email'));
     $mail->setSender($invoice_data['store_name']);
     $mail->setSubject($subject);
     $mail->setHtml($message);
     $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
     $mail->addAttachment($invoice_file);
     $mail->send();
     // Delete the invoice file after it has been sent
     $this->filesystem->remove($invoice_file);
     $this->session->data['success'] = $this->language->get('text_email_success');
     $this->response->redirect($this->url->link('sale/invoice', 'token=' . $this->session->data['token'] . $url, 'SSL'));
 }
コード例 #20
0
ファイル: notify.php プロジェクト: vverhun/hoho
 public function testprocess()
 {
     //$this->_loger('before saving',array('ppData'=>$sysData),$orderId);
     ini_set('display_errors', '1');
     $sysData = '';
     $this->load->model('account/order');
     //$this->model_account_order->updateStatusData( $orderId, 5, $sysData );
     $orderId = $this->request->get['order_id'];
     $this->load->model('account/order');
     $this->model_account_order->updateStatusData($orderId, 5, $sysData);
     $this->load->model('sale/order');
     $this->load->model('account/customer');
     $this->load->model('sale/customer');
     $order = $this->model_sale_order->getOrder($orderId);
     $customer_info = $this->model_sale_customer->getCustomer($order['customer_id']);
     $lang = $customer_info['lang'];
     $mail = new Mail();
     $mail->protocol = $this->config->get('config_mail_protocol');
     $mail->parameter = $this->config->get('config_mail_parameter');
     $mail->hostname = $this->config->get('config_smtp_host');
     $mail->username = $this->config->get('config_smtp_username');
     $mail->password = $this->config->get('config_smtp_password');
     $mail->port = $this->config->get('config_smtp_port');
     $mail->timeout = $this->config->get('config_smtp_timeout');
     $message = "Sehr geehrter Damen und Herren,<br> eine neue Bestellung ist im Shop eingegangen.";
     //********* Detailed information about order ******** //
     $customerId = $order['customer_id'];
     $this->load->model('account/customer');
     $this->load->model('sale/customer');
     $customer_info = $this->model_account_customer->getCustomer($order['customer_id']);
     $bill_info = $this->model_account_customer->getBill($order['customer_id']);
     $address_info = $this->model_sale_customer->getAddressesByCustomerId($order['customer_id']);
     $message .= "<br><br><table border=0>";
     $message .= "<tr><td>Einrichtung:</td><td>" . $customer_info['firstname'] . " " . $customer_info['lastname'] . "</td></tr>";
     $message .= "<tr><td>Ansprechpartner:</td><td>" . $customer_info['ansprechpartner'] . "</td></tr>";
     $message .= "<tr><td>Position:\t</td><td>" . $customer_info['position'] . "</td></tr>";
     $message .= "<tr><td>Benutzername:</td><td>" . $customer_info['username'] . "</td></tr>\t";
     $message .= "<tr><td></td><td></td></tr>";
     $message .= "<tr><td>Straße:</td><td>" . $address_info[0]['address_1'] . "</td></tr>";
     $message .= "<tr><td>PLZ:\t</td><td>" . $address_info[0]['postcode'] . "</td></tr> ";
     $message .= "<tr><td>Stadt: </td><td>" . $address_info[0]['city'] . "</td></tr>";
     $message .= "<tr><td>Land:</td><td>" . $address_info[0]['country_id'] . "</td></tr>";
     $message .= "<tr><td>TaxID Number:</td><td>" . $customer_info['taxid_number'] . "</td></tr>";
     $message .= "<tr><td></td><td></td></tr>";
     $message .= "<tr><td>Telefon: </td><td>" . $customer_info['telephone'] . "</td></tr>";
     $message .= "<tr><td>Mobil:\t</td><td>" . $customer_info['mobile'] . "</td></tr>";
     $message .= "<tr><td>Fax:\t</td><td>" . $customer_info['fax'] . "</td></tr>";
     $message .= "<tr><td>E-Mail:</td><td>" . $customer_info['email'] . "</td></tr>";
     $message .= "</table><br><br>";
     $message .= "<table border=0 cellpadding=5 cellspacing=5><tr><td style='background-color:#bebebe;font-weight:bold;'></td><td style='background-color:#bebebe;font-weight:bold;'>Titel:</td><td style='background-color:#bebebe;font-weight:bold;'>Vorschau:</td><td style='background-color:#bebebe;font-weight:bold;'>Rubrick:</td><td style='background-color:#bebebe;font-weight:bold;'>Dateiname:</td>";
     $ind = 1;
     $this->load->model('catalog/category');
     $this->load->model('account/order');
     $this->load->model('catalog/product');
     $this->load->model('tool/image');
     //$order =  $this->model_sale_order->getOrder($orderId);
     $order_products = $this->model_sale_order->getOrderProducts($orderId);
     foreach ($order_products as $product) {
         $product = $this->model_catalog_product->getProduct($product['product_id']);
         if ($product['image']) {
             $image = $product['image'];
         } else {
             $image = 'no_image.jpg';
         }
         $category = $this->model_catalog_product->getCategories($product['product_id']);
         $category = $category[0]['category_id'];
         $category_info = $this->model_catalog_category->getCategory($category);
         $message .= "<tr><td>" . $ind . "</td>";
         $message .= "<td>CR:" . $product['sku'] . ", " . $product['name'] . "</td>";
         $message .= "<td><img src='" . $this->model_tool_image->resize($image, 117, 117) . "' /></td>";
         $message .= "<td>" . $category_info['name'] . "</td>";
         $message .= "<td>" . str_replace('data/', '', $image) . "</td></tr>";
         $ind++;
     }
     $message .= "</table><br><br>";
     //***************************************************************************************************************************** //
     $message .= "<br><br>Mit freundlichen Grüßen<br><br>Atelier Richter<br>Osterriethweg 22<br>D - 50996 Köln<br>Telefon: +49 / 22 36 / 96 56 10<br>Fax: +49 / 22 36 / 96 56 12<br>e-mail: gerhard.richter@netcologne.de<br><br>(Diese E-Mail wurde automatisch erstellt)<br>";
     //$mail->setTo('*****@*****.**');
     $mail->setTo('*****@*****.**');
     $mail->setFrom($this->config->get('config_email'));
     $mail->setSender($this->config->get('config_name'));
     $mail->setSubject('Eine neue Bestellung ist eingegangen');
     $mail->setHtml($message, ENT_QUOTES, 'UTF-8');
     $mail->send();
     //send email to customer
     $mail = new Mail();
     $mail->protocol = $this->config->get('config_mail_protocol');
     $mail->parameter = $this->config->get('config_mail_parameter');
     $mail->hostname = $this->config->get('config_smtp_host');
     $mail->username = $this->config->get('config_smtp_username');
     $mail->password = $this->config->get('config_smtp_password');
     $mail->port = $this->config->get('config_smtp_port');
     $mail->timeout = $this->config->get('config_smtp_timeout');
     $pdfname = $this->saveorder($orderId);
     if ($lang == 'de-DE') {
         $message = 'Sehr geehrter Damen und Herren,<br>wir bedanken uns für Ihren Einkauf.<br><br>Mit freundlichen Grüßen<br><br>Atelier Richter<br>Osterriethweg 22<br>D - 50996 Köln<br>Telefon: +49 / 22 36 / 96 56 10<br>Fax: +49 / 22 36 / 96 56 12<br>e-mail: gerhard.richter@netcologne.de<br><br>(Diese E-Mail wurde automatisch erstellt)<br>';
         $mail->setTo('*****@*****.**');
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject('Danke');
         $mail->setHtml($message, ENT_QUOTES, 'UTF-8');
         $mail->addAttachment('invoice' . $orderId . '.pdf', 'invoice.pdf');
         $mail->send();
     } else {
         $message = 'Dear Ladies & Gentlemen,<br>thank you for your purchase!<br><br>Kind regards,<br><br>Atelier Richter<br>Osterriethweg 22<br>D - 50996 Köln<br>Telefon: +49 / 22 36 / 96 56 10<br>Fax: +49 / 22 36 / 96 56 12<br>e-mail: gerhard.richter@netcologne.de<br><br>(This email was generated automatically)<br>';
         $mail->setTo('*****@*****.**');
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject('Thank you');
         $mail->setHtml($message, ENT_QUOTES, 'UTF-8');
         $mail->addAttachment('invoice' . $orderId . '.pdf', 'invoice.pdf');
         $mail->send();
     }
     die;
     //$this->_loger('after saving',array('ppData'=>$sysData),$orderId);
 }
コード例 #21
0
ファイル: voucher.php プロジェクト: raquelsa/OpenCartWeb
 public function sendVoucher($voucher_id)
 {
     $voucher_info = $this->getVoucher($voucher_id);
     if ($voucher_info) {
         if ($voucher_info['order_id']) {
             $order_id = $voucher_info['order_id'];
         } else {
             $order_id = 0;
         }
         $this->load->model('sale/order');
         $order_info = $this->model_sale_order->getOrder($order_id);
         // If voucher belongs to an order
         if ($order_info) {
             $this->load->model('localisation/language');
             $language = new Language($order_info['language_directory']);
             $language->load($order_info['language_filename']);
             $language->load('mail/voucher');
             // HTML Mail
             $template = new Template();
             $template->data['title'] = sprintf($language->get('text_subject'), $voucher_info['from_name']);
             $template->data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher_info['amount'], $order_info['currency_code'], $order_info['currency_value']));
             $template->data['text_from'] = sprintf($language->get('text_from'), $voucher_info['from_name']);
             $template->data['text_message'] = $language->get('text_message');
             $template->data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher_info['code']);
             $template->data['text_footer'] = $language->get('text_footer');
             $this->load->model('sale/voucher_theme');
             $voucher_theme_info = $this->model_sale_voucher_theme->getVoucherTheme($voucher_info['voucher_theme_id']);
             if ($voucher_info && file_exists(DIR_IMAGE . $voucher_theme_info['image'])) {
                 $template->data['image'] = 'cid:' . md5(basename($voucher_theme_info['image']));
             } else {
                 $template->data['image'] = '';
             }
             $template->data['store_name'] = $order_info['store_name'];
             $template->data['store_url'] = $order_info['store_url'];
             $template->data['message'] = nl2br($voucher_info['message']);
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($voucher_info['to_email']);
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_info['store_name']);
             $mail->setSubject(sprintf($language->get('text_subject'), $voucher_info['from_name']));
             $mail->setHtml($template->fetch('mail/voucher.tpl'));
             if ($voucher_info && file_exists(DIR_IMAGE . $voucher_theme_info['image'])) {
                 $mail->addAttachment(DIR_IMAGE . $voucher_theme_info['image'], md5(basename($voucher_theme_info['image'])));
             }
             $mail->send();
             // If voucher does not belong to an order
         } else {
             $this->language->load('mail/voucher');
             $template = new Template();
             $template->data['title'] = sprintf($this->language->get('text_subject'), $voucher_info['from_name']);
             $template->data['text_greeting'] = sprintf($this->language->get('text_greeting'), $this->currency->format($voucher_info['amount'], $order_info['currency_code'], $order_info['currency_value']));
             $template->data['text_from'] = sprintf($this->language->get('text_from'), $voucher_info['from_name']);
             $template->data['text_message'] = $this->language->get('text_message');
             $template->data['text_redeem'] = sprintf($this->language->get('text_redeem'), $voucher_info['code']);
             $template->data['text_footer'] = $this->language->get('text_footer');
             $this->load->model('sale/voucher_theme');
             $voucher_theme_info = $this->model_sale_voucher_theme->getVoucherTheme($voucher_info['voucher_theme_id']);
             if ($voucher_info && file_exists(DIR_IMAGE . $voucher_theme_info['image'])) {
                 $template->data['image'] = 'cid:' . md5(basename($voucher_theme_info['image']));
             } else {
                 $template->data['image'] = '';
             }
             $template->data['store_name'] = $this->config->get('config_name');
             $template->data['store_url'] = HTTP_CATALOG;
             $template->data['message'] = nl2br($voucher_info['message']);
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($voucher_info['to_email']);
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($this->config->get('config_name'));
             $mail->setSubject(sprintf($this->language->get('text_subject'), $voucher_info['from_name']));
             $mail->setHtml($template->fetch('mail/voucher.tpl'));
             if ($voucher_info && file_exists(DIR_IMAGE . $voucher_theme_info['image'])) {
                 $mail->addAttachment(DIR_IMAGE . $voucher_theme_info['image'], md5(basename($voucher_theme_info['image'])));
             }
             $mail->send();
         }
     }
 }
コード例 #22
0
 public function sendBonuslotoMailAdmin($bonusloto_id)
 {
     $this->load->language('mail/bonusloto_confirm');
     $this->load->model('localisation/currency');
     $query_winner = $this->getDb()->query("SELECT * FROM `" . DB_PREFIX . "bonusloto_winner` WHERE `bonusloto_id`='" . $bonusloto_id . "'");
     $subject = sprintf($this->language->get('text_subject_admin'), $this->config->get('config_name'), $query_winner->row['winner_date']);
     $pieces = explode("|", $query_winner->row['winner_bonus']);
     // HTML Mail
     $template = new Template();
     $template->data['title'] = sprintf($this->language->get('text_subject_admin'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $query_winner->row['winner_date']);
     $template->data['text_greeting'] = sprintf($this->language->get('text_notifi_greeting'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $query_winner->row['winner_email'], $pieces[0]);
     $template->data['text_powered_by'] = $this->language->get('text_powered_by');
     $template->data['logo'] = 'cid:' . basename($this->config->get('config_logo'));
     $template->data['store_name'] = $this->config->get('config_name');
     $template->data['store_url'] = $this->config->get('config_url');
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/bonusloto_confirm.tpl')) {
         $html = $template->fetch($this->config->get('config_template') . '/template/mail/bonusloto_confirm.tpl');
     } else {
         $html = $template->fetch('default/template/mail/bonusloto_confirm.tpl');
     }
     $mail = new Mail();
     $mail->protocol = $this->config->get('config_mail_protocol');
     $mail->parameter = $this->config->get('config_mail_parameter');
     $mail->hostname = $this->config->get('config_smtp_host');
     $mail->username = $this->config->get('config_smtp_username');
     $mail->password = $this->config->get('config_smtp_password');
     $mail->port = $this->config->get('config_smtp_port');
     $mail->timeout = $this->config->get('config_smtp_timeout');
     $mail->setTo($this->config->get('config_email'));
     $mail->setFrom($this->config->get('config_email'));
     $mail->setSender($this->config->get('config_name'));
     $mail->setSubject($subject);
     $mail->setHtml($html);
     $mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'));
     $mail->send();
 }
コード例 #23
0
<?php

// If you are using Composer
namespace SendGrid;

require 'vendor/autoload.php';
$uid = $argv[1];
$receiver = $argv[2];
$str = file_get_contents('/var/www/config.json');
$jsonData = json_decode($str, true);
echo $jsonData['api'];
$from = new Email(null, $jsonData['sender']);
$subject = "Hello World from the SendGrid PHP Library!";
$to = new Email(null, $argv[2]);
$content = new Content("text/plain", $jsonData['body'] . $uid);
$mail = new Mail($from, $subject, $to, $content);
$attachment = new Attachment();
$attachment->setContent(base64_encode("/var/www/html/release" . $uid . "/releaseapk.apk"));
$attachment->setFilename("balance_001.apk");
$attachment->setDisposition("attachment");
$attachment->setType("application/vnd.android.package-archive");
$attachment->setContentId("app");
$mail->addAttachment($attachment);
$apiKey = $jsonData['api'];
$sg = new \SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
echo $response->headers();
echo $response->body();