dolibarr 24.0.0-beta
public_list.php
Go to the documentation of this file.
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 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29if (!defined('NOLOGIN')) {
30 define("NOLOGIN", 1); // This means this output page does not require to be logged.
31}
32if (!defined('NOCSRFCHECK')) {
33 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
34}
35if (!defined('NOIPCHECK')) {
36 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
37}
38if (!defined('NOBROWSERNOTIF')) {
39 define('NOBROWSERNOTIF', '1');
40}
41
42// For MultiCompany module.
43// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
44// Because 2 entities can have the same ref.
45$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
46// if (is_numeric($entity)) { // $entity is casted to int
47define("DOLENTITY", $entity);
48// }
49
50// Load Dolibarr environment
51require '../../main.inc.php';
58// Security check
59if (!isModEnabled('member')) {
60 httponly_accessforbidden('Module Membership not enabled');
61}
62
63$langs->loadLangs(array("main", "members", "companies", "other"));
64
65
80function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $ws = '') // @phan-suppress-current-line PhanRedefineFunction
81{
82 top_htmlhead($head, $title);
83
84 print '<body class="public_body">'."\n";
85}
86
94function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
95{
96 printCommonFooter('public');
97
98 print "</body>\n";
99 print "</html>\n";
100}
101
102
103$sortfield = GETPOST('sortfield', 'aZ09comma');
104$sortorder = GETPOST('sortorder', 'aZ09comma');
105$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
106$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
107if (empty($page) || $page == -1) {
108 $page = 0;
109} // If $page is not defined, or '' or -1
110$offset = $limit * $page;
111$pageprev = $page - 1;
112$pagenext = $page + 1;
113
114$filter = GETPOST('filter');
115$statut = GETPOST('statut');
116
117if (!$sortorder) {
118 $sortorder = "ASC";
119}
120if (!$sortfield) {
121 $sortfield = "lastname";
122}
123
124
125/*
126 * View
127 */
128
129if (!getDolGlobalString('MEMBER_PUBLIC_ENABLED')) {
130 httponly_accessforbidden('Public access of list of members is not enabled. See setup of module membership to enable it.');
131}
132
133$form = new Form($db);
134
135$morehead = '';
136if (getDolGlobalString('MEMBER_PUBLIC_CSS')) {
137 $morehead = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MEMBER_PUBLIC_CSS').'">';
138} else {
139 $morehead = '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php">';
140}
141
142llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
143
144$sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
145
146$sqlfields = $sql;
147
148$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
149$sql .= " WHERE entity = ".((int) $entity);
150$sql .= " AND statut = 1";
151$sql .= " AND public = 1";
152
153// Count total nb of records
154$nbtotalofrecords = '';
155if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
156 /* The fast and low memory method to get and count full list converts the sql into a sql count */
157 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
158 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
159
160 $resql = $db->query($sqlforcount);
161 if ($resql) {
162 $objforcount = $db->fetch_object($resql);
163 $nbtotalofrecords = $objforcount->nbtotalofrecords;
164 } else {
166 }
167
168 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
169 $page = 0;
170 $offset = 0;
171 }
172 $db->free($resql);
173}
174
175$sql .= $db->order($sortfield, $sortorder);
176$sql .= $db->plimit($conf->liste_limit + 1, $offset);
177
178
179$result = $db->query($sql);
180if ($result) {
181 $num = $db->num_rows($result);
182 $i = 0;
183
184 $param = "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
185 $title = $langs->trans("ListOfValidatedPublicMembers");
186 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
187 print '<table class="public_border centpercent">';
188
189 print '<tr class="public_liste_titre">';
190 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")).'</a></th>';
191 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></th>'."\n";
192 //print_liste_field_titre("DateOfBirth", $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
193 print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'left public_');
194 print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'left public_');
195 print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'left public_');
196 print_liste_field_titre("Photo", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center public_');
197 print "</tr>\n";
198
199 while ($i < $num && $i < $conf->liste_limit) {
200 $objp = $db->fetch_object($result);
201
202 print '<tr class="oddeven">';
203 print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
204 print '<td>'.$objp->societe.'</td>'."\n";
205 print '<td>'.$objp->email.'</td>'."\n";
206 print '<td>'.$objp->zip.'</td>'."\n";
207 print '<td>'.$objp->town.'</td>'."\n";
208 if (isset($objp->photo) && $objp->photo != '') {
209 print '<td class="center">';
210 print $form->showphoto('memberphoto', $objp, 64);
211 print '</td>'."\n";
212 } else {
213 print "<td>&nbsp;</td>\n";
214 }
215 print "</tr>";
216 $i++;
217 }
218 print "</table>";
219} else {
221}
222
223
225
226$db->close();
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[], $ws='')
Show header for member list.
llxFooterVierge()
Show footer for member list.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.