dolibarr 19.0.3
rapport.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
5 * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33
34$action = GETPOST('action', 'aZ09');
35
36$socid = 0;
37if ($user->socid > 0) {
38 $action = '';
39 $socid = $user->socid;
40}
41
42$dir = $conf->facture->dir_output.'/payments';
43if (!$user->hasRight('societe', 'client', 'voir') || $socid) {
44 $dir .= '/private/'.$user->id; // If user has no permission to see all, output dir is specific to user
45}
46
47$year = GETPOST('year', 'int');
48if (!$year) {
49 $year = date("Y");
50}
51
52// Security check
53if (!$user->hasRight('facture', 'lire')) {
55}
56
57
58/*
59 * Actions
60 */
61
62if ($action == 'builddoc') {
63 $rap = new pdf_paiement($db);
64
65 $outputlangs = $langs;
66 if (GETPOST('lang_id', 'aZ09')) {
67 $outputlangs = new Translate("", $conf);
68 $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
69 }
70
71 // We save charset_output to restore it because write_file can change it if needed for
72 // output format that does not support UTF8.
73 $sav_charset_output = $outputlangs->charset_output;
74 if ($rap->write_file($dir, GETPOST("remonth", "int"), GETPOST("reyear", "int"), $outputlangs) > 0) {
75 $outputlangs->charset_output = $sav_charset_output;
76 } else {
77 $outputlangs->charset_output = $sav_charset_output;
78 dol_print_error($db, $obj->error);
79 }
80
81 $year = GETPOST("reyear", "int");
82}
83
84
85/*
86 * View
87 */
88
89$formother = new FormOther($db);
90$formfile = new FormFile($db);
91
92llxHeader();
93
94$titre = ($year ? $langs->trans("PaymentsReportsForYear", $year) : $langs->trans("PaymentsReports"));
95print load_fiche_titre($titre, '', 'bill');
96
97// Formulaire de generation
98print '<form method="post" action="rapport.php?year='.$year.'">';
99print '<input type="hidden" name="token" value="'.newToken().'">';
100print '<input type="hidden" name="action" value="builddoc">';
101$cmonth = GETPOST("remonth") ? GETPOST("remonth") : date("n", time());
102$syear = GETPOST("reyear") ? GETPOST("reyear") : date("Y", time());
103
104print $formother->select_month($cmonth, 'remonth');
105
106print $formother->selectyear($syear, 'reyear');
107
108print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
109print '</form>';
110print '<br>';
111
112clearstatcache();
113
114// Show link on other years
115$year_dirs = dol_dir_list($dir, 'directories', 0, '^[0-9]{4}$', '', 'DESC');
116foreach ($year_dirs as $d) {
117 print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$d['name'].'">'.$d['name'].'</a> &nbsp;';
118}
119
120if ($year) {
121 if (is_dir($dir.'/'.$year)) {
122 if (!empty($year_dirs)) {
123 print '<br>';
124 }
125 print '<br>';
126 print '<table width="100%" class="noborder">';
127 print '<tr class="liste_titre">';
128 print '<td>'.$langs->trans("Reporting").'</td>';
129 print '<td class="right">'.$langs->trans("Size").'</td>';
130 print '<td class="right">'.$langs->trans("Date").'</td>';
131 print '</tr>';
132
133 $files = (dol_dir_list($dir.'/'.$year, 'files', 0, '^payments-[0-9]{4}-[0-9]{2}\.pdf$', '', 'name', 'DESC', 1));
134 foreach ($files as $f) {
135 $relativepath = $f['level1name'].'/'.$f['name'];
136 print '<tr class="oddeven">';
137 print '<td><a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?modulepart=facture_paiement&amp;file='.urlencode($relativepath).'">'.img_pdf().' '.$f['name'].'</a>'.$formfile->showPreview($f['name'], 'facture_paiement', $relativepath, 0).'</td>';
138 print '<td class="right">'.dol_print_size($f['size']).'</td>';
139 print '<td class="right">'.dol_print_date($f['date'], "dayhour").'</td>';
140 print '</tr>';
141 }
142 print '</table>';
143 }
144}
145
146// End of page
147llxFooter();
148$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to offer components to list and upload files.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage translations.
Class to manage reporting of payments.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_pdf($titlealt='default', $size=3)
Show pdf logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.