dolibarr 22.0.5
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 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
79function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = []) // @phan-suppress-current-line PhanRedefineFunction
80{
81 top_htmlhead($head, $title);
82
83 print '<body class="public_body">'."\n";
84}
85
93function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
94{
95 printCommonFooter('public');
96
97 print "</body>\n";
98 print "</html>\n";
99}
100
101
102$sortfield = GETPOST('sortfield', 'aZ09comma');
103$sortorder = GETPOST('sortorder', 'aZ09comma');
104$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
105$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
106if (empty($page) || $page == -1) {
107 $page = 0;
108} // If $page is not defined, or '' or -1
109$offset = $limit * $page;
110$pageprev = $page - 1;
111$pagenext = $page + 1;
112
113$filter = GETPOST('filter');
114$statut = GETPOST('statut');
115
116if (!$sortorder) {
117 $sortorder = "ASC";
118}
119if (!$sortfield) {
120 $sortfield = "lastname";
121}
122
123
124/*
125 * View
126 */
127
128if (!getDolGlobalString('MEMBER_PUBLIC_ENABLED')) {
129 httponly_accessforbidden('Public access of list of members is not enabled. See setup of module membership to enable it.');
130}
131
132$form = new Form($db);
133
134$morehead = '';
135if (getDolGlobalString('MEMBER_PUBLIC_CSS')) {
136 $morehead = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MEMBER_PUBLIC_CSS').'">';
137} else {
138 $morehead = '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php">';
139}
140
141llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
142
143$sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
144
145$sqlfields = $sql;
146
147$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
148$sql .= " WHERE entity = ".((int) $entity);
149$sql .= " AND statut = 1";
150$sql .= " AND public = 1";
151
152// Count total nb of records
153$nbtotalofrecords = '';
154if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
155 /* The fast and low memory method to get and count full list converts the sql into a sql count */
156 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
157 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
158
159 $resql = $db->query($sqlforcount);
160 if ($resql) {
161 $objforcount = $db->fetch_object($resql);
162 $nbtotalofrecords = $objforcount->nbtotalofrecords;
163 } else {
164 dol_print_error($db);
165 }
166
167 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
168 $page = 0;
169 $offset = 0;
170 }
171 $db->free($resql);
172}
173
174$sql .= $db->order($sortfield, $sortorder);
175$sql .= $db->plimit($conf->liste_limit + 1, $offset);
176
177
178$result = $db->query($sql);
179if ($result) {
180 $num = $db->num_rows($result);
181 $i = 0;
182
183 $param = "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
184 $title = $langs->trans("ListOfValidatedPublicMembers");
185 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
186 print '<table class="public_border centpercent">';
187
188 print '<tr class="public_liste_titre">';
189 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")).'</a></th>';
190 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></th>'."\n";
191 //print_liste_field_titre("DateOfBirth", $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
192 print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'left public_');
193 print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'left public_');
194 print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'left public_');
195 print_liste_field_titre("Photo", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center public_');
196 print "</tr>\n";
197
198 while ($i < $num && $i < $conf->liste_limit) {
199 $objp = $db->fetch_object($result);
200
201 print '<tr class="oddeven">';
202 print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
203 print '<td>'.$objp->societe.'</td>'."\n";
204 print '<td>'.$objp->email.'</td>'."\n";
205 print '<td>'.$objp->zip.'</td>'."\n";
206 print '<td>'.$objp->town.'</td>'."\n";
207 if (isset($objp->photo) && $objp->photo != '') {
208 print '<td class="center">';
209 print $form->showphoto('memberphoto', $objp, 64);
210 print '</td>'."\n";
211 } else {
212 print "<td>&nbsp;</td>\n";
213 }
214 print "</tr>";
215 $i++;
216 }
217 print "</table>";
218} else {
219 dol_print_error($db);
220}
221
222
224
225$db->close();
Class to manage generation of HTML components Only common components must be here.
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.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
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.