dolibarr  7.0.0-beta
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-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2013-2015 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
6  * Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
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 <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33 
34 $langs->loadLangs(array("members","companies"));
35 
36 $action=GETPOST('action','aZ09');
37 $massaction=GETPOST('massaction','alpha');
38 $show_files=GETPOST('show_files','int');
39 $confirm=GETPOST('confirm','alpha');
40 $toselect = GETPOST('toselect', 'array');
41 
42 // Security check
43 $result=restrictedArea($user,'adherent');
44 
45 $filter=GETPOST("filter");
46 $statut=GETPOST("statut");
47 $search=GETPOST("search");
48 $search_ref=GETPOST("search_ref");
49 $search_lastname=GETPOST("search_lastname");
50 $search_firstname=GETPOST("search_firstname");
51 $search_login=GETPOST("search_login");
52 $search_address=GETPOST("search_address");
53 $search_zip=GETPOST("search_zip");
54 $search_town=GETPOST("search_town");
55 $search_state=GETPOST("search_state");
56 $search_country=GETPOST("search_country");
57 $search_phone=GETPOST("search_phone");
58 $search_phone_perso=GETPOST("search_phone_perso");
59 $search_phone_mobile=GETPOST("search_phone_mobile");
60 $search_type=GETPOST("search_type");
61 $search_email=GETPOST("search_email");
62 $search_categ = GETPOST("search_categ",'int');
63 $catid = GETPOST("catid",'int');
64 $optioncss = GETPOST('optioncss','alpha');
65 
66 $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
67 
68 if ($statut < -1) $statut = '';
69 
70 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
71 $sortfield = GETPOST("sortfield",'alpha');
72 $sortorder = GETPOST("sortorder",'alpha');
73 $page = GETPOST("page",'int');
74 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
75 $offset = $limit * $page ;
76 $pageprev = $page - 1;
77 $pagenext = $page + 1;
78 if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); }
79 if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); }
80 
81 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
82 $hookmanager->initHooks(array('memberlist'));
83 $extrafields = new ExtraFields($db);
84 
85 // fetch optionals attributes and labels
86 $extralabels = $extrafields->fetch_name_optionals_label('adherent');
87 $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
88 
89 // List of fields to search into when doing a "search in all"
90 $fieldstosearchall = array(
91  'd.rowid'=>'Ref',
92  'd.login'=>'Login',
93  'd.lastname'=>'Lastname',
94  'd.firstname'=>'Firstname',
95  'd.login'=>'Login',
96  'd.societe'=>"Company",
97  'd.email'=>'EMail',
98  'd.address'=>'Address',
99  'd.zip'=>'Zip',
100  'd.town'=>'Town',
101  'd.note_public'=>'NotePublic',
102  'd.note_private'=>'NotePrivate',
103 );
104 if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
105 $arrayfields=array(
106  'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
107  'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
108  'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
109  'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
110  'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
111  'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1),
112  't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
113  'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
114  'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
115  'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
116  'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
117  'd.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
118  'd.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
119  'd.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>0),
120  'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0),
121  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
122  /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
123  'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
124  'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500),
125  'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
126  'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
127  'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
128 );
129 // Extra fields
130 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
131 {
132  foreach($extrafields->attribute_label as $key => $val)
133  {
134  if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
135  }
136 }
137 
138 
139 /*
140  * Actions
141  */
142 
143 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
144 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
145 
146 $parameters=array('socid'=>$socid);
147 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
148 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
149 
150 if (empty($reshook))
151 {
152  // Selection of new fields
153  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
154 
155  // Purge search criteria
156  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
157  {
158  $search="";
159  $search_ref="";
160  $search_lastname="";
161  $search_firstname="";
162  $search_login="";
163  $search_company="";
164  $search_type="";
165  $search_email="";
166  $search_address="";
167  $search_zip="";
168  $search_town="";
169  $search_state="";
170  $search_country='';
171  $search_phone='';
172  $search_phone_perso='';
173  $search_phone_mobile='';
174  $search_morphy="";
175  $search_categ="";
176  $catid="";
177  $sall="";
178  $statut='';
179  $toselect='';
180  $search_array_options=array();
181  }
182 
183  // Mass actions
184  $objectclass='Adherent';
185  $objectlabel='Members';
186  $permtoread = $user->rights->adherent->lire;
187  $permtodelete = $user->rights->adherent->supprimer;
188  $uploaddir = $conf->adherent->dir_output;
189  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
190 }
191 
192 
193 /*
194  * View
195  */
196 
197 $form=new Form($db);
198 $formother=new FormOther($db);
199 $membertypestatic=new AdherentType($db);
200 $memberstatic=new Adherent($db);
201 
202 $now=dol_now();
203 
204 $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,";
205 $sql.= " d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
206 $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,";
207 $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
208 $sql.= " t.libelle as type, t.subscription,";
209 $sql.= " state.code_departement as state_code, state.nom as state_name";
210 // Add fields from extrafields
211 foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
212 // Add fields from hooks
213 $parameters=array();
214 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
215 $sql.=$hookmanager->resPrint;
216 $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
217 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
218 if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ
219 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
220 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
221 $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
222 $sql.= " WHERE d.fk_adherent_type = t.rowid ";
223 if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid);
224 if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
225 if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
226 if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
227 $sql.= " AND d.entity IN (".getEntity('adherent').")";
228 if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
229 if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type);
230 if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
231 if ($search_ref)
232 {
233  if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")";
234  else $sql.=" AND 1 = 2"; // Always wrong
235 }
236 if ($search_firstname) $sql.= natural_search("d.firstname", $search_firstname);
237 if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
238 if ($search_login) $sql.= natural_search("d.login", $search_login);
239 if ($search_email) $sql.= natural_search("d.email", $search_email);
240 if ($search_town) $sql.= natural_search("d.town",$search_town);
241 if ($search_zip) $sql.= natural_search("d.zip",$search_zip);
242 if ($search_state) $sql.= natural_search("state.nom",$search_state);
243 if ($search_country) $sql .= " AND d.country IN (".$search_country.')';
244 if ($filter == 'uptodate') $sql.=" AND datefin >= '".$db->idate($now)."'";
245 if ($filter == 'outofdate') $sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')";
246 
247 // Add where from extra fields
248 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
249 
250 // Add where from hooks
251 $parameters=array();
252 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
253 $sql.=$hookmanager->resPrint;
254 
255 $sql.= $db->order($sortfield,$sortorder);
256 
257 // Count total nb of records with no order and no limits
258 $nbtotalofrecords = '';
259 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
260 {
261  $resql = $db->query($sql);
262  if ($resql) $nbtotalofrecords = $db->num_rows($resql);
263  else dol_print_error($db);
264 }
265 // Add limit
266 $sql.= $db->plimit($limit+1, $offset);
267 
268 dol_syslog("get list", LOG_DEBUG);
269 $resql = $db->query($sql);
270 if (! $resql)
271 {
272  dol_print_error($db);
273  exit;
274 }
275 
276 $num = $db->num_rows($resql);
277 
278 $arrayofselected=is_array($toselect)?$toselect:array();
279 
280 if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
281 {
282  $obj = $db->fetch_object($resql);
283  $id = $obj->rowid;
284  header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id);
285  exit;
286 }
287 
288 llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
289 
290 $titre=$langs->trans("MembersList");
291 if (isset($_GET["statut"]))
292 {
293  if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
294  if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); }
295  if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
296  if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
297  if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
298  if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); }
299 }
300 elseif ($action == 'search')
301 {
302  $titre=$langs->trans("MembersListQualified");
303 }
304 
305 if ($search_type > 0)
306 {
307  $membertype=new AdherentType($db);
308  $result=$membertype->fetch(GETPOST("type",'int'));
309  $titre.=" (".$membertype->label.")";
310 }
311 
312 $param='';
313 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
314 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
315 if ($sall != "") $param.="&sall=".urlencode($sall);
316 if ($statut != "") $param.="&statut=".urlencode($statut);
317 if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
318 if ($search_nom) $param.="&search_nom=".urlencode($search_nom);
319 if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname);
320 if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname);
321 if ($search_login) $param.="&search_login=".urlencode($search_login);
322 if ($search_email) $param.="&search_email=".urlencode($search_email);
323 if ($search_company) $param.="&search_company=".urlencode($search_company);
324 if ($search_address != '') $param.= "&search_address=".urlencode($search_address);
325 if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
326 if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip);
327 if ($search_state != '') $param.= "&search_state=".urlencode($search_state);
328 if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
329 if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
330 if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso);
331 if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile);
332 if ($filter) $param.="&filter=".urlencode($filter);
333 if ($search_type > 0) $param.="&search_type=".urlencode($search_type);
334 if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
335 // Add $param from extra fields
336 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
337 
338 // List of mass actions available
339 $arrayofmassactions = array(
340 // 'presend'=>$langs->trans("SendByMail"),
341 // 'builddoc'=>$langs->trans("PDFMerge"),
342 );
343 if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
344 if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
345 $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
346 
347 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
348 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
349 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
350 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
351 print '<input type="hidden" name="action" value="list">';
352 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
353 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
354 print '<input type="hidden" name="page" value="'.$page.'">';
355 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
356 
357 print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit);
358 
359 $topicmail="Information";
360 $modelmail="member";
361 $objecttmp=new Adherent($db);
362 $trackid='mem'.$object->id;
363 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
364 
365 if ($sall)
366 {
367  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
368  print $langs->trans("FilterOnInto", $sall) . implode(', ',$fieldstosearchall);
369 }
370 
371 // Filter on categories
372 $moreforfilter='';
373 if (! empty($conf->categorie->enabled))
374 {
375  require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
376  $moreforfilter.='<div class="divsearchfield">';
377  $moreforfilter.=$langs->trans('Categories'). ': ';
378  $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1);
379  $moreforfilter.='</div>';
380 }
381 $parameters=array();
382 $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
383 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
384 else $moreforfilter = $hookmanager->resPrint;
385 if (! empty($moreforfilter))
386 {
387  print '<div class="liste_titre liste_titre_bydiv centpercent">';
388  print $moreforfilter;
389  print '</div>';
390 }
391 
392 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
393 $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
394 if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
395 
396 print '<div class="div-table-responsive">';
397 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
398 
399 
400 // Line for filters fields
401 print '<tr class="liste_titre_filter">';
402 
403 // Line numbering
404 if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
405 {
406  print '<td class="liste_titre">&nbsp;</td>';
407 }
408 
409 // Ref
410 if (! empty($arrayfields['d.ref']['checked']))
411 {
412  print '<td class="liste_titre">';
413  print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
414  print '</td>';
415 }
416 
417 if (! empty($arrayfields['d.firstname']['checked']))
418 {
419  print '<td class="liste_titre" align="left">';
420  print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
421 }
422 
423 if (! empty($arrayfields['d.lastname']['checked']))
424 {
425  print '<td class="liste_titre" align="left">';
426  print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
427 }
428 
429 if (! empty($arrayfields['d.company']['checked']))
430 {
431  print '<td class="liste_titre" align="left">';
432  print '<input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
433 }
434 
435 if (! empty($arrayfields['d.login']['checked']))
436 {
437  print '<td class="liste_titre" align="left">';
438  print '<input class="flat maxwidth50" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
439 }
440 
441 if (! empty($arrayfields['d.morphy']['checked']))
442 {
443  print '<td class="liste_titre" align="left">';
444  print '</td>';
445 }
446 
447 if (! empty($arrayfields['t.libelle']['checked']))
448 {
449  print '<td class="liste_titre">';
450  $listetype=$membertypestatic->liste_array();
451  print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32);
452  print '</td>';
453 }
454 
455 if (! empty($arrayfields['d.address']['checked']))
456 {
457  print '<td class="liste_titre" align="left">';
458  print '<input class="flat maxwidth50" type="text" name="search_address" value="'.$search_address.'"></td>';
459 }
460 
461 if (! empty($arrayfields['d.zip']['checked']))
462 {
463  print '<td class="liste_titre" align="left">';
464  print '<input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
465 }
466 if (! empty($arrayfields['d.town']['checked']))
467 {
468  print '<td class="liste_titre" align="left">';
469  print '<input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
470 }
471 // State
472 if (! empty($arrayfields['state.nom']['checked']))
473 {
474  print '<td class="liste_titre">';
475  print '<input class="flat searchstring maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
476  print '</td>';
477 }
478 // Country
479 if (! empty($arrayfields['country.code_iso']['checked']))
480 {
481  print '<td class="liste_titre" align="center">';
482  print $form->select_country($search_country,'search_country','',0,'maxwidth100');
483  print '</td>';
484 }
485 // Phone pro
486 if (! empty($arrayfields['d.phone']['checked']))
487 {
488  print '<td class="liste_titre" align="left">';
489  print '<input class="flat maxwidth50" type="text" name="search_phone" value="'.$search_phone.'"></td>';
490 }
491 // Phone perso
492 if (! empty($arrayfields['d.phone_perso']['checked']))
493 {
494  print '<td class="liste_titre" align="left">';
495  print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.$search_phone_perso.'"></td>';
496 }
497 // Phone mobile
498 if (! empty($arrayfields['d.phone_mobile']['checked']))
499 {
500  print '<td class="liste_titre" align="left">';
501  print '<input class="flat maxwidth50" type="text" name="search_phone_mobile" value="'.$search_phone_mobile.'"></td>';
502 }
503 // Email
504 if (! empty($arrayfields['d.email']['checked']))
505 {
506  print '<td class="liste_titre" align="left">';
507  print '<input class="flat maxwidth50" type="text" name="search_email" value="'.$search_email.'"></td>';
508 }
509 
510 if (! empty($arrayfields['d.datefin']['checked']))
511 {
512  print '<td class="liste_titre" align="left">';
513  print '</td>';
514 }
515 // Extra fields
516 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
517 
518 // Fields from hook
519 $parameters=array('arrayfields'=>$arrayfields);
520 $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
521 print $hookmanager->resPrint;
522 // Date creation
523 if (! empty($arrayfields['d.datec']['checked']))
524 {
525  print '<td class="liste_titre">';
526  print '</td>';
527 }
528 // Date modification
529 if (! empty($arrayfields['d.tms']['checked']))
530 {
531  print '<td class="liste_titre">';
532  print '</td>';
533 }
534 // Status
535 if (! empty($arrayfields['d.statut']['checked']))
536 {
537  print '<td class="liste_titre maxwidthonsmartphone" align="right">';
538  $liststatus=array(
539  '-1'=>$langs->trans("Draft"),
540  '1'=>$langs->trans("Validated"),
541  '0'=>$langs->trans("Resiliated")
542  );
543  print $form->selectarray('statut', $liststatus, $statut, -2);
544  print '</td>';
545 }
546 // Action column
547 print '<td class="liste_titre" align="middle">';
548 $searchpicto=$form->showFilterButtons();
549 print $searchpicto;
550 print '</td>';
551 
552 print "</tr>\n";
553 
554 print '<tr class="liste_titre">';
555 if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID",$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
556 if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder);
557 if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder);
558 if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder);
559 if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder);
560 if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder);
561 if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder);
562 if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'],$_SERVER["PHP_SELF"],'t.libelle','',$param,'',$sortfield,$sortorder);
563 if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'],$_SERVER["PHP_SELF"],'d.address','',$param,'',$sortfield,$sortorder);
564 if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'],$_SERVER["PHP_SELF"],'d.zip','',$param,'',$sortfield,$sortorder);
565 if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'],$_SERVER["PHP_SELF"],'d.town','',$param,'',$sortfield,$sortorder);
566 if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.town']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
567 if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
568 if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'],$_SERVER["PHP_SELF"],'d.phone','',$param,'',$sortfield,$sortorder);
569 if (! empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'],$_SERVER["PHP_SELF"],'d.phone_perso','',$param,'',$sortfield,$sortorder);
570 if (! empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'],$_SERVER["PHP_SELF"],'d.phone_mobile','',$param,'',$sortfield,$sortorder);
571 if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'],$_SERVER["PHP_SELF"],'d.email','',$param,'',$sortfield,$sortorder);
572 if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'],$_SERVER["PHP_SELF"],'d.datefin','',$param,'align="center"',$sortfield,$sortorder);
573 // Extra fields
574 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
575 
576 // Hook fields
577 $parameters=array('arrayfields'=>$arrayfields);
578 $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
579 print $hookmanager->resPrint;
580 if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
581 if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
582 if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'],$_SERVER["PHP_SELF"],"d.statut","",$param,'align="right"',$sortfield,$sortorder);
583 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
584 print "</tr>\n";
585 
586 $i = 0;
587 while ($i < min($num, $limit))
588 {
589  $obj = $db->fetch_object($resql);
590 
591  $datefin=$db->jdate($obj->datefin);
592  $memberstatic->id=$obj->rowid;
593  $memberstatic->ref=$obj->rowid;
594  $memberstatic->lastname=$obj->lastname;
595  $memberstatic->firstname=$obj->firstname;
596  $memberstatic->societe=$obj->company;
597  $memberstatic->statut=$obj->statut;
598  $memberstatic->datefin= $datefin;
599  $memberstatic->socid = $obj->fk_soc;
600  $memberstatic->photo = $obj->photo;
601 
602  if (! empty($obj->fk_soc)) {
603  $memberstatic->fetch_thirdparty();
604  $companyname=$memberstatic->thirdparty->name;
605  } else {
606  $companyname=$obj->company;
607  }
608 
609  print '<tr class="oddeven">';
610 
611  if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
612  {
613  print '<td align="center">'.$obj->rowid.'</td>';
614  }
615 
616  // Ref
617  if (! empty($arrayfields['d.ref']['checked']))
618  {
619  print "<td>";
620  print $memberstatic->getNomUrl(-1, 0, 'card', 'ref');
621  print "</td>\n";
622  }
623  // Firstname
624  if (! empty($arrayfields['d.firstname']['checked']))
625  {
626  print "<td>";
627  print $obj->firstname;
628  print "</td>\n";
629  }
630  // Lastname
631  if (! empty($arrayfields['d.lastname']['checked']))
632  {
633  print "<td>";
634  print $obj->lastname;
635  print "</td>\n";
636  }
637  // Company
638  if (! empty($arrayfields['d.company']['checked']))
639  {
640  print "<td>";
641  print $companyname;
642  print "</td>\n";
643  }
644  // Login
645  if (! empty($arrayfields['d.login']['checked']))
646  {
647  print "<td>".$obj->login."</td>\n";
648  }
649  // Moral/Physique
650  if (! empty($arrayfields['d.morphy']['checked']))
651  {
652  print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n";
653  }
654  // Type label
655  if (! empty($arrayfields['t.libelle']['checked']))
656  {
657  $membertypestatic->id=$obj->type_id;
658  $membertypestatic->label=$obj->type;
659  print '<td class="nowrap">';
660  print $membertypestatic->getNomUrl(1,32);
661  print '</td>';
662  }
663  // Address
664  if (! empty($arrayfields['d.address']['checked']))
665  {
666  print '<td class="nocellnopadd">';
667  print $obj->address;
668  print '</td>';
669  }
670  // Zip
671  if (! empty($arrayfields['d.zip']['checked']))
672  {
673  print '<td class="nocellnopadd">';
674  print $obj->zip;
675  print '</td>';
676  if (! $i) $totalarray['nbfield']++;
677  }
678  // Town
679  if (! empty($arrayfields['d.town']['checked']))
680  {
681  print '<td class="nocellnopadd">';
682  print $obj->town;
683  print '</td>';
684  if (! $i) $totalarray['nbfield']++;
685  }
686  // State
687  if (! empty($arrayfields['state.nom']['checked']))
688  {
689  print "<td>".$obj->state_name."</td>\n";
690  if (! $i) $totalarray['nbfield']++;
691  }
692  // Country
693  if (! empty($arrayfields['country.code_iso']['checked']))
694  {
695  print '<td align="center">';
696  $tmparray=getCountry($obj->country,'all');
697  print $tmparray['label'];
698  print '</td>';
699  if (! $i) $totalarray['nbfield']++;
700  }
701  // Phone pro
702  if (! empty($arrayfields['d.phone']['checked']))
703  {
704  print '<td class="nocellnopadd">';
705  print $obj->phone;
706  print '</td>';
707  if (! $i) $totalarray['nbfield']++;
708  }
709  // Phone perso
710  if (! empty($arrayfields['d.phone_perso']['checked']))
711  {
712  print '<td class="nocellnopadd">';
713  print $obj->phone_perso;
714  print '</td>';
715  if (! $i) $totalarray['nbfield']++;
716  }
717  // Phone mobile
718  if (! empty($arrayfields['d.phone_mobile']['checked']))
719  {
720  print '<td class="nocellnopadd">';
721  print $obj->phone_mobile;
722  print '</td>';
723  if (! $i) $totalarray['nbfield']++;
724  }
725  // EMail
726  if (! empty($arrayfields['d.email']['checked']))
727  {
728  print "<td>".dol_print_email($obj->email,0,0,1)."</td>\n";
729  }
730  // End of subscription date
731  $datefin=$db->jdate($obj->datefin);
732  if (! empty($arrayfields['d.datefin']['checked']))
733  {
734  if ($datefin)
735  {
736  print '<td align="center" class="nowrap">';
737  print dol_print_date($datefin,'day');
738  if ($memberstatic->hasDelay()) {
739  $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay/60/60/24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay/60/60/24).' '.$langs->trans("days").')';
740  print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
741  }
742  print '</td>';
743  }
744  else
745  {
746  print '<td align="left" class="nowrap">';
747  if ($obj->subscription == 'yes')
748  {
749  print $langs->trans("SubscriptionNotReceived");
750  if ($obj->statut > 0) print " ".img_warning();
751  }
752  else
753  {
754  print '&nbsp;';
755  }
756  print '</td>';
757  }
758  }
759  // Extra fields
760  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
761  // Fields from hook
762  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
763  $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
764  print $hookmanager->resPrint;
765  // Date creation
766  if (! empty($arrayfields['d.datec']['checked']))
767  {
768  print '<td align="center" class="nowrap">';
769  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
770  print '</td>';
771  if (! $i) $totalarray['nbfield']++;
772  }
773  // Date modification
774  if (! empty($arrayfields['d.tms']['checked']))
775  {
776  print '<td align="center" class="nowrap">';
777  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
778  print '</td>';
779  if (! $i) $totalarray['nbfield']++;
780  }
781  // Status
782  if (! empty($arrayfields['d.statut']['checked']))
783  {
784  print '<td align="right" class="nowrap">';
785  print $memberstatic->LibStatut($obj->statut,$obj->subscription,$datefin,5);
786  print '</td>';
787  if (! $i) $totalarray['nbfield']++;
788  }
789  // Action column
790  print '<td align="center">';
791  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
792  {
793  $selected=0;
794  if (in_array($obj->rowid, $arrayofselected)) $selected=1;
795  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
796  }
797  print '</td>';
798  if (! $i) $totalarray['nbfield']++;
799 
800  print "</tr>\n";
801  $i++;
802 }
803 
804 $db->free($resql);
805 
806 $parameters=array('sql' => $sql);
807 $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
808 print $hookmanager->resPrint;
809 
810 print "</table>\n";
811 print "</div>";
812 print '</form>';
813 
814 if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1);
815 
816 
817 llxFooter();
818 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Classe permettant la generation de composants html autre Only common components are here...
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:46
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='gmt')
Return date for now.
Class to manage members type.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.