donateurs_code.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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('NOBROWSERNOTIF')) {
  27. define('NOBROWSERNOTIF', '1');
  28. }
  29. if (!defined('NOIPCHECK')) {
  30. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  31. }
  32. // C'est un wrapper, donc header vierge
  33. /**
  34. * Header function
  35. *
  36. * @return void
  37. */
  38. function llxHeaderVierge()
  39. {
  40. print '<html><title>List of donators</title><body>';
  41. }
  42. /**
  43. * Header function
  44. *
  45. * @return void
  46. */
  47. function llxFooterVierge()
  48. {
  49. print '</body></html>';
  50. }
  51. // Load Dolibarr environment
  52. require '../../main.inc.php';
  53. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  54. // Security check
  55. if (!isModEnabled('don')) {
  56. httponly_accessforbidden('Module Donation not enabled');
  57. }
  58. $langs->load("donations");
  59. /*
  60. * View
  61. */
  62. llxHeaderVierge();
  63. $sql = "SELECT d.datedon as datedon, d.lastname, d.firstname, d.amount, d.public, d.societe";
  64. $sql .= " FROM ".MAIN_DB_PREFIX."don as d";
  65. $sql .= " WHERE d.fk_statut in (2, 3) ORDER BY d.datedon DESC";
  66. $resql = $db->query($sql);
  67. if ($resql) {
  68. $num = $db->num_rows($resql);
  69. if ($num) {
  70. print "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
  71. print '<tr>';
  72. print "<td>".$langs->trans("Name")." / ".$langs->trans("Company")."</td>";
  73. print "<td>Date</td>";
  74. print '<td class="right">'.$langs->trans("Amount").'</td>';
  75. print "</tr>\n";
  76. while ($i < $num) {
  77. $objp = $db->fetch_object($resql);
  78. print '<tr class="oddeven">';
  79. if ($objp->public) {
  80. print "<td>".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".dol_escape_htmltag($objp->societe)."</td>\n";
  81. } else {
  82. print "<td>".$langs->trans("Anonymous")."</td>\n";
  83. }
  84. print "<td>".dol_print_date($db->jdate($objp->datedon))."</td>\n";
  85. print '<td class="right">'.number_format($objp->amount, 2, '.', ' ').' '.$langs->trans("Currency".$conf->currency).'</td>';
  86. print "</tr>";
  87. $i++;
  88. }
  89. print "</table>";
  90. } else {
  91. print $langs->trans("Donation");
  92. }
  93. } else {
  94. dol_print_error($db);
  95. }
  96. $db->close();
  97. llxFooterVierge();