/**
  * Transport a mail.
  *
  * @param string $strRecipientEmail
  * @param Mail   $email
  *
  * @return void
  * @throws AvisotaTransportException
  */
 public function transportEmail($recipient, Mail $email)
 {
     global $page;
     try {
         // set sender email
         if ($this->config->sender) {
             $email->setSender($this->config->sender);
         } else {
             if (isset($page) && strlen($page->adminEmail)) {
                 $email->setSender($page->adminEmail);
             } else {
                 $email->setSender($GLOBALS['TL_CONFIG']['adminEmail']);
             }
         }
         // set sender name
         if (strlen($this->config->senderName)) {
             $email->setSenderName($this->config->senderName);
         }
         // set reply email
         if ($this->config->replyTo) {
             $email->setReplyTo($this->config->replyTo);
         }
         // set reply name
         if ($this->config->replyToName) {
             $email->setReplyToName($this->config->replyToName);
         }
         $this->mailer->send($email, $recipient);
     } catch (Swift_RfcComplianceException $e) {
         throw new AvisotaTransportEmailException($recipient, $email, $e->getMessage(), $e->getCode(), $e);
     }
 }
예제 #2
0
 public function index()
 {
     $data['email'] = isset($this->request->post['email']) ? $this->request->post['email'] : ($this->auth->isLogged() ? $this->auth->getEmail() : false);
     $data['subject'] = isset($this->request->post['subject']) ? $this->request->post['subject'] : false;
     $data['message'] = isset($this->request->post['message']) ? $this->request->post['message'] : false;
     if ('POST' == $this->request->getRequestMethod() && $this->_validatePost()) {
         $mail = new Mail();
         $mail->setTo(MAIL_INFO);
         $mail->setFrom(MAIL_FROM);
         $mail->setReplyTo($this->request->post['email']);
         $mail->setSender(MAIL_SENDER);
         $mail->setSubject($this->request->post['subject']);
         $mail->setText($this->request->post['message']);
         $mail->send();
         $this->session->setUserMessage(array('success' => tt('Your message was sent successfully!')));
         $data['subject'] = false;
         $data['message'] = false;
     }
     $this->document->setTitle(tt('Contact Us'));
     $data['module_breadcrumbs'] = $this->load->controller('module/breadcrumbs', array(array('name' => tt('Home'), 'href' => $this->url->link('common/home'), 'active' => false), array('name' => tt('Contact Us'), 'href' => $this->url->link('common/contact', '', 'SSL'), 'active' => true)));
     $data['error'] = $this->_error;
     $data['href_common_information_licenses'] = $this->url->link('common/information/licenses');
     $data['href_common_information_terms'] = $this->url->link('common/information/terms');
     $data['href_common_information_faq'] = $this->url->link('common/information/faq');
     $data['action'] = $this->url->link('common/contact', '', 'SSL');
     $data['alert_success'] = $this->load->controller('common/alert/success');
     $data['footer'] = $this->load->controller('common/footer');
     $data['header'] = $this->load->controller('common/header');
     $this->response->setOutput($this->load->view('common/contact.tpl', $data));
 }
예제 #3
0
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
    } else {
        trigger_error('Error: Could not load template ' . $file . '!');
        return false;
    }
}
function tt($string)
{
    return htmlentities($string);
}
// Init mail
$mail = new Mail();
$mail->setFrom(MAIL_EMAIL_SUPPORT_ADDRESS);
$mail->setReplyTo(MAIL_EMAIL_SUPPORT_ADDRESS);
$mail->setSender(MAIL_EMAIL_SENDER_NAME);
// Init Database
try {
    $db = new PDO('mysql:dbname=' . DB_DATABASE . ';host=' . DB_HOSTNAME . ';charset=utf8', DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
} catch (PDOException $e) {
    $error[] = $e->getMessage();
    exit;
}
// Init BitCoin
try {
    $bitcoin = new BitCoin(BITCOIN_RPC_USERNAME, BITCOIN_RPC_PASSWORD, BITCOIN_RPC_HOST, BITCOIN_RPC_PORT);
} catch (Exception $e) {
    $error[] = $bitcoin->error . '/' . $e->getMessage();
예제 #4
0
 public function addOrderHistory($order_id, $order_status_id, $comment = '', $notify = false)
 {
     $this->event->trigger('pre.order.history.add', $order_id);
     $order_info = $this->getOrder($order_id);
     if ($order_info) {
         // Fraud Detection
         $this->load->model('account/customer');
         $customer_info = $this->model_account_customer->getCustomer($order_info['customer_id']);
         if ($customer_info && $customer_info['safe']) {
             $safe = true;
         } else {
             $safe = false;
         }
         if ($this->config->get('config_fraud_detection')) {
             $this->load->model('checkout/fraud');
             $risk_score = $this->model_checkout_fraud->getFraudScore($order_info);
             if (!$safe && $risk_score > $this->config->get('config_fraud_score')) {
                 $order_status_id = $this->config->get('config_fraud_status_id');
             }
         }
         // Ban IP
         if (!$safe) {
             $status = false;
             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 = '" . (int) $notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()");
         // If current order status is not processing or complete but new status is processing or complete then commence completing the order
         if (!in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
             // Stock subtraction
             $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'");
                 }
             }
             // Redeem coupon, vouchers and reward points
             $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);
                 }
             }
             // Add commission if sale is linked to affiliate referral.
             if ($order_info['affiliate_id'] && $this->config->get('config_affiliate_auto')) {
                 $this->load->model('affiliate/affiliate');
                 $this->model_affiliate_affiliate->addTransaction($order_info['affiliate_id'], $order_info['commission'], $order_id);
             }
         }
         // If old order status is the processing or complete status but new status is not then commence restock, and remove coupon, voucher and reward history
         if (in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && !in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
             // Restock
             $product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
             foreach ($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'");
                 $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 ($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'");
                 }
             }
             // Remove coupon, vouchers and reward points history
             $this->load->model('account/order');
             $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']}, 'unconfirm')) {
                     $this->{'model_total_' . $order_total['code']}->unconfirm($order_id);
                 }
             }
             // Remove commission if sale is linked to affiliate referral.
             if ($order_info['affiliate_id']) {
                 $this->load->model('affiliate/affiliate');
                 $this->model_affiliate_affiliate->deleteTransaction($order_id);
             }
         }
         $this->cache->delete('product');
         // If order status is 0 then becomes greater than 0 send main html email
         if (!$order_info['order_status_id'] && $order_status_id) {
             // Check for any downloadable products
             $download_status = false;
             $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) {
                 // Check if there are any linked downloads
                 $product_download_query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "product_to_download` WHERE product_id = '" . (int) $order_product['product_id'] . "'");
                 if ($product_download_query->row['total']) {
                     $download_status = true;
                 }
             }
             // Load the language for any mails that might be required to be sent out
             $language = new Language($order_info['language_directory']);
             $language->load('default');
             $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
             $data = array();
             $data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             $data['text_greeting'] = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
             $data['text_link'] = $language->get('text_new_link');
             $data['text_download'] = $language->get('text_new_download');
             $data['text_order_detail'] = $language->get('text_new_order_detail');
             $data['text_instruction'] = $language->get('text_new_instruction');
             $data['text_order_id'] = $language->get('text_new_order_id');
             $data['text_date_added'] = $language->get('text_new_date_added');
             $data['text_payment_method'] = $language->get('text_new_payment_method');
             $data['text_shipping_method'] = $language->get('text_new_shipping_method');
             $data['text_email'] = $language->get('text_new_email');
             $data['text_telephone'] = $language->get('text_new_telephone');
             $data['text_ip'] = $language->get('text_new_ip');
             $data['text_order_status'] = $language->get('text_new_order_status');
             $data['text_payment_address'] = $language->get('text_new_payment_address');
             $data['text_shipping_address'] = $language->get('text_new_shipping_address');
             $data['text_product'] = $language->get('text_new_product');
             $data['text_model'] = $language->get('text_new_model');
             $data['text_quantity'] = $language->get('text_new_quantity');
             $data['text_price'] = $language->get('text_new_price');
             $data['text_total'] = $language->get('text_new_total');
             $data['text_footer'] = $language->get('text_new_footer');
             $data['logo'] = $this->config->get('config_url') . 'image/' . $this->config->get('config_logo');
             $data['store_name'] = $order_info['store_name'];
             $data['store_url'] = $order_info['store_url'];
             $data['customer_id'] = $order_info['customer_id'];
             $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
             if ($download_status) {
                 $data['download'] = $order_info['store_url'] . 'index.php?route=account/download';
             } else {
                 $data['download'] = '';
             }
             $data['order_id'] = $order_id;
             $data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
             $data['payment_method'] = $order_info['payment_method'];
             $data['shipping_method'] = $order_info['shipping_method'];
             $data['email'] = $order_info['email'];
             $data['telephone'] = $order_info['telephone'];
             $data['ip'] = $order_info['ip'];
             $data['order_status'] = $order_status;
             if ($comment && $notify) {
                 $data['comment'] = nl2br($comment);
             } else {
                 $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']);
             $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']);
             $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))));
             $this->load->model('tool/upload');
             // Products
             $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 {
                         $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                         if ($upload_info) {
                             $value = $upload_info['name'];
                         } else {
                             $value = '';
                         }
                     }
                     $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
                 }
                 $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
             $data['vouchers'] = array();
             $order_voucher_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int) $order_id . "'");
             foreach ($order_voucher_query->rows as $voucher) {
                 $data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']));
             }
             // 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 $total) {
                 $data['totals'][] = array('title' => $total['title'], 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']));
             }
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
                 $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
             } else {
                 $html = $this->load->view('default/template/mail/order.tpl', $data);
             }
             // 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) {
                         if ($option['type'] != 'file') {
                             $value = $option['value'];
                         } else {
                             $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                             if ($upload_info) {
                                 $value = $upload_info['name'];
                             } else {
                                 $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($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), 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 ($download_status) {
                     $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($this->config->get('config_mail'));
                 $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($text);
                 $mail->send();
             }
             // Admin Alert Mail
             if ($this->config->get('config_order_mail')) {
                 $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
                 // HTML Mail
                 $data['text_greeting'] = $language->get('text_new_received');
                 if ($comment) {
                     if ($order_info['comment']) {
                         $data['comment'] = nl2br($comment) . '<br/><br/>' . $order_info['comment'];
                     } else {
                         $data['comment'] = nl2br($comment);
                     }
                 } else {
                     if ($order_info['comment']) {
                         $data['comment'] = $order_info['comment'];
                     } else {
                         $data['comment'] = '';
                     }
                 }
                 $data['text_download'] = '';
                 $data['text_footer'] = '';
                 $data['text_link'] = '';
                 $data['link'] = '';
                 $data['download'] = '';
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
                     $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
                 } else {
                     $html = $this->load->view('default/template/mail/order.tpl', $data);
                 }
                 // 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($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), 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($this->config->get('config_mail'));
                 $mail->setTo($this->config->get('config_email'));
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setReplyTo($order_info['email']);
                 $mail->setSender($order_info['store_name']);
                 $mail->setSubject($subject);
                 $mail->setHtml($html);
                 $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
                 $mail->send();
                 // Send to additional alert emails
                 $emails = explode(',', $this->config->get('config_mail_alert'));
                 foreach ($emails as $email) {
                     if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                         $mail->setTo($email);
                         $mail->send();
                     }
                 }
             }
         }
         // If order status is not 0 then send update text email
         if ($order_info['order_status_id'] && $order_status_id) {
             $language = new Language($order_info['language_directory']);
             $language->load('default');
             $language->load('mail/order');
             $subject = sprintf($language->get('text_update_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             $message = $language->get('text_update_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_update_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) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
             if ($order_status_query->num_rows) {
                 $message .= $language->get('text_update_order_status') . "\n\n";
                 $message .= $order_status_query->row['name'] . "\n\n";
             }
             if ($order_info['customer_id']) {
                 $message .= $language->get('text_update_link') . "\n";
                 $message .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n";
             }
             if ($notify && $comment) {
                 $message .= $language->get('text_update_comment') . "\n\n";
                 $message .= strip_tags($comment) . "\n\n";
             }
             $message .= $language->get('text_update_footer');
             $mail = new Mail($this->config->get('config_mail'));
             $mail->setTo($order_info['email']);
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_info['store_name']);
             $mail->setSubject($subject);
             $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
             $mail->send();
         }
         // If order status in the complete range create any vouchers that where in the order need to be made available.
         if (in_array($order_info['order_status_id'], $this->config->get('config_complete_status'))) {
             // Send out any gift voucher mails
             $this->load->model('checkout/voucher');
             $this->model_checkout_voucher->confirm($order_id);
         }
     }
     $this->event->trigger('post.order.history.add', $order_id);
 }
