25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/modules/rapport/pdf_paiement_fourn.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 $langs->loadLangs(array(
'bills'));
35 if (!empty($user->socid)) {
36 $socid = $user->socid;
38 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
40 $action =
GETPOST(
'action',
'aZ09');
43 if ($user->socid > 0) {
45 $socid = $user->socid;
48 $dir = $conf->fournisseur->facture->dir_output.
'/payments';
49 if (empty($user->rights->societe->client->voir) || $socid) {
50 $dir .=
'/private/'.$user->id;
63 if ($action ==
'builddoc') {
66 $outputlangs = $langs;
67 if (
GETPOST(
'lang_id',
'aZ09')) {
69 $outputlangs->setDefaultLang(
GETPOST(
'lang_id',
'aZ09'));
74 $sav_charset_output = $outputlangs->charset_output;
75 if ($rap->write_file($dir,
GETPOST(
"remonth",
'int'),
GETPOST(
"reyear",
'int'), $outputlangs) > 0) {
76 $outputlangs->charset_output = $sav_charset_output;
78 $outputlangs->charset_output = $sav_charset_output;
82 $year =
GETPOST(
"reyear",
'int');
93 $titre = ($year ? $langs->trans(
"PaymentsReportsForYear", $year) : $langs->trans(
"PaymentsReports"));
100 print
'<form method="post" action="rapport.php?year='.$year.
'">';
101 print
'<input type="hidden" name="token" value="'.newToken().
'">';
102 print
'<input type="hidden" name="action" value="builddoc">';
103 $cmonth =
GETPOST(
"remonth") ?
GETPOST(
"remonth") : date(
"n", time());
104 $syear =
GETPOST(
"reyear") ?
GETPOST(
"reyear") : date(
"Y", time());
106 print $formother->select_month($cmonth,
'remonth');
108 print $formother->selectyear($syear,
'reyear');
110 print
'<input type="submit" class="button" value="'.$langs->trans(
"Create").
'">';
117 $linkforyear = array();
120 $handle = opendir($dir);
121 if (is_resource($handle)) {
122 while (($file = readdir($handle)) !==
false) {
123 if (is_dir($dir.
'/'.$file) && !preg_match(
'/^\./', $file) && is_numeric($file)) {
125 $linkforyear[] = $file;
131 foreach ($linkforyear as $cursoryear) {
132 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$cursoryear.
'">'.$cursoryear.
'</a> ';
136 if (is_dir($dir.
'/'.$year)) {
137 $handle = opendir($dir.
'/'.$year);
143 print
'<table width="100%" class="noborder">';
144 print
'<tr class="liste_titre">';
145 print
'<td>'.$langs->trans(
"Reporting").
'</td>';
146 print
'<td class="right">'.$langs->trans(
"Size").
'</td>';
147 print
'<td class="right">'.$langs->trans(
"Date").
'</td>';
150 if (is_resource($handle)) {
151 while (($file = readdir($handle)) !==
false) {
152 if (preg_match(
'/^supplier_payment/i', $file)) {
153 $tfile = $dir.
'/'.$year.
'/'.$file;
154 $relativepath = $year.
'/'.$file;
155 print
'<tr class="oddeven"><td><a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?modulepart=facture_fournisseur&file=payments/'.urlencode($relativepath).
'">'.
img_pdf().
' '.$file.
'</a>'.$formfile->showPreview($file,
'facture_fournisseur',
'payments/'.$relativepath, 0).
'</td>';
156 print
'<td class="right">'.dol_print_size(
dol_filesize($tfile)).
'</td>';
157 print
'<td class="right">'.dol_print_date(
dol_filemtime($tfile),
"dayhour").
'</td></tr>';