diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 2ac4b817..6c915114 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -46,9 +46,11 @@ * @param string $removeaction (optional) The action to remove a file * @param int $active (optional) To show gen button disabled * @param string $tooltiptext (optional) Tooltip text when gen button disabled + * @param string $sortfield (optional) Allows to sort the list of files by a field + * @param string $sortorder (optional) Allows to sort the list of files with a specific order * @return string Output string with HTML array of documents (might be empty string) */ -function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, string $urlsource, $genallowed, int $delallowed = 0, string $modelselected = '', int $allowgenifempty = 1, int $forcenomultilang = 0, int $notused = 0, int $noform = 0, string $param = '', string $title = '', string $buttonlabel = '', string $codelang = '', string $morepicto = '', $object = null, int $hideifempty = 0, string $removeaction = 'remove_file', int $active = 1, string $tooltiptext = ''): string +function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, string $urlsource, $genallowed, int $delallowed = 0, string $modelselected = '', int $allowgenifempty = 1, int $forcenomultilang = 0, int $notused = 0, int $noform = 0, string $param = '', string $title = '', string $buttonlabel = '', string $codelang = '', string $morepicto = '', $object = null, int $hideifempty = 0, string $removeaction = 'remove_file', int $active = 1, string $tooltiptext = '', string $sortfield = '', string $sortorder = ''): string { global $conf, $db, $form, $hookmanager, $langs; @@ -63,6 +65,23 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str $param .= ($param ? '&' : '') . 'entity=' . (!empty($object->entity) ? $object->entity : $conf->entity); } + if (empty($sortfield)) { + if (GETPOST('sortfield')) { + $sortfield = GETPOST('sortfield'); + } else { + $sortfield = 'name'; + } + } + + + if (empty($sortorder)) { + if (GETPOST('sortorder')) { + $sortorder = GETPOST('sortorder'); + } else { + $sortorder = 'desc'; + } + } + $hookmanager->initHooks(['formfile']); // Get list of files @@ -239,7 +258,20 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str if ($conf->global->$manualPdfGenerationConf > 0) { $out .= '