diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php
index 0af202016df..c76697c8401 100644
--- a/htdocs/compta/paiement/rapport.php
+++ b/htdocs/compta/paiement/rapport.php
@@ -109,36 +109,18 @@ print '
';
clearstatcache();
// Show link on other years
-$linkforyear = array();
-$found = 0;
-if (is_dir($dir))
+$year_dirs = dol_dir_list($dir, 'directories', 0, '^[0-9]{4}$', '', 'DESC');
+foreach ($year_dirs as $d)
{
- $handle = opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle)) !== false)
- {
- if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file))
- {
- $found = 1;
- $linkforyear[] = $file;
- }
- }
- }
-}
-asort($linkforyear);
-foreach ($linkforyear as $cursoryear)
-{
- print ''.$cursoryear.' ';
+ print ''.$d['name'].' ';
}
+$found = true;
if ($year)
{
if (is_dir($dir.'/'.$year))
{
- $handle = opendir($dir.'/'.$year);
-
- if ($found) print '
';
+ if (!empty($year_dirs)) print '
';
print '
';
print '
| '.$langs->trans("Date").' | '; 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 '
| '.img_pdf().' '.$f['name'].''.$formfile->showPreview($f['name'], 'facture_paiement', $relativepath, 0).' | '; + print ''.dol_print_size($f['size']).' | '; + print ''.dol_print_date($f['date'], "dayhour").' | '; + print '