From 1f9aa856d52fa5a39e135675c794e0008d90b123 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2016 18:37:40 +0200 Subject: [PATCH] NEW the list of linked files on card does not forget external links. --- htdocs/core/class/html.formfile.class.php | 50 +++++++++++++++++++---- htdocs/product/card.php | 5 ++- htdocs/product/document.php | 1 + 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 67c8f015740..e52818305b5 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -268,9 +268,10 @@ class FormFile * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled * @param string $morepicto Add more HTML content into cell with picto + * @param Object $object Object when method is called from an object card. * @return string Output string with HTML array of documents (might be empty string) */ - function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='') + function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='',$object=null) { // Deprecation warning if (0 !== $iconPDF) { @@ -581,15 +582,25 @@ class FormFile } } + // Get list of files if (! empty($filedir)) { $file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview\.png)$','date',SORT_DESC); + $link_list = array(); + if (is_object($object)) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + $link = new Link($this->db); + $sortfield = $sortorder = null; + $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); + } + $out.= ''."\n"; // Show title of array if not already shown - if ((! empty($file_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) + if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { $headershown=1; $out.= '
'.$titletoshow.'
'."\n"; @@ -621,7 +632,6 @@ class FormFile $out.= ' target="_blank">'; $out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]).' '.dol_trunc($file["name"],$maxfilenamelength); $out.= ''."\n"; - $out.= $this->showPreview($file,$modulepart,$relativepath); $out.= ''; @@ -673,13 +683,37 @@ class FormFile } } - if (count($file_list) == 0 && $headershown) - { - $out.=''.$langs->trans("None").''; - } - $this->numoffiles++; } + // Loop on each file found + if (is_array($link_list)) + { + $colspan=2; + + foreach($link_list as $file) + { + $var=!$var; + + $out.= ""; + $out.=''; + $out.=''; + $out.=$file->label; + $out.=''; + $out.=''; + $out.=''; + $out.=dol_print_date($file->datea,'dayhour'); + $out.=''; + if ($delallowed || $printer || $morepicto) $out.=''; + $out.=''; + } + $this->numoffiles++; + } + + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) + { + $out.=''.$langs->trans("None").''; + } + } if ($headershown) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index aaf6f4437b2..13820f620d3 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1981,8 +1981,9 @@ if ($action == '' || $action == 'view') $var=true; - $somethingshown=$formfile->show_documents($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang); - + print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); + $somethingshown=$formfile->numoffiles; + print '
'; print '
'; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 05d25b4085a..2e241d9c156 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -231,6 +231,7 @@ if ($object->id) $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + // Merge propal PDF document PDF files if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) {