예제 #5
0
파일: order.php 프로젝트: evo9/design
 public function sendOrder($order_id)
 {
     $this->event->trigger('pre.order.history.add', $order_id);
     $order_info = $this->getOrder($order_id);
     if ($order_info) {
         // Fraud Detection
         $this->cache->delete('product');
         // If order status is 0 then becomes greater than 0 send main html email
         // if (!$order_info['order_status_id'] && $order_status_id) {
         // Check for any downloadable products
         $download_status = false;
         $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) {
             // Check if there are any linked downloads
             $product_download_query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "product_to_download` WHERE product_id = '" . (int) $order_product['product_id'] . "'");
             if ($product_download_query->row['total']) {
                 $download_status = true;
             }
         }
         // Load the language for any mails that might be required to be sent out
         $language = new Language($order_info['language_directory']);
         $language->load('default');
         $language->load('mail/order');
         $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_info['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
         $data = array();
         $data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
         $data['text_greeting'] = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
         $data['text_link'] = $language->get('text_new_link');
         $data['text_download'] = $language->get('text_new_download');
         $data['text_order_detail'] = $language->get('text_new_order_detail');
         $data['text_instruction'] = $language->get('text_new_instruction');
         $data['text_order_id'] = $language->get('text_new_order_id');
         $data['text_date_added'] = $language->get('text_new_date_added');
         $data['text_email'] = $language->get('text_new_email');
         $data['text_telephone'] = $language->get('text_new_telephone');
         $data['text_ip'] = $language->get('text_new_ip');
         $data['text_order_status'] = $language->get('text_new_order_status');
         $data['text_product'] = $language->get('text_new_product');
         $data['text_model'] = $language->get('text_new_model');
         $data['text_quantity'] = $language->get('text_new_quantity');
         $data['text_price'] = $language->get('text_new_price');
         $data['text_total'] = $language->get('text_new_total');
         $data['text_footer'] = $language->get('text_new_footer');
         $data['config_phone'] = explode(',', $this->config->get('config_telephone'));
         $data['config_address'] = $this->config->get('config_address');
         $data['config_email'] = $this->config->get('config_email');
         $data['config_host'] = HTTP_SERVER;
         $data['logo'] = $this->config->get('config_url') . 'image/' . $this->config->get('config_logo');
         $data['store_name'] = $order_info['store_name'];
         $data['store_url'] = $order_info['store_url'];
         $data['customer_id'] = $order_info['customer_id'];
         $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
         if ($download_status) {
             $data['download'] = $order_info['store_url'] . 'index.php?route=account/download';
         } else {
             $data['download'] = '';
         }
         $data['order_id'] = $order_id;
         $data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
         $data['email'] = $order_info['email'];
         $data['telephone'] = $order_info['telephone'];
         $data['ip'] = $order_info['ip'];
         $data['order_status'] = $order_status;
         $data['comment'] = '';
         $this->load->model('tool/upload');
         // Products
         $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 {
                     $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                     if ($upload_info) {
                         $value = $upload_info['name'];
                     } else {
                         $value = '';
                     }
                 }
                 $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
             }
             $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']));
         }
         // 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 $total) {
             $data['totals'][] = array('title' => $total['title'], 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']));
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
             $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
         } else {
             $html = $this->load->view('default/template/mail/order.tpl', $data);
         }
         // 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";
         // 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) {
                 if ($option['type'] != 'file') {
                     $value = $option['value'];
                 } else {
                     $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                     if ($upload_info) {
                         $value = $upload_info['name'];
                     } else {
                         $value = '';
                     }
                 }
                 $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n";
             }
         }
         $text .= "\n";
         $text .= $language->get('text_new_order_total') . "\n";
         foreach ($order_total_query->rows as $total) {
             $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), 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 ($download_status) {
             $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->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($text);
         $mail->send();
         // Admin Alert Mail
         if ($this->config->get('config_order_mail')) {
             $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
             // HTML Mail
             $data['text_greeting'] = $language->get('text_new_received');
             $data['text_download'] = '';
             $data['text_footer'] = '';
             $data['text_link'] = '';
             $data['link'] = '';
             $data['download'] = '';
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
                 $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
             } else {
                 $html = $this->load->view('default/template/mail/order.tpl', $data);
             }
             // 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";
                 }
             }
             $text .= "\n";
             $text .= $language->get('text_new_order_total') . "\n";
             foreach ($order_total_query->rows as $total) {
                 $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), 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->setTo($this->config->get('config_email'));
             $mail->setFrom($this->config->get('config_email'));
             $mail->setReplyTo($order_info['email']);
             $mail->setSender($order_info['store_name']);
             $mail->setSubject($subject);
             $mail->setHtml($html);
             $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
             $mail->send();
             // Send to additional alert emails
             $emails = explode(',', $this->config->get('config_mail_alert'));
             foreach ($emails as $email) {
                 if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                     $mail->setTo($email);
                     $mail->send();
                 }
             }
         }
         // }
     }
     $this->event->trigger('post.order.history.add', $order_id);
 }
 public function addOrderHistory($order_id, $order_status_id, $comment = '', $notify = false)
 {
     $this->event->trigger('pre.order.history.add', $order_id);
     $order_info = $this->getOrder($order_id);
     if ($order_info) {
         // Fraud Detection
         $this->load->model('account/customer');
         $customer_info = $this->model_account_customer->getCustomer($order_info['customer_id']);
         if ($customer_info && $customer_info['safe']) {
             $safe = true;
         } else {
             $safe = false;
         }
         if (!$safe) {
             // Ban IP
             $status = false;
             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');
             }
             // Anti-Fraud
             $this->load->model('extension/extension');
             $extensions = $this->model_extension_extension->getExtensions('fraud');
             foreach ($extensions as $extension) {
                 if ($this->config->get($extension['code'] . '_status')) {
                     $this->load->model('fraud/' . $extension['code']);
                     $fraud_status_id = $this->{'model_fraud_' . $extension['code']}->check($order_info);
                     if ($fraud_status_id) {
                         $order_status_id = $fraud_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 = '" . (int) $notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()");
         // If current order status is not processing or complete but new status is processing or complete then commence completing the order
         if (!in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
             // Stock subtraction
             $order_product_query = $this->db->query("SELECT o.*, pd.language_id FROM " . DB_PREFIX . "order_product AS o LEFT JOIN " . DB_PREFIX . "product_description as pd on o.product_id = pd.product_id WHERE o.order_id = '" . (int) $order_id . "' GROUP BY o.product_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'");
                 }
                 // serialkeys
                 $order_product_serials_query = $this->db->query("SELECT pd.name, p.product_id, s.serial_id, s.serialkey FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "serialkeys s ON s.product_id = p.product_id LEFT JOIN " . DB_PREFIX . "product_description pd ON s.product_id = pd.product_id WHERE p.product_id = '" . (int) $order_product['product_id'] . "'  AND pd.language_id = '" . (int) $order_info['language_id'] . "' AND p.saleserials ='Y' ORDER BY s.serial_id");
                 // downloadlinks
                 $order_product_downloadlinks_query = $this->db->query("SELECT pd.name, p.product_id, d.downloadlink_id, d.downloadlink AS downloadlink, d.language_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "downloadlinks d ON d.product_id=p.product_id LEFT JOIN " . DB_PREFIX . "product_description pd ON d.product_id=pd.product_id WHERE p.product_id = '" . (int) $order_product['product_id'] . "' AND p.saledownloadlinks='Y'  AND pd.language_id = d.language_id ORDER BY d.downloadlink_id");
                 if ($order_product_serials_query->num_rows) {
                     $serials = $order_product_serials_query->rows;
                     for ($i = 0; $i < $order_product['quantity']; $i++) {
                         // add key then delete it from all table
                         $this->db->query("INSERT INTO " . DB_PREFIX . "order_serialkey SET order_id = '" . (int) $order_id . "', order_product_id = '" . (int) $order_product['product_id'] . "', productname = '" . $this->db->escape($serials[$i]['name']) . "', serialkey = '" . $this->db->escape($serials[$i]['serialkey']) . "'");
                         $this->db->query("DELETE FROM " . DB_PREFIX . "serialkeys WHERE serial_id='" . (int) $serials[$i]['serial_id'] . "'");
                     }
                 }
                 if ($order_product_downloadlinks_query->num_rows) {
                     $downloadlinks = $order_product_downloadlinks_query->rows;
                     foreach ($downloadlinks as $d) {
                         if (!empty($d['downloadlink'])) {
                             $this->db->query("INSERT INTO " . DB_PREFIX . "order_downloadlink SET order_id = '" . (int) $order_id . "', order_product_id = '" . (int) $order_product['product_id'] . "', productname = '" . $this->db->escape($d['name']) . "', downloadlink = '" . $this->db->escape($d['downloadlink']) . "', language_id = '" . $this->db->escape($d['language_id']) . "'");
                         }
                     }
                 }
             }
             // Notify admin about out of stock
             $subject_text = 'Out of stock on products';
             $message_text = 'There is less than ' . $this->config->get('config_stock_notify') . ' items left of: <br />';
             $i = 1;
             $send_notify = false;
             if ($order_product_query->rows) {
                 foreach ($order_product_query->rows as $product_info) {
                     $quantity_check = $this->db->query("SELECT quantity FROM `" . DB_PREFIX . "product` WHERE product_id='" . $product_info['product_id'] . "'");
                     if ($quantity_check->row['quantity'] <= $this->config->get('config_stock_notify')) {
                         if (count($order_product_query->rows) > 1) {
                             $message_text .= $i . '. ' . $product_info['name'] . '<br />';
                         } else {
                             $subject_text = 'Out of stock on: ' . $product_info['name'];
                             $message_text .= $product_info['name'] . '<br />';
                         }
                         $send_notify = true;
                     }
                     $i++;
                 }
             }
             if ($send_notify) {
                 $this->load->model('setting/store');
                 $this->load->language('mail/customer');
                 $mail = new Mail();
                 $mail->protocol = $this->config->get('config_mail_protocol');
                 $mail->parameter = $this->config->get('config_mail_parameter');
                 $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
                 $mail->smtp_username = $this->config->get('config_mail_smtp_username');
                 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
                 $mail->smtp_port = $this->config->get('config_mail_smtp_port');
                 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
                 $mail->setTo($this->config->get('config_email'));
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setReplyTo($order_info['email']);
                 $mail->setSender('Out stock Alert');
                 $mail->setSubject($subject_text);
                 $mail->setHtml($message_text);
                 $mail->send();
             }
             // Redeem coupon, vouchers and reward points
             $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);
                 }
             }
             // Add commission if sale is linked to affiliate referral.
             if ($order_info['affiliate_id'] && $this->config->get('config_affiliate_auto')) {
                 $this->load->model('affiliate/affiliate');
                 $this->model_affiliate_affiliate->addTransaction($order_info['affiliate_id'], $order_info['commission'], $order_id);
             }
         }
         // If old order status is the processing or complete status but new status is not then commence restock, and remove coupon, voucher and reward history
         if (in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && !in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
             // Restock
             $product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
             foreach ($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'");
                 $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 ($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'");
                 }
             }
             // Get serial keys from order
             $order_sk_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_serialkey WHERE order_id = '" . (int) $order_id . "'");
             // Insert serial keys back in order
             foreach ($order_sk_query->rows as $serial) {
                 $this->db->query("INSERT INTO `" . DB_PREFIX . "serialkeys` SET product_id='" . (int) $serial['order_product_id'] . "', serialkey='" . $serial['serialkey'] . "'");
             }
             // Delete serial from order
             $this->db->query("DELETE FROM `" . DB_PREFIX . "order_serialkey` WHERE order_id = '" . $order_id . "'");
             // Delete download links from order
             $this->db->query("DELETE FROM `" . DB_PREFIX . "order_downloadlink` WHERE order_id = '" . $order_id . "'");
             // Remove coupon, vouchers and reward points history
             $this->load->model('account/order');
             $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']}, 'unconfirm')) {
                     $this->{'model_total_' . $order_total['code']}->unconfirm($order_id);
                 }
             }
             // Remove commission if sale is linked to affiliate referral.
             if ($order_info['affiliate_id']) {
                 $this->load->model('affiliate/affiliate');
                 $this->model_affiliate_affiliate->deleteTransaction($order_id);
             }
         }
         $this->cache->delete('product');
         // Serialkeys
         $order_sk_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_serialkey WHERE order_id = '" . (int) $order_id . "'");
         // Download links
         $order_dl_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_downloadlink WHERE order_id = '" . (int) $order_id . "'");
         // If order status is 0 then becomes greater than 0 send main html email
         if (!$order_info['order_status_id'] && $order_status_id) {
             // Check for any downloadable products
             $download_status = false;
             $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) {
                 // Check if there are any linked downloads
                 $product_download_query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "product_to_download` WHERE product_id = '" . (int) $order_product['product_id'] . "'");
                 if ($product_download_query->row['total']) {
                     $download_status = true;
                 }
             }
             // Load the language for any mails that might be required to be sent out
             $language = new Language($order_info['language_directory']);
             $language->load($order_info['language_directory']);
             $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'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             //added by KC 10-09-2015
             $subject = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_info['order_reference']);
             // HTML Mail
             $data = array();
             $data['title'] = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id);
             $data['text_greeting'] = sprintf($language->get('text_new_greeting'), $order_info['store_name']);
             $data['text_link'] = $language->get('text_new_link');
             $message = "";
             $query = $this->db->query("SELECT order_status_id FROM " . DB_PREFIX . "order WHERE order_id = " . $order_id);
             foreach ($query->rows as $row) {
                 $order_status = $row['order_status_id'];
             }
             $query = $this->db->query("SELECT serialkey FROM " . DB_PREFIX . "order_serialkey \n\t\t\t\t\t\t\t\t\t\t\tWHERE order_id = " . $order_id);
             $complete_status = $this->config->get('config_complete_status');
             if ($query->num_rows && $order_status == $complete_status['0']) {
                 foreach ($query->rows as $row) {
                     $message .= "\n Your pin: " . strip_tags(html_entity_decode($row['serialkey'], ENT_QUOTES, 'UTF-8')) . "\n";
                 }
                 $message .= "\n";
             }
             $data['text_link2'] = $language->get('text_new_link2') . $message;
             $data['text_download'] = $language->get('text_new_download');
             $data['text_serialkey'] = $language->get('text_new_serialkey');
             $data['text_order_detail'] = $language->get('text_new_order_detail');
             $data['text_instruction'] = $language->get('text_new_instruction');
             $data['text_order_id'] = $language->get('text_new_order_id');
             $data['text_date_added'] = $language->get('text_new_date_added');
             $data['text_payment_method'] = $language->get('text_new_payment_method');
             $data['text_shipping_method'] = $language->get('text_new_shipping_method');
             $data['text_email'] = $language->get('text_new_email');
             $data['text_telephone'] = $language->get('text_new_telephone');
             $data['text_ip'] = $language->get('text_new_ip');
             $data['text_order_status'] = $language->get('text_new_order_status');
             $data['text_payment_address'] = $language->get('text_new_payment_address');
             $data['text_shipping_address'] = $language->get('text_new_shipping_address');
             $data['text_product'] = $language->get('text_new_product');
             $data['text_model'] = $language->get('text_new_model');
             $data['text_quantity'] = $language->get('text_new_quantity');
             $data['text_price'] = $language->get('text_new_price');
             $data['text_total'] = $language->get('text_new_total');
             $data['text_seriallink'] = $language->get('text_new_seriallink');
             $data['text_footer'] = $language->get('text_new_footer');
             $data['logo'] = $this->config->get('config_url') . 'image/' . $this->config->get('config_logo');
             $data['store_name'] = $order_info['store_name'];
             $data['store_url'] = $order_info['store_url'];
             $data['customer_id'] = $order_info['customer_id'];
             $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
             $data['link2'] = $order_info['store_url'] . 'index.php?route=account/serial_keys';
             if ($download_status) {
                 $data['download'] = $order_info['store_url'] . 'index.php?route=account/download';
             } else {
                 $data['download'] = '';
             }
             $data['order_id'] = $order_id;
             $data['order_reference'] = $order_info['order_reference'];
             $data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
             $data['payment_method'] = $order_info['payment_method'];
             $data['shipping_method'] = $order_info['shipping_method'];
             $data['email'] = $order_info['email'];
             $data['telephone'] = $order_info['telephone'];
             $data['ip'] = $order_info['ip'];
             $data['order_status'] = $order_status;
             if ($order_status_id == $this->config->get('config_complete_status')[0]) {
                 $message .= $language->get('text_new_link2') . "\n";
                 $message .= html_entity_decode($order_info['store_url'] . 'index.php?route=account/serial_keys', ENT_QUOTES, 'UTF-8') . "\n\n";
                 $query = $this->db->query("SELECT serialkey FROM " . DB_PREFIX . "order_serialkey\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE order_id = " . $order_id);
                 if ($query->num_rows) {
                     foreach ($query->rows as $row) {
                         $message .= "Your pin: " . strip_tags(html_entity_decode($row['serialkey'], ENT_QUOTES, 'UTF-8')) . "\n";
                     }
                 }
             }
             if ($comment && $notify) {
                 $data['comment'] = nl2br($comment);
             } else {
                 $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']);
             $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']);
             $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))));
             $this->load->model('tool/upload');
             // Products
             $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 {
                         $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                         if ($upload_info) {
                             $value = $upload_info['name'];
                         } else {
                             $value = '';
                         }
                     }
                     $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
                 }
                 $data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'information' => $this->getInfo($product['product_id'], $order_id, $order_info['language_id']), '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
             $data['vouchers'] = array();
             $order_voucher_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int) $order_id . "'");
             foreach ($order_voucher_query->rows as $voucher) {
                 $data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']));
             }
             /* added to show serials and links */
             if ($order_sk_query->num_rows) {
                 $data['serialkey'] = '';
                 foreach ($order_sk_query->rows as $sk) {
                     $data['serialkey'] .= $sk['productname'] . ": " . $sk['serialkey'] . "\n\n";
                 }
             }
             if ($order_dl_query->num_rows) {
                 $data['downloadlink'] = '';
                 foreach ($order_dl_query->rows as $dl) {
                     $data['downloadlink'] .= $dl['downloadlink'];
                 }
             }
             // 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 $total) {
                 $data['totals'][] = array('title' => $total['title'], 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']));
             }
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
                 $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
             } else {
                 $html = $this->load->view('default/template/mail/order.tpl', $data);
             }
             // 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) {
                         if ($option['type'] != 'file') {
                             $value = $option['value'];
                         } else {
                             $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                             if ($upload_info) {
                                 $value = $upload_info['name'];
                             } else {
                                 $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($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), 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";
                 }
                 $text .= $language->get('text_new_link2');
                 $text .= $order_info['store_url'] . 'index.php?route=account/serial_keys' . "\n\n";
                 if ($download_status) {
                     $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->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
                 $mail->smtp_username = $this->config->get('config_mail_smtp_username');
                 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
                 $mail->smtp_port = $this->config->get('config_mail_smtp_port');
                 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
                 $mail->setTo($order_info['email']);
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
                 $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
                 $mail->setHtml($html);
                 $mail->setText($text);
                 $mail->send();
             }
             // Admin Alert Mail
             if ($this->config->get('config_order_mail')) {
                 //$subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
                 // added by KC 10-09-2015
                 $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_info['order_reference']);
                 // HTML Mail
                 $data['text_greeting'] = $language->get('text_new_received');
                 $message .= $language->get('text_new_serialkey') . "\n";
                 $message .= $order_info['store_url'] . 'index.php?route=account/serial_keys' . "\n\n";
                 if ($comment) {
                     if ($order_info['comment']) {
                         $data['comment'] = nl2br($comment) . '<br/><br/>' . $order_info['comment'];
                     } else {
                         $data['comment'] = nl2br($comment);
                     }
                 } else {
                     if ($order_info['comment']) {
                         $data['comment'] = $order_info['comment'];
                     } else {
                         $data['comment'] = '';
                     }
                 }
                 $data['text_download'] = '';
                 $data['text_footer'] = '';
                 $data['text_link'] = '';
                 $data['link'] = '';
                 $data['download'] = '';
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
                     $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
                 } else {
                     $html = $this->load->view('default/template/mail/order.tpl', $data);
                 }
                 // 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($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), 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->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
                 $mail->smtp_username = $this->config->get('config_mail_smtp_username');
                 $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
                 $mail->smtp_port = $this->config->get('config_mail_smtp_port');
                 $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
                 $mail->setTo($this->config->get('config_email'));
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
                 $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
                 $mail->setHtml($html);
                 $mail->setText($text);
                 $mail->send();
                 // Send to additional alert emails
                 $emails = explode(',', $this->config->get('config_mail_alert'));
                 foreach ($emails as $email) {
                     if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                         $mail->setTo($email);
                         $mail->send();
                     }
                 }
             }
         }
         // If order status is not 0 then send update text email
         if ($order_info['order_status_id'] && $order_status_id && $notify) {
             $language = new Language($order_info['language_directory']);
             $language->load($order_info['language_directory']);
             $language->load('mail/order');
             $subject = sprintf($language->get('text_update_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             $message = $language->get('text_update_order') . ' ' . $order_id . "\n";
             $message .= $language->get('text_update_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) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
             if ($order_status_query->num_rows) {
                 $message .= $language->get('text_update_order_status') . "\n\n";
                 $message .= $order_status_query->row['name'] . "\n\n";
             }
             if ($order_info['customer_id']) {
                 $message .= $language->get('text_update_link') . "\n";
                 $message .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n";
             }
             $message .= $language->get('text_new_serialkey') . "\n";
             $message .= $order_info['store_url'] . 'index.php?route=account/serial_keys' . "\n\n";
             if ($comment) {
                 $message .= $language->get('text_update_comment') . "\n\n";
                 $message .= strip_tags($comment) . "\n\n";
             }
             $message .= $language->get('text_update_footer');
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
             $mail->smtp_username = $this->config->get('config_mail_smtp_username');
             $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
             $mail->smtp_port = $this->config->get('config_mail_smtp_port');
             $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
             $mail->setTo($order_info['email']);
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
             $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
             $mail->setText($message);
             $mail->send();
         }
         // If order status in the complete range create any vouchers that where in the order need to be made available.
         if (in_array($order_info['order_status_id'], $this->config->get('config_complete_status'))) {
             // Send out any gift voucher mails
             $this->load->model('checkout/voucher');
             $this->model_checkout_voucher->confirm($order_id);
         }
     }
     $this->event->trigger('post.order.history.add', $order_id);
 }
예제 #7
0
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;
}
예제 #8
0
 public function forgot()
 {
     // Redirect if user is already logged
     if ($this->auth->isLogged()) {
         $this->response->redirect($this->url->link('account/account', '', 'SSL'));
     }
     $this->document->setTitle(tt('Request a password reset'));
     $data = array();
     if ('POST' == $this->request->getRequestMethod() && $this->_validateForgot()) {
         // Reset password
         $password = substr(sha1(uniqid(mt_rand(), true)), 0, 10);
         $this->model_account_user->resetPassword($this->request->post['email'], $password);
         $mail = new Mail();
         $mail->setTo($this->request->post['email']);
         $mail->setFrom(MAIL_FROM);
         $mail->setReplyTo(MAIL_INFO);
         $mail->setSender(MAIL_SENDER);
         $mail->setSubject(tt('BitsyBay - Password recovery'));
         $mail->setText(sprintf(tt("A new password was requested from %s\n"), $this->request->post['email']) . sprintf(tt("Your new password is: %s"), $password));
         $mail->send();
         $this->session->setUserMessage(array('success' => tt('Recovery instructions sent to your email address!')));
         // Redirect to login page
         $this->response->redirect($this->url->link('account/account/login', isset($this->request->get['redirect']) ? 'redirect=' . $this->request->get['redirect'] : false, 'SSL'));
     }
     $data['error'] = $this->_error;
     $data['action'] = $this->url->link('account/account/forgot', isset($this->request->get['redirect']) ? 'redirect=' . $this->request->get['redirect'] : false, 'SSL');
     $data['href_account_account_create'] = $this->url->link('account/account/create', '', 'SSL');
     $data['href_account_account_login'] = $this->url->link('account/account/login', '', 'SSL');
     $data['href_common_information_faq'] = $this->url->link('common/information/faq');
     $data['href_common_contact'] = $this->url->link('common/contact');
     $data['footer'] = $this->load->controller('common/footer');
     $data['header'] = $this->load->controller('common/header');
     $data['email'] = isset($this->request->post['email']) ? $this->request->post['email'] : false;
     $data['module_breadcrumbs'] = $this->load->controller('module/breadcrumbs', array(array('name' => tt('Home'), 'href' => $this->url->link('common/home'), 'active' => false), array('name' => tt('Account'), 'href' => $this->url->link('account/account', '', 'SSL'), 'active' => false), array('name' => tt('Forgot'), 'href' => $this->url->link('account/account/forgot', '', 'SSL'), 'active' => true)));
     // Renter the template
     $this->response->setOutput($this->load->view('account/account/forgot.tpl', $data));
 }
