fix entity if interventions are shared between entities (#28317)

This commit is contained in:
Eric 2024-02-20 23:01:16 +01:00 committed by GitHub
parent 05cf98fae8
commit 75ad2e82fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -575,7 +575,8 @@ class Fichinter extends CommonObject
$sql .= ", date_valid = '".$this->db->idate($now)."'";
$sql .= ", fk_user_valid = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);
$sql .= " AND entity = ".((int) $conf->entity);
$sql .= " AND entity IN (".getEntity('intervention').")";
$sql .= " AND fk_statut = 0";
dol_syslog(get_class($this)."::setValid", LOG_DEBUG);
@ -603,7 +604,7 @@ class Fichinter extends CommonObject
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'ficheinter/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this->ref)."' and entity IN (".getEntity('intervention').")";
$resql = $this->db->query($sql);
if (!$resql) {
$error++; $this->error = $this->db->lasterror();