dolibarr 24.0.0-beta
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-2026 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
51function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $ws = '') // @phan-suppress-current-line PhanRedefineFunction
52{
53 print '<html><title>List of donators</title><body>';
54}
62function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
63{
64 print '</body></html>';
65}
66
67// Load Dolibarr environment
68require '../../main.inc.php';
69require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
75// Security check
76if (!isModEnabled('don')) {
77 httponly_accessforbidden('Module Donation not enabled');
78}
79
80
81$langs->load("donations");
82
83
84/*
85 * View
86 */
87
89
90$sql = "SELECT d.datedon as datedon, d.lastname, d.firstname, d.amount, d.public, d.societe";
91$sql .= " FROM ".MAIN_DB_PREFIX."don as d";
92$sql .= " WHERE d.fk_statut in (2, 3) ORDER BY d.datedon DESC";
93
94$resql = $db->query($sql);
95if ($resql) {
96 $num = $db->num_rows($resql);
97 if ($num) {
98 print '<table class="centpercent" cellspacing="0" cellpadding="4">';
99
100 print '<tr>';
101 print "<td>".$langs->trans("Name")." / ".$langs->trans("Company")."</td>";
102 print "<td>Date</td>";
103 print '<td class="right">'.$langs->trans("Amount").'</td>';
104 print "</tr>\n";
105 $i = 0;
106 while ($i < $num) {
107 $objp = $db->fetch_object($resql);
108
109 print '<tr class="oddeven">';
110 if ($objp->public) {
111 print "<td>".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".dol_escape_htmltag($objp->societe)."</td>\n";
112 } else {
113 print "<td>".$langs->trans("Anonymous")."</td>\n";
114 }
115 print "<td>".dol_print_date($db->jdate($objp->datedon))."</td>\n";
116 print '<td class="right">'.price($objp->amount).' '.$langs->trans("Currency".getDolCurrency()).'</td>';
117 print "</tr>";
118 $i++;
119 }
120 print "</table>";
121 } else {
122 print $langs->trans("Donation");
123 }
124} else {
126}
127
128
130$db->close();
if(!defined( 'NOLOGIN')) if(!defined('NOBROWSERNOTIF')) if(!defined( 'NOIPCHECK')) llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[], $ws='')
Header function.
llxFooterVierge()
Footer function.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.