예제 #9
0
 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":"*****@*****.**"}}');
 }
예제 #10
0
파일: contact.php 프로젝트: qahar/opencart
 public function index()
 {
     $this->load->language('information/contact');
     $this->document->setTitle($this->language->get('heading_title'));
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
         $mail->smtp_username = $this->config->get('config_mail_smtp_username');
         $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
         $mail->smtp_port = $this->config->get('config_mail_smtp_port');
         $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
         $mail->setTo($this->config->get('config_email'));
         $mail->setFrom($this->config->get('config_email'));
         $mail->setReplyTo($this->request->post['email']);
         $mail->setSender(html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8'));
         $mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
         $mail->setText($this->request->post['enquiry']);
         $mail->send();
         $this->response->redirect($this->url->link('information/contact/success'));
     }
     $data['breadcrumbs'] = array();
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('information/contact'));
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_location'] = $this->language->get('text_location');
     $data['text_store'] = $this->language->get('text_store');
     $data['text_contact'] = $this->language->get('text_contact');
     $data['text_address'] = $this->language->get('text_address');
     $data['text_telephone'] = $this->language->get('text_telephone');
     $data['text_fax'] = $this->language->get('text_fax');
     $data['text_open'] = $this->language->get('text_open');
     $data['text_comment'] = $this->language->get('text_comment');
     $data['entry_name'] = $this->language->get('entry_name');
     $data['entry_email'] = $this->language->get('entry_email');
     $data['entry_enquiry'] = $this->language->get('entry_enquiry');
     $data['button_map'] = $this->language->get('button_map');
     if (isset($this->error['name'])) {
         $data['error_name'] = $this->error['name'];
     } else {
         $data['error_name'] = '';
     }
     if (isset($this->error['email'])) {
         $data['error_email'] = $this->error['email'];
     } else {
         $data['error_email'] = '';
     }
     if (isset($this->error['enquiry'])) {
         $data['error_enquiry'] = $this->error['enquiry'];
     } else {
         $data['error_enquiry'] = '';
     }
     $data['button_submit'] = $this->language->get('button_submit');
     $data['action'] = $this->url->link('information/contact', '', true);
     $this->load->model('tool/image');
     if ($this->config->get('config_image')) {
         $data['image'] = $this->model_tool_image->resize($this->config->get('config_image'), $this->config->get($this->config->get('config_theme') . '_image_location_width'), $this->config->get($this->config->get('config_theme') . '_image_location_height'));
     } else {
         $data['image'] = false;
     }
     $data['store'] = $this->config->get('config_name');
     $data['address'] = nl2br($this->config->get('config_address'));
     $data['geocode'] = $this->config->get('config_geocode');
     $data['geocode_hl'] = $this->config->get('config_language');
     $data['telephone'] = $this->config->get('config_telephone');
     $data['fax'] = $this->config->get('config_fax');
     $data['open'] = nl2br($this->config->get('config_open'));
     $data['comment'] = $this->config->get('config_comment');
     $data['locations'] = array();
     $this->load->model('localisation/location');
     foreach ((array) $this->config->get('config_location') as $location_id) {
         $location_info = $this->model_localisation_location->getLocation($location_id);
         if ($location_info) {
             if ($location_info['image']) {
                 $image = $this->model_tool_image->resize($location_info['image'], $this->config->get($this->config->get('config_theme') . '_image_location_width'), $this->config->get($this->config->get('config_theme') . '_image_location_height'));
             } else {
                 $image = false;
             }
             $data['locations'][] = array('location_id' => $location_info['location_id'], 'name' => $location_info['name'], 'address' => nl2br($location_info['address']), 'geocode' => $location_info['geocode'], 'telephone' => $location_info['telephone'], 'fax' => $location_info['fax'], 'image' => $image, 'open' => nl2br($location_info['open']), 'comment' => $location_info['comment']);
         }
     }
     if (isset($this->request->post['name'])) {
         $data['name'] = $this->request->post['name'];
     } else {
         $data['name'] = $this->customer->getFirstName();
     }
     if (isset($this->request->post['email'])) {
         $data['email'] = $this->request->post['email'];
     } else {
         $data['email'] = $this->customer->getEmail();
     }
     if (isset($this->request->post['enquiry'])) {
         $data['enquiry'] = $this->request->post['enquiry'];
     } else {
         $data['enquiry'] = '';
     }
     // Captcha
     if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('contact', (array) $this->config->get('config_captcha_page'))) {
         $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'), $this->error);
     } else {
         $data['captcha'] = '';
     }
     $data['column_left'] = $this->load->controller('common/column_left');
     $data['column_right'] = $this->load->controller('common/column_right');
     $data['content_top'] = $this->load->controller('common/content_top');
     $data['content_bottom'] = $this->load->controller('common/content_bottom');
     $data['footer'] = $this->load->controller('common/footer');
     $data['header'] = $this->load->controller('common/header');
     $this->response->setOutput($this->load->view('information/contact', $data));
 }
