/** * sendConfirmationMail (This source code come from AuthControllerCore) * @param Customer $customer * @return bool */ public static function sendConfirmationMail($social_customer, $passwd) { if (!Configuration::get('PS_CUSTOMER_CREATION_EMAIL') || !Configuration::get('FSL_CUSTOMER_CREATION_EMAIL')) { return true; } return Mail::Send(Context::getContext()->language->id, 'social_account', Mail::l('Welcome!'), array('{provider}' => $social_customer->getProvider(), '{username}' => $social_customer->username, '{firstname}' => $social_customer->firstname, '{lastname}' => $social_customer->lastname, '{email}' => $social_customer->email, '{passwd}' => $passwd), $social_customer->email, $social_customer->firstname . ' ' . $social_customer->lastname, null, null, null, null, dirname(__FILE__) . '/../mails/'); }
private function newMessage($type, $phone, $cname, $message, $email_theme, $email_param = "") { $host = Tools::getHttpHost(); $phone = "+" . preg_replace('#\\D+#', '', $phone); // insert to DB $query = "insert into " . _DB_PREFIX_ . egmarketing::INSTALL_SQL_BD1NAME . " \r\n\t\t(`id_shop`, `host`, `type`, `phone`, `fname`, `lname`, `message`) \r\n\t\tvalues ('" . (int) $context->shop->id . "', '" . Tools::getHttpHost() . "', '" . $type . "', '" . $phone . "',\r\n\t\t\t'" . $cname . "', '" . $cname . "', '" . $message . "')"; Db::getInstance()->execute(trim($query)); // notify by email if ($email_param == "") { $email_param = Configuration::get('EGCALLME_EMAIL_NOTIFY'); } if (trim($email_param) != "") { $context = Context::getContext(); $param = array('{phone}' => $phone, '{message}' => $message, '{fname}' => $cname, '{shop_url}' => $host); $emails = explode(';', $email_param); foreach ($emails as $email) { Mail::Send((int) $context->language->id, $email_theme, Mail::l($type, " " . $phone . " " . $host), $param, $email, $cname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $context->shop->id); } } // sms notification $sms_message = "%type %host %phone %cname %message"; $sms_message = Meta::sprintf2($sms_message, array('host' => $host, 'type' => $type, 'phone' => $phone, 'cname' => $cname, 'message' => $message)); //$this->sendSMS($sms_message,"79601652555",2); $param = array('{phone}' => str_replace('+', '', $phone), '{message}' => $message, '{fname}' => $cname, '{type}' => 'FastOrder', '{host}' => $host, '{shost}' => str_replace('.', '-', $host)); $this->sendTelegramm($param, $sms_message); }
private function newMessage($phone, $fname, $lname, $message, $context) { $host = Tools::getHttpHost(); // insert to DB $query = "insert into " . _DB_PREFIX_ . egcallme::INSTALL_SQL_BD1NAME . " \n (`id_shop`, `host`, `type`, `phone`, `fname`,`lname`, `message`) \n values ('" . (int) $context->shop->id . "', '" . $host . "', 'callback', '" . $phone . "',\n '" . $fname . "','" . $lname . "', '" . $message . "')"; Db::getInstance()->execute(trim($query)); // notify by email $emails_param = Configuration::get('EGCALLME_EMAIL_NOTIFY'); if (trim($emails_param) != "") { $param = array('{phone}' => $phone, '{message}' => $message, '{fname}' => $fname, '{lname}' => $lname, '{host}' => $host); $emails = explode(';', $emails_param); $dir = egcallme::getModuleDir() . '/mails/'; foreach ($emails as $email) { $email_theme = "email_notify"; Mail::Send((int) $context->language->id, $email_theme, Mail::l("NEW Callback " . $phone, $this->context->language->id), $param, trim($email), "", null, null, null, null, $dir, false, (int) $context->shop->id); } $param['{phone}'] = preg_replace('#\\D+#', '', $param['{phone}']); $requests = Configuration::getMultiple(array('EGCALLME_HTTPNOT_1', 'EGCALLME_HTTPNOT_2', 'EGCALLME_HTTPNOT_3')); $texts = Configuration::getMultiple(array('EGCALLME_HTTPNOT_1_TXT', 'EGCALLME_HTTPNOT_2_TXT', 'EGCALLME_HTTPNOT_3_TXT')); foreach ($requests as $key => $request) { $request = $this->replaceKeywords($param, $request, $texts[$key . '_TXT']); $result = file_get_contents($request); } } }
public static function sendByMail($log) { /* Send e-mail to the shop owner only if the minimal severity level has been reached */ if (intval(Configuration::get('PS_LOGS_BY_EMAIL')) <= intval($log->severity)) { Mail::Send((int) Configuration::get('PS_LANG_DEFAULT'), 'log_alert', Mail::l('Log: You have a new alert from your shop'), array(), Configuration::get('PS_SHOP_EMAIL')); } }
/** * Start forms process * @see FrontController::postProcess() */ public function postProcess() { if (Tools::isSubmit('email')) { if (!($email = Tools::getValue('email')) || !Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } else { $customer = new Customer(); $customer->getByemail($email); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('There is no account registered to this e-mail address.'); } elseif (!$customer->active) { $this->errors[] = Tools::displayError('You cannot regenerate the password for this account.'); } elseif (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) { $this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), (int) $min_time); } else { $mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => $this->context->link->getPageLink('password', true, null, 'token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id)); if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) { $this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email)); } else { $this->errors[] = Tools::displayError('Error occurred while sending the e-mail.'); } } } } elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) { $email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer); if ($email) { $customer = new Customer(); $customer->getByemail($email); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('Customer account not found'); } elseif (!$customer->active) { $this->errors[] = Tools::displayError('You cannot regenerate the password for this account.'); } elseif (strtotime($customer->last_passwd_gen . '+' . (int) Configuration::get('PS_PASSWD_TIME_FRONT') . ' minutes') - time() > 0) { Tools::redirect('index.php?controller=authentication&error_regen_pwd'); } else { $customer->passwd = Tools::encrypt($password = Tools::passwdGen(MIN_PASSWD_LENGTH)); $customer->last_passwd_gen = date('Y-m-d H:i:s', time()); if ($customer->update()) { Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password)); $mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password); if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) { $this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email)); } else { $this->errors[] = Tools::displayError('Error occurred while sending the e-mail.'); } } else { $this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.'); } } } else { $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted'); } } elseif (Tools::getValue('token') || Tools::getValue('id_customer')) { $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted'); } }
/** * Assign wishlist template */ public function assign() { $errors = array(); if ($this->context->customer->isLogged()) { $add = Tools::getIsset('add'); $add = empty($add) === false ? 1 : 0; $delete = Tools::getIsset('deleted'); $delete = empty($delete) === false ? 1 : 0; $id_wishlist = Tools::getValue('id_wishlist'); if (Tools::isSubmit('submitWishlist')) { if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 and strcmp(Tools::getToken(), Tools::getValue('token'))) { $errors[] = $this->module->l('Invalid token', 'mywishlist'); } if (!sizeof($errors)) { $name = Tools::getValue('name'); if (empty($name)) { $errors[] = $this->module->l('You must specify a name.', 'mywishlist'); } if (WishList::isExistsByNameForUser($name)) { $errors[] = $this->module->l('This name is already used by another list.', 'mywishlist'); } if (!sizeof($errors)) { $wishlist = new WishList(); $wishlist->id_shop = $this->context->shop->id; $wishlist->id_shop_group = $this->context->shop->id_shop_group; $wishlist->name = $name; $wishlist->id_customer = (int) $this->context->customer->id; list($us, $s) = explode(' ', microtime()); srand($s * $us); $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $this->context->customer->id), 0, 16)); $wishlist->add(); Mail::Send($this->context->language->id, 'wishlink', Mail::l('Your wishlist\'s link', $this->context->language->id), array('{wishlist}' => $wishlist->name, '{message}' => Tools::getProtocol() . htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/blockwishlist/view.php?token=' . $wishlist->token), $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, $this->module->getLocalPath() . 'mails/'); } } } else { if ($add) { WishList::addCardToWishlist($this->context->customer->id, Tools::getValue('id_wishlist'), $this->context->language->id); } else { if ($delete and empty($id_wishlist) === false) { $wishlist = new WishList((int) $id_wishlist); if (Validate::isLoadedObject($wishlist)) { $wishlist->delete(); } else { $errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist'); } } } } $this->context->smarty->assign('wishlists', WishList::getByIdCustomer($this->context->customer->id)); $this->context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($this->context->customer->id)); } else { Tools::redirect('index.php?controller=authentication&back=' . urlencode($this->context->link->getModuleLink('blockwishlist', 'mywishlist'))); } $this->context->smarty->assign(array('id_customer' => (int) $this->context->customer->id, 'errors' => $errors, 'form_link' => $errors)); $this->setTemplate('mywishlist.tpl'); }
public static function SendTranslateSubject($id_lang, $template, $templateVars, $to, $toName = NULL, $from = NULL, $fromName = NULL, $fileAttachment = NULL, $modeSMTP = NULL, $templatePath = _PS_MAIL_DIR_, $die = false, $id_shop = NULL, $bcc = null) { ${"GLOBALS"}["ofwtthdu"] = "templatePath"; ${"GLOBALS"}["waqsvhsc"] = "from"; ${"GLOBALS"}["oljyfstsifb"] = "fileAttachment"; ${"GLOBALS"}["ktavbwwuty"] = "die"; ${"GLOBALS"}["pbykixc"] = "toName"; ${"GLOBALS"}["ygkvnpurdj"] = "id_lang"; ${"GLOBALS"}["nrxherkluqq"] = "toName"; $pvdkehuv = "toName"; $uiwfgerto = "fromName"; ${"GLOBALS"}["mwjoukbjfci"] = "templatePath"; ${"GLOBALS"}["asvlqglenan"] = "die"; ${"GLOBALS"}["gtukoxtrtzfi"] = "modeSMTP"; ${"GLOBALS"}["kesvwedp"] = "to"; ${"GLOBALS"}["kdgoyhmsahxr"] = "bcc"; $hfncmd = "id_lang"; $wyjnsgeimx = "templatePath"; ${"GLOBALS"}["comjqjca"] = "templateVars"; $chllfgsuw = "from"; ${"GLOBALS"}["ggypray"] = "id_shop"; $ungkmvucvl = "id_shop"; ${"GLOBALS"}["nmxbjsqu"] = "id_shop"; $vjstsi = "fileAttachment"; ${"GLOBALS"}["ohlqtao"] = "id_lang"; ${"GLOBALS"}["viwpzapqypm"] = "from"; $uebssytghjjc = "fromName"; ${"GLOBALS"}["ffrcidosklbi"] = "fromName"; ${"GLOBALS"}["rcvwsfnutml"] = "id_shop"; ${"GLOBALS"}["vuhnpgm"] = "id_lang"; ${"GLOBALS"}["qtvkxqmputu"] = "to"; ${"GLOBALS"}["tlsoaxi"] = "modeSMTP"; $orgwjctvwjf = "modeSMTP"; ${"GLOBALS"}["drwyhg"] = "templateVars"; ${"GLOBALS"}["jxxusew"] = "toName"; $spcvktgi = "die"; ${"GLOBALS"}["ihiiypxhojun"] = "bcc"; $uvoidyuj = "templatePath"; $euugydhqjd = "templatePath"; $cimcxfmih = "to"; switch (${${"GLOBALS"}["obburiaad"]}) { case "new_order": return Mail::Send(${${"GLOBALS"}["vuhnpgm"]}, "new_order", Mail::l('New Order'), ${${"GLOBALS"}["opsyefhwbkot"]}, ${$cimcxfmih}, ${${"GLOBALS"}["pximfkjwj"]}, ${$chllfgsuw}, ${${"GLOBALS"}["ffrcidosklbi"]}, ${${"GLOBALS"}["leiyninz"]}, ${${"GLOBALS"}["gtukoxtrtzfi"]}, ${${"GLOBALS"}["ghlgsfyfdx"]}, ${${"GLOBALS"}["mryvscjv"]}, ${${"GLOBALS"}["rcvwsfnutml"]}, ${${"GLOBALS"}["llhlusocwbt"]}); case "fund_request": return Mail::Send(${${"GLOBALS"}["ohlqtao"]}, "fund_request", Mail::l('Fund request from a seller'), ${${"GLOBALS"}["drwyhg"]}, ${${"GLOBALS"}["xjcxgnow"]}, ${${"GLOBALS"}["nrxherkluqq"]}, ${${"GLOBALS"}["ufhhkde"]}, ${${"GLOBALS"}["ebejdcjwvbis"]}, ${$vjstsi}, ${${"GLOBALS"}["yuvpsy"]}, ${${"GLOBALS"}["ofwtthdu"]}, ${${"GLOBALS"}["asvlqglenan"]}, ${${"GLOBALS"}["nmxbjsqu"]}, ${${"GLOBALS"}["llhlusocwbt"]}); case "app_selleraccount": return Mail::Send(${$hfncmd}, "app_selleraccount", Mail::l('Your seller account approved!'), ${${"GLOBALS"}["comjqjca"]}, ${${"GLOBALS"}["xjcxgnow"]}, ${${"GLOBALS"}["pbykixc"]}, ${${"GLOBALS"}["viwpzapqypm"]}, ${${"GLOBALS"}["ebejdcjwvbis"]}, ${${"GLOBALS"}["oljyfstsifb"]}, ${${"GLOBALS"}["yuvpsy"]}, ${$euugydhqjd}, ${${"GLOBALS"}["ktavbwwuty"]}, ${${"GLOBALS"}["cfimirivyt"]}, ${${"GLOBALS"}["llhlusocwbt"]}); case "new_selleraccount": return Mail::Send(${${"GLOBALS"}["edbldrigs"]}, "new_selleraccount", Mail::l('Your seller account'), ${${"GLOBALS"}["opsyefhwbkot"]}, ${${"GLOBALS"}["kesvwedp"]}, ${$pvdkehuv}, ${${"GLOBALS"}["ufhhkde"]}, ${$uebssytghjjc}, ${${"GLOBALS"}["leiyninz"]}, ${${"GLOBALS"}["tlsoaxi"]}, ${$uvoidyuj}, ${$spcvktgi}, ${$ungkmvucvl}, ${${"GLOBALS"}["ihiiypxhojun"]}); case "new_selleraccount_admin": return Mail::Send(${${"GLOBALS"}["edbldrigs"]}, "new_selleraccount_admin", Mail::l('A new seller account has been added'), ${${"GLOBALS"}["opsyefhwbkot"]}, ${${"GLOBALS"}["xjcxgnow"]}, ${${"GLOBALS"}["jxxusew"]}, ${${"GLOBALS"}["ufhhkde"]}, ${${"GLOBALS"}["ebejdcjwvbis"]}, ${${"GLOBALS"}["leiyninz"]}, ${$orgwjctvwjf}, ${${"GLOBALS"}["mwjoukbjfci"]}, ${${"GLOBALS"}["mryvscjv"]}, ${${"GLOBALS"}["ggypray"]}, ${${"GLOBALS"}["llhlusocwbt"]}); case "new_product": return Mail::Send(${${"GLOBALS"}["ygkvnpurdj"]}, "new_product", Mail::l('New product approval request'), ${${"GLOBALS"}["opsyefhwbkot"]}, ${${"GLOBALS"}["qtvkxqmputu"]}, ${${"GLOBALS"}["pximfkjwj"]}, ${${"GLOBALS"}["waqsvhsc"]}, ${$uiwfgerto}, ${${"GLOBALS"}["leiyninz"]}, ${${"GLOBALS"}["yuvpsy"]}, ${$wyjnsgeimx}, ${${"GLOBALS"}["mryvscjv"]}, ${${"GLOBALS"}["cfimirivyt"]}, ${${"GLOBALS"}["kdgoyhmsahxr"]}); } }
protected function sendConfirmationMail(Customer $customer) { /* * EU-Legal * Password not visible */ if (!Configuration::get('PS_CUSTOMER_CREATION_EMAIL')) { return true; } return Mail::Send($this->context->language->id, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => '***'), $customer->email, $customer->firstname . ' ' . $customer->lastname); }
public function sendCampaign() { // get abandoned cart : $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86400, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t) AS toto WHERE id_order='Abandoned cart'"; $currency = Context::getContext()->currency->sign; $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $abandoned_carts = Db::getInstance()->ExecuteS($sql); // get all available campaigns $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1'; $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns); // loop on all abandoned carts foreach ($abandoned_carts as $abncart) { // loop on all available campaigns foreach ($allCampaigns as $camp) { $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']); if ($cartIsOnCampaign) { $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $customer = new Customer($abncart['id_customer']); $cR = new CartRule($camp['id_voucher'], $id_lang); $cart = new Cart($abncart['id_cart']); $products = $cart->getProducts(); $campM = new Campaign($camp['id_campaign']); if (!empty($products)) { $cart_content = $campM->getCartContentHeader(); } else { $cart_content = ''; } foreach ($products as $prod) { $p = new Product($prod['id_product'], true, $id_lang); $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false); $total_no_tax = $prod['cart_quantity'] * $price_no_tax; $images = Image::getImages((int) $id_lang, (int) $p->id); $link = new Link(); $cart_content .= '<tr > <td align="center" ><img src="' . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td> <td align="center" ><a href="' . $link->getProductLink($p) . '"/>' . $p->name . '</a></td> <td align="center" >' . Tools::displayprice($price_no_tax) . '</td> <td align="center" >' . $prod['cart_quantity'] . '</td> <td align="center" >' . Tools::displayprice($total_no_tax) . '</td> </tr>'; } $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{coupon_name}' => $cR->name, '{coupon_code}' => $cR->code, '{cart_content}' => $cart_content, '{coupon_value}' => $camp['voucher_amount_type'] == 'percent' ? $cR->reduction_percent . '%' : $currency . $cR->reduction_amount, '{coupon_valid_to}' => date('d/m/Y', strtotime($cR->date_to)), '{campaign_name}' => $camp['name']); $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/'; // send email to customer : Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id); // Email to admin : Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id); // echo 'ID ' . $abncart['id_cart']; } } } }
public function postEmail($data) { $validate = $this->validation($data); if ($validate && empty($validate['error'])) { $template_vars = array('{guest_name}' => $validate['name'], '{guest_phone}' => $validate['phone']); $shop_email = strval(Configuration::get('PS_SHOP_EMAIL')); if (Mail::Send($this->context->language->id, 'callme', Mail::l('Email Call Me', $this->context->language->id), $template_vars, $shop_email, null, null, null, null, null, dirname(__FILE__) . '/mails/', false, $this->context->shop->id)) { return $this->viewStatus(true); } } else { return $this->viewStatus(false); } }
public function hookActionObjectCustomerUpdateAfter($params) { $data = parse_str($_SERVER['HTTP_REFERER']); $customer_id = $id_customer; $customer = new Customer($customer_id); $customer_status_after = strval(Tools::getValue('active')); if ($this->customer_status_before != $customer_status_after && $customer_status_after === '1') { /*echo '<script type="text/javascript">'; echo 'console.log(Name:'.dirname(__FILE__).'/mails/)'; echo '</script>';*/ Mail::Send($this->context->language->id, 'account_activated', Mail::l('Your account has been activated.', $this->context->language->id), array('{email}' => $customer->email, '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{shopname}' => $this->context->shop->name), $customer->email, $customer->lastname, NULL, $this->context->shop->name, NULL, NULL, dirname(__FILE__) . '/mails/'); } }
public function postProcess() { global $currentIndex, $cookie; if (Tools::isSubmit('deleteorder_return_detail')) { if ($this->tabAccess['delete'] === '1') { if ($id_order_detail = (int) Tools::getValue('id_order_detail') and Validate::isUnsignedId($id_order_detail)) { if ($id_order_return = (int) Tools::getValue('id_order_return') and Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); if (!Validate::isLoadedObject($orderReturn)) { die(Tools::displayError()); } if ((int) $orderReturn->countProduct() > 1) { if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, (int) Tools::getValue('id_customization', 0))) { Tools::redirectAdmin($currentIndex . '&conf=4token=' . $this->token); } else { $this->_errors[] = Tools::displayError('An error occurred while deleting an order return detail.'); } } else { $this->_errors[] = Tools::displayError('You need at least one product.'); } } else { $this->_errors[] = Tools::displayError('The order return is invalid.'); } } else { $this->_errors[] = Tools::displayError('The order return detail is invalid.'); } } else { $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } } elseif (Tools::isSubmit('submitAddorder_return')) { if ($this->tabAccess['edit'] === '1') { if ($id_order_return = (int) Tools::getValue('id_order_return') and Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); $order = new Order($orderReturn->id_order); $customer = new Customer($orderReturn->id_customer); $orderReturn->state = (int) Tools::getValue('state'); if ($orderReturn->save()) { $orderReturnState = new OrderReturnState($orderReturn->state); $vars = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order_return}' => $id_order_return, '{order_name}' => sprintf("#%06d", (int) $order->id), '{state_order_return}' => isset($orderReturnState->name[(int) $order->id_lang]) ? $orderReturnState->name[(int) $order->id_lang] : $orderReturnState->name[(int) _PS_LANG_DEFAULT_]); Mail::Send((int) $order->id_lang, 'order_return_state', Mail::l('Your order return state has changed', (int) $order->id_lang), $vars, $customer->email, $customer->firstname . ' ' . $customer->lastname, NULL, NULL, NULL, NULL, _PS_MAIL_DIR_, true); Tools::redirectAdmin($currentIndex . '&conf=4&token=' . $this->token); } } else { $this->_errors[] = Tools::displayError('No order return ID.'); } } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } parent::postProcess(); }
private function onConversionExpired() { if (!Configuration::get('CASHWAY_SEND_EMAIL')) { $this->terminateReply(202, 'Ok, but not sending email per shop config.'); } $order = new Order((int) $this->data->order_id); if (!Validate::isLoadedObject($order)) { $this->terminateReply(404, 'Could not find such an order.'); } $customer = new Customer($order->id_customer); $reorder_url = $this->context->link->getPageLink('order', true, $this->context->language->id, array('submitReorder' => '1', 'id_order' => (int) $order->id)); Mail::Send($this->context->language->id, 'conversion_expired', Mail::l('', $this->context->language->id), array('{reorder_url}' => $reorder_url), $customer->email, null, null, null, null, null, dirname(__FILE__) . '/mails/', false, $this->context->shop->id); $this->terminateReply(201, 'Call back email sent.'); }
public function process() { parent::process(); if (Tools::isSubmit('email')) { if (!($email = Tools::getValue('email')) or !Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } else { $customer = new Customer(); $customer->getByemail($email); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('There is no account registered to this e-mail address.'); } else { if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) { $this->errors[] = Tools::displayError('You can regenerate your password only every') . ' ' . (int) $min_time . ' ' . Tools::displayError('minute(s)'); } else { if (Mail::Send((int) self::$cookie->id_lang, 'password_query', Mail::l('Password query confirmation'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => self::$link->getPageLink('password.php', true) . '?token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id), $customer->email, $customer->firstname . ' ' . $customer->lastname)) { self::$smarty->assign(array('confirmation' => 2, 'email' => $customer->email)); } else { $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.'); } } } } } elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) { $email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer); if ($email) { $customer = new Customer(); $customer->getByemail($email); if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) { Tools::redirect('authentication.php?error_regen_pwd'); } else { $customer->passwd = Tools::encrypt($password = Tools::passwdGen((int) MIN_PASSWD_LENGTH)); $customer->last_passwd_gen = date('Y-m-d H:i:s', time()); if ($customer->update()) { if (Mail::Send((int) self::$cookie->id_lang, 'password', Mail::l('Your password'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password), $customer->email, $customer->firstname . ' ' . $customer->lastname)) { self::$smarty->assign(array('confirmation' => 1, 'email' => $customer->email)); } else { $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.'); } } else { $this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.'); } } } else { $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted'); } } elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer'))) { $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted'); } }
public function displayFrontForm() { global $smarty; $error = false; $confirm = false; if (isset($_POST['submitAddtoafriend'])) { global $cookie, $link; /* Product informations */ $product = new Product((int) Tools::getValue('id_product'), false, (int) $cookie->id_lang); $productLink = $link->getProductLink($product); /* Fields verifications */ if (empty($_POST['email']) or empty($_POST['name'])) { $error = $this->l('You must fill in all fields.'); } elseif (empty($_POST['email']) or !Validate::isEmail($_POST['email'])) { $error = $this->l('The e-mail given is invalid.'); } elseif (!Validate::isName($_POST['name'])) { $error = $this->l('The name given is invalid.'); } elseif (!isset($_GET['id_product']) or !is_numeric($_GET['id_product'])) { $error = $this->l('An error occurred during the process.'); } else { /* Email generation */ $subject = ($cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend')) . ' ' . $this->l('sent you a link to') . ' ' . $product->name; $templateVars = array('{product}' => $product->name, '{product_link}' => $productLink, '{customer}' => $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend'), '{name}' => Tools::safeOutput($_POST['name'])); /* Email sending */ if (!Mail::Send((int) $cookie->id_lang, 'send_to_a_friend', Mail::l('A friend sent you a link to') . ' ' . $product->name, $templateVars, $_POST['email'], NULL, $cookie->email ? $cookie->email : NULL, $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : NULL, NULL, NULL, dirname(__FILE__) . '/mails/')) { $error = $this->l('An error occurred during the process.'); } else { Tools::redirect(_MODULE_DIR_ . '/' . $this->name . '/sendtoafriend-form.php?id_product=' . $product->id . '&submited'); } } } else { global $cookie, $link; /* Product informations */ $product = new Product((int) Tools::getValue('id_product'), false, (int) $cookie->id_lang); $productLink = $link->getProductLink($product); } /* Image */ $images = $product->getImages((int) $cookie->id_lang); foreach ($images as $k => $image) { if ($image['cover']) { $cover['id_image'] = (int) $product->id . '-' . (int) $image['id_image']; $cover['legend'] = $image['legend']; } } if (!isset($cover)) { $cover = array('id_image' => Language::getIsoById((int) $cookie->id_lang) . '-default', 'legend' => 'No picture'); } $smarty->assign(array('cover' => $cover, 'errors' => $error, 'confirm' => $confirm, 'product' => $product, 'productLink' => $productLink)); return $this->display(__FILE__, 'sendtoafriend.tpl'); }
public function hookOrderReturn($params) { $sEmail = Configuration::get('NOW_ORDER_RETURN_EMAIL'); if (Configuration::get('NOW_ORDER_RETURN_ACTIVE') && $sEmail) { $oOrderReturn = $params['orderReturn']; $oOrder = new Order((int) $oOrderReturn->id_order); if (Validate::isLoadedObject($oOrderReturn)) { $context = Context::getContext(); $aProducts = OrderReturn::getOrdersReturnProducts((int) $oOrderReturn->id, $oOrder); $aParamsEmail = array('{firstname}' => $context->customer->firstname, '{lastname}' => $context->customer->lastname, '{id_order_return}' => $oOrderReturn->id, '{id_order}' => $oOrderReturn->id_order, '{product_html}' => $this->getProductListforEmailHTML($aProducts), '{product_txt}' => $this->getProductListforEmailTXT($aProducts)); $return = Mail::Send($context->language->id, 'order_return', Mail::l('Order Return', $context->language->id), $aParamsEmail, $sEmail, 'Administrator', $context->customer->email, $context->customer->lastname . ' - ' . $context->customer->firstname, NULL, NULL, $this->module_dir . 'mails/'); return $return; } } }
/** * sendConfirmationMail * @param Customer $customer * @return bool */ protected function sendConfirmationMail(Customer $customer) { if (!Configuration::get('PS_CUSTOMER_CREATION_EMAIL')) { return true; } $is_affiliate = false; // At this stage we can't do this because the affiliate entry is not yet created. //if (function_exists('affiliates_user_is_affiliate')) { // $is_affiliate = affiliates_user_is_affiliate($customer->id); //} // ... so instead, we check if the customer requested to sign up for the affiliate program: if (isset($_POST['aff']) && $_POST['aff'] == '1') { $is_affiliate = true; } if ($is_affiliate) { $affiliate_area_url = Tools::getHttpHost(true) . __PS_BASE_URI__ . 'index.php?fc=module&module=affiliatesprops&controller=affiliatearea'; $result = Mail::Send($this->context->language->id, 'account-affiliates', Mail::l('Welcome to the Affiliate Program!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd'), '{affiliate_area_url}' => $affiliate_area_url), $customer->email, $customer->firstname . ' ' . $customer->lastname); } else { $result = Mail::Send($this->context->language->id, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname); } }
public function preProcess() { parent::preProcess(); $id_customer = self::$cookie->id_customer; $customer = new Customer($id_customer); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); //self::$smarty->assign('display_thanks', 1); if (!Tools::isSubmit('submitFeedback')) { return; } $overall = Tools::getValue('overall'); $recommend = Tools::getValue('recommend'); $collection = Tools::getValue('collection'); $products = Tools::getValue('products'); $fitting = Tools::getValue('fitting'); $delivery = Tools::getValue('delivery'); $support = Tools::getValue('support'); $suggestions = Tools::getValue('suggestions'); $id_order = Tools::getValue('oid'); if (empty($id_order)) { $id_order = 0; } $suggestions = pSQL($suggestions); $query = 'INSERT INTO `ps_order_feedback`(id_customer, overall, recommend, collection, products, fitting, delivery, support, suggestion,id_order) values( ' . $id_customer . ', ' . $overall . ', ' . $recommend . ', ' . $collection . ', ' . $products . ', ' . $fitting . ', ' . $delivery . ', ' . $support . ', "' . $suggestions . '", ' . $id_order . ' )'; $db->Execute($query); Mail::Send(1, 'neworderfeedback', Mail::l('New Order Feedback'), array('{customer_name}' => $customer->firstname . ' - ' . $customer->email . ' - (Order Id # ' . $id_order . ')', '{$overall}' => $overall, '{$recommend}' => $recommend, '{$collection}' => $collection, '{$products}' => $products, '{$fitting}' => $fitting, '{$delivery}' => $delivery, '{$support}' => $support, '{$suggestions}' => $suggestions), array('*****@*****.**', '*****@*****.**', '*****@*****.**'), 'IndusDiva Order Feedback'); self::$smarty->assign('display_thanks', 1); Tools::sendSQSRuleMessage(EVENT_ORDER_FEEDBACK, $id_order, $cookie->id_customer, date('Y-m-d H:i:s')); }
public function preProcess() { parent::preProcess(); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); //self::$smarty->assign('display_thanks', 1); $phone = Tools::getValue('phone'); $country = Tools::getValue('country'); $enquiry = Tools::getValue('enquiry'); $name = Tools::getValue('name'); $email = Tools::getValue('email'); $enquiry = pSQL($enquiry); $query = 'INSERT INTO `ps_design_enquiries`(name, email, phone, country, enquiry) values( "' . $name . '", "' . $email . '", "' . $phone . '", "' . $country . '", "' . $enquiry . '" )'; $db->Execute($query); Mail::Send(1, 'designenquiry', Mail::l('New Design Enquiry'), array('{name}' => $name, '{email}' => $email, '{phone}' => $phone, '{country}' => $country, '{enquiry}' => $enquiry), array('*****@*****.**', '*****@*****.**'), 'IndusDiva Design Enquiry'); echo "success"; exit; }
public function transformToCustomer($id_lang, $password = null) { if (!$this->isGuest()) { return false; } if (empty($password)) { $password = Tools::passwdGen(8, 'RANDOM'); } if (!Validate::isPasswd($password)) { return false; } $this->is_guest = 0; $this->passwd = Tools::encrypt($password); $this->cleanGroups(); $this->addGroups(array(Configuration::get('PS_CUSTOMER_GROUP'))); // add default customer group if ($this->update()) { $vars = array('{firstname}' => $this->firstname, '{lastname}' => $this->lastname, '{email}' => $this->email, '{passwd}' => $password); Mail::Send((int) $id_lang, 'guest_to_customer', Mail::l('Your guest account has been transformed into a customer account', (int) $id_lang), $vars, $this->email, $this->firstname . ' ' . $this->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $this->id_shop); return true; } return false; }
public function processForgot() { if (_PS_MODE_DEMO_) { $this->errors[] = Tools::displayError('This functionality has been disabled.'); } elseif (!($email = trim(Tools::getValue('email_forgot')))) { $this->errors[] = Tools::displayError('Email is empty.'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } else { $employee = new Employee(); if (!$employee->getByEmail($email) || !$employee) { $this->errors[] = Tools::displayError('This account does not exist.'); } elseif (strtotime($employee->last_passwd_gen . '+' . Configuration::get('PS_PASSWD_TIME_BACK') . ' minutes') - time() > 0) { $this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), Configuration::get('PS_PASSWD_TIME_BACK')); } } if (!count($this->errors)) { $pwd = Tools::passwdGen(10, 'RANDOM'); $employee->passwd = Tools::encrypt($pwd); $employee->last_passwd_gen = date('Y-m-d H:i:s', time()); $params = array('{email}' => $employee->email, '{lastname}' => $employee->lastname, '{firstname}' => $employee->firstname, '{passwd}' => $pwd); if (Mail::Send($employee->id_lang, 'employee_password', Mail::l('Your new password', $employee->id_lang), $params, $employee->email, $employee->firstname . ' ' . $employee->lastname)) { // Update employee only if the mail can be sent Shop::setContext(Shop::CONTEXT_SHOP, (int) min($employee->getAssociatedShops())); $result = $employee->update(); if (!$result) { $this->errors[] = Tools::displayError('An error occurred while attempting to change your password.'); } else { die(Tools::jsonEncode(array('hasErrors' => false, 'confirm' => $this->l('Your password has been emailed to you.', 'AdminTab', false, false)))); } } else { die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => array(Tools::displayError('An error occurred while attempting to change your password.'))))); } } elseif (Tools::isSubmit('ajax')) { die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors))); } }
public function preProcess() { parent::preProcess(); $id_customer = self::$cookie->id_customer; $customer = new Customer($id_customer); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); //self::$smarty->assign('display_thanks', 1); if (!Tools::isSubmit('submitEnquiry')) { return; } $phone = Tools::getValue('phone'); $country = Tools::getValue('country'); $enquiry = Tools::getValue('enquiry'); $enquiry = pSQL($enquiry); $query = 'INSERT INTO `ps_bulk_enquiries`(id_customer, phone, country, enquiry) values( ' . $id_customer . ', "' . $phone . '", "' . $country . '", "' . $enquiry . '" )'; $db->Execute($query); Mail::Send(1, 'bulkenquiry', Mail::l('New Bulk Enquiry'), array('{customer_name}' => $customer->firstname . ' ' . $customer->lastname . ' (' . $customer->email . ')', '{phone}' => $phone, '{country}' => $country, '{enquiry}' => $enquiry), array('*****@*****.**', '*****@*****.**'), 'IndusDiva Bulk Enquiry'); self::$smarty->assign('display_thanks', 1); }
function hookLeftColumn($params) { global $smarty; if (Tools::isSubmit('submitNewsletter')) { $this->newsletterRegistration(); if ($this->error) { $smarty->assign(array('color' => 'red', 'msg' => $this->error, 'nw_value' => isset($_POST['email']) ? pSQL($_POST['email']) : false, 'nw_error' => true, 'action' => $_POST['action'])); } elseif ($this->valid) { if (Configuration::get('NW_CONFIRMATION_EMAIL') and isset($_POST['action']) and (int) $_POST['action'] == 0) { Mail::Send((int) $params['cookie']->id_lang, 'newsletter_conf', Mail::l('Newsletter confirmation', (int) $params['cookie']->id_lang), array(), pSQL($_POST['email']), NULL, NULL, NULL, NULL, NULL, dirname(__FILE__) . '/mails/'); } $smarty->assign(array('color' => 'green', 'msg' => $this->valid, 'nw_error' => false)); } } $smarty->assign('this_path', $this->_path); return $this->display(__FILE__, 'blocknewsletter.tpl'); }
/** * Hook called when order status changed * register a discount for sponsor and send him an e-mail */ public function hookUpdateOrderStatus($params) { if (!Validate::isLoadedObject($params['newOrderStatus'])) { die($this->l('Missing parameters')); } $orderState = $params['newOrderStatus']; $order = new Order((int) $params['id_order']); if ($order and !Validate::isLoadedObject($order)) { die($this->l('Incorrect Order object.')); } include_once dirname(__FILE__) . '/ReferralProgramModule.php'; $customer = new Customer((int) $order->id_customer); $stats = $customer->getStats(); $nbOrdersCustomer = (int) $stats['nb_orders'] + 1; // hack to count current order $referralprogram = new ReferralProgramModule(ReferralProgramModule::isSponsorised((int) $customer->id, true)); if (!Validate::isLoadedObject($referralprogram)) { return false; } $sponsor = new Customer((int) $referralprogram->id_sponsor); if ((int) $orderState->logable and $nbOrdersCustomer >= (int) $this->_configuration['REFERRAL_ORDER_QUANTITY'] and $referralprogram->registerDiscountForSponsor((int) $order->id_currency)) { $cartRule = new CartRule((int) $referralprogram->id_cart_rule_sponsor); $currency = new Currency((int) $order->id_currency); $discount_display = ReferralProgram::displayDiscount($cartRule->reduction_percent ? $cartRule->reduction_percent : $cartRule->reduction_amount, $cartRule->reduction_percent ? 1 : 2, $currency); $data = array('{sponsored_firstname}' => $customer->firstname, '{sponsored_lastname}' => $customer->lastname, '{discount_display}' => $discount_display, '{discount_name}' => $cartRule->code); Mail::Send((int) $order->id_lang, 'referralprogram-congratulations', Mail::l('Congratulations!', (int) $order->id_lang), $data, $sponsor->email, $sponsor->firstname . ' ' . $sponsor->lastname, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__) . '/mails/'); return true; } return false; }
public function postProcess() { if ($id_customer_thread = (int) Tools::getValue('id_customer_thread')) { if ($id_contact = (int) Tools::getValue('id_contact')) { Db::getInstance()->execute(' UPDATE ' . _DB_PREFIX_ . 'customer_thread SET id_contact = ' . (int) $id_contact . ' WHERE id_customer_thread = ' . (int) $id_customer_thread); } if ($id_status = (int) Tools::getValue('setstatus')) { $status_array = array(1 => 'open', 2 => 'closed', 3 => 'pending1', 4 => 'pending2'); Db::getInstance()->execute(' UPDATE ' . _DB_PREFIX_ . 'customer_thread SET status = "' . $status_array[$id_status] . '" WHERE id_customer_thread = ' . (int) $id_customer_thread . ' LIMIT 1 '); } if (isset($_POST['id_employee_forward'])) { $messages = Db::getInstance()->getRow(' SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname FROM ' . _DB_PREFIX_ . 'customer_thread ct LEFT JOIN ' . _DB_PREFIX_ . 'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread) LEFT JOIN ' . _DB_PREFIX_ . 'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = ' . (int) $this->context->language->id . ') LEFT OUTER JOIN ' . _DB_PREFIX_ . 'employee e ON e.id_employee = cm.id_employee LEFT OUTER JOIN ' . _DB_PREFIX_ . 'customer c ON (c.email = ct.email) WHERE ct.id_customer_thread = ' . (int) Tools::getValue('id_customer_thread') . ' ORDER BY cm.date_add DESC '); $output = $this->displayMessage($messages, true, (int) Tools::getValue('id_employee_forward')); $cm = new CustomerMessage(); $cm->id_employee = (int) $this->context->employee->id; $cm->id_customer_thread = (int) Tools::getValue('id_customer_thread'); $cm->ip_address = (int) ip2long(Tools::getRemoteAddr()); $current_employee = $this->context->employee; $id_employee = (int) Tools::getValue('id_employee_forward'); $employee = new Employee($id_employee); $email = Tools::getValue('email'); $message = Tools::getValue('message_forward'); if (($error = $cm->validateField('message', $message, null, array(), true)) !== true) { $this->errors[] = $error; } elseif ($id_employee && $employee && Validate::isLoadedObject($employee)) { $params = array('{messages}' => stripslashes($output), '{employee}' => $current_employee->firstname . ' ' . $current_employee->lastname, '{comment}' => stripslashes(Tools::nl2br($_POST['message_forward'])), '{firstname}' => $employee->firstname, '{lastname}' => $employee->lastname); if (Mail::Send($this->context->language->id, 'forward_msg', Mail::l('Fwd: Customer message', $this->context->language->id), $params, $employee->email, $employee->firstname . ' ' . $employee->lastname, $current_employee->email, $current_employee->firstname . ' ' . $current_employee->lastname, null, null, _PS_MAIL_DIR_, true)) { $cm->private = 1; $cm->message = $this->l('Message forwarded to') . ' ' . $employee->firstname . ' ' . $employee->lastname . "\n" . $this->l('Comment:') . ' ' . $message; $cm->add(); } } elseif ($email && Validate::isEmail($email)) { $params = array('{messages}' => Tools::nl2br(stripslashes($output)), '{employee}' => $current_employee->firstname . ' ' . $current_employee->lastname, '{comment}' => stripslashes($_POST['message_forward'])); if (Mail::Send($this->context->language->id, 'forward_msg', Mail::l('Fwd: Customer message', $this->context->language->id), $params, $email, null, $current_employee->email, $current_employee->firstname . ' ' . $current_employee->lastname, null, null, _PS_MAIL_DIR_, true)) { $cm->message = $this->l('Message forwarded to') . ' ' . $email . "\n" . $this->l('Comment:') . ' ' . $message; $cm->add(); } } else { $this->errors[] = '<div class="alert error">' . Tools::displayError('The email address is invalid.') . '</div>'; } } if (Tools::isSubmit('submitReply')) { $ct = new CustomerThread($id_customer_thread); ShopUrl::cacheMainDomainForShop((int) $ct->id_shop); $cm = new CustomerMessage(); $cm->id_employee = (int) $this->context->employee->id; $cm->id_customer_thread = $ct->id; $cm->ip_address = (int) ip2long(Tools::getRemoteAddr()); $cm->message = Tools::getValue('reply_message'); if (($error = $cm->validateField('message', $cm->message, null, array(), true)) !== true) { $this->errors[] = $error; } elseif (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0) { $this->errors[] = Tools::displayError('An error occurred during the file upload process.'); } elseif ($cm->add()) { $file_attachment = null; if (!empty($_FILES['joinFile']['name'])) { $file_attachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']); $file_attachment['name'] = $_FILES['joinFile']['name']; $file_attachment['mime'] = $_FILES['joinFile']['type']; } $customer = new Customer($ct->id_customer); $params = array('{reply}' => Tools::nl2br(Tools::getValue('reply_message')), '{link}' => Tools::url($this->context->link->getPageLink('contact', true), 'id_customer_thread=' . (int) $ct->id . '&token=' . $ct->token), '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname); //#ct == id_customer_thread #tc == token of thread <== used in the synchronization imap $contact = new Contact((int) $ct->id_contact, (int) $ct->id_lang); if (Validate::isLoadedObject($contact)) { $from_name = $contact->name; $from_email = $contact->email; } else { $from_name = null; $from_email = null; } if (Mail::Send((int) $ct->id_lang, 'reply_msg', sprintf(Mail::l('An answer to your message is available #ct%1$s #tc%2$s', $ct->id_lang), $ct->id, $ct->token), $params, Tools::getValue('msg_email'), null, $from_email, $from_name, $file_attachment, null, _PS_MAIL_DIR_, true)) { $ct->status = 'closed'; $ct->update(); } Tools::redirectAdmin(self::$currentIndex . '&id_customer_thread=' . (int) $id_customer_thread . '&viewcustomer_thread&token=' . Tools::getValue('token')); } else { $this->errors[] = Tools::displayError('An error occurred. Your message was not sent. Please contact your system administrator.'); } } } return parent::postProcess(); }
/** * Send a verification email * * @param string $email * @param string $token * * @return bool */ protected function sendVerificationEmail($email, $token) { $verif_url = Context::getContext()->link->getModuleLink('blocknewsletter', 'verification', array('token' => $token)); return Mail::Send($this->context->language->id, 'newsletter_verif', Mail::l('Email verification', $this->context->language->id), array('{verif_url}' => $verif_url), $email, null, null, null, null, null, dirname(__FILE__) . '/mails/', false, $this->context->shop->id); }
public function update_cart_by_junglee_xml($order_id, $data) { $xml = simplexml_load_string($data); $prefix = _DB_PREFIX_; $tablename = $prefix . 'orders'; $total_amount = 0; $total_principal = 0; $shipping_amount = 0; $total_promo = 0; foreach ($xml->ProcessedOrder->ProcessedOrderItems->ProcessedOrderItem as $item) { $product_id = (string) $item->SKU; $product = new Product((int) $product_id); $SKU = $product->reference; $Title = (string) $item->Title; $Amount = (double) $item->Price->Amount; $other_promo = 0; foreach ($item->ItemCharges->Component as $amount_type) { $item_charge_type = (string) $amount_type->Type; if ($item_charge_type == 'Principal') { $principal = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'Shipping') { $Shipping = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'PrincipalPromo') { $principal_promo = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'ShippingPromo') { $shipping_promo = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'OtherPromo') { $other_promo = (string) $amount_type->Charge->Amount; } } $CurrencyCode = (string) $item->Price->CurrencyCode; $Quantity = (int) $item->Quantity; $total_principal += $principal; $total_amount += $principal - $principal_promo + ($Shipping - $shipping_promo); $shipping_amount += $Shipping; $total_promo += $principal_promo + $shipping_promo + $other_promo; } $ShippingServiceLevel = (string) $xml->ProcessedOrder->ShippingServiceLevel; $sql = 'UPDATE `' . $prefix . 'pwa_orders` set `shipping_service` = "' . $ShippingServiceLevel . '" , `order_type` = "junglee" where `prestashop_order_id` = "' . $order_id . '" '; Db::getInstance()->Execute($sql); $email = (string) $xml->ProcessedOrder->BuyerInfo->BuyerEmailAddress; $sql = 'SELECT * from `' . $prefix . 'customer` where email = "' . $email . '" '; $results = Db::getInstance()->ExecuteS($sql); if (empty($results)) { $name = (string) $xml->ProcessedOrder->BuyerInfo->BuyerName; $name_arr = explode(' ', $name); if (count($name_arr) > 1) { $firstname = ''; for ($i = 0; $i <= count($name_arr) - 2; $i++) { $firstname = $firstname . ' ' . $name_arr[$i]; } $lastname = $name_arr[count($name_arr) - 1]; } else { $firstname = $name; $lastname = '.'; } $password = Tools::passwdGen(); $customer = new Customer(); $customer->firstname = trim($firstname); $customer->lastname = $lastname; $customer->email = (string) $xml->ProcessedOrder->BuyerInfo->BuyerEmailAddress; $customer->passwd = md5($password); $customer->active = 1; if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) { $customer->is_guest = 1; } else { $customer->is_guest = 0; } $customer->add(); $customer_id = $customer->id; if (Configuration::get('PS_CUSTOMER_CREATION_EMAIL') && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) { Mail::Send($this->context->language->id, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => $password), $customer->email, $customer->firstname . ' ' . $customer->lastname); } } else { $customer_id = $results[0]['id_customer']; } $id_country = Country::getByIso((string) $xml->ProcessedOrder->ShippingAddress->CountryCode); if ($id_country == 0 || $id_country == '') { $id_country = 110; } $name = (string) $xml->ProcessedOrder->ShippingAddress->Name; $name_arr = explode(' ', $name); if (count($name_arr) > 1) { $firstname = ''; for ($i = 0; $i <= count($name_arr) - 2; $i++) { $firstname = $firstname . ' ' . $name_arr[$i]; } $lastname = $name_arr[count($name_arr) - 1]; } else { $firstname = $name; $lastname = '.'; } $address = new Address(); $address->id_country = $id_country; $address->id_state = 0; $address->id_customer = $customer_id; $address->alias = 'My Address'; $address->firstname = trim($firstname); $address->lastname = $lastname; $address->address1 = (string) $xml->ProcessedOrder->ShippingAddress->AddressFieldOne; $address->address2 = (string) $xml->ProcessedOrder->ShippingAddress->AddressFieldTwo; $address->postcode = (string) $xml->ProcessedOrder->ShippingAddress->PostalCode; $address->city = (string) $xml->ProcessedOrder->ShippingAddress->City . ' ' . (string) $xml->ProcessedOrder->ShippingAddress->State; $address->active = 1; $address->add(); $address_id = $address->id; //$id_order_state = Configuration::get('PS_OS_PREPARATION'); $id_order_state = 99; $reference = Order::generateReference(); $order = new Order(); $order->id = $order_id; $order->id_customer = (int) $customer_id; $order->id_address_invoice = (int) $address_id; $carrier = null; $sql = 'SELECT id_carrier from `' . $prefix . 'carrier` where `active` = 1 and `deleted` = 0 limit 0,1'; $result = Db::getInstance()->ExecuteS($sql); $id_carrier = $result[0]['id_carrier']; $sql = 'SELECT id_currency from `' . $prefix . 'currency` where `active` = 1 and `deleted` = 0 and `iso_code` = "INR" limit 0,1'; $result = Db::getInstance()->ExecuteS($sql); $currency_id = $result[0]['id_currency']; $sql = 'UPDATE `' . $tablename . '` set `id_customer` = ' . (int) $customer_id . ', `id_carrier` = ' . $id_carrier . ', `id_address_invoice` = ' . (int) $address_id . ', `id_address_delivery` = ' . (int) $address_id . ', `id_currency` = ' . $currency_id . ', `reference` = "' . $reference . '", `secure_key` = "' . md5(uniqid()) . '", `total_paid` = ' . $total_amount . ', `total_paid_tax_incl` = ' . $total_amount . ', `total_paid_tax_excl` = ' . $total_amount . ', `total_paid_real` = 0, `total_shipping` = ' . $shipping_amount . ', `total_shipping_tax_incl` = ' . $shipping_amount . ', `total_shipping_tax_excl` = ' . $shipping_amount . ', `total_discounts` = ' . (double) $total_promo . ', `total_discounts_tax_incl` = ' . (double) $total_promo . ', `total_discounts_tax_excl` = ' . (double) $total_promo . ', `total_products` = ' . $total_principal . ', `total_products_wt` = ' . $total_principal . ', `invoice_date` = "0000-00-00 00:00:00", `delivery_date` = "0000-00-00 00:00:00" where `id_order` = ' . $order_id . ' '; //`round_mode` = '.Configuration::get('PS_PRICE_ROUND_MODE').', /*`total_wrapping_tax_incl` = '.$WrappingAmount.', `total_wrapping_tax_excl` = '.$WrappingAmount.', `total_wrapping` = '.$WrappingAmount.',*/ Db::getInstance()->Execute($sql); $acknowledge_arr = array(); $i = 0; foreach ($xml->ProcessedOrder->ProcessedOrderItems->ProcessedOrderItem as $item) { $product_id = (string) $item->SKU; $product = new Product((int) $product_id); $SKU = $product->reference; $AmazonOrderItemCode = (string) $item->AmazonOrderItemCode; $Title = (string) $item->Title; $Amount = (double) $item->Price->Amount; $acknowledge_arr['items'][$i]['AmazonOrderItemCode'] = $AmazonOrderItemCode; $acknowledge_arr['items'][$i]['product_id'] = $product_id; $CurrencyCode = (string) $item->Price->CurrencyCode; $Quantity = (int) $item->Quantity; $other_promo = 0; foreach ($item->ItemCharges->Component as $amount_type) { $item_charge_type = (string) $amount_type->Type; if ($item_charge_type == 'Principal') { $principal = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'Shipping') { $Shipping = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'PrincipalPromo') { $principal_promo = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'ShippingPromo') { $shipping_promo = (string) $amount_type->Charge->Amount; } if ($item_charge_type == 'OtherPromo') { $other_promo = (string) $amount_type->Charge->Amount; } } $sql = 'INSERT into `' . $prefix . 'order_detail` set `id_order` = ' . $order_id . ', `product_id` = ' . $product_id . ', `product_name` = "' . $Title . '", `product_quantity` = ' . $Quantity . ', `product_quantity_in_stock` = ' . $Quantity . ', `product_price` = ' . $Amount . ', `product_reference` = "' . $SKU . '", `total_price_tax_incl` = ' . $Amount * $Quantity . ', `total_price_tax_excl` = ' . $Amount * $Quantity . ', `unit_price_tax_incl` = ' . $Amount . ', `unit_price_tax_excl` = ' . $Amount . ', `original_product_price` = ' . $Amount . ' '; Db::getInstance()->Execute($sql); $sql = 'UPDATE `' . $prefix . 'stock_available` set `quantity` = `quantity` - ' . $Quantity . ' where `id_product` = ' . $product_id . ' and `id_product_attribute` = 0 '; Db::getInstance()->Execute($sql); $date = date('Y-m-d'); $sql = 'UPDATE `' . $prefix . 'product_sale` set `quantity` = `quantity` + ' . $Quantity . ', `sale_nbr` = `sale_nbr` + ' . $Quantity . ', `date_upd` = ' . $date . ' where `id_product` = ' . $product_id . ' '; Db::getInstance()->Execute($sql); $i++; } // Adding an entry in order_carrier table if (!is_null($carrier)) { $order_carrier = new OrderCarrier(); $order_carrier->id_order = (int) $order->id; $order_carrier->id_carrier = (int) $id_carrier; $order_carrier->weight = '0'; $order_carrier->shipping_cost_tax_excl = (double) $shipping_amount; $order_carrier->shipping_cost_tax_incl = (double) $shipping_amount; $order_carrier->add(); } else { $order_carrier = new OrderCarrier(); $order_carrier->id_order = (int) $order->id; $order_carrier->id_carrier = (int) $id_carrier; $order_carrier->weight = '0'; $order_carrier->shipping_cost_tax_excl = (double) $shipping_amount; $order_carrier->shipping_cost_tax_incl = (double) $shipping_amount; $order_carrier->add(); } // Set the order status $history = new OrderHistory(); $history->id_order = (int) $order->id; $history->changeIdOrderState((int) $id_order_state, $order->id, true); $history->addWithemail(true, array()); $acknowledge_arr['MerchantOrderID'] = (int) $order->id; }
*/ require_once dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; require_once dirname(__FILE__) . '/WishList.php'; $context = Context::getContext(); // Instance of module class for translations $module = new BlockWishList(); if (Configuration::get('PS_TOKEN_ENABLE') == 1 and strcmp(Tools::getToken(false), Tools::getValue('token')) and $context->customer->isLogged() === true) { exit($module->l('invalid token', 'sendwishlist')); } if ($context->customer->isLogged()) { $id_wishlist = (int) Tools::getValue('id_wishlist'); if (empty($id_wishlist) === true) { exit($module->l('Invalid wishlist', 'sendwishlist')); } for ($i = 1; empty($_POST['email' . strval($i)]) === false; ++$i) { $to = Tools::getValue('email' . $i); $wishlist = WishList::exists($id_wishlist, $context->customer->id, true); if ($wishlist === false) { exit($module->l('Invalid wishlist', 'sendwishlist')); } if (WishList::addEmail($id_wishlist, $to) === false) { exit($module->l('Wishlist send error', 'sendwishlist')); } $toName = strval(Configuration::get('PS_SHOP_NAME')); $customer = $context->customer; if (Validate::isLoadedObject($customer)) { Mail::Send($context->language->id, 'wishlist', sprintf(Mail::l('Message from %1$s %2$s', $context->language->id), $customer->lastname, $customer->firstname), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{wishlist}' => $wishlist['name'], '{message}' => Tools::getProtocol() . htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/blockwishlist/view.php?token=' . $wishlist['token']), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname, NULL, NULL, dirname(__FILE__) . '/mails/'); } } }
public function postProcess() { $this->context = Context::getContext(); if (Tools::isSubmit('deleteorder_return_detail')) { if ($this->tabAccess['delete'] === '1') { if (($id_order_detail = (int) Tools::getValue('id_order_detail')) && Validate::isUnsignedId($id_order_detail)) { if (($id_order_return = (int) Tools::getValue('id_order_return')) && Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); if (!Validate::isLoadedObject($orderReturn)) { die(Tools::displayError()); } if ((int) $orderReturn->countProduct() > 1) { if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, (int) Tools::getValue('id_customization', 0))) { Tools::redirectAdmin(self::$currentIndex . '&conf=4token=' . $this->token); } else { $this->errors[] = Tools::displayError('An error occurred while deleting the details of your order return.'); } } else { $this->errors[] = Tools::displayError('You need at least one product.'); } } else { $this->errors[] = Tools::displayError('The order return is invalid.'); } } else { $this->errors[] = Tools::displayError('The order return content is invalid.'); } } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } elseif (Tools::isSubmit('submitAddorder_return') || Tools::isSubmit('submitAddorder_returnAndStay')) { if ($this->tabAccess['edit'] === '1') { if (($id_order_return = (int) Tools::getValue('id_order_return')) && Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); $order = new Order($orderReturn->id_order); $customer = new Customer($orderReturn->id_customer); $orderReturn->state = (int) Tools::getValue('state'); if ($orderReturn->save()) { $orderReturnState = new OrderReturnState($orderReturn->state); $vars = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order_return}' => $id_order_return, '{state_order_return}' => isset($orderReturnState->name[(int) $order->id_lang]) ? $orderReturnState->name[(int) $order->id_lang] : $orderReturnState->name[(int) Configuration::get('PS_LANG_DEFAULT')]); Mail::Send((int) $order->id_lang, 'order_return_state', Mail::l('Your order return status has changed', $order->id_lang), $vars, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop); if (Tools::isSubmit('submitAddorder_returnAndStay')) { Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . $this->token . '&updateorder_return&id_order_return=' . (int) $id_order_return); } else { Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . $this->token); } } } else { $this->errors[] = Tools::displayError('No order return ID has been specified.'); } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } parent::postProcess(); }
public function sendChangedNotification(Order $order = null) { if (is_null($order)) { $order = new Order(Tools::getValue('id_order')); } $data = array('{lastname}' => $order->getCustomer()->lastname, '{firstname}' => $order->getCustomer()->firstname, '{id_order}' => (int) $order->id, '{order_name}' => $order->getUniqReference()); Mail::Send((int) $order->id_lang, 'order_changed', Mail::l('Your order has been changed', (int) $order->id_lang), $data, $order->getCustomer()->email, $order->getCustomer()->firstname . ' ' . $order->getCustomer()->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop); }