* @copyright Magavenue * @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0 * @category modules * * @note If you want to customize the module, contact us at contact@magavenue.com */ require_once(dirname(__FILE__) . '/../../config/config.inc.php'); include(dirname(__FILE__) . '/../../init.php'); include(dirname(__FILE__) . '/installmentpayment.php'); if (!defined('_PS_VERSION_') || !Tools::getIsset('key') || Tools::getValue('key') != 'Zrt978heov87MagT') { exit; } $time = time(); $tendays = time() - (Configuration::get('ACOMPTE_DAYS') * 24 * 60 * 60); $date = date('Y-d-m', $tendays); $sql = 'SELECT id_order FROM `' . _DB_PREFIX_ . 'orders` where `date_add` like "' . $date . '%" '; $return = Db::getInstance()->executeS($sql); if (!empty($return)) { foreach ($return as $key => $order) { $context; $order = new Order($order['id_order']); $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` where `id_cart`=' . (int) $order->id_cart . ' and `rest` > 0'; $installement = Db::getInstance()->executeS($sql); if (!empty($installement)) { $iso = Language::getIsoById((int) $context->language->id); $customer = new Customer((int) $order->id_customer); $link = new LinkCore(); $installement = $installement[0]; if (isset($installement['state'])) { $templateVars = array( '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{reference}' => $order->reference, '{pay}' => Tools::displayPrice($installement['payer'], new Currency($order->id_currency)), '{rest}' => Tools::displayPrice($installement['rest'], new Currency($order->id_currency)), '{total}' => Tools::displayPrice($installement['total'], new Currency($order->id_currency)), '{be_paid}' => Tools::displayPrice((float) Tools::getValue('installmentpayment'), new Currency($order->id_currency)), '{installement_url}' => $link->getModuleLink('installmentpayment', 'installmentpayment', array('select' => $order->id)) ); $template = 'claim'; //$customer->email = 'magavenueanuj@gmail.com'; $subject = 'Il reste à payer pour la commande n° #' . $order->reference; if (file_exists(_PS_MODULE_DIR_ . 'installmentpayment/mails/' . $iso . '/' . $template . '.txt') and file_exists(_PS_MODULE_DIR_ . 'installmentpayment/mails/' . $iso . '/' . $template . '.html')) { Mail::Send((int) $context->language->id, $template, $subject, $templateVars, $customer->email, null, Configuration::get('PS_SHOP_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, _PS_MODULE_DIR_ . 'installmentpayment/mails/'); } } } } echo 'Ok'; } exit;