Mutualize code to show files generated for mass actions

This commit is contained in:
Laurent Destailleur 2016-10-28 12:00:30 +02:00
parent 54bd355800
commit 6938b05219
8 changed files with 34 additions and 31 deletions

View File

@ -530,11 +530,7 @@ if ($resql)
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire;
print '<br><a name="show_files"></a>';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
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
{

View File

@ -1016,11 +1016,7 @@ if ($resql)
$genallowed=$user->rights->propal->lire;
$delallowed=$user->rights->propal->lire;
print '<br><a name="show_files"></a>';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
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
{

View File

@ -1438,10 +1438,6 @@ if ($resql)
$genallowed=$user->rights->commande->lire;
$delallowed=$user->rights->commande->lire;
print '<br><a name="show_files"></a>';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else

View File

@ -1155,10 +1155,6 @@ if ($resql)
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire;
print '<br><a name="show_files"></a>';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else

View File

@ -305,12 +305,37 @@ class FormFile
$showempty=0;
$i=0;
$titletoshow=$langs->trans("Documents");
if (! empty($title)) $titletoshow=$title;
$out.= "\n".'<!-- Start show_document -->'."\n";
//print 'filedir='.$filedir;
if (preg_match('/massfilesarea_/', $modulepart))
{
$out.='<br><a name="show_files"></a>';
$title=$langs->trans("MassFilesArea").' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans("Hide").')</a>';
$title.='<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery(\'#togglemassfilesarea\').click(function() {
if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown")
{
jQuery(\'#'.$modulepart.'_table\').hide();
jQuery(\'#togglemassfilesarea\').attr("ref", "hidden");
jQuery(\'#togglemassfilesarea\').text("('.dol_escape_js($langs->trans("Show")).')");
}
else
{
jQuery(\'#'.$modulepart.'_table\').show();
jQuery(\'#togglemassfilesarea\').attr("ref","shown");
jQuery(\'#togglemassfilesarea\').text("('.dol_escape_js($langs->trans("Hide")).')");
}
return false;
});
});
</script>';
}
$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.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">';
$out.= '<input type="hidden" name="action" value="builddoc">';
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$out.= load_fiche_titre($titletoshow, '', '');
$out.= '<table class="liste formdoc noborder" summary="listofdocumentstable" width="100%">';
@ -622,7 +648,7 @@ class FormFile
{
$headershown=1;
$out.= '<div class="titre">'.$titletoshow.'</div>'."\n";
$out.= '<table class="border" summary="listofdocumentstable" width="100%">'."\n";
$out.= '<table class="border" summary="listofdocumentstable" id="'.$modulepart.'_table" width="100%">'."\n";
}
// Loop on each file found

View File

@ -677,10 +677,6 @@ if ($resql)
$genallowed=$user->rights->expensereport->lire;
$delallowed=$user->rights->expensereport->lire;
print '<br><a name="show_files"></a>';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else

View File

@ -162,6 +162,7 @@ Go=Go
Run=Run
CopyOf=Copy of
Show=Show
Hide=Hide
ShowCardHere=Show card
Search=Search
SearchOf=Search

View File

@ -601,10 +601,6 @@ if ($resql)
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire;
print '<br><a name="show_files"></a>';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else