From 6e2d62bea6a555d9df33298a214c56ddd48c64e0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 29 Oct 2018 12:30:36 +0100 Subject: [PATCH] FIX wrong entity id --- htdocs/core/class/html.formfile.class.php | 10 ++++------ htdocs/projet/element.php | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7a0c07bb996..72e14fefdd6 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -879,15 +879,13 @@ class FormFile $out=''; $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); + $entity = 1; // Without multicompany + // Get object entity - if (empty($conf->multicompany->enabled)) - { - $entity = $conf->entity; - } - else + if (! empty($conf->multicompany->enabled)) { preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,'/').'$/', $filedir, $regs); - $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : $conf->entity); + $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default } // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3f611e5525e..d2b1948b5ec 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -882,16 +882,16 @@ foreach ($listofreferent as $key => $value) $element_doc = $element->element; $filename=dol_sanitizeFileName($element->ref); - $filedir=$conf->{$element_doc}->dir_output . '/' . dol_sanitizeFileName($element->ref); + $filedir=$conf->{$element_doc}->multidir_output[$element->entity] . '/' . dol_sanitizeFileName($element->ref); if ($element_doc === 'order_supplier') { $element_doc='commande_fournisseur'; - $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($element->ref); + $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].'/'.dol_sanitizeFileName($element->ref); } else if ($element_doc === 'invoice_supplier') { $element_doc='facture_fournisseur'; $filename = get_exdir($element->id,2,0,0,$element,'product').dol_sanitizeFileName($element->ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($element->id,2,0,0,$element,'invoice_supplier').dol_sanitizeFileName($element->ref); + $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].'/'.get_exdir($element->id,2,0,0,$element,'invoice_supplier').dol_sanitizeFileName($element->ref); } print '
'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'
';