From 972776819290ef76ec38eb5ea967fa2835faa484 Mon Sep 17 00:00:00 2001 From: Indelog Date: Mon, 3 May 2021 09:46:51 +0200 Subject: [PATCH] Fix show table of pdf payments repports in file order Use scandir() rather opendir() and readdir() to get a sorted list of files. --- htdocs/compta/paiement/rapport.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index 0af202016df..7670e03d094 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -136,7 +136,6 @@ if ($year) { if (is_dir($dir.'/'.$year)) { - $handle = opendir($dir.'/'.$year); if ($found) print '
'; print '
'; @@ -147,22 +146,17 @@ if ($year) print ''.$langs->trans("Date").''; print ''; - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^payment/i', $file)) - { - $tfile = $dir.'/'.$year.'/'.$file; - $relativepath = $year.'/'.$file; - print ''; - print ''.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).''; - print ''.dol_print_size(dol_filesize($tfile)).''; - print ''.dol_print_date(dol_filemtime($tfile), "dayhour").''; - print ''; - } + $files = (scandir($dir.'/'.$year)); + foreach ($files as $f) { + $tfile = $dir.'/'.$year.'/'.$f; + $relativepath = $year.'/'.$f; + if (is_file($tfile)) { + print ''; + print ''.img_pdf().' '.$f.''.$formfile->showPreview($f, 'facture_paiement', $relativepath, 0).''; + print ''.dol_print_size(dol_filesize($tfile)).''; + print ''.dol_print_date(dol_filemtime($tfile), "dayhour").''; + print ''; } - closedir($handle); } print ''; }