Merge branch 'ticket-14805-creditexpiration'

This commit is contained in:
Michael RICOIS 2017-12-06 09:36:17 +01:00
commit b30cfbd7ce

View File

@ -16,7 +16,8 @@ if(!Tools::isCli()){
$longopts = array(
'verbose',
'dry-run',
'date:'
'date:',
'cron',
);
$shortopts = "";
$options = getopt($shortopts, $longopts);
@ -32,6 +33,11 @@ if (isset($options['dry-run'])) {
$optTest = true;
}
$optCron = false;
if (isset($options['cron'])) {
$optCron = true;
}
// Date
$delay = new DateInterval('P1M');
$dateSelect = new DateTime();
@ -46,6 +52,11 @@ echo date('YmdHis')." - 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";
}
$sql = "
SELECT
d.id_discount,
@ -57,11 +68,6 @@ FROM `"._DB_PREFIX_."discount` d, "._DB_PREFIX_."loyalty l, "._DB_PREFIX_."order
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."'";
if ($optVerbose) {
echo date('YmdHis')." - START ".$dateSelect->format('Y-m-d')." \n";
}
$result = Db::getInstance()->ExecuteS($sql);
$nb = count($result);
if ($optVerbose) { echo date('YmdHis')." - $nb mails to send \n"; }