donateurs_code.php 2.8 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. define("NOLOGIN", 1); // This means this output page does not require to be logged.
  24. define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
  25. // C'est un wrapper, donc header vierge
  26. /**
  27. * Header function
  28. *
  29. * @return void
  30. */
  31. function llxHeaderVierge()
  32. {
  33. print '<html><title>Export agenda cal</title><body>';
  34. }
  35. /**
  36. * Header function
  37. *
  38. * @return void
  39. */
  40. function llxFooterVierge()
  41. {
  42. print '</body></html>';
  43. }
  44. require '../../main.inc.php';
  45. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  46. // Security check
  47. if (empty($conf->don->enabled)) accessforbidden('', 0, 0, 1);
  48. $langs->load("donations");
  49. /*
  50. * View
  51. */
  52. llxHeaderVierge();
  53. $sql = "SELECT d.datedon as datedon, d.lastname, d.firstname, d.amount, d.public, d.societe";
  54. $sql .= " FROM ".MAIN_DB_PREFIX."don as d";
  55. $sql .= " WHERE d.fk_statut in (2, 3) ORDER BY d.datedon DESC";
  56. $resql = $db->query($sql);
  57. if ($resql)
  58. {
  59. $num = $db->num_rows($resql);
  60. if ($num)
  61. {
  62. print "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
  63. print '<tr>';
  64. print "<td>".$langs->trans("Name")." / ".$langs->trans("Company")."</td>";
  65. print "<td>Date</td>";
  66. print '<td class="right">'.$langs->trans("Amount").'</td>';
  67. print "</tr>\n";
  68. while ($i < $num)
  69. {
  70. $objp = $db->fetch_object($resql);
  71. print '<tr class="oddeven">';
  72. if ($objp->public)
  73. {
  74. print "<td>".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".$objp->societe."</td>\n";
  75. }
  76. else
  77. {
  78. print "<td>Anonyme Anonyme</td>\n";
  79. }
  80. print "<td>".dol_print_date($db->jdate($objp->datedon))."</td>\n";
  81. print '<td class="right">'.number_format($objp->amount, 2, '.', ' ').' '.$langs->trans("Currency".$conf->currency).'</td>';
  82. print "</tr>";
  83. $i++;
  84. }
  85. print "</table>";
  86. }
  87. else
  88. {
  89. print "Aucun don publique";
  90. }
  91. }
  92. else
  93. {
  94. dol_print_error($db);
  95. }
  96. $db->close();
  97. llxFooterVierge();