diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index f04ff69d936..70c62071d76 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -480,6 +480,7 @@ class FormFile
* @param permtodelete Permission to delete
* @param useinecm Change output for use in ecm module
* @param textifempty Text to show if filearray is empty
+ * @param maxlength Maximum length of file name shown
* @return int <0 if KO, nb of files shown if OK
*/
function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0)
@@ -513,7 +514,8 @@ class FormFile
if (! $relativepath) $relativepath=dol_sanitizeFileName($object->ref).'/';
$var=!$var;
- print '
';
+ print '';
//print "XX".$file['name']; //$file['name'] must be utf8
print '";
// Fin de zone
-
}
+
+ /**
+ * Show list of documents in a directory
+ * @param filearray Array of files loaded by dol_dir_list function
+ * @param modulepart Value for modulepart used by download wrapper
+ * @param param Parameters on sort links
+ * @param forcedownload Force to open dialog box "Save As" when clicking on file
+ * @param relativepath Relative path of docs (autodefined if not provided)
+ * @param permtodelete Permission to delete
+ * @param useinecm Change output for use in ecm module
+ * @param textifempty Text to show if filearray is empty
+ * @param maxlength Maximum length of file name shown
+ * @return int <0 if KO, nb of files shown if OK
+ */
+ function list_of_autoecmfiles($upload_dir,$filearray,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0)
+ {
+ global $user, $conf, $langs;
+ global $bc;
+ global $sortfield, $sortorder;
+
+ // Affiche liste des documents existant
+ if (empty($useinecm)) print_titre($langs->trans("AttachedFiles"));
+ //else { $bc[true]=''; $bc[false]=''; };
+ $url=$_SERVER["PHP_SELF"];
+ print '';
+ print '';
+ print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"","",$param,'align="left"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Documents2"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre('','','');
+ print ' ';
+
+ if ($modulepart == 'invoice_supplier')
+ {
+ include_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php');
+ $object_static=new FactureFournisseur($this->db);
+ }
+
+ $var=true;
+ foreach($filearray as $key => $file)
+ {
+ if (!is_dir($dir.$file['name'])
+ && $file['name'] != '.'
+ && $file['name'] != '..'
+ && $file['name'] != 'CVS'
+ && ! preg_match('/\.meta$/i',$file['name']))
+ {
+ // Define relative path used to store the file
+ $relativefile=preg_replace('/'.preg_quote($upload_dir.'/','/').'/','',$file['fullname']);
+ //print 'eeee'.$relativefile;
+ //var_dump($file);
+ $var=!$var;
+ print '';
+ print '| ';
+ $id='';$ref='';
+ if ($modulepart == 'invoice_supplier')
+ {
+ preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg);
+ $id=$reg[1];
+ $object_static->fetch($id);
+ //print $relativefile.'rr'.$id;
+ print $object_static->getNomUrl(1);
+ }
+ print ' | ';
+ print '';
+ //print "XX".$file['name']; //$file['name'] must be utf8
+ print '';
+ print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' ';
+ print dol_trunc($file['name'],$maxlength,'middle');
+ print '';
+ print " | \n";
+ print ''.dol_print_size($file['size'],1,1).' | ';
+ print ''.dol_print_date($file['date'],"dayhour").' | ';
+ print '';
+ if (! empty($useinecm)) print '';
+ print img_view().' ';
+ //if ($permtodelete) print ''.img_delete().'';
+ //else print ' ';
+ print " | \n";
+ }
+ }
+ if (sizeof($filearray) == 0)
+ {
+ print '| ';
+ if (empty($textifempty)) print $langs->trans("NoFileFound");
+ else print $textifempty;
+ print ' | ';
+ }
+ print " ";
+ // Fin de zone
+ }
+
+
}
?>
diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php
index 32521b1db0b..4195d378c3d 100644
--- a/htdocs/ecm/class/ecmdirectory.class.php
+++ b/htdocs/ecm/class/ecmdirectory.class.php
@@ -423,9 +423,9 @@ class EcmDirectory // extends CommonObject
}
/**
- * \brief Return relative path of a directory on disk
- * \param force Force reload of full arbo even if already loaded
- * \return string Relative physical path
+ * Return relative path of a directory on disk
+ * @param force Force reload of full arbo even if already loaded
+ * @return string Relative physical path
*/
function getRelativePath($force=0)
{
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index eaae26d7bc3..95974a0265e 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -55,6 +55,7 @@ $user->getrights('ecm');
$socid=GETPOST('socid');
$action=GETPOST("action");
$section=GETPOST("section");
+$module=GETPOST("module");
if (! $section) $section=0;
$upload_dir = $conf->ecm->dir_output.'/'.$section;
@@ -357,9 +358,9 @@ if ($conf->societe->enabled) { $rowspan++; $sectionauto[]=array('level'=>1,
if ($conf->propal->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Prop"), 'desc'=>$langs->trans("ECMDocsByProposals")); }
if ($conf->contrat->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); }
if ($conf->commande->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
-if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
+if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
if ($conf->facture->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
-if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
+if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
//***********************
@@ -804,15 +805,31 @@ else
print ' | ';
}
-// Right area
-$relativepath=$ecmdir->getRelativePath();
-$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
-$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
-
$formfile=new FormFile($db);
-$param='§ion='.$section;
-$textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")));
-$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,40);
+
+// Right area
+if ($module == 'invoice_supplier') // Auto area for suppliers invoices
+{
+ $relativepath='facture';
+ $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath;
+ $filearray=dol_dir_list($upload_dir,"files",1,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
+
+ $param='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,40);
+}
+else // Manual area
+{
+ $relativepath=$ecmdir->getRelativePath();
+ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+ $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
+
+ $param='§ion='.$section;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")));
+
+ $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,40);
+}
// print ' |