From 2b5295497b04616e8a7dc4dab3f17db82ece3a82 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 12 Feb 2025 16:22:06 +0100 Subject: [PATCH] Debug v21 --- htdocs/ecm/class/ecmfiles.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 142aaf70270..28db17eceb0 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -1013,9 +1013,17 @@ class EcmFiles extends CommonObject } elseif ($option == 'commande_fournisseur') { $tmppath = preg_replace('/^fournisseur\/commande\//', '', $this->filepath); } else { - $tmppath = preg_replace('/^[^\/]+\//', '', $this->filepath); + if ((int) $this->entity > 1) { + // Remove the part "entityid/commande/" into "entityid/commande/REFXXX" to get only the ref + $tmppath = preg_replace('/^\d+\/[^\/]+\//', '', $this->filepath); + } else { + // Remove the part "commande/" into "commande/REFXXX" to get only the ref + $tmppath = preg_replace('/^[^\/]+\//', '', $this->filepath); + } } - $url = DOL_URL_ROOT.'/document.php?modulepart='.urlencode($option).'&file='.urlencode($tmppath.'/'.$this->filename).'&entity='.$this->entity; + //var_dump($this->filepath); + + $url = DOL_URL_ROOT.'/document.php?modulepart='.urlencode($option).'&file='.urlencode($tmppath.'/'.$this->filename).'&entity='.((int) $this->entity); } else { $url = DOL_URL_ROOT.'/ecm/file_card.php?id='.$this->id; }