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 ''; print ''; @@ -147,22 +129,14 @@ if ($year) print ''; 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 ''; - print ''; - print ''; - print ''; - } - } - closedir($handle); + $files = (dol_dir_list($dir.'/'.$year, 'files', 0, '^payments-[0-9]{4}-[0-9]{2}\.pdf$', '', 'name', 'DESC', 1)); + foreach ($files as $f) { + $relativepath = $f['level1name'].'/'.$f['name']; + print ''; + print ''; + print ''; + print ''; + print ''; } print '
'.$langs->trans("Date").'
'.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).''.dol_print_size(dol_filesize($tfile)).''.dol_print_date(dol_filemtime($tfile), "dayhour").'
'.img_pdf().' '.$f['name'].''.$formfile->showPreview($f['name'], 'facture_paiement', $relativepath, 0).''.dol_print_size($f['size']).''.dol_print_date($f['date'], "dayhour").'
'; }