dolibarr  13.0.2
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')) define("NOLOGIN", 1); // This means this output page does not require to be logged.
28 if (!defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
29 if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
30 if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1');
31 
32 // For MultiCompany module.
33 // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
34 // TODO This should be useless. Because entity must be retrieve from object ref and not from url.
35 $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
36 if (is_numeric($entity)) define("DOLENTITY", $entity);
37 
38 require '../../main.inc.php';
39 
40 // Security check
41 if (empty($conf->adherent->enabled)) accessforbidden('', 0, 0, 1);
42 
43 
44 $langs->loadLangs(array("main", "members", "companies", "other"));
45 
46 
54 function llxHeaderVierge($title, $head = "")
55 {
56  global $user, $conf, $langs;
57 
58  header("Content-type: text/html; charset=".$conf->file->character_set_client);
59  print "<html>\n";
60  print "<head>\n";
61  print "<title>".$title."</title>\n";
62  if ($head) print $head."\n";
63  print "</head>\n";
64  print '<body class="public_body">'."\n";
65 }
66 
72 function llxFooterVierge()
73 {
74  printCommonFooter('public');
75 
76  print "</body>\n";
77  print "</html>\n";
78 }
79 
80 
81 $sortfield = GETPOST("sortfield", 'alpha');
82 $sortorder = GETPOST("sortorder", 'alpha');
83 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
84 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
85 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
86 $offset = $limit * $page;
87 $pageprev = $page - 1;
88 $pagenext = $page + 1;
89 
90 $filter = GETPOST('filter');
91 $statut = GETPOST('statut');
92 
93 if (!$sortorder) { $sortorder = "ASC"; }
94 if (!$sortfield) { $sortfield = "lastname"; }
95 
96 
97 /*
98  * View
99  */
100 
101 $form = new Form($db);
102 
103 $morehead = '';
104 if (!empty($conf->global->MEMBER_PUBLIC_CSS)) $morehead = '<link rel="stylesheet" type="text/css" href="'.$conf->global->MEMBER_PUBLIC_CSS.'">';
105 else $morehead = '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php">';
106 
107 llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
108 
109 $sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
110 $sql .= " FROM ".MAIN_DB_PREFIX."adherent";
111 $sql .= " WHERE entity = ".$entity;
112 $sql .= " AND statut = 1";
113 $sql .= " AND public = 1";
114 $sql .= $db->order($sortfield, $sortorder);
115 $sql .= $db->plimit($conf->liste_limit + 1, $offset);
116 //$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, zip, town, d.email, t.libelle as type, d.morphy, d.statut, t.subscription";
117 //$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
118 //$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut";
119 //$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
120 
121 $result = $db->query($sql);
122 if ($result)
123 {
124  $num = $db->num_rows($result);
125  $i = 0;
126 
127  $param = "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
128  print_barre_liste($langs->trans("ListOfValidatedPublicMembers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, '');
129  print '<table class="public_border centpercent">';
130 
131  print '<tr class="public_liste_titre">';
132  print '<td><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")).'</a></td>';
133  print '<td><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></td>'."\n";
134  //print_liste_field_titre("DateToBirth", $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nĂ©cessaire ??
135  print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'public_');
136  print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'public_');
137  print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'public_');
138  print_liste_field_titre("Photo", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'public_');
139  print "</tr>\n";
140 
141  while ($i < $num && $i < $conf->liste_limit)
142  {
143  $objp = $db->fetch_object($result);
144 
145  print '<tr class="oddeven">';
146  print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
147  print '<td>'.$objp->societe.'</td>'."\n";
148  print '<td>'.$objp->email.'</td>'."\n";
149  print '<td>'.$objp->zip.'</td>'."\n";
150  print '<td>'.$objp->town.'</td>'."\n";
151  if (isset($objp->photo) && $objp->photo != '')
152  {
153  print '<td>';
154  print $form->showphoto('memberphoto', $objp, 64);
155  print '</td>'."\n";
156  } else {
157  print "<td>&nbsp;</td>\n";
158  }
159  print "</tr>";
160  $i++;
161  }
162  print "</table>";
163 } else {
164  dol_print_error($db);
165 }
166 
167 
169 
170 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
printCommonFooter($zone= 'private')
Print common footer : conf-&gt;global-&gt;MAIN_HTML_FOOTER js for switch of menu hider js for conf-&gt;global-...
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
llxHeaderVierge()
Header function.
print
Draft customers invoices.
Definition: index.php:89
llxFooterVierge()
Footer function.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.