fix from prod

This commit is contained in:
root 2017-09-18 11:01:28 +02:00
parent ede8721e84
commit 9c2cce3d0b

View File

@ -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();
}