Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
cc7d2048f5
@ -55,6 +55,7 @@ class AdminAntAlert extends AdminTab {
|
|||||||
} else {
|
} else {
|
||||||
$alert = new AntAlert();
|
$alert = new AntAlert();
|
||||||
$alert->date_last_sent = date("Y-m-d H:i:s");
|
$alert->date_last_sent = date("Y-m-d H:i:s");
|
||||||
|
$alert->date_last_check = date("Y-m-d H:i:s");
|
||||||
}
|
}
|
||||||
|
|
||||||
$alert->id_contact = (int)Tools::getValue('id_contact');
|
$alert->id_contact = (int)Tools::getValue('id_contact');
|
||||||
|
@ -96,12 +96,21 @@ class Ant_Alert extends Module
|
|||||||
if ((int)$dteDiff->format("%H") >= (int)$alert->hours) { // prod
|
if ((int)$dteDiff->format("%H") >= (int)$alert->hours) { // prod
|
||||||
|
|
||||||
$open_messages = Db::getInstance()->getRow('
|
$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
|
FROM '._DB_PREFIX_.'customer_thread ct
|
||||||
WHERE ct.status = "open"
|
WHERE ct.status = "open"
|
||||||
|
AND ct.date_add >= "'.pSQL($alert->date_last_check).'"
|
||||||
GROUP BY ct.id_contact HAVING COUNT(*) > 0 AND ct.id_contact ='.(int)$alert->id_contact
|
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);
|
||||||
|
$hourLimitMin = (int)$alert->hours;
|
||||||
|
$hourLimitMax = (int)$alert->hours+1;
|
||||||
|
if (
|
||||||
|
(int)$open_messages['total'] >= (int)$alert->limit
|
||||||
|
&& (int)$minDiff->format("%H") >= $hourLimitMin
|
||||||
|
&& (int)$minDiff->format("%H") <= $hourLimitMax
|
||||||
|
) {
|
||||||
// dev
|
// dev
|
||||||
//$to = array('marion@antadis.com');
|
//$to = array('marion@antadis.com');
|
||||||
// prod
|
// prod
|
||||||
@ -117,11 +126,15 @@ class Ant_Alert extends Module
|
|||||||
'{contact}' => $contact->name,
|
'{contact}' => $contact->name,
|
||||||
);
|
);
|
||||||
foreach ($to as $email) {
|
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->date_last_sent = date('Y-m-d H:i:s');
|
||||||
|
$alert->date_last_check = date('Y-m-d H:i:s');
|
||||||
$alert->save();
|
$alert->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} elseif((int)$open_messages['total'] >= (int)$alert->limit && (int)$minDiff->format("%H") > $hourLimitMax) {
|
||||||
|
$alert->date_last_check = date('Y-m-d H:i:s');
|
||||||
|
$alert->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,19 @@ class AntAlert extends ObjectModel
|
|||||||
public $date_add;
|
public $date_add;
|
||||||
public $date_upd;
|
public $date_upd;
|
||||||
public $date_last_sent;
|
public $date_last_sent;
|
||||||
|
public $date_last_check;
|
||||||
|
|
||||||
protected $fieldsRequired = array('id_contact','limit','hours');
|
protected $fieldsRequired = array('id_contact','limit','hours');
|
||||||
protected $fieldsValidate = array(
|
protected $fieldsValidate = array(
|
||||||
'id_alert' => 'isUnsignedId',
|
'id_alert' => 'isUnsignedId',
|
||||||
'enabled' => 'isBool',
|
'enabled' => 'isBool',
|
||||||
'id_contact' => 'isUnsignedId',
|
'id_contact' => 'isUnsignedId',
|
||||||
'limit' => 'isInt',
|
'limit' => 'isInt',
|
||||||
'hours' => 'isInt',
|
'hours' => 'isInt',
|
||||||
'date_add' => 'isDate',
|
'date_add' => 'isDate',
|
||||||
'date_upd' => 'isDate',
|
'date_upd' => 'isDate',
|
||||||
'date_last_sent' => 'isDate',
|
'date_last_sent' => 'isDate',
|
||||||
|
'date_last_check' => 'isDate',
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $table = 'ant_alert';
|
protected $table = 'ant_alert';
|
||||||
@ -32,14 +34,15 @@ class AntAlert extends ObjectModel
|
|||||||
{
|
{
|
||||||
parent::validateFields();
|
parent::validateFields();
|
||||||
|
|
||||||
$fields['id_alert'] = (int)$this->id_alert;
|
$fields['id_alert'] = (int)$this->id_alert;
|
||||||
$fields['enabled'] = (int)$this->enabled;
|
$fields['enabled'] = (int)$this->enabled;
|
||||||
$fields['id_contact'] = (int)$this->id_contact;
|
$fields['id_contact'] = (int)$this->id_contact;
|
||||||
$fields['limit'] = (int)$this->limit;
|
$fields['limit'] = (int)$this->limit;
|
||||||
$fields['hours'] = (int)$this->hours;
|
$fields['hours'] = (int)$this->hours;
|
||||||
$fields['date_add'] = pSQL($this->date_add);
|
$fields['date_add'] = pSQL($this->date_add);
|
||||||
$fields['date_upd'] = pSQL($this->date_upd);
|
$fields['date_upd'] = pSQL($this->date_upd);
|
||||||
$fields['date_last_sent'] = pSQL($this->date_last_sent);
|
$fields['date_last_sent'] = pSQL($this->date_last_sent);
|
||||||
|
$fields['date_last_check'] = pSQL($this->date_last_check);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user