dolibarr 23.0.3
donateurs_code.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26if (!defined('NOLOGIN')) {
27 define('NOLOGIN', '1');
28}
29if (!defined('NOBROWSERNOTIF')) {
30 define('NOBROWSERNOTIF', '1');
31}
32if (!defined('NOIPCHECK')) {
33 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
34}
35
36// C'est un wrapper, donc header vierge
50function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = []) // @phan-suppress-current-line PhanRedefineFunction
51{
52 print '<html><title>List of donators</title><body>';
53}
61function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
62{
63 print '</body></html>';
64}
65
66// Load Dolibarr environment
67require '../../main.inc.php';
68require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
74// Security check
75if (!isModEnabled('don')) {
76 httponly_accessforbidden('Module Donation not enabled');
77}
78
79
80$langs->load("donations");
81
82
83/*
84 * View
85 */
86
88
89$sql = "SELECT d.datedon as datedon, d.lastname, d.firstname, d.amount, d.public, d.societe";
90$sql .= " FROM ".MAIN_DB_PREFIX."don as d";
91$sql .= " WHERE d.fk_statut in (2, 3) ORDER BY d.datedon DESC";
92
93$resql = $db->query($sql);
94if ($resql) {
95 $num = $db->num_rows($resql);
96 if ($num) {
97 print '<table class="centpercent" cellspacing="0" cellpadding="4">';
98
99 print '<tr>';
100 print "<td>".$langs->trans("Name")." / ".$langs->trans("Company")."</td>";
101 print "<td>Date</td>";
102 print '<td class="right">'.$langs->trans("Amount").'</td>';
103 print "</tr>\n";
104 $i = 0;
105 while ($i < $num) {
106 $objp = $db->fetch_object($resql);
107
108 print '<tr class="oddeven">';
109 if ($objp->public) {
110 print "<td>".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".dol_escape_htmltag($objp->societe)."</td>\n";
111 } else {
112 print "<td>".$langs->trans("Anonymous")."</td>\n";
113 }
114 print "<td>".dol_print_date($db->jdate($objp->datedon))."</td>\n";
115 print '<td class="right">'.price($objp->amount).' '.$langs->trans("Currency".getDolCurrency()).'</td>';
116 print "</tr>";
117 $i++;
118 }
119 print "</table>";
120 } else {
121 print $langs->trans("Donation");
122 }
123} else {
124 dol_print_error($db);
125}
126
127
129$db->close();
llxFooterVierge()
Footer function.
if(!defined( 'NOLOGIN')) if(!defined('NOBROWSERNOTIF')) if(!defined( 'NOIPCHECK')) llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Header function.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.