From 6938b05219cd4f158343d6b2718d9e5fda07be2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Oct 2016 12:00:30 +0200 Subject: [PATCH] Mutualize code to show files generated for mass actions --- dev/skeletons/skeleton_list.php | 6 +--- htdocs/comm/propal/list.php | 6 +--- htdocs/commande/list.php | 4 --- htdocs/compta/facture/list.php | 4 --- htdocs/core/class/html.formfile.class.php | 36 +++++++++++++++++++---- htdocs/expensereport/list.php | 4 --- htdocs/langs/en_US/main.lang | 1 + htdocs/product/stock/productlot_list.php | 4 --- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 7715b17b4d8..27515db3c68 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -530,11 +530,7 @@ if ($resql) $genallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire; - print '
'; - $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); - $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; - - print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 88f8f8fa3df..05b27663b4b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1016,11 +1016,7 @@ if ($resql) $genallowed=$user->rights->propal->lire; $delallowed=$user->rights->propal->lire; - print '
'; - $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); - $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; - - print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); } else { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d9438d9a93f..ab25895b561 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1438,10 +1438,6 @@ if ($resql) $genallowed=$user->rights->commande->lire; $delallowed=$user->rights->commande->lire; - print '
'; - $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); - $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; - print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 36873d15963..48ed568e3f9 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1155,10 +1155,6 @@ if ($resql) $genallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire; - print '
'; - $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); - $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; - print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 93695201062..6bb6334e085 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -305,12 +305,37 @@ class FormFile $showempty=0; $i=0; - $titletoshow=$langs->trans("Documents"); - if (! empty($title)) $titletoshow=$title; - $out.= "\n".''."\n"; //print 'filedir='.$filedir; + if (preg_match('/massfilesarea_/', $modulepart)) + { + $out.='
'; + $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; + $title.=''; + } + + $titletoshow=$langs->trans("Documents"); + if (! empty($title)) $titletoshow=$title; + // Show table if ($genallowed) { @@ -518,6 +543,7 @@ class FormFile } } + // Set headershown to avoit to have table opened a second time later $headershown=1; $buttonlabeltoshow=$buttonlabel; @@ -526,7 +552,7 @@ class FormFile if (empty($noform)) $out.= '
'; $out.= ''; $out.= ''; - + $out.= load_fiche_titre($titletoshow, '', ''); $out.= ''; @@ -622,7 +648,7 @@ class FormFile { $headershown=1; $out.= '
'.$titletoshow.'
'."\n"; - $out.= '
'."\n"; + $out.= '
'."\n"; } // Loop on each file found diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 722fb05767d..e6493fe36db 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -677,10 +677,6 @@ if ($resql) $genallowed=$user->rights->expensereport->lire; $delallowed=$user->rights->expensereport->lire; - print '
'; - $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); - $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; - print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a3851b89339..01510e065f6 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -162,6 +162,7 @@ Go=Go Run=Run CopyOf=Copy of Show=Show +Hide=Hide ShowCardHere=Show card Search=Search SearchOf=Search diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index ecd14237787..ef8556aeb9c 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -601,10 +601,6 @@ if ($resql) $genallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire; - print '
'; - $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); - $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; - print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else