예제 #11
0
// Language
$language = new Language($registry, $request, DEFAULT_LANGUAGE_ID);
$registry->set('language', $language);
// Currency
$currency = new Currency($registry, DEFAULT_CURRENCY_ID);
$registry->set('currency', $currency);
// Currency
$ffmpeg = new FFmpeg(FFMPEG_PATH);
$registry->set('ffmpeg', $ffmpeg);
// Cache
$cache = new Cache($registry);
$registry->set('cache', $cache);
// Email
$mail = new Mail();
$mail->setFrom(MAIL_EMAIL_SENDER_ADDRESS);
$mail->setReplyTo(MAIL_EMAIL_SENDER_ADDRESS);
$mail->setSender(MAIL_EMAIL_SENDER_NAME);
$registry->set('mail', $mail);
// Storage
$storage = new Storage($registry);
$registry->set('storage', $storage);
// Document
$registry->set('document', new Document());
// Auth
$auth = new Auth($registry);
$registry->set('auth', $auth);
// Security log
$security_log = new Log('security.txt', $auth->getId(), $request->getRemoteAddress());
$registry->set('security_log', $security_log);
// Tracking Code
if (isset($request->get['ref'])) {
예제 #12
0
 public function addOrderHistory($order_id, $order_status_id, $comment = '', $notify = false, $code_tracking = '', $subtract_stock = true, $user_log = 'loja')
 {
     $this->event->trigger('pre.order.history.add', $order_id);
     $order_info = $this->getOrder($order_id);
     if ($order_info) {
         // Fraud Detection
         $this->load->model('account/customer');
         $customer_info = $this->model_account_customer->getCustomer($order_info['customer_id']);
         if ($customer_info && $customer_info['safe']) {
             $safe = true;
         } else {
             $safe = false;
         }
         if ($this->config->get('config_fraud_detection')) {
             $this->load->model('checkout/fraud');
             $risk_score = $this->model_checkout_fraud->getFraudScore($order_info);
             if (!$safe && $risk_score > $this->config->get('config_fraud_score')) {
                 $order_status_id = $this->config->get('config_fraud_status_id');
             }
         }
         // Ban IP
         if (!$safe) {
             $status = false;
             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 . "', code_tracking = '" . $code_tracking . "', date_modified = NOW(), date_last_order_history = NOW() WHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("DELETE FROM " . DB_PREFIX . "order_history WHERE order_id = '" . (int) $order_id . "' AND order_status_id = '" . (int) $order_status_id . "'");
         $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '" . (int) $notify . "', comment = '" . $this->db->escape($comment) . "', user_log = '" . $user_log . "', date_added = NOW()");
         $this->cache->delete('order_status');
         if ($subtract_stock) {
             // Stock subtraction
             $order_product_query = $this->db->query("SELECT order_product_id, quantity, product_id FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
             // Customer Cart
             $this->db->query("DELETE FROM " . DB_PREFIX . "customer_cart WHERE session_id = '" . $this->session->getId() . "'");
             if (isset($this->session->data['cart_id'])) {
                 $this->db->query("UPDATE " . DB_PREFIX . "customer_cart SET order_id = '" . (int) $order_id . "' WHERE md5(customer_cart_id) = '" . $this->session->data['cart_id'] . "'");
             }
             // Customer Cart
             foreach ($order_product_query->rows as $order_product) {
                 $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->db->query("DELETE FROM " . DB_PREFIX . "stock_temporary WHERE product_id = '" . (int) $order_product['product_id'] . "' AND session_id = '" . session_id() . "'");
                 }
             }
         }
         // Redeem coupon, vouchers and reward points
         $order_total_query = $this->db->query("SELECT code, order_id, title, value, sort_order 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);
             }
         }
         // Add commission if sale is linked to affiliate referral.
         if ($order_info['affiliate_id'] && $this->config->get('config_affiliate_auto')) {
             $this->load->model('affiliate/affiliate');
             $this->model_affiliate_affiliate->addTransaction($order_info['affiliate_id'], $order_info['commission'], $order_id);
         }
         // Remove commission if sale is linked to affiliate referral.
         if ($order_info['affiliate_id']) {
             $this->load->model('affiliate/affiliate');
             $this->model_affiliate_affiliate->deleteTransaction($order_id);
         }
         $this->cache->delete('product');
         // If order status is 0 then becomes greater than 0 send main html email
         if (!$order_info['order_status_id'] && $order_status_id && $order_status_id != $this->config->get('config_status_canceled') && $order_info['payment_code'] != 'out_ecommerce') {
             // Check for any downloadable products
             $download_status = false;
             $order_product_query = $this->db->query("SELECT op.product_id, op.order_product_id, op.order_id, op.name, op.model, op.quantity, op.price, op.price_attacked ,op.total, op.total_attacked, op.reward, p.image FROM " . DB_PREFIX . "order_product op INNER JOIN " . DB_PREFIX . "product p ON (op.product_id = p.product_id) WHERE op.order_id = '" . (int) $order_id . "'");
             foreach ($order_product_query->rows as $order_product) {
                 // Check if there are any linked downloads
                 $product_download_query = $this->db->query("SELECT COUNT(product_id) AS total FROM `" . DB_PREFIX . "product_to_download` WHERE product_id = '" . (int) $order_product['product_id'] . "'");
                 if ($product_download_query->row['total']) {
                     $download_status = true;
                 }
             }
             // Load the language for anytext_name mails that might be required to be sent out
             $language = new Language($order_info['language_directory']);
             $language->load('default');
             $language->load('mail/order');
             $order_status_query = $this->db->query("SELECT name FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_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
             $data = array();
             $data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
             $data['url_store'] = $this->config->get('config_url');
             $data['text_cnpj'] = $language->get('text_cnpj');
             $data['billet_print'] = $language->get('billet_print');
             $data['billet_printing'] = $language->get('billet_printing');
             $data['text_ie'] = $language->get('text_ie');
             $data['text_greeting'] = $language->get('text_new_greeting');
             $data['text_url_store'] = $language->get('text_url_store');
             $data['text_link'] = $language->get('text_update_link');
             $data['text_download'] = $language->get('text_new_download');
             $data['text_order_detail'] = $language->get('text_new_order_detail');
             $data['text_instruction'] = $language->get('text_new_instruction');
             $data['text_name'] = $language->get('text_name');
             $data['text_cpf_cnpj'] = $language->get('text_cpf_cnpj');
             $data['text_rg_ie'] = $language->get('text_rg_ie');
             $data['text_order_id'] = $language->get('text_new_order_id');
             $data['text_date_added'] = $language->get('text_new_date_added');
             $data['text_payment_method'] = $language->get('text_new_payment_method');
             $data['text_shipping_method'] = $language->get('text_new_shipping_method');
             $data['text_email'] = $language->get('text_new_email');
             $data['text_telephone'] = $language->get('text_new_telephone');
             $data['text_ip'] = $language->get('text_new_ip');
             $data['text_image'] = $language->get('text_image');
             $data['text_order_status'] = $language->get('text_new_order_status');
             $data['text_payment_address'] = $language->get('text_new_payment_address');
             $data['text_shipping_address'] = $language->get('text_new_shipping_address');
             $data['text_product'] = $language->get('text_new_product');
             $data['text_model'] = $language->get('text_new_model');
             $data['text_quantity'] = $language->get('text_new_quantity');
             $data['text_price'] = $language->get('text_new_price');
             $data['text_total'] = $language->get('text_new_total');
             $data['text_footer'] = $language->get('text_new_footer');
             $data['logo'] = $this->config->get('config_url') . 'image/' . $this->config->get('config_logo');
             $data['store_name'] = $order_info['store_name'];
             $data['store_url'] = $order_info['store_url'];
             $data['customer_id'] = $order_info['customer_id'];
             $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
             if ($download_status) {
                 $data['download'] = $order_info['store_url'] . 'index.php?route=account/download';
             } else {
                 $data['download'] = '';
             }
             if (isset($this->session->data['url'])) {
                 if ($this->session->data['payment_method']['code'] == 'pagseguro_billet' || $this->session->data['payment_method']['code'] == 'moip_billet' || $this->session->data['payment_method']['code'] == 'bcash_billet' || $this->session->data['payment_method']['code'] == 'payu_billet' || $this->session->data['payment_method']['code'] == 'bb_generic_billet' || $this->session->data['payment_method']['code'] == 'caixa_generic_billet' || $this->session->data['payment_method']['code'] == 'santander_generic_billet' || $this->session->data['payment_method']['code'] == 'braspag_billet') {
                     $data['link_billet'] = $this->session->data['url'];
                     $data['link_billet_form'] = '';
                 } else {
                     if ($this->session->data['payment_method']['code'] == 'bb_billet' || $this->session->data['payment_method']['code'] == 'itau_billet') {
                         $data['link_billet_form'] = $this->session->data['url'];
                         $data['link_billet'] = '';
                     } else {
                         $data['link_billet'] = '';
                         $data['link_billet_form'] = '';
                     }
                 }
             } else {
                 $data['link_billet'] = '';
                 $data['link_billet_form'] = '';
             }
             $data['url_store'] = $this->config->get('config_url');
             $data['name_store'] = $this->config->get('config_name');
             $data['config_name'] = $this->config->get('config_name');
             $data['config_email'] = $this->config->get('config_email');
             $data['config_cnpj_store'] = $this->config->get('config_cnpj_store');
             $data['config_ie'] = $this->config->get('config_ie');
             $data['config_address_number'] = $this->config->get('config_address_number');
             $data['config_address_number'] = $this->config->get('config_address_number');
             $data['config_highlights_store'] = $this->config->get('config_highlights_store');
             $data['store_city_store'] = $this->config->get('config_city_store');
             $data['store_zone_id'] = $this->getZone($this->config->get('config_zone_id'));
             $data['config_telephone'] = $this->config->get('config_telephone');
             $data['config_address'] = $this->config->get('config_address');
             $data['invoice'] = $order_info['store_url'] . 'index.php?route=account/history';
             $time_date = explode(" ", $order_info['date_added']);
             $schedule = explode(":", $time_date[1]);
             $data['time'] = $schedule[0];
             $data['minutes'] = $schedule[1];
             $data['firstname'] = $order_info['firstname'];
             $data['lastname'] = $order_info['lastname'];
             $data['cpf_cnpj'] = $order_info['cpf_cnpj'];
             $data['rg_ie'] = $order_info['rg_ie'];
             $data['order_id'] = $order_id;
             $data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
             $data['payment_method'] = $order_info['payment_method'];
             $data['shipping_method'] = $order_info['shipping_method'];
             $data['email'] = $order_info['email'];
             $data['telephone'] = $order_info['telephone'];
             $data['cellphone'] = $order_info['cellphone'];
             $data['ip'] = $order_info['ip'];
             $data['order_status'] = $order_status;
             $data['attacked_status'] = $order_info['attacked_status'];
             if ($comment && $notify) {
                 $data['comment'] = nl2br($comment);
             } else {
                 if ($order_info['payment_code'] == 'deposit') {
                     $data['comment'] = '<br />' . $this->config->get('deposit_data');
                 } else {
                     $data['comment'] = '';
                 }
             }
             if ($order_info['payment_address_format']) {
                 $format = $order_info['payment_address_format'];
             } else {
                 $format = '{firstname} {lastname}' . "\n" . '{address_1}, {number_home}' . "\n" . '{address_2}' . "\n" . '{neighborhood}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
             }
             $find = array('{firstname}', '{lastname}', '{number_home}', '{address_1}', '{neighborhood}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
             $replace = array('firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'address_1' => $order_info['payment_address_1'], 'number_home' => $order_info['payment_number_home'], 'address_2' => $order_info['payment_address_2'], 'neighborhood' => $order_info['payment_neighborhood'], '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']);
             $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" . '{address_1}, {number_home}' . "\n" . '{address_2}' . "\n" . '{neighborhood}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
             }
             $find = array('{firstname}', '{lastname}', '{number_home}', '{address_1}', '{address_2}', '{neighborhood}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
             $replace = array('firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'address_1' => $order_info['shipping_address_1'], 'number_home' => $order_info['shipping_number_home'], 'address_2' => $order_info['shipping_address_2'], 'neighborhood' => $order_info['shipping_neighborhood'], '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']);
             $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))));
             $this->load->model('tool/upload');
             $this->load->model('tool/image');
             // Products
             $data['products'] = array();
             foreach ($order_product_query->rows as $product) {
                 $option_data = array();
                 $order_option_query = $this->db->query("SELECT type, value, name 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 {
                         $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                         if ($upload_info) {
                             $value = $upload_info['name'];
                         } else {
                             $value = '';
                         }
                     }
                     $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
                 }
                 if ($product['image']) {
                     $thumbs = $this->model_tool_image->resize($product['image'], '45', '45');
                 } else {
                     $thumbs = $this->model_tool_image->resize('placeholder.png', '45', '45');
                 }
                 $data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'thumbs' => $thumbs, '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']), 'price_attacked' => $this->currency->format($product['price_attacked'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), 'total_attacked' => $this->currency->format($product['total_attacked'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']));
             }
             // Vouchers
             $data['vouchers'] = array();
             $order_voucher_query = $this->db->query("SELECT description, amount FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int) $order_id . "'");
             foreach ($order_voucher_query->rows as $voucher) {
                 $data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount']));
             }
             // Order Totals
             $order_total_query = $this->db->query("SELECT title, value FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC");
             foreach ($order_total_query->rows as $total) {
                 $data['totals'][] = array('title' => $total['title'], 'text' => $this->currency->format($total['value']));
             }
             $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);
             }
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
                 $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
             } else {
                 $html = $this->load->view('default/template/mail/order.tpl', $data);
             }
             // 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 type, name, value 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 {
                         $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                         if ($upload_info) {
                             $value = $upload_info['name'];
                         } else {
                             $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']);
             }
             $text .= "\n";
             $text .= $language->get('text_new_order_total') . "\n";
             foreach ($order_total_query->rows as $total) {
                 $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value']), 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 ($download_status) {
                 $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($this->config->get('config_mail'));
             $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($text);
             $mail->send();
             if ($this->config->get('config_order_mail')) {
                 $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
                 $data['text_greeting'] = $language->get('text_new_received');
                 if ($comment) {
                     if ($order_info['comment']) {
                         $data['comment'] = nl2br($comment) . '<br/><br/>' . $order_info['comment'];
                     } else {
                         $data['comment'] = nl2br($comment);
                     }
                 } else {
                     if ($order_info['comment']) {
                         $data['comment'] = $order_info['comment'];
                     } else {
                         $data['comment'] = '';
                     }
                 }
                 $data['text_download'] = '';
                 $data['text_footer'] = '';
                 $data['text_link'] = '';
                 $data['link'] = '';
                 $data['download'] = '';
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
                     $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data);
                 } else {
                     $html = $this->load->view('default/template/mail/order.tpl', $data);
                 }
                 $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']);
                 }
                 $text .= "\n";
                 $text .= $language->get('text_new_order_total') . "\n";
                 foreach ($order_total_query->rows as $total) {
                     $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value']), 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($this->config->get('config_mail'));
                 $mail->setTo($this->config->get('config_email'));
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setReplyTo($order_info['email']);
                 $mail->setSender($order_info['store_name']);
                 $mail->setSubject($subject);
                 $mail->setHtml($html);
                 $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
                 $mail->send();
                 // Send to additional alert emails
                 $emails = explode(',', $this->config->get('config_mail_alert'));
                 foreach ($emails as $email) {
                     if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                         $mail->setTo($email);
                         $mail->send();
                     }
                 }
             }
         }
         // If order status is not 0 then send update text email
         if ($order_info['order_status_id'] && $order_status_id && $notify) {
             $language = new Language($order_info['language_directory']);
             $language->load('default');
             $language->load('mail/order');
             $data['url_store'] = $this->config->get('config_url');
             $data['logo_store'] = $data['url_store'] . 'image/' . $this->config->get('config_logo');
             $data['name_store'] = $this->config->get('config_name');
             $data['subject'] = sprintf($language->get('text_update_subject'), html_entity_decode($data['name_store'], ENT_QUOTES, 'UTF-8'), $order_id);
             $data['text_update_order'] = $language->get('text_update_order') . ' <b>' . $order_id . "</b><br/>";
             $data['text_update_date_added'] = $language->get('text_update_date_added') . ' <b>' . date($language->get('datetime_format'), strtotime($order_info['date_added'])) . "</b>";
             $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'] . "'");
             $data['order_status'] = $order_status_query->num_rows;
             $data['text_update_order_status'] = $language->get('text_update_order_status');
             $data['order_name'] = $order_status_query->row['name'];
             $data['text_code'] = "Segue abaixo o link para rastreio de sua encomenda:";
             $data['order_status_id'] = $order_status_id;
             $data['code_tracking'] = $code_tracking;
             $data['customer_id'] = $order_info['customer_id'];
             $data['text_update_link'] = $language->get('text_update_link');
             $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
             $data['comment'] = $comment;
             $data['text_update_comment'] = $language->get('text_update_comment');
             $data['text_coment'] = strip_tags($comment);
             $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);
             }
             $data['history_timeline'] = file_get_contents(HTTP_SERVER . 'index.php?route=api/order/history_timeline&source=email&order_id=' . $order_info['order_id']);
             //exit($message);
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order_status.tpl')) {
                 $html = $this->load->view($this->config->get('config_template') . '/template/mail/order_status.tpl', $data);
             } else {
                 $html = $this->load->view('default/template/mail/order_status.tpl', $data);
             }
             $subject = sprintf($language->get('text_update_subject'), html_entity_decode($data['name_store'], ENT_QUOTES, 'UTF-8'), $order_id);
             $mail = new Mail($this->config->get('config_mail'));
             $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->send();
             // Send to additional alert emails
             $emails = explode(',', $this->config->get('config_mail_alert'));
             foreach ($emails as $email) {
                 if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
                     $mail->setTo($email);
                     $mail->send();
                 }
             }
         }
         // Send out any gift voucher mails
         $this->load->model('checkout/voucher');
         $this->model_checkout_voucher->confirm($order_id);
     }
     $this->event->trigger('post.order.history.add', $order_id);
 }
