donateurs_code.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/public/donations/donateurs_code.php
  20. * \ingroup donation
  21. * \brief Page to list donators
  22. */
  23. if (!defined('NOLOGIN')) {
  24. define('NOLOGIN', '1');
  25. }
  26. if (!defined('NOCSRFCHECK')) {
  27. define('NOCSRFCHECK', '1');
  28. }
  29. if (!defined('NOBROWSERNOTIF')) {
  30. define('NOBROWSERNOTIF', '1');
  31. }
  32. if (!defined('NOIPCHECK')) {
  33. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  34. }
  35. // C'est un wrapper, donc header vierge
  36. /**
  37. * Header function
  38. *
  39. * @return void
  40. */
  41. function llxHeaderVierge()
  42. {
  43. print '<html><title>List of donators</title><body>';
  44. }
  45. /**
  46. * Header function
  47. *
  48. * @return void
  49. */
  50. function llxFooterVierge()
  51. {
  52. print '</body></html>';
  53. }
  54. require '../../main.inc.php';
  55. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  56. // Security check
  57. if (empty($conf->don->enabled)) {
  58. httponly_accessforbidden('Module Donation not enabled');
  59. }
  60. $langs->load("donations");
  61. /*
  62. * View
  63. */
  64. llxHeaderVierge();
  65. $sql = "SELECT d.datedon as datedon, d.lastname, d.firstname, d.amount, d.public, d.societe";
  66. $sql .= " FROM ".MAIN_DB_PREFIX."don as d";
  67. $sql .= " WHERE d.fk_statut in (2, 3) ORDER BY d.datedon DESC";
  68. $resql = $db->query($sql);
  69. if ($resql) {
  70. $num = $db->num_rows($resql);
  71. if ($num) {
  72. print "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
  73. print '<tr>';
  74. print "<td>".$langs->trans("Name")." / ".$langs->trans("Company")."</td>";
  75. print "<td>Date</td>";
  76. print '<td class="right">'.$langs->trans("Amount").'</td>';
  77. print "</tr>\n";
  78. while ($i < $num) {
  79. $objp = $db->fetch_object($resql);
  80. print '<tr class="oddeven">';
  81. if ($objp->public) {
  82. print "<td>".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".dol_escape_htmltag($objp->societe)."</td>\n";
  83. } else {
  84. print "<td>".$langs->trans("Anonymous")."</td>\n";
  85. }
  86. print "<td>".dol_print_date($db->jdate($objp->datedon))."</td>\n";
  87. print '<td class="right">'.number_format($objp->amount, 2, '.', ' ').' '.$langs->trans("Currency".$conf->currency).'</td>';
  88. print "</tr>";
  89. $i++;
  90. }
  91. print "</table>";
  92. } else {
  93. print $langs->trans("Donation");
  94. }
  95. } else {
  96. dol_print_error($db);
  97. }
  98. $db->close();
  99. llxFooterVierge();