dolibarr 21.0.0-alpha
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));
45if (is_numeric($entity)) {
46 define("DOLENTITY", $entity);
47}
48
49// Load Dolibarr environment
50require '../../main.inc.php';
51
52// Security check
53if (!isModEnabled('member')) {
54 httponly_accessforbidden('Module Membership not enabled');
55}
56
57$langs->loadLangs(array("main", "members", "companies", "other"));
58
59
71function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
72{
73 top_htmlhead($head, $title);
74
75 print '<body class="public_body">'."\n";
76}
77
84{
85 printCommonFooter('public');
86
87 print "</body>\n";
88 print "</html>\n";
89}
90
91
92$sortfield = GETPOST('sortfield', 'aZ09comma');
93$sortorder = GETPOST('sortorder', 'aZ09comma');
94$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
95$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
96if (empty($page) || $page == -1) {
97 $page = 0;
98} // If $page is not defined, or '' or -1
99$offset = $limit * $page;
100$pageprev = $page - 1;
101$pagenext = $page + 1;
102
103$filter = GETPOST('filter');
104$statut = GETPOST('statut');
105
106if (!$sortorder) {
107 $sortorder = "ASC";
108}
109if (!$sortfield) {
110 $sortfield = "lastname";
111}
112
113
114/*
115 * View
116 */
117
118if (!getDolGlobalString('MEMBER_PUBLIC_ENABLED')) {
119 httponly_accessforbidden('Public access of list of members is not enabled');
120}
121
122$form = new Form($db);
123
124$morehead = '';
125if (getDolGlobalString('MEMBER_PUBLIC_CSS')) {
126 $morehead = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MEMBER_PUBLIC_CSS').'">';
127} else {
128 $morehead = '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php">';
129}
130
131llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
132
133$sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
134
135$sqlfields = $sql;
136
137$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
138$sql .= " WHERE entity = ".((int) $entity);
139$sql .= " AND statut = 1";
140$sql .= " AND public = 1";
141
142// Count total nb of records
143$nbtotalofrecords = '';
144if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
145 /* The fast and low memory method to get and count full list converts the sql into a sql count */
146 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
147 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
148
149 $resql = $db->query($sqlforcount);
150 if ($resql) {
151 $objforcount = $db->fetch_object($resql);
152 $nbtotalofrecords = $objforcount->nbtotalofrecords;
153 } else {
154 dol_print_error($db);
155 }
156
157 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
158 $page = 0;
159 $offset = 0;
160 }
161 $db->free($resql);
162}
163
164$sql .= $db->order($sortfield, $sortorder);
165$sql .= $db->plimit($conf->liste_limit + 1, $offset);
166//$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, zip, town, d.email, t.libelle as type, d.morphy, d.statut, t.subscription";
167//$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
168//$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut";
169//$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
170
171
172$result = $db->query($sql);
173if ($result) {
174 $num = $db->num_rows($result);
175 $i = 0;
176
177 $param = "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
178 $title = $langs->trans("ListOfValidatedPublicMembers");
179 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
180 print '<table class="public_border centpercent">';
181
182 print '<tr class="public_liste_titre">';
183 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")).'</a></th>';
184 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></th>'."\n";
185 //print_liste_field_titre("DateOfBirth", $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
186 print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'left public_');
187 print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'left public_');
188 print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'left public_');
189 print_liste_field_titre("Photo", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center public_');
190 print "</tr>\n";
191
192 while ($i < $num && $i < $conf->liste_limit) {
193 $objp = $db->fetch_object($result);
194
195 print '<tr class="oddeven">';
196 print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
197 print '<td>'.$objp->societe.'</td>'."\n";
198 print '<td>'.$objp->email.'</td>'."\n";
199 print '<td>'.$objp->zip.'</td>'."\n";
200 print '<td>'.$objp->town.'</td>'."\n";
201 if (isset($objp->photo) && $objp->photo != '') {
202 print '<td class="center">';
203 print $form->showphoto('memberphoto', $objp, 64);
204 print '</td>'."\n";
205 } else {
206 print "<td>&nbsp;</td>\n";
207 }
208 print "</tr>";
209 $i++;
210 }
211 print "</table>";
212} else {
213 dol_print_error($db);
214}
215
216
218
219$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.
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.