dolibarr  17.0.4
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 
27 if (!defined('NOLOGIN')) {
28  define("NOLOGIN", 1); // This means this output page does not require to be logged.
29 }
30 if (!defined('NOCSRFCHECK')) {
31  define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
32 }
33 if (!defined('NOIPCHECK')) {
34  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
35 }
36 if (!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 // TODO This should be useless. Because entity must be retrieve from object ref and not from url.
43 $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
44 if (is_numeric($entity)) {
45  define("DOLENTITY", $entity);
46 }
47 
48 // Load Dolibarr environment
49 require '../../main.inc.php';
50 
51 // Security check
52 if (empty($conf->adherent->enabled)) {
53  httponly_accessforbidden('Module Membership not enabled');
54 }
55 
56 
57 $langs->loadLangs(array("main", "members", "companies", "other"));
58 
59 
67 function llxHeaderVierge($title, $head = "")
68 {
69  top_htmlhead($head, $title);
70 
71  print '<body class="public_body">'."\n";
72 }
73 
79 function llxFooterVierge()
80 {
81  printCommonFooter('public');
82 
83  print "</body>\n";
84  print "</html>\n";
85 }
86 
87 
88 $sortfield = GETPOST('sortfield', 'aZ09comma');
89 $sortorder = GETPOST('sortorder', 'aZ09comma');
90 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
91 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
92 if (empty($page) || $page == -1) {
93  $page = 0;
94 } // If $page is not defined, or '' or -1
95 $offset = $limit * $page;
96 $pageprev = $page - 1;
97 $pagenext = $page + 1;
98 
99 $filter = GETPOST('filter');
100 $statut = GETPOST('statut');
101 
102 if (!$sortorder) {
103  $sortorder = "ASC";
104 }
105 if (!$sortfield) {
106  $sortfield = "lastname";
107 }
108 
109 
110 /*
111  * View
112  */
113 
114 if (empty($conf->global->MEMBER_PUBLIC_ENABLED)) {
115  httponly_accessforbidden('Public access of list of members is not enabled');
116 }
117 
118 $form = new Form($db);
119 
120 $morehead = '';
121 if (!empty($conf->global->MEMBER_PUBLIC_CSS)) {
122  $morehead = '<link rel="stylesheet" type="text/css" href="'.$conf->global->MEMBER_PUBLIC_CSS.'">';
123 } else {
124  $morehead = '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php">';
125 }
126 
127 llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
128 
129 $sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
130 $sql .= " FROM ".MAIN_DB_PREFIX."adherent";
131 $sql .= " WHERE entity = ".((int) $entity);
132 $sql .= " AND statut = 1";
133 $sql .= " AND public = 1";
134 $sql .= $db->order($sortfield, $sortorder);
135 $sql .= $db->plimit($conf->liste_limit + 1, $offset);
136 //$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, zip, town, d.email, t.libelle as type, d.morphy, d.statut, t.subscription";
137 //$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
138 //$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut";
139 //$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
140 
141 $result = $db->query($sql);
142 if ($result) {
143  $num = $db->num_rows($result);
144  $i = 0;
145 
146  $param = "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
147  print_barre_liste($langs->trans("ListOfValidatedPublicMembers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, '');
148  print '<table class="public_border centpercent">';
149 
150  print '<tr class="public_liste_titre">';
151  print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")).'</a></th>';
152  print '<th class="left"><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></th>'."\n";
153  //print_liste_field_titre("DateOfBirth", $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nĂ©cessaire ??
154  print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'left public_');
155  print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'left public_');
156  print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'left public_');
157  print_liste_field_titre("Photo", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center public_');
158  print "</tr>\n";
159 
160  while ($i < $num && $i < $conf->liste_limit) {
161  $objp = $db->fetch_object($result);
162 
163  print '<tr class="oddeven">';
164  print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
165  print '<td>'.$objp->societe.'</td>'."\n";
166  print '<td>'.$objp->email.'</td>'."\n";
167  print '<td>'.$objp->zip.'</td>'."\n";
168  print '<td>'.$objp->town.'</td>'."\n";
169  if (isset($objp->photo) && $objp->photo != '') {
170  print '<td class="center">';
171  print $form->showphoto('memberphoto', $objp, 64);
172  print '</td>'."\n";
173  } else {
174  print "<td>&nbsp;</td>\n";
175  }
176  print "</tr>";
177  $i++;
178  }
179  print "</table>";
180 } else {
181  dol_print_error($db);
182 }
183 
184 
186 
187 $db->close();
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
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.
print_barre_liste($titre, $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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1571
llxFooterVierge()
Show footer for member list.
Definition: public_list.php:79
llxHeaderVierge($title, $head="")
Show header for member list.
Definition: public_list.php:67
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.