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