public_list.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/public/members/public_list.php
  22. * \ingroup member
  23. * \brief File sample to list members
  24. */
  25. if (!defined('NOLOGIN')) {
  26. define("NOLOGIN", 1); // This means this output page does not require to be logged.
  27. }
  28. if (!defined('NOCSRFCHECK')) {
  29. define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
  30. }
  31. if (!defined('NOIPCHECK')) {
  32. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  33. }
  34. if (!defined('NOBROWSERNOTIF')) {
  35. define('NOBROWSERNOTIF', '1');
  36. }
  37. // For MultiCompany module.
  38. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
  39. // TODO This should be useless. Because entity must be retrieve from object ref and not from url.
  40. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
  41. if (is_numeric($entity)) {
  42. define("DOLENTITY", $entity);
  43. }
  44. // Load Dolibarr environment
  45. require '../../main.inc.php';
  46. // Security check
  47. if (empty($conf->adherent->enabled)) {
  48. httponly_accessforbidden('Module Membership not enabled');
  49. }
  50. $langs->loadLangs(array("main", "members", "companies", "other"));
  51. /**
  52. * Show header for member list
  53. *
  54. * @param string $title Title
  55. * @param string $head More info into header
  56. * @return void
  57. */
  58. function llxHeaderVierge($title, $head = "")
  59. {
  60. top_htmlhead($head, $title);
  61. print '<body class="public_body">'."\n";
  62. }
  63. /**
  64. * Show footer for member list
  65. *
  66. * @return void
  67. */
  68. function llxFooterVierge()
  69. {
  70. printCommonFooter('public');
  71. print "</body>\n";
  72. print "</html>\n";
  73. }
  74. $sortfield = GETPOST('sortfield', 'aZ09comma');
  75. $sortorder = GETPOST('sortorder', 'aZ09comma');
  76. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  77. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  78. if (empty($page) || $page == -1) {
  79. $page = 0;
  80. } // If $page is not defined, or '' or -1
  81. $offset = $limit * $page;
  82. $pageprev = $page - 1;
  83. $pagenext = $page + 1;
  84. $filter = GETPOST('filter');
  85. $statut = GETPOST('statut');
  86. if (!$sortorder) {
  87. $sortorder = "ASC";
  88. }
  89. if (!$sortfield) {
  90. $sortfield = "lastname";
  91. }
  92. /*
  93. * View
  94. */
  95. $form = new Form($db);
  96. $morehead = '';
  97. if (!empty($conf->global->MEMBER_PUBLIC_CSS)) {
  98. $morehead = '<link rel="stylesheet" type="text/css" href="'.$conf->global->MEMBER_PUBLIC_CSS.'">';
  99. } else {
  100. $morehead = '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php">';
  101. }
  102. llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
  103. $sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
  104. $sql .= " FROM ".MAIN_DB_PREFIX."adherent";
  105. $sql .= " WHERE entity = ".((int) $entity);
  106. $sql .= " AND statut = 1";
  107. $sql .= " AND public = 1";
  108. $sql .= $db->order($sortfield, $sortorder);
  109. $sql .= $db->plimit($conf->liste_limit + 1, $offset);
  110. //$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, zip, town, d.email, t.libelle as type, d.morphy, d.statut, t.subscription";
  111. //$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
  112. //$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut";
  113. //$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
  114. $result = $db->query($sql);
  115. if ($result) {
  116. $num = $db->num_rows($result);
  117. $i = 0;
  118. $param = "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
  119. print_barre_liste($langs->trans("ListOfValidatedPublicMembers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, '');
  120. print '<table class="public_border centpercent">';
  121. print '<tr class="public_liste_titre">';
  122. print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")).'</a></th>';
  123. print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></th>'."\n";
  124. //print_liste_field_titre("DateOfBirth", $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
  125. print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'left public_');
  126. print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'left public_');
  127. print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'left public_');
  128. print_liste_field_titre("Photo", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center public_');
  129. print "</tr>\n";
  130. while ($i < $num && $i < $conf->liste_limit) {
  131. $objp = $db->fetch_object($result);
  132. print '<tr class="oddeven">';
  133. print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
  134. print '<td>'.$objp->societe.'</td>'."\n";
  135. print '<td>'.$objp->email.'</td>'."\n";
  136. print '<td>'.$objp->zip.'</td>'."\n";
  137. print '<td>'.$objp->town.'</td>'."\n";
  138. if (isset($objp->photo) && $objp->photo != '') {
  139. print '<td class="center">';
  140. print $form->showphoto('memberphoto', $objp, 64);
  141. print '</td>'."\n";
  142. } else {
  143. print "<td>&nbsp;</td>\n";
  144. }
  145. print "</tr>";
  146. $i++;
  147. }
  148. print "</table>";
  149. } else {
  150. dol_print_error($db);
  151. }
  152. llxFooterVierge();
  153. $db->close();