Skip to content

Commit

Permalink
FIX: on change ref for bank account attachement are lost
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Aug 2, 2024
1 parent 3715d53 commit f9dffe2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions htdocs/compta/bank/class/account.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,14 @@ public function update(User $user, $notrigger = 0)
}

if (!$error && !empty($this->oldref) && $this->oldref !== $this->ref) {
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'bank/".$this->db->escape($this->ref)."'";
$sql .= " WHERE filepath = 'bank/".$this->db->escape($this->oldref)."' and src_object_type='bank_account' and entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
}

// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->oldref);
$newref = dol_sanitizeFileName($this->ref);
Expand All @@ -912,8 +920,6 @@ public function update(User $user, $notrigger = 0)
dol_syslog(get_class($this)."::update rename dir ".$dirsource." into ".$dirdest, LOG_DEBUG);
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok", LOG_DEBUG);
} else {
$error++;
}
}
}
Expand Down

0 comments on commit f9dffe2

Please sign in to comment.