From 9c2cce3d0bfad343f7fbe0d9a1a324e10c3e10b1 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 18 Sep 2017 11:01:28 +0200 Subject: [PATCH] fix from prod --- modules/ant_alert/ant_alert.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/ant_alert/ant_alert.php b/modules/ant_alert/ant_alert.php index 55cd3a0e..0eb7dbc1 100644 --- a/modules/ant_alert/ant_alert.php +++ b/modules/ant_alert/ant_alert.php @@ -96,12 +96,15 @@ class Ant_Alert extends Module if ((int)$dteDiff->format("%H") >= (int)$alert->hours) { // prod $open_messages = Db::getInstance()->getRow(' - SELECT COUNT(*) as total + SELECT COUNT(*) as total, MIN(ct.`date_add`) as `min_date` FROM '._DB_PREFIX_.'customer_thread ct WHERE ct.status = "open" + AND ct.date_add > "'.pSQL($alert->date_last_sent).'" GROUP BY ct.id_contact HAVING COUNT(*) > 0 AND ct.id_contact ='.(int)$alert->id_contact ); - if ((int)$open_messages['total'] >= (int)$alert->limit) { + $date_min = new Datetime($open_messages['min_date']); + $minDiff = $date_min->diff($now); + if ((int)$open_messages['total'] >= (int)$alert->limit && (int)$minDiff->format("%H") >= (int)$alert->hours) { // dev //$to = array('marion@antadis.com'); // prod @@ -117,7 +120,7 @@ class Ant_Alert extends Module '{contact}' => $contact->name, ); foreach ($to as $email) { - if(Mail::Send(2, 'ant_alert', 'Alert error', $data, $to)) { + if(Mail::Send(2, 'ant_alert', 'Alert error', $data, $email)) { $alert->date_last_sent = date('Y-m-d H:i:s'); $alert->save(); }