Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into 12.0

This commit is contained in:
Laurent Destailleur 2021-06-29 15:47:58 +02:00
commit e2c4a14939

View File

@ -744,38 +744,32 @@ class Contact extends CommonObject
$this->error = $this->db->lasterror();
}
// Mis a jour alerte birthday
if ($this->birthday_alert)
{
//check existing
$sql_check = "SELECT rowid FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id;
$result_check = $this->db->query($sql_check);
if (!$result_check || ($this->db->num_rows($result_check) < 1))
{
//insert
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_alert(type,fk_contact,fk_user) ";
$sql .= "VALUES (1,".$this->db->escape($id).",".$user->id.")";
$result = $this->db->query($sql);
if (!$result)
{
$error++;
$this->error = $this->db->lasterror();
if ($user) {
// Mis a jour alerte birthday
if ($this->birthday_alert) {
//check existing
$sql_check = "SELECT rowid FROM " . MAIN_DB_PREFIX . "user_alert WHERE type=1 AND fk_contact=" . $this->db->escape($id) . " AND fk_user=" . $user->id;
$result_check = $this->db->query($sql_check);
if (!$result_check || ($this->db->num_rows($result_check) < 1)) {
//insert
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_alert(type,fk_contact,fk_user) ";
$sql .= "VALUES (1," . $this->db->escape($id) . "," . $user->id . ")";
$result = $this->db->query($sql);
if (!$result) {
$error++;
$this->error = $this->db->lasterror();
}
} else {
$result = true;
}
} else {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_alert ";
$sql .= "WHERE type=1 AND fk_contact=" . $this->db->escape($id) . " AND fk_user=" . $user->id;
$result = $this->db->query($sql);
if (!$result) {
$error++;
$this->error = $this->db->lasterror();
}
}
else
{
$result = true;
}
}
else
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert ";
$sql .= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id;
$result = $this->db->query($sql);
if (!$result)
{
$error++;
$this->error = $this->db->lasterror();
}
}