Fix sql
This commit is contained in:
parent
4bbf978846
commit
62b7f44ed5
@ -48,13 +48,13 @@ if (isset($options['date'])) {
|
||||
}
|
||||
|
||||
// Start
|
||||
echo date('YmdHis')." - START ".$dateSelect->format('Y-m-d')." \n";
|
||||
echo date('Y-m-d H:i:s')." - START ".$dateSelect->format('Y-m-d')." \n";
|
||||
|
||||
$dateSqlStart = $dateSelect->format('Y-m-d').' 00:00:00';
|
||||
$dateSqlEnd = $dateSelect->format('Y-m-d').' 23:59:59';
|
||||
|
||||
if ($optVerbose) {
|
||||
echo date('YmdHis')." - START DATE ".$dateSqlStart." to ".$dateSqlEnd." \n";
|
||||
echo date('Y-m-d H:i:s')." - START DATE ".$dateSqlStart." to ".$dateSqlEnd." \n";
|
||||
}
|
||||
|
||||
$sql = "
|
||||
@ -65,53 +65,58 @@ SELECT
|
||||
d.date_to,
|
||||
l.id_order
|
||||
FROM `"._DB_PREFIX_."discount` d, "._DB_PREFIX_."loyalty l, "._DB_PREFIX_."order_discount
|
||||
LEFT OUTER JOIN `"._DB_PREFIX_."order_discount od ON (od.id_discount IS NULL)
|
||||
LEFT OUTER JOIN `"._DB_PREFIX_."order_discount` od ON (od.id_discount IS NULL)
|
||||
WHERE d.active=1 AND d.id_discount=l.id_discount
|
||||
AND d.date_to > '".$dateSqlStart."' AND d.date_to < '".$dateSqlEnd."'";
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
$nb = count($result);
|
||||
if ($optVerbose) { echo date('YmdHis')." - $nb mails to send \n"; }
|
||||
if ($nb > 0) {
|
||||
foreach($result as $l) {
|
||||
// Customer infos
|
||||
$customerModel = new Customer($l['id_customer']);
|
||||
|
||||
// Order infos
|
||||
$orderModel = new Order($l['id_order']);
|
||||
$id_lang = $orderModel->id_lang;
|
||||
|
||||
$templateVars = array(
|
||||
'{firstname}' => $customerModel->firstname,
|
||||
'{lastname}' => $customerModel->lastname,
|
||||
'{commandenum}' => $orderModel->id,
|
||||
);
|
||||
|
||||
echo date('YmdHis')." - Rappel credit pour le client ".$customerModel->email;
|
||||
|
||||
$to = $customerModel->email;
|
||||
// @todo : for test
|
||||
$to = 'ricois@antadis.com';
|
||||
|
||||
// Only Display values
|
||||
if ($optTest) {
|
||||
print_r($templateVars);
|
||||
if ($result === false) {
|
||||
echo $sql;
|
||||
echo "\n";
|
||||
} else {
|
||||
$nb = count($result);
|
||||
if ($optVerbose) { echo date('YmdHis')." - $nb mails to send \n"; }
|
||||
if ($nb > 0) {
|
||||
foreach($result as $l) {
|
||||
// Customer infos
|
||||
$customerModel = new Customer($l['id_customer']);
|
||||
|
||||
// Order infos
|
||||
$orderModel = new Order($l['id_order']);
|
||||
$id_lang = $orderModel->id_lang;
|
||||
|
||||
$templateVars = array(
|
||||
'{firstname}' => $customerModel->firstname,
|
||||
'{lastname}' => $customerModel->lastname,
|
||||
'{commandenum}' => $orderModel->id,
|
||||
);
|
||||
|
||||
echo date('Y-m-d H:i:s')." - Rappel credit pour le client ".$customerModel->email;
|
||||
|
||||
$to = $customerModel->email;
|
||||
// @todo : for test
|
||||
$to = 'ricois@antadis.com';
|
||||
|
||||
// Only Display values
|
||||
if ($optTest) {
|
||||
print_r($templateVars);
|
||||
echo "\n";
|
||||
}
|
||||
// Send mail
|
||||
else {
|
||||
$isSent = Mail::Send($id_lang, 'loyalty_discount_reminder',
|
||||
Mail::l('Your loyalty credits', $id_lang), $templateVars, $to,
|
||||
$customerModel->firstname.' '.$customerModel->lastname);
|
||||
if ($isSent) {
|
||||
echo " - Envoyé";
|
||||
}
|
||||
else {
|
||||
echo " - ERROR";
|
||||
}
|
||||
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
// Send mail
|
||||
else {
|
||||
$isSent = Mail::Send($id_lang, 'loyalty_discount_reminder',
|
||||
Mail::l('Your loyalty credits', $id_lang), $templateVars, $to,
|
||||
$customerModel->firstname.' '.$customerModel->lastname);
|
||||
if ($isSent) {
|
||||
echo " - Envoyé";
|
||||
}
|
||||
else {
|
||||
echo " - ERROR";
|
||||
}
|
||||
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo date('YmdHis')." - END\n";
|
||||
echo date('Y-m-d H:i:s')." - END\n";
|
||||
|
Loading…
Reference in New Issue
Block a user