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 *
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
27if (!defined('NOLOGIN')) {
28 define("NOLOGIN", 1); // This means this output page does not require to be logged.
29}
30if (!defined('NOCSRFCHECK')) {
31 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
32}
33if (!defined('NOIPCHECK')) {
34 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
35}
36if (!defined('NOBROWSERNOTIF')) {
37 define('NOBROWSERNOTIF', '1');
38}
39
40// For MultiCompany module.
41// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
42// Because 2 entities can have the same ref.
43$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
44if (is_numeric($entity)) {
45 define("DOLENTITY", $entity);
46}
47
48// Load Dolibarr environment
49require '../../main.inc.php';
50
51// Security check
52if (!isModEnabled('member')) {
53 httponly_accessforbidden('Module Membership not enabled');
54}
55
56$langs->loadLangs(array("main", "members", "companies", "other"));
57
58
66function llxHeaderVierge($title, $head = "")
67{
68 top_htmlhead($head, $title);
69
70 print '<body class="public_body">'."\n";
71}
72
79{
80 printCommonFooter('public');
81
82 print "</body>\n";
83 print "</html>\n";
84}
85
86
87$sortfield = GETPOST('sortfield', 'aZ09comma');
88$sortorder = GETPOST('sortorder', 'aZ09comma');
89$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
90$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
91if (empty($page) || $page == -1) {
92 $page = 0;
93} // If $page is not defined, or '' or -1
94$offset = $limit * $page;
95$pageprev = $page - 1;
96$pagenext = $page + 1;
97
98$filter = GETPOST('filter');
99$statut = GETPOST('statut');
100
101if (!$sortorder) {
102 $sortorder = "ASC";
103}
104if (!$sortfield) {
105 $sortfield = "lastname";
106}
107
108
109/*
110 * View
111 */
112
113if (!getDolGlobalString('MEMBER_PUBLIC_ENABLED')) {
114 httponly_accessforbidden('Public access of list of members is not enabled');
115}
116
117$form = new Form($db);
118
119$morehead = '';
120if (getDolGlobalString('MEMBER_PUBLIC_CSS')) {
121 $morehead = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MEMBER_PUBLIC_CSS').'">';
122} else {
123 $morehead = '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php">';
124}
125
126llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
127
128$sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
129
130$sqlfields = $sql;
131
132$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
133$sql .= " WHERE entity = ".((int) $entity);
134$sql .= " AND statut = 1";
135$sql .= " AND public = 1";
136
137// Count total nb of records
138$nbtotalofrecords = '';
139if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
140 /* The fast and low memory method to get and count full list converts the sql into a sql count */
141 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
142 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
143
144 $resql = $db->query($sqlforcount);
145 if ($resql) {
146 $objforcount = $db->fetch_object($resql);
147 $nbtotalofrecords = $objforcount->nbtotalofrecords;
148 } else {
149 dol_print_error($db);
150 }
151
152 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
153 $page = 0;
154 $offset = 0;
155 }
156 $db->free($resql);
157}
158
159$sql .= $db->order($sortfield, $sortorder);
160$sql .= $db->plimit($conf->liste_limit + 1, $offset);
161//$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, zip, town, d.email, t.libelle as type, d.morphy, d.statut, t.subscription";
162//$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
163//$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut";
164//$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
165
166
167$result = $db->query($sql);
168if ($result) {
169 $num = $db->num_rows($result);
170 $i = 0;
171
172 $param = "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
173 $title = $langs->trans("ListOfValidatedPublicMembers");
174 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
175 print '<table class="public_border centpercent">';
176
177 print '<tr class="public_liste_titre">';
178 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")).'</a></th>';
179 print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></th>'."\n";
180 //print_liste_field_titre("DateOfBirth", $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
181 print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'left public_');
182 print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'left public_');
183 print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'left public_');
184 print_liste_field_titre("Photo", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center public_');
185 print "</tr>\n";
186
187 while ($i < $num && $i < $conf->liste_limit) {
188 $objp = $db->fetch_object($result);
189
190 print '<tr class="oddeven">';
191 print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
192 print '<td>'.$objp->societe.'</td>'."\n";
193 print '<td>'.$objp->email.'</td>'."\n";
194 print '<td>'.$objp->zip.'</td>'."\n";
195 print '<td>'.$objp->town.'</td>'."\n";
196 if (isset($objp->photo) && $objp->photo != '') {
197 print '<td class="center">';
198 print $form->showphoto('memberphoto', $objp, 64);
199 print '</td>'."\n";
200 } else {
201 print "<td>&nbsp;</td>\n";
202 }
203 print "</tr>";
204 $i++;
205 }
206 print "</table>";
207} else {
208 dol_print_error($db);
209}
210
211
213
214$db->close();
if(!defined( 'NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined( 'NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined( 'NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined( 'NOIPCHECK')) llxHeaderVierge()
Header function.
Class to manage generation of HTML components Only common components must be here.
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.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
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.