mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 19:02:35 +01:00
Merge pull request #28952 from JonBendtsen/fix_notification_count
Fix Thirdparty Notification number persist after Contact deletion
This commit is contained in:
@@ -1298,6 +1298,18 @@ class Contact extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// Remove Notifications
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def WHERE fk_contact = ".((int) $this->id);
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error .= $this->db->lasterror();
|
||||
$errorflag = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// Remove category
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople = ".((int) $this->id);
|
||||
|
||||
@@ -321,9 +321,12 @@ function societe_prepare_head(Societe $object)
|
||||
if (!is_null($dataretrieved)) {
|
||||
$nbNotif = $dataretrieved;
|
||||
} else {
|
||||
// List of notifications enabled for contacts
|
||||
$sql = "SELECT COUNT(n.rowid) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
|
||||
$sql .= " WHERE fk_soc = ".((int) $object->id);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
|
||||
$sql .= " WHERE a.rowid = n.fk_action";
|
||||
$sql .= " AND n.fk_soc = ".((int) $object->id);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
@@ -233,7 +233,7 @@ if ($result > 0) {
|
||||
$sql .= " c.rowid as contactid, c.lastname, c.firstname, c.email";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."socpeople c";
|
||||
$sql .= " ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= " WHERE a.rowid = n.fk_action";
|
||||
$sql .= " AND c.rowid = n.fk_contact";
|
||||
$sql .= " AND c.fk_soc = ".((int) $object->id);
|
||||
|
||||
Reference in New Issue
Block a user