/** * sendEmail */ public function sendEmail($node_detail) { if (!is_array($node_detail)) { return false; } require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //setup mail data $content = print_r($node_detail, true); $mail_to = $node_detail['author_detail']['email']; $mail_to_name = $node_detail['author_detail']['name']; $mail_from = false; // use system default $mail_from_name = false; // use system default $_GET['node_id'] = $node_detail['id']; //send mail if ($EmailForm->sendEmail($this->mail_template, $content, $mail_to, $mail_to_name, $mail_from, $mail_from_name)) { msg("Email to {$mail_to} has been sent"); return true; } else { msg("Cannot send email", 'error'); return false; } }
/** * process form send action */ public function processEmailForm($formdata) { if (!is_array($formdata)) { return false; } require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $content = $EmailForm->exploreFormData($formdata); $node_id = (int) $this->GET['node_id']; $reg_key = "form_notify_" . $node_id; if ($this->GET['mail_to'] == '') { $mail_to = $EmailForm->conf['mail_recipient_address']; $mail_toname = $EmailForm->conf['mail_recipient_name']; } else { $mail_to = $this->GET['mail_to']; $mail_toname = $this->GET['mail_toname']; } if ($this->enableCaptcha) { $word = strtolower($_SESSION['captcha'][$node_id]); $isCaptchaValid = strlen($formdata['captcha']) > 0 && $formdata['captcha'] == $word; $EmailForm->setValid("captcha", $isCaptchaValid); } if ($EmailForm->sendEmail('contact_form', $content, $mail_to, $mail_toname, $formdata['required_email'], $formdata['required_name'])) { Zend_Registry::set($reg_key, 'sent'); } else { Zend_Registry::set($reg_key, 'failed'); $this->tpl->assign('FORMDATA', $formdata); } return true; }
/** * main action */ public function mainAction() { /** * client */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($_POST['submit']) { $customer_data = $Customer->getClientByEmail($_POST['client']['customer']['email']); if (is_array($customer_data)) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['customer'] = $customer_data; if (!$EmailForm->sendEmail('password_reminder', 'n/a', $customer_data['email'], $customer_data['first_name'] . " " . $customer_data['last_name'])) { msg("Can't send email with password reminder", 'error'); } $this->tpl->parse('content.password_sent'); $hide_form = 1; } } if ($hide_form == 0) { $this->tpl->parse('content.request_form'); } //sanitize before we add HTML attribute checked="checked" :) if (is_array($_POST['client'])) { $this->tpl->assign('CLIENT', $_POST['client']); } return true; }
protected function displaySentEmails() { $EmailForm = new common_email(); $EmailForm->setCacheable(false); $email = pg_escape_string($_SESSION['client']['customer']['email']); $emails = $EmailForm->listing("email_from = '{$email}' AND template = 'referral_invite'", "created DESC"); if (is_array($emails) && count($emails) > 0) { foreach ($emails as $email) { $this->tpl->assign("ITEM", $email); $this->tpl->parse("content.email_list.email"); } $this->tpl->parse("content.email_list"); } }
/** * prepare data for payment gateway */ function prepare($order_id) { $order_data = $this->Transaction->getOrderDetail($order_id); // send email to the customer require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~"); $order_data['order_detail'] = $_Onxshop_Request->getContent(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['transaction'] = $transaction_data; $GLOBALS['common_email']['order'] = $order_data; if (!$EmailForm->sendEmail('pay_by_cheque', 'n/a', $order_data['client']['customer']['email'], $order_data['client']['customer']['first_name'] . " " . $order_data['client']['customer']['last_name'])) { msg('payment: Cant send email pay_by_cheque.', 'error', 2); } }
/** * notify about created backup */ private function notificationEmail() { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $mail_to = ONXSHOP_SUPPORT_EMAIL; $mail_toname = ONXSHOP_SUPPORT_NAME; $content = array(); if ($EmailForm->sendEmail('backup_created', $content, $mail_to, $mail_toname, $EmailForm->conf['mail_recipient_address'], $EmailForm->conf['mail_recipient_name'])) { Zend_Registry::set('notify', 'sent'); } else { Zend_Registry::set('notify', 'failed'); } }
/** * sendCSVEmail */ public function sendCSVEmail($email, $filename = 'unknown') { // get content $this->tpl->parse('content'); $text = $this->tpl->text('content'); $export_file = ONXSHOP_PROJECT_DIR . "var/tmp/{$filename}.csv"; file_put_contents($export_file, $text); // send email $GLOBALS['common_email'] = array('date_from' => date("d/m/Y", strtotime("first day of last month")), 'date_to' => date("d/m/Y", strtotime("first day of this month"))); $GLOBALS['onxshop_atachments'] = array($export_file); $EmailForm = new common_email(); $template = 'notices_report'; $content = 'NA'; $email_recipient = $email; $name_recipient = false; $email_from = false; $name_from = false; $email_sent_status = $EmailForm->sendEmail($template, $content, $email_recipient, $name_recipient, $email_from, $name_from); unset($GLOBALS['common_email']); unset($GLOBALS['onxshop_atachments']); return $email_sent_status; }
/** * notify about created backup */ private function notificationEmail($filename) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $mail_to = ONXSHOP_SUPPORT_EMAIL; $mail_toname = ONXSHOP_SUPPORT_NAME; $file_info = $this->getFileInfo($filename); $content = print_r($file_info, true); if ($EmailForm->sendEmail('backup_created', $content, $mail_to, $mail_toname)) { Zend_Registry::set('notify', 'sent'); } else { Zend_Registry::set('notify', 'failed'); } }
/** * process callback */ function paymentProcess($order_id, $crypt) { //hack for changing white space to + sign $crypt = str_replace(' ', '+', $crypt); require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); //decode crypt $decoded = self::decryptAes($crypt, ECOMMERCE_TRANSACTION_PROTX_PASSWORD); //explode protx data parse_str($decoded, $response); $this->msgProtxStatus($response['Status']); $order_data = $Order->getOrder($order_id); $transaction_data['order_id'] = $order_data['id']; $transaction_data['pg_data'] = serialize($response); $transaction_data['currency_code'] = GLOBAL_DEFAULT_CURRENCY; if (is_numeric($response['Amount'])) { $transaction_data['amount'] = $response['Amount']; } else { $transaction_data['amount'] = 0; } $transaction_data['created'] = date('c'); $transaction_data['type'] = 'protx'; if ($response['Status'] == 'OK') { $transaction_data['status'] = 1; } else { $transaction_data['status'] = 0; } /** * insert */ if ($id = $this->Transaction->insert($transaction_data)) { // in payment_success must be everytime Status OK if ($response['Status'] == 'OK') { $Order->setStatus($order_id, 1); //send email to admin require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~"); $order_data['order_detail'] = $_Onxshop_Request->getContent(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['transaction'] = $transaction_data; $GLOBALS['common_email']['order'] = $order_data; if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $order_data['client']['customer']['email'], $order_data['client']['customer']['first_name'] . " " . $order_data['client']['customer']['last_name'])) { msg('ecommerce_transaction: Cant send email.', 'error', 2); } if ($Order->conf['mail_to_address']) { if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $Order->conf['mail_to_address'], $Order->conf['mail_to_name'])) { msg('ecommerce_transaction: Cant send email.', 'error', 2); } } } else { $Order->setStatus($order_id, 5); } return $id; } else { //to be sure... if ($response['Status'] == 'OK') { msg("Payment for order {$order_id} was successfully Authorised, but I cant save the transaction TxAuthNo {$pg_data['TxAuthNo']}!", 'error'); } msg("payment/protx: cannot insert serialized pg_data: {$transaction_data['pg_data']}", 'error'); return false; } }
/** * main action */ public function mainAction() { /** * initialise client_customer object */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); /** * process when submited */ if ($_POST['submit']) { /** * assign first */ if (is_array($_POST['client'])) { $this->tpl->assign('CLIENT', $_POST['client']); } /** * get detail */ $customer_data = $Customer->getClientByEmail($_POST['client']['customer']['email']); /** * when real client, get key */ if (is_array($customer_data)) { $current_key = $Customer->getPasswordKey($_POST['client']['customer']['email']); $customer_data['password_key'] = $current_key; } /** * if key was generated successfully, than send it by email */ if ($current_key) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['customer'] = $customer_data; if (!$EmailForm->sendEmail('request_password_change', 'n/a', $customer_data['email'], $customer_data['first_name'] . " " . $customer_data['last_name'])) { msg("Can't send email with request for password reset", 'error'); } $this->tpl->parse('content.request_sent'); $hide_form = 1; } } /** * reset password when valied email and key is provided */ if ($this->GET['email'] && $this->GET['key']) { if ($Customer->resetPassword($this->GET['email'], $this->GET['key'])) { msg("Password for {$this->GET['email']} has for been renewed.", 'ok', 2); $this->tpl->parse('content.password_changed'); $hide_form = 1; } } /** * conditional display form */ if ($hide_form == 0) { $this->tpl->parse('content.request_form'); } return true; }
/** * sendEmail */ public function sendEmail() { require_once 'models/common/common_email.php'; $CommonEmail = new common_email(); require_once 'models/ecommerce/ecommerce_order.php'; $ecommerce_order_conf = ecommerce_order::initConfiguration(); //admin_email_name $template = 'return'; $content = $this->getResultHtml(); $email_recipient = $ecommerce_order_conf['product_returns_mail_to_address']; $name_recipient = $ecommerce_order_conf['product_returns_mail_to_name']; $email_from = $_SESSION['client']['customer']['email']; $name_from = "{$_SESSION['client']['customer']['first_name']} {$_SESSION['client']['customer']['last_name']}"; if ($CommonEmail->sendEmail($template, $content, $email_recipient, $name_recipient, $email_from, $name_from)) { return true; } else { return false; } }
/** * insert a new order * * @return unknown */ function insertOrder($order_data) { // set status to 0 (Not processed payment) $order_data['status'] = 0; $insert_order_data = $order_data; $insert_order_data['other_data'] = serialize($insert_order_data['other_data']); $insert_order_data['created'] = date('c'); $insert_order_data['modified'] = date('c'); if (is_numeric($id = $this->insert($insert_order_data))) { $order_data['id'] = $id; //insert delivery record //need to be inserted before recording usage of promotion code, otherwise delivery calculation thinks coupon has be already used when uses_per_customer = 1 if (!$this->insertDelivery($order_data)) { msg("Cannot insert delivery data", 'error'); return false; } //record promotion code use if ($order_data['other_data']['promotion_code']) { require_once 'models/ecommerce/ecommerce_promotion_code.php'; $Promotion_code = new ecommerce_promotion_code(); if ($inserted_code_id = $Promotion_code->insertPromotionCode($order_data['other_data']['promotion_code'], $order_data['id'])) { // } else { msg("Can't insert promotion code {$order_data['other_data']['promotion_code']} ", 'error'); } } //get full order data $order_data = $this->getOrder($id); //descrement stock $this->decrementStock($order_data); // calculate payable amount $this->updatePayableDue($order_data); //set status $this->setStatus($id, 0); //send email to admin require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~"); $order_data['order_detail'] = $_Onxshop_Request->getContent(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['order'] = $order_data; if ($this->conf['mail_unpaid']) { if (!$EmailForm->sendEmail('new_order_unpaid', 'n/a', $this->conf['mail_to_address'], $this->conf['mail_to_name'])) { msg("ecommerce_order: can't send email", 'error', 2); } } //return order.id return $id; } else { return false; } }
/** * process callback */ function paymentProcess($order_id, $crypt) { //hack for changing white space to + sign $crypt = str_replace(' ', '+', $crypt); require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); require_once 'lib/protx.functions.php'; //decode crypt $pg_data_x = simpleXor(base64Decode($crypt), ECOMMERCE_TRANSACTION_PROTX_PASSWORD); //explode protx data $pg_data = getToken($pg_data_x); /** * PROTX: * vpstxid [int] * avscv2 [int] * txauthno[int] * vpsstatus[int] */ /* $pg_data_x = explode('&', $pg_data_x); for ($i=1; $i<count($pg_data_x); $i++) { $param = explode('=', $pg_data_x[$i]); $pg_data[$param[0]] = $param[1]; } */ //print_r($pg_data); // check if $pg_data['VendorTxCode'] = $_GET['order_id'] $this->msgProtxStatus($pg_data['Status']); $order_data = $Order->getOrder($order_id); //print_r($order_data); /** * optional: save only orders in valid status */ /* if ($order_data['status'] == 1 || $order_data['status'] == 2 || $order_data['status'] == 3 || $order_data['status'] == 4) { msg("Ecommerce_transaction: Order in status New (paid), Dispatched, Completed, Cancelled", 'error', 2); msg("This order (id=$order_id) was already paid before.", 'error'); } */ $transaction_data['order_id'] = $order_data['id']; $transaction_data['pg_data'] = serialize($pg_data); $transaction_data['currency_code'] = GLOBAL_DEFAULT_CURRENCY; if (is_numeric($pg_data['Amount'])) { $transaction_data['amount'] = $pg_data['Amount']; } else { $transaction_data['amount'] = 0; } $transaction_data['created'] = date('c'); $transaction_data['type'] = 'protx'; if ($pg_data['Status'] == 'OK') { $transaction_data['status'] = 1; } else { $transaction_data['status'] = 0; } /** * insert */ if ($id = $this->Transaction->insert($transaction_data)) { // in payment_success must be everytime Status OK if ($pg_data['Status'] == 'OK') { $Order->setStatus($order_id, 1); //send email to admin require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~"); $order_data['order_detail'] = $_Onxshop_Request->getContent(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['transaction'] = $transaction_data; $GLOBALS['common_email']['order'] = $order_data; if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $order_data['client']['customer']['email'], $order_data['client']['customer']['first_name'] . " " . $order_data['client']['customer']['last_name'])) { msg('ecommerce_transaction: Cant send email.', 'error', 2); } if ($Order->conf['mail_to_address']) { if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $Order->conf['mail_to_address'], $Order->conf['mail_to_name'])) { msg('ecommerce_transaction: Cant send email.', 'error', 2); } } } else { $Order->setStatus($order_id, 5); } return $id; } else { //to be sure... if ($pg_data['Status'] == 'OK') { msg("Payment for order {$order_id} was successfully Authorised, but I cant save the transaction TxAuthNo {$pg_data['TxAuthNo']}!", 'error'); } msg("payment/protx: cannot insert serialized pg_data: {$transaction_data['pg_data']}", 'error'); return false; } }
/** * Send email to administrator */ public function sendAlertEmail($store, $notice) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $GLOBALS['common_email']['store'] = $store; $GLOBALS['common_email']['notice'] = $notice; $to_email = false; // admin $to_name = false; $email_from = $store['email']; $name_from = $store['manager_name']; $_FILES = array(); // remove to attach uploaded file $EmailForm->sendEmail('store_notice_notify', 'n/a', $to_email, $to_name); }
/** * send voucher email */ public function sendEmail($promotion_data, $voucher_data, $gift_voucher_filename) { $GLOBALS['common_email'] = array('promotion_data' => $promotion_data, 'voucher_data' => $voucher_data, 'gift_voucher_filename' => $gift_voucher_filename); //$GLOBALS['onxshop_atachments'] = array($gift_voucher_filename_fullpath); require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $template = 'gift_voucher'; $content = $gift_voucher_filename; $email_recipient = $voucher_data['recipient_email']; $name_recipient = $voucher_data['recipient_name']; $email_from = false; $name_from = "{$GLOBALS['onxshop_conf']['global']['title']} Gifts"; $email_sent_status = $EmailForm->sendEmail($template, $content, $email_recipient, $name_recipient, $email_from, $name_from); unset($GLOBALS['common_email']); //unset($GLOBALS['onxshop_atachments']); return $email_sent_status; }
/** * Process share request (form submission) */ protected function processShareRequest($code) { $referral = array(); $min = money_format("%n", $this->conf['minimum_order_amount']); $discount = money_format("%n", $this->conf['discount_value']); $default_message = "Hello," . "\n\n" . "JING sources exceptional teas from across the world, and designs modern and " . "elegant JINGware specifically designed to infuse their teas." . "\n\n" . "As we all appreciate tea, I have chosen you to receive {$discount} off when you " . " spend over {$min} on your first order." . "\n\n" . "Your {$discount} discount voucher is: {$code}" . "\n\n" . "If you use this code I shall also receive a {$discount} discount on my next order over {$min}" . "\n\n" . " Browse JING Tea’s range at http://jingtea.com, and don’t forget to use your code at the checkout." . "\n\n" . " With warm regards, \n" . $_SESSION['client']['customer']['first_name']; $jing_message = "\n\n--\n\n" . "This email was sent by " . $_SESSION['client']['customer']['first_name'] . " " . $_SESSION['client']['customer']['last_name'] . " who already enjoys JING and thought you would be interested in JING’s range of teas and JINGware. " . "If you do not know this person, please let us know by replying to <a href=\"mailto:customerservices@jingtea.com\">customerservices@jingtea.com</a>."; // process form if ($_POST['referral']['send'] == 'send') { $referral['message'] = $_POST['referral']['message']; $referral['recipient'] = $_POST['referral']['recipient']; $EmailForm = new common_email(); $EmailForm->setCacheable(false); // set sender $from = $_SESSION['client']['customer']['email']; $from_name = $_SESSION['client']['customer']['first_name'] . " " . $_SESSION['client']['customer']['last_name']; // set customer's message (remove CRs so it can be compared) $content = preg_replace("/\r\n/", "\n", $referral['message']); // create jing url clickable $content = str_replace("http://jingtea.com", '<a href="http://jingtea.com">http://jingtea.com</a>', $content); // amend message from Jing, if a customer changed the message // if (strcmp($content, $default_message) != 0) $content .= $jing_message2; $content .= $jing_message; // pass variable to email template $GLOBALS['common_email']['customer'] = $_SESSION['client']['customer']; $numSent = 0; $emails = explode(",", $referral['recipient']); $msg = ''; $unsentEmails = array(); if (is_array($emails)) { foreach ($emails as $email) { $email = trim($email); $customer = $this->Customer->getClientByEmail($email); if ($customer) { $msg .= "Customer {$email} is already registered."; $unsentEmails[] = $email; } else { $emailEsc = pg_escape_string($email); $fromEsc = pg_escape_string($from); $count = $EmailForm->count("email_recipient = '{$emailEsc}' AND email_from = '{$fromEsc}' AND template = 'referral_invite'"); if ($count > 0) { $msg .= " You have already invited {$email}."; $unsentEmails[] = $email; } else { if ($EmailForm->sendEmail('referral_invite', $content, $email, $email, $from, $from_name)) { $numSent++; } else { $msg .= " Unable to send email to {$email}."; $unsentEmails[] = $email; } } } } } if ($numSent == 1) { $msg = "One email has been sent. " . $msg; } else { if ($numSent > 1) { $msg = "{$numSent} emails have been sent. " . $msg; } } msg($msg); $referral['recipient'] = implode(",", $unsentEmails); } else { // default message $referral['message'] = $default_message; } $this->tpl->assign("REFERRAL", $referral); }
/** * notification email * * @param integer $comment_id * ID of comment - not used * * @param array $comment_data * information about comment */ public function sendNewCommentNotificationEmail($comment_id, $comment_data) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //is passed as DATA array into the template at common_email->_format $GLOBALS['common_email']['comment'] = $comment_data; if (!$EmailForm->sendEmail('comment_notify')) { msg('New comment notification email sending failed.', 'error'); } }
/** * process callback */ function paymentProcess($order_id, $pg_data) { require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); // check if $pg_data['VendorTxCode'] = $_GET['order_id'] //$this->msgProtxStatus($pg_data['Status']); $order_data = $Order->getOrder($order_id); //print_r($order_data); /** * optional: process payment method only if status = 0 unpaid or 5 failed payment * (better to save transaction every time) */ //if (!$this->checkOrderStatusValidForPayment($order_data['status'])) return false; $transaction_data['order_id'] = $order_data['id']; $transaction_data['pg_data'] = serialize($pg_data); $transaction_data['currency_code'] = GLOBAL_DEFAULT_CURRENCY; if (is_numeric($pg_data['authCost'])) { $transaction_data['amount'] = $pg_data['authCost']; } else { $transaction_data['amount'] = 0; } $transaction_data['created'] = date('c'); $transaction_data['type'] = 'worldpay'; if ($pg_data['transStatus'] == 'Y') { $transaction_data['status'] = 1; } else { $transaction_data['status'] = 0; } /** * check installation id */ if ($pg_data['installation'] != ECOMMERCE_TRANSACTION_WORLDPAY_INSID) { msg("payment/worldpay: wrong installation id {$pg_data['installation']}, serialized pg_data: {$transaction_data['pg_data']}", 'error'); return false; } /** * insert */ if ($id = $this->Transaction->insert($transaction_data)) { // in payment_success must be everytime Status OK if ($pg_data['transStatus'] == 'Y') { $Order->setStatus($order_id, 1); //send email to admin require_once 'models/common/common_email.php'; $EmailForm = new common_email(); $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~"); $order_data['order_detail'] = $_Onxshop_Request->getContent(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['transaction'] = $transaction_data; $GLOBALS['common_email']['order'] = $order_data; if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $order_data['client']['customer']['email'], $order_data['client']['customer']['first_name'] . " " . $order_data['client']['customer']['last_name'])) { msg("ecommerce_transaction: Can't send email.", 'error', 2); } if ($Order->conf['mail_to_address']) { if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $Order->conf['mail_to_address'], $Order->conf['mail_to_name'])) { msg('ecommerce_transaction: Cant send email.', 'error', 2); } } /** * cancel immediatelly if it was only a test */ if ($pg_data['testMode'] == 100) { $Order->setStatus($order_id, 4); msg("Order #{$order_id} has been cancelled, because Worldpay testMode was active."); } } else { $Order->setStatus($order_id, 5); } return $id; } else { //to be sure... if ($pg_data['Status'] == 'OK') { msg("Payment for order {$order_id} was successfully Authorised, but I cant save the transaction id {$pg_data['transId']}!", 'error'); } msg("payment/worldpay: cannot insert serialized pg_data: {$transaction_data['pg_data']}", 'error'); return false; } }
public function getDataForReport($date_from, $date_to) { require_once 'models/common/common_email.php'; $Email = new common_email(); $date_from = date("Y-m-d", strtotime($date_from)); $date_to = date("Y-m-d", strtotime($date_to)); $where = "created > '{$date_from}' AND created < '{$date_to}' "; $where .= "AND template IN ('notification_back_in_stock_admin', 'notification_out_of_stock_admin', 'notification_back_in_stock_customer')"; $list = $Email->listing($where, "id DESC"); $result = array(); foreach ($list as $item) { $params = unserialize($item['content']); $variety_id = $params['product']['variety']['id']; if ($variety_id > 0) { $day = date("Y-m-d", strtotime($item['created'])); $is_back_in_stock = strpos($item['template'], "back_in_stock") !== false; $is_customer = strpos($item['template'], "customer") !== false; $key = $variety_id . "-" . $day . "-" . (int) $is_back_in_stock; if (isset($result[$key])) { if ($is_customer) { $result[$key]["Customer Notification Sent"]++; if (!empty($result[$key]["Customer Receipent Addresses"])) { $result[$key]["Customer Receipent Addresses"] .= ", "; } $result[$key]["Customer Receipent Addresses"] .= $item['email_recipient']; } else { $result[$key]["Admin Notification Sent"]++; if (!empty($result[$key]["Admin Receipent Addresses"])) { $result[$key]["Admin Receipent Addresses"] .= ", "; } $result[$key]["Admin Receipent Addresses"] .= $item['email_recipient']; } } else { $product = $this->getProductInfo($variety_id); $row = array("Type" => $is_back_in_stock ? "Back in Stock" : "Out of Stock", "SKU" => $product['variety']['sku'], "Product Id" => $params['product']['id'], "Variety Id" => $variety_id, "Product Name" => $product['name'], "Variety Name" => $product['variety']['name'], "Date and Time" => date("d/m/Y H:i:s", strtotime($item['created']))); if ($is_customer) { $row["Admin Notification Sent"] = 0; $row["Customer Notification Sent"] = 1; $row["Admin Receipent Addresses"] = ""; $row["Customer Receipent Addresses"] = $item['email_recipient']; } else { $row["Admin Notification Sent"] = 1; $row["Customer Notification Sent"] = 0; $row["Admin Receipent Addresses"] = $item['email_recipient']; $row["Customer Receipent Addresses"] = ""; } $result[$key] = $row; } } } return $result; }
/** * reset password * * @param string $email * customer's e-mail address * * @param string $key * a key for this customer's password reset * * @return boolean * is a reset successfull? * * @see getPasswordKey */ function resetPassword($email, $key) { $email = strtolower($email); $client = $this->getClientByEmail($email); if (is_array($client)) { $current_key = $this->getPasswordKey($email); if ($current_key == $key) { $client_current_data = $client; $password_new = $this->randomPassword(); if ($this->updatePassword($client_current_data['password'], $password_new, $password_new, $client_current_data)) { msg("Password for {$email} has been updated", 'ok', 2); $customer_data = $client_current_data; $customer_data['password'] = $password_new; /** * send email */ require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email']['customer'] = $customer_data; if (!$EmailForm->sendEmail('password_reset', 'n/a', $customer_data['email'], $customer_data['first_name'] . " " . $customer_data['last_name'])) { msg('Password reset email sending failed.', 'error'); } return true; } } else { msg("Wrong key!", 'error'); } } else { //msg('failed', 'error'); return false; } }
/** * Send email after succesfull reward code allocation */ public function sendRewardEmail($invited_customer_id, $rewarded_customer_id, $code, $usage) { require_once 'models/common/common_email.php'; require_once 'models/client/client_customer.php'; $EmailForm = new common_email(); $Customer = new client_customer(); $Customer->setCacheable(false); $rewarded_customer = $Customer->getDetail($rewarded_customer_id); $invited_customer = $Customer->getDetail($invited_customer_id); $GLOBALS['common_email']['invited_customer'] = $invited_customer; $GLOBALS['common_email']['rewarded_customer'] = $rewarded_customer; $GLOBALS['common_email']['code'] = $code; $GLOBALS['common_email']['total_invited'] = $usage; $conf = ecommerce_promotion::initConfiguration(); $GLOBALS['common_email']['minimum_order_amount'] = $conf['minimum_order_amount']; $GLOBALS['common_email']['discount_value'] = $conf['discount_value']; $to_email = $rewarded_customer['email']; $to_name = $rewarded_customer['first_name'] . " " . $rewarded_customer['last_name']; $EmailForm->sendEmail('referral_reward', 'n/a', $to_email, $to_name); }