예제 #13
0
        $text .= sprintf("\tBuyer #%s\n", $approved_order['buyer_id']);
        $text .= sprintf("\tSeller #%s\n", $approved_order['seller_id']);
        $text .= sprintf("\tProduct #%s\n", $approved_order['product_id']);
        $text .= sprintf("\tAmount: %s / Currency #%s\n", $approved_order['amount'], $approved_order['currency_id']);
        $text .= sprintf("\tWithdraw address: %s\n", $approved_order['withdraw_address']);
        $text .= sprintf("\tApproved time: %s\n\n", $approved_order['date']);
    }
}
// Withdraw to the Bank Storage if Current Balance more than 0
$total_balance = $bitcoin->getbalance();
if (BITCOIN_STORAGE_WITHDRAW_ENABLED && 0 < $total_balance && $total_balance > BITCOIN_STORAGE_WITHDRAW_MINIMUM_AMOUNT) {
    if ($bitcoin->sendtoaddress(BITCOIN_STORAGE_WITHDRAW_ADDRESS, $total_balance, 'BITSYBAY BACKUP')) {
        $text .= "\n\nFund " . $total_balance . ' BTC has been send to the reserve address ' . BITCOIN_STORAGE_WITHDRAW_ADDRESS . ' at ' . date('d.m.y H:i:s');
    } else {
        $text .= "\n\nFund " . $total_balance . ' BTC has not been send to the reserve address ' . BITCOIN_STORAGE_WITHDRAW_ADDRESS . ' at ' . date('d.m.y H:i:s');
        $text .= sprintf("\nReason: %s", $bitcoin->error);
    }
}
// Send billing report
if (!empty($text)) {
    $mail = new Mail();
    $mail->setTo(MAIL_BILLING);
    $mail->setFrom(MAIL_FROM);
    $mail->setReplyTo(MAIL_INFO);
    $mail->setSender(MAIL_SENDER);
    $mail->setSubject('BitsyBay - ORDER PROCESSOR REPORT');
    $mail->setText($text);
    $mail->send();
}
// Output response
die('Done.');
예제 #14
0
 public function report()
 {
     // Check request
     if (!$this->request->isAjax()) {
         $this->security_log->write('Try to send report without ajax request');
         exit;
     }
     // Set variables
     $product_id = (int) isset($this->request->post['product_id']) ? $this->request->post['product_id'] : 0;
     $message = (int) isset($this->request->post['message']) ? $this->request->post['message'] : false;
     if ($this->model_catalog_product->createReport($product_id, $message, $this->auth->getId())) {
         $json = array('status' => 200, 'title' => tt('Report successfully sent!'), 'message' => tt('Your message will be reviewed in the near time.'));
         $mail = new Mail();
         $mail->setTo(MAIL_INFO);
         $mail->setFrom(MAIL_FROM);
         $mail->setReplyTo(MAIL_FROM);
         $mail->setSender(MAIL_SENDER);
         $mail->setSubject(tt('Report for product_id #' . $product_id));
         $mail->setText($this->request->post['message']);
         $mail->send();
     } else {
         $json = array('status' => 500, 'title' => tt('Connection error'), 'message' => tt('Please, try again later'));
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }