dolibarr  19.0.0-dev
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-2022 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  * Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
8  * Copyright (C) 2021-2023 Frédéric France <frederic.france@netlogic.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
31 // Load Dolibarr environment
32 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37 
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array("members", "companies", "categories"));
41 
42 
43 // Get parameters
44 $action = GETPOST('action', 'aZ09');
45 $massaction = GETPOST('massaction', 'alpha');
46 $show_files = GETPOST('show_files', 'int');
47 $confirm = GETPOST('confirm', 'alpha');
48 $cancel = GETPOST('cancel', 'alpha');
49 $toselect = GETPOST('toselect', 'array');
50 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search
51 $backtopage = GETPOST('backtopage', 'alpha');
52 $optioncss = GETPOST('optioncss', 'aZ');
53 $mode = GETPOST('mode', 'alpha');
54 
55 // Search fields
56 $search = GETPOST("search", 'alpha');
57 $search_ref = GETPOST("search_ref", 'alpha');
58 $search_lastname = GETPOST("search_lastname", 'alpha');
59 $search_firstname = GETPOST("search_firstname", 'alpha');
60 $search_gender = GETPOST("search_gender", 'alpha');
61 $search_civility = GETPOST("search_civility", 'alpha');
62 $search_company = GETPOST('search_company', 'alphanohtml');
63 $search_login = GETPOST("search_login", 'alpha');
64 $search_address = GETPOST("search_address", 'alpha');
65 $search_zip = GETPOST("search_zip", 'alpha');
66 $search_town = GETPOST("search_town", 'alpha');
67 $search_state = GETPOST("search_state", 'alpha'); // county / departement / federal state
68 $search_country = GETPOST("search_country", 'alpha');
69 $search_phone = GETPOST("search_phone", 'alpha');
70 $search_phone_perso = GETPOST("search_phone_perso", 'alpha');
71 $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
72 $search_type = GETPOST("search_type", 'alpha');
73 $search_email = GETPOST("search_email", 'alpha');
74 $search_categ = GETPOST("search_categ", 'int');
75 $search_morphy = GETPOST("search_morphy", 'alpha');
76 $search_import_key = trim(GETPOST("search_import_key", 'alpha'));
77 
78 $catid = GETPOST("catid", 'int');
79 $socid = GETPOST('socid', 'int');
80 
81 $search_filter = GETPOST("search_filter", 'alpha');
82 $search_status = GETPOST("search_status", 'intcomma'); // statut
83 
84 $filter = GETPOST("filter", 'alpha');
85 if ($filter) {
86  $search_filter = $filter; // For backward compatibility
87 }
88 
89 $statut = GETPOST("statut", 'alpha');
90 if ($statut != '') {
91  $search_status = $statut; // For backward compatibility
92 }
93 
94 $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
95 
96 if ($search_status < -2) {
97  $search_status = '';
98 }
99 
100 // Pagination parameters
101 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
102 $sortfield = GETPOST('sortfield', 'aZ09comma');
103 $sortorder = GETPOST('sortorder', 'aZ09comma');
104 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
105 if (empty($page) || $page == -1) {
106  $page = 0;
107 } // If $page is not defined, or '' or -1
108 $offset = $limit * $page;
109 $pageprev = $page - 1;
110 $pagenext = $page + 1;
111 if (!$sortorder) {
112  $sortorder = ($filter == 'outofdate' ? "DESC" : "ASC");
113 }
114 if (!$sortfield) {
115  $sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname");
116 }
117 
118 $object = new Adherent($db);
119 
120 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
121 $hookmanager->initHooks(array('memberlist'));
122 $extrafields = new ExtraFields($db);
123 
124 // fetch optionals attributes and labels
125 $extrafields->fetch_name_optionals_label($object->table_element);
126 
127 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
128 
129 // List of fields to search into when doing a "search in all"
130 $fieldstosearchall = array(
131  'd.ref'=>'Ref',
132  'd.login'=>'Login',
133  'd.lastname'=>'Lastname',
134  'd.firstname'=>'Firstname',
135  'd.societe'=>"Company",
136  'd.email'=>'EMail',
137  'd.address'=>'Address',
138  'd.zip'=>'Zip',
139  'd.town'=>'Town',
140  'd.phone'=>"Phone",
141  'd.phone_perso'=>"PhonePerso",
142  'd.phone_mobile'=>"PhoneMobile",
143  'd.note_public'=>'NotePublic',
144  'd.note_private'=>'NotePrivate',
145 );
146 if ($db->type == 'pgsql') {
147  unset($fieldstosearchall['d.rowid']);
148 }
149 
150 $arrayfields = array(
151  'd.ref'=>array('label'=>"Ref", 'checked'=>1),
152  'd.civility'=>array('label'=>"Civility", 'checked'=>0),
153  'd.lastname'=>array('label'=>"Lastname", 'checked'=>1),
154  'd.firstname'=>array('label'=>"Firstname", 'checked'=>1),
155  'd.gender'=>array('label'=>"Gender", 'checked'=>0),
156  'd.company'=>array('label'=>"Company", 'checked'=>1),
157  'd.login'=>array('label'=>"Login", 'checked'=>1),
158  'd.morphy'=>array('label'=>"MemberNature", 'checked'=>1),
159  't.libelle'=>array('label'=>"Type", 'checked'=>1),
160  'd.email'=>array('label'=>"Email", 'checked'=>1),
161  'd.address'=>array('label'=>"Address", 'checked'=>0),
162  'd.zip'=>array('label'=>"Zip", 'checked'=>0),
163  'd.town'=>array('label'=>"Town", 'checked'=>0),
164  'd.phone'=>array('label'=>"Phone", 'checked'=>0),
165  'd.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0),
166  'd.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>0),
167  'state.nom'=>array('label'=>"State", 'checked'=>0),
168  'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
169  /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
170  'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
171  'd.datefin'=>array('label'=>"EndSubscription", 'checked'=>1, 'position'=>500),
172  'd.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
173  'd.birth'=>array('label'=>"Birthday", 'checked'=>0, 'position'=>500),
174  'd.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
175  'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
176  'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
177 );
178 
179 // Extra fields
180 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
181 
182 // Security check
183 $result = restrictedArea($user, 'adherent');
184 
185 
186 /*
187  * Actions
188  */
189 
190 if (GETPOST('cancel', 'alpha')) {
191  $action = 'list';
192  $massaction = '';
193 }
194 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
195  $massaction = '';
196 }
197 
198 $parameters = array('socid'=>isset($socid) ? $socid : null);
199 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
200 if ($reshook < 0) {
201  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
202 }
203 
204 if (empty($reshook)) {
205  // Selection of new fields
206  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
207 
208  // Purge search criteria
209  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
210  $statut = '';
211  $filter = '';
212 
213  $search = "";
214  $search_ref = "";
215  $search_lastname = "";
216  $search_firstname = "";
217  $search_gender = "";
218  $search_civility = "";
219  $search_login = "";
220  $search_company = "";
221  $search_type = "";
222  $search_email = "";
223  $search_address = "";
224  $search_zip = "";
225  $search_town = "";
226  $search_state = "";
227  $search_country = '';
228  $search_phone = '';
229  $search_phone_perso = '';
230  $search_phone_mobile = '';
231  $search_morphy = "";
232  $search_categ = "";
233  $search_filter = "";
234  $search_status = "";
235  $search_import_key = '';
236  $catid = "";
237  $search_all = "";
238  $toselect = array();
239  $search_array_options = array();
240  }
241 
242  // Close
243  if ($massaction == 'close' && $user->hasRight('adherent', 'creer')) {
244  $tmpmember = new Adherent($db);
245  $error = 0;
246  $nbclose = 0;
247 
248  $db->begin();
249 
250  foreach ($toselect as $idtoclose) {
251  $tmpmember->fetch($idtoclose);
252  $result = $tmpmember->resiliate($user);
253 
254  if ($result < 0 && !count($tmpmember->errors)) {
255  setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
256  } else {
257  if ($result > 0) {
258  $nbclose++;
259  }
260  }
261  }
262 
263  if (!$error) {
264  setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs');
265 
266  $db->commit();
267  } else {
268  $db->rollback();
269  }
270  }
271 
272  // Create external user
273  if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) {
274  $tmpmember = new Adherent($db);
275  $error = 0;
276  $nbcreated = 0;
277 
278  $db->begin();
279 
280  foreach ($toselect as $idtoclose) {
281  $tmpmember->fetch($idtoclose);
282 
283  if (!empty($tmpmember->fk_soc)) {
284  $nuser = new User($db);
285  $tmpuser = dol_clone($tmpmember);
286 
287  $result = $nuser->create_from_member($tmpuser, $tmpmember->login);
288 
289  if ($result < 0 && !count($tmpmember->errors)) {
290  setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
291  } else {
292  if ($result > 0) {
293  $nbcreated++;
294  }
295  }
296  }
297  }
298 
299  if (!$error) {
300  setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs');
301 
302  $db->commit();
303  } else {
304  $db->rollback();
305  }
306  }
307 
308  // Mass actions
309  $objectclass = 'Adherent';
310  $objectlabel = 'Members';
311  $permissiontoread = $user->hasRight('adherent', 'lire');
312  $permissiontodelete = $user->hasRight('adherent', 'supprimer');
313  $permissiontoadd = $user->hasRight('adherent', 'creer');
314  $uploaddir = $conf->adherent->dir_output;
315  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
316 }
317 
318 
319 /*
320  * View
321  */
322 
323 $form = new Form($db);
324 $formother = new FormOther($db);
325 $membertypestatic = new AdherentType($db);
326 $memberstatic = new Adherent($db);
327 
328 $now = dol_now();
329 
330 // Page Header
331 $title = $langs->trans("Members")." - ".$langs->trans("List");
332 $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
333 $morejs = array();
334 $morecss = array();
335 
336 
337 // Build and execute select
338 // --------------------------------------------------------------------
339 if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) {
340  $sql = "SELECT DISTINCT";
341 } else {
342  $sql = "SELECT";
343 }
344 $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,";
345 $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
346 $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,";
347 $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
348 $sql .= " d.note_private, d.note_public, d.import_key,";
349 $sql .= " s.nom,";
350 $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,";
351 $sql .= " t.libelle as type, t.subscription,";
352 $sql .= " state.code_departement as state_code, state.nom as state_name";
353 
354 // Add fields from extrafields
355 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
356  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
357  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
358  }
359 }
360 
361 // Add fields from hooks
362 $parameters = array();
363 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
364 $sql .= $hookmanager->resPrint;
365 $sql = preg_replace('/,\s*$/', '', $sql);
366 
367 $sqlfields = $sql; // $sql fields to remove for count total
368 
369 // SQL Aliase adherent
370 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; // maybe better to use ad (adh) instead od d
371 if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
372  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
373 }
374 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
375 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
376 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
377 
378 // SQL Aliase adherent_type
379 $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
380 $sql .= " WHERE d.fk_adherent_type = t.rowid";
381 
382 if ($catid && empty($search_categ)) {
383  $search_categ = $catid;
384 }
385 
386 $searchCategoryContactList = $search_categ ? array($search_categ) : array();
387 $searchCategoryContactOperator = 0;
388 // Search for tag/category ($searchCategoryContactList is an array of ID)
389 if (!empty($searchCategoryContactList)) {
390  $searchCategoryContactSqlList = array();
391  $listofcategoryid = '';
392  foreach ($searchCategoryContactList as $searchCategoryContact) {
393  if (intval($searchCategoryContact) == -2) {
394  $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member)";
395  } elseif (intval($searchCategoryContact) > 0) {
396  if ($searchCategoryContactOperator == 0) {
397  $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member AND ck.fk_categorie = ".((int) $searchCategoryContact).")";
398  } else {
399  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
400  }
401  }
402  }
403  if ($listofcategoryid) {
404  $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
405  }
406  if ($searchCategoryContactOperator == 1) {
407  if (!empty($searchCategoryContactSqlList)) {
408  $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
409  }
410  } else {
411  if (!empty($searchCategoryContactSqlList)) {
412  $sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
413  }
414  }
415 }
416 
417 $sql .= " AND d.entity IN (".getEntity('adherent').")";
418 if ($search_all) {
419  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
420 }
421 if ($search_type > 0) {
422  $sql .= " AND t.rowid=".((int) $search_type);
423 }
424 if ($search_filter == 'withoutsubscription') {
425  $sql .= " AND (datefin IS NULL)";
426 }
427 if ($search_filter == 'waitingsubscription') {
428  $sql .= " AND (datefin IS NULL AND t.subscription = '1')";
429 }
430 if ($search_filter == 'uptodate') {
431  $sql .= " AND (datefin >= '".$db->idate($now)."' OR (datefin IS NULL AND t.subscription = '0'))";
432 }
433 if ($search_filter == 'outofdate') {
434  $sql .= " AND (datefin < '".$db->idate($now)."')";
435 }
436 if ($search_status != '') {
437  // Peut valoir un nombre ou liste de nombre separes par virgules
438  $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
439 }
440 if ($search_morphy != '' && $search_morphy != '-1') {
441  $sql .= natural_search("d.morphy", $search_morphy);
442 }
443 if ($search_ref) {
444  $sql .= natural_search("d.ref", $search_ref);
445 }
446 if ($search_civility) {
447  $sql .= natural_search("d.civility", $search_civility);
448 }
449 if ($search_firstname) {
450  $sql .= natural_search("d.firstname", $search_firstname);
451 }
452 if ($search_lastname) {
453  $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
454 }
455 if ($search_gender != '' && $search_gender != '-1') {
456  $sql .= natural_search("d.gender", $search_gender);
457 }
458 if ($search_login) {
459  $sql .= natural_search("d.login", $search_login);
460 }
461 if ($search_company) {
462  $sql .= natural_search("s.nom", $search_company);
463 }
464 if ($search_email) {
465  $sql .= natural_search("d.email", $search_email);
466 }
467 if ($search_address) {
468  $sql .= natural_search("d.address", $search_address);
469 }
470 if ($search_town) {
471  $sql .= natural_search("d.town", $search_town);
472 }
473 if ($search_zip) {
474  $sql .= natural_search("d.zip", $search_zip);
475 }
476 if ($search_state) {
477  $sql .= natural_search("state.nom", $search_state);
478 }
479 if ($search_phone) {
480  $sql .= natural_search("d.phone", $search_phone);
481 }
482 if ($search_phone_perso) {
483  $sql .= natural_search("d.phone_perso", $search_phone_perso);
484 }
485 if ($search_phone_mobile) {
486  $sql .= natural_search("d.phone_mobile", $search_phone_mobile);
487 }
488 if ($search_country) {
489  $sql .= " AND d.country IN (".$db->sanitize($search_country).')';
490 }
491 if ($search_import_key) {
492  $sql .= natural_search("d.import_key", $search_import_key);
493 }
494 // Add where from extra fields
495 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
496 // Add where from hooks
497 $parameters = array();
498 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
499 $sql .= $hookmanager->resPrint;
500 
501 // Count total nb of records
502 $nbtotalofrecords = '';
503 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
504  /* The fast and low memory method to get and count full list converts the sql into a sql count */
505  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
506  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
507  $resql = $db->query($sqlforcount);
508  if ($resql) {
509  $objforcount = $db->fetch_object($resql);
510  $nbtotalofrecords = $objforcount->nbtotalofrecords;
511  } else {
512  dol_print_error($db);
513  }
514 
515  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
516  $page = 0;
517  $offset = 0;
518  }
519  $db->free($resql);
520 }
521 //print $sql;
522 
523 // Complete request and execute it with limit
524 $sql .= $db->order($sortfield, $sortorder);
525 if ($limit) {
526  $sql .= $db->plimit($limit + 1, $offset);
527 }
528 
529 $resql = $db->query($sql);
530 if (!$resql) {
531  dol_print_error($db);
532  exit;
533 }
534 
535 $num = $db->num_rows($resql);
536 
537 
538 // Direct jump if only one record found
539 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
540  $obj = $db->fetch_object($resql);
541  $id = $obj->rowid;
542  header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id);
543  exit;
544 }
545 
546 // Output page
547 // --------------------------------------------------------------------
548 
549 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
550 
551 $arrayofselected = is_array($toselect) ? $toselect : array();
552 
553 
554 if ($search_type > 0) {
555  $membertype = new AdherentType($db);
556  $result = $membertype->fetch($search_type);
557  $title .= " (".$membertype->label.")";
558 }
559 
560 // $parameters
561 $param = '';
562 if (!empty($mode)) {
563  $param .= '&mode='.urlencode($mode);
564 }
565 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
566  $param .= '&contextpage='.urlencode($contextpage);
567 }
568 if ($limit > 0 && $limit != $conf->liste_limit) {
569  $param .= '&limit='.((int) $limit);
570 }
571 if ($optioncss != '') {
572  $param .= '&optioncss='.urlencode($optioncss);
573 }
574 if ($search_all != "") {
575  $param .= "&search_all=".urlencode($search_all);
576 }
577 if ($search_ref) {
578  $param .= "&search_ref=".urlencode($search_ref);
579 }
580 if ($search_civility) {
581  $param .= "&search_civility=".urlencode($search_civility);
582 }
583 if ($search_firstname) {
584  $param .= "&search_firstname=".urlencode($search_firstname);
585 }
586 if ($search_lastname) {
587  $param .= "&search_lastname=".urlencode($search_lastname);
588 }
589 if ($search_gender) {
590  $param .= "&search_gender=".urlencode($search_gender);
591 }
592 if ($search_login) {
593  $param .= "&search_login=".urlencode($search_login);
594 }
595 if ($search_email) {
596  $param .= "&search_email=".urlencode($search_email);
597 }
598 if ($search_categ > 0 || $search_categ == -2) {
599  $param .= "&search_categ=".urlencode($search_categ);
600 }
601 if ($search_company) {
602  $param .= "&search_company=".urlencode($search_company);
603 }
604 if ($search_address != '') {
605  $param .= "&search_address=".urlencode($search_address);
606 }
607 if ($search_town != '') {
608  $param .= "&search_town=".urlencode($search_town);
609 }
610 if ($search_zip != '') {
611  $param .= "&search_zip=".urlencode($search_zip);
612 }
613 if ($search_state != '') {
614  $param .= "&search_state=".urlencode($search_state);
615 }
616 if ($search_country != '') {
617  $param .= "&search_country=".urlencode($search_country);
618 }
619 if ($search_phone != '') {
620  $param .= "&search_phone=".urlencode($search_phone);
621 }
622 if ($search_phone_perso != '') {
623  $param .= "&search_phone_perso=".urlencode($search_phone_perso);
624 }
625 if ($search_phone_mobile != '') {
626  $param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
627 }
628 if ($search_filter && $search_filter != '-1') {
629  $param .= "&search_filter=".urlencode($search_filter);
630 }
631 if ($search_status != "" && $search_status != -3) {
632  $param .= "&search_status=".urlencode($search_status);
633 }
634 if ($search_import_key != '') {
635  $param .= '&search_import_key='.urlencode($search_import_key);
636 }
637 if ($search_type > 0) {
638  $param .= "&search_type=".urlencode($search_type);
639 }
640 
641 // Add $param from extra fields
642 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
643 
644 // List of mass actions available
645 $arrayofmassactions = array(
646  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
647  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
648 );
649 if ($user->hasRight('adherent', 'creer')) {
650  $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Resiliate");
651 }
652 if ($user->hasRight('adherent', 'supprimer')) {
653  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
654 }
655 if (isModEnabled('category') && $user->hasRight('adherent', 'creer')) {
656  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
657 }
658 if ($user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) {
659  $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser");
660 }
661 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
662  $arrayofmassactions = array();
663 }
664 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
665 
666 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
667 if ($optioncss != '') {
668  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
669 }
670 print '<input type="hidden" name="token" value="'.newToken().'">';
671 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
672 print '<input type="hidden" name="action" value="list">';
673 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
674 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
675 print '<input type="hidden" name="page" value="'.$page.'">';
676 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
677 print '<input type="hidden" name="page_y" value="">';
678 print '<input type="hidden" name="mode" value="'.$mode.'">';
679 
680 
681 $newcardbutton = '';
682 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
683 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
684 if ($user->hasRight('adherent', 'creer')) {
685  $newcardbutton .= dolGetButtonTitleSeparator();
686  $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create');
687 }
688 
689 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
690 
691 $topicmail = "Information";
692 $modelmail = "member";
693 $objecttmp = new Adherent($db);
694 $trackid = 'mem'.$object->id;
695 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
696 
697 if ($search_all) {
698  $setupstring = '';
699  foreach ($fieldstosearchall as $key => $val) {
700  $fieldstosearchall[$key] = $langs->trans($val);
701  $setupstring .= $key."=".$val.";";
702  }
703  print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
704  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
705 }
706 
707 $moreforfilter = '';
708 // Filter on categories
709 if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
710  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
711  $moreforfilter .= '<div class="divsearchfield">';
712  $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedlength"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1, $langs->trans("MembersCategoriesShort"));
713  $moreforfilter .= '</div>';
714 }
715 $parameters = array();
716 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
717 if (empty($reshook)) {
718  $moreforfilter .= $hookmanager->resPrint;
719 } else {
720  $moreforfilter = $hookmanager->resPrint;
721 }
722 if (!empty($moreforfilter)) {
723  print '<div class="liste_titre liste_titre_bydiv centpercent">';
724  print $moreforfilter;
725  $parameters = array();
726  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
727  print $hookmanager->resPrint;
728  print '</div>';
729 }
730 
731 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
732 $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
733 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
734 
735 print '<div class="div-table-responsive">';
736 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
737 
738 // Fields title search
739 // --------------------------------------------------------------------
740 print '<tr class="liste_titre_filter">';
741 
742 // Action column
743 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
744  print '<td class="liste_titre center maxwidthsearch">';
745  $searchpicto = $form->showFilterButtons('left');
746  print $searchpicto;
747  print '</td>';
748 }
749 
750 // Line numbering
751 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
752  print '<td class="liste_titre">&nbsp;</td>';
753 }
754 
755 // Ref
756 if (!empty($arrayfields['d.ref']['checked'])) {
757  print '<td class="liste_titre">';
758  print '<input type="text" class="flat maxwidth75imp" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
759  print '</td>';
760 }
761 
762 // Civility
763 if (!empty($arrayfields['d.civility']['checked'])) {
764  print '<td class="liste_titre left">';
765  print '<input class="flat maxwidth50imp" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>';
766 }
767 
768 // First Name
769 if (!empty($arrayfields['d.firstname']['checked'])) {
770  print '<td class="liste_titre left">';
771  print '<input class="flat maxwidth75imp" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
772 }
773 
774 // Last Name
775 if (!empty($arrayfields['d.lastname']['checked'])) {
776  print '<td class="liste_titre left">';
777  print '<input class="flat maxwidth75imp" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
778 }
779 
780 // Gender
781 if (!empty($arrayfields['d.gender']['checked'])) {
782  print '<td class="liste_titre">';
783  $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
784  print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
785  print '</td>';
786 }
787 
788 // Company
789 if (!empty($arrayfields['d.company']['checked'])) {
790  print '<td class="liste_titre left">';
791  print '<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
792 }
793 
794 // Login
795 if (!empty($arrayfields['d.login']['checked'])) {
796  print '<td class="liste_titre left">';
797  print '<input class="flat maxwidth75imp" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
798 }
799 
800 // Nature
801 if (!empty($arrayfields['d.morphy']['checked'])) {
802  print '<td class="liste_titre center">';
803  $arraymorphy = array('mor'=>$langs->trans("Moral"), 'phy'=>$langs->trans("Physical"));
804  print $form->selectarray('search_morphy', $arraymorphy, $search_morphy, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
805  print '</td>';
806 }
807 
808 // Member Type
809 if (!empty($arrayfields['t.libelle']['checked'])) {
810  print '</td>';
811 }
812 if (!empty($arrayfields['t.libelle']['checked'])) {
813  print '<td class="liste_titre">';
814  $listetype = $membertypestatic->liste_array();
815  print $form->selectarray("search_type", $listetype, $search_type, 1, 0, 0, '', 0, 32);
816  print '</td>';
817 }
818 
819 // Address - Street
820 if (!empty($arrayfields['d.address']['checked'])) {
821  print '<td class="liste_titre left">';
822  print '<input class="flat maxwidth75imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'"></td>';
823 }
824 
825 // ZIP
826 if (!empty($arrayfields['d.zip']['checked'])) {
827  print '<td class="liste_titre left">';
828  print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
829 }
830 
831 // Town/City
832 if (!empty($arrayfields['d.town']['checked'])) {
833  print '<td class="liste_titre left">';
834  print '<input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
835 }
836 
837 // State / County / Departement
838 if (!empty($arrayfields['state.nom']['checked'])) {
839  print '<td class="liste_titre">';
840  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
841  print '</td>';
842 }
843 
844 // Country
845 if (!empty($arrayfields['country.code_iso']['checked'])) {
846  print '<td class="liste_titre center">';
847  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
848  print '</td>';
849 }
850 
851 // Phone pro
852 if (!empty($arrayfields['d.phone']['checked'])) {
853  print '<td class="liste_titre left">';
854  print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'"></td>';
855 }
856 
857 // Phone perso
858 if (!empty($arrayfields['d.phone_perso']['checked'])) {
859  print '<td class="liste_titre left">';
860  print '<input class="flat maxwidth75imp" type="text" name="search_phone_perso" value="'.dol_escape_htmltag($search_phone_perso).'"></td>';
861 }
862 
863 // Phone mobile
864 if (!empty($arrayfields['d.phone_mobile']['checked'])) {
865  print '<td class="liste_titre left">';
866  print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="'.dol_escape_htmltag($search_phone_mobile).'"></td>';
867 }
868 
869 // Email
870 if (!empty($arrayfields['d.email']['checked'])) {
871  print '<td class="liste_titre left">';
872  print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
873 }
874 
875 // End of subscription date
876 if (!empty($arrayfields['d.datefin']['checked'])) {
877  print '<td class="liste_titre center">';
878  //$selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
879  $selectarray = array('-1'=>'', 'waitingsubscription'=>$langs->trans("WaitingSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
880  print $form->selectarray('search_filter', $selectarray, $search_filter);
881  print '</td>';
882 }
883 
884 // Extra fields
885 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
886 
887 // Fields from hook
888 $parameters = array('arrayfields'=>$arrayfields);
889 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
890 print $hookmanager->resPrint;
891 
892 // Date creation
893 if (!empty($arrayfields['d.datec']['checked'])) {
894  print '<td class="liste_titre">';
895  print '</td>';
896 }
897 
898 // Birthday
899 if (!empty($arrayfields['d.birth']['checked'])) {
900  print '<td class="liste_titre">';
901  print '</td>';
902 }
903 
904 // Date modification
905 if (!empty($arrayfields['d.tms']['checked'])) {
906  print '<td class="liste_titre">';
907  print '</td>';
908 }
909 
910 // Status
911 if (!empty($arrayfields['d.statut']['checked'])) {
912  print '<td class="liste_titre right parentonrightofpage">';
913  $liststatus = array(
914  Adherent::STATUS_DRAFT => $langs->trans("Draft"),
915  Adherent::STATUS_VALIDATED => $langs->trans("Validated"),
916  Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"),
917  Adherent::STATUS_EXCLUDED =>$langs->trans("MemberStatusExcludedShort")
918  );
919  print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
920  print '</td>';
921 }
922 
923 // Import Key
924 if (!empty($arrayfields['d.import_key']['checked'])) {
925  print '<td class="liste_titre center">';
926  print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
927  print '</td>';
928 }
929 
930 // Action column
931 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
932  print '<td class="liste_titre center maxwidthsearch">';
933  $searchpicto = $form->showFilterButtons();
934  print $searchpicto;
935  print '</td>';
936 }
937 print '</tr>'."\n";
938 
939 $totalarray = array();
940 $totalarray['nbfield'] = 0;
941 
942 // Fields title label
943 // --------------------------------------------------------------------
944 print '<tr class="liste_titre">';
945 // Action column
946 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
947  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');
948  $totalarray['nbfield']++;
949 }
950 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
951  print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
952  $totalarray['nbfield']++;
953 }
954 if (!empty($arrayfields['d.ref']['checked'])) {
955  print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
956  $totalarray['nbfield']++;
957 }
958 if (!empty($arrayfields['d.civility']['checked'])) {
959  print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
960  $totalarray['nbfield']++;
961 }
962 if (!empty($arrayfields['d.firstname']['checked'])) {
963  print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
964  $totalarray['nbfield']++;
965 }
966 if (!empty($arrayfields['d.lastname']['checked'])) {
967  print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
968  $totalarray['nbfield']++;
969 }
970 if (!empty($arrayfields['d.gender']['checked'])) {
971  print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder);
972  $totalarray['nbfield']++;
973 }
974 if (!empty($arrayfields['d.company']['checked'])) {
975  print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'companyname', '', $param, '', $sortfield, $sortorder);
976  $totalarray['nbfield']++;
977 }
978 if (!empty($arrayfields['d.login']['checked'])) {
979  print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder);
980  $totalarray['nbfield']++;
981 }
982 if (!empty($arrayfields['d.morphy']['checked'])) {
983  print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder);
984  $totalarray['nbfield']++;
985 }
986 if (!empty($arrayfields['t.libelle']['checked'])) {
987  print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
988  $totalarray['nbfield']++;
989 }
990 if (!empty($arrayfields['d.address']['checked'])) {
991  print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
992  $totalarray['nbfield']++;
993 }
994 if (!empty($arrayfields['d.zip']['checked'])) {
995  print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
996  $totalarray['nbfield']++;
997 }
998 if (!empty($arrayfields['d.town']['checked'])) {
999  print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder);
1000  $totalarray['nbfield']++;
1001 }
1002 if (!empty($arrayfields['state.nom']['checked'])) {
1003  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1004  $totalarray['nbfield']++;
1005 }
1006 if (!empty($arrayfields['country.code_iso']['checked'])) {
1007  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1008  $totalarray['nbfield']++;
1009 }
1010 if (!empty($arrayfields['d.phone']['checked'])) {
1011  print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
1012  $totalarray['nbfield']++;
1013 }
1014 if (!empty($arrayfields['d.phone_perso']['checked'])) {
1015  print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
1016  $totalarray['nbfield']++;
1017 }
1018 if (!empty($arrayfields['d.phone_mobile']['checked'])) {
1019  print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
1020  $totalarray['nbfield']++;
1021 }
1022 if (!empty($arrayfields['d.email']['checked'])) {
1023  print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
1024  $totalarray['nbfield']++;
1025 }
1026 if (!empty($arrayfields['d.datefin']['checked'])) {
1027  print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin,t.subscription', '', $param, '', $sortfield, $sortorder, 'center ');
1028  $totalarray['nbfield']++;
1029 }
1030 // Extra fields
1031 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1032 
1033 // Hook fields
1034 $parameters = array('arrayfields'=>$arrayfields, 'totalarray'=>&$totalarray, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1035 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1036 print $hookmanager->resPrint;
1037 
1038 if (!empty($arrayfields['d.datec']['checked'])) {
1039  print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
1040  $totalarray['nbfield']++;
1041 }
1042 if (!empty($arrayfields['d.birth']['checked'])) {
1043  print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
1044  $totalarray['nbfield']++;
1045 }
1046 if (!empty($arrayfields['d.tms']['checked'])) {
1047  print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
1048  $totalarray['nbfield']++;
1049 }
1050 if (!empty($arrayfields['d.statut']['checked'])) {
1051  print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut,t.subscription,d.datefin", "", $param, 'class="right"', $sortfield, $sortorder);
1052  $totalarray['nbfield']++;
1053 }
1054 if (!empty($arrayfields['d.import_key']['checked'])) {
1055  print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER["PHP_SELF"], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1056  $totalarray['nbfield']++;
1057 }
1058 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1059  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
1060  $totalarray['nbfield']++;
1061 }
1062 print "</tr>\n";
1063 
1064 // Loop on record
1065 // --------------------------------------------------------------------
1066 $i = 0;
1067 $savnbfield = $totalarray['nbfield'];
1068 $totalarray = array();
1069 $totalarray['nbfield'] = 0;
1070 $imaxinloop = ($limit ? min($num, $limit) : $num);
1071 while ($i < $imaxinloop) {
1072  $obj = $db->fetch_object($resql);
1073  if (empty($obj)) {
1074  break; // Should not happen
1075  }
1076 
1077  $datefin = $db->jdate($obj->datefin);
1078 
1079  $memberstatic->id = $obj->rowid;
1080  $memberstatic->ref = $obj->ref;
1081  $memberstatic->civility_id = $obj->civility;
1082  $memberstatic->login = $obj->login;
1083  $memberstatic->lastname = $obj->lastname;
1084  $memberstatic->firstname = $obj->firstname;
1085  $memberstatic->gender = $obj->gender;
1086  $memberstatic->statut = $obj->statut;
1087  $memberstatic->datefin = $datefin;
1088  $memberstatic->socid = $obj->fk_soc;
1089  $memberstatic->photo = $obj->photo;
1090  $memberstatic->email = $obj->email;
1091  $memberstatic->morphy = $obj->morphy;
1092  $memberstatic->note_public = $obj->note_public;
1093  $memberstatic->note_private = $obj->note_private;
1094  $memberstatic->need_subscription = $obj->subscription;
1095 
1096  if (!empty($obj->fk_soc)) {
1097  $memberstatic->fetch_thirdparty();
1098  if ($memberstatic->thirdparty->id > 0) {
1099  $companyname = $memberstatic->thirdparty->name;
1100  $companynametoshow = $memberstatic->thirdparty->getNomUrl(1);
1101  }
1102  } else {
1103  $companyname = $obj->company;
1104  $companynametoshow = $obj->company;
1105  }
1106  $memberstatic->company = $companyname;
1107 
1108  if ($mode == 'kanban') {
1109  if ($i == 0) {
1110  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1111  print '<div class="box-flex-container kanban">';
1112  }
1113  $membertypestatic->id = $obj->type_id;
1114  $membertypestatic->label = $obj->type;
1115  $memberstatic->type = $membertypestatic->label;
1116  $memberstatic->photo = $obj->photo;
1117  // Output Kanban
1118  print $memberstatic->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
1119  if ($i == (min($num, $limit) - 1)) {
1120  print '</div>';
1121  print '</td></tr>';
1122  }
1123  } else {
1124  // Show line of result
1125  $j = 0;
1126  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
1127 
1128  // Action column
1129  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1130  print '<td class="nowrap center">';
1131  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1132  $selected = 0;
1133  if (in_array($obj->rowid, $arrayofselected)) {
1134  $selected = 1;
1135  }
1136  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1137  }
1138  print '</td>';
1139  if (!$i) {
1140  $totalarray['nbfield']++;
1141  }
1142  }
1143  // Technical ID
1144  if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
1145  print '<td class="center" data-key="id">'.$obj->rowid.'</td>';
1146  if (!$i) {
1147  $totalarray['nbfield']++;
1148  }
1149  }
1150  // Ref
1151  if (!empty($arrayfields['d.ref']['checked'])) {
1152  print "<td>";
1153  print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
1154  print "</td>\n";
1155  if (!$i) {
1156  $totalarray['nbfield']++;
1157  }
1158  }
1159  // Civility
1160  if (!empty($arrayfields['d.civility']['checked'])) {
1161  print "<td>";
1162  print $obj->civility;
1163  print "</td>\n";
1164  if (!$i) {
1165  $totalarray['nbfield']++;
1166  }
1167  }
1168  // Firstname
1169  if (!empty($arrayfields['d.firstname']['checked'])) {
1170  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).'">';
1171  print $memberstatic->getNomUrl(0, 0, 'card', 'firstname');
1172  //print $obj->firstname;
1173  print "</td>\n";
1174  if (!$i) {
1175  $totalarray['nbfield']++;
1176  }
1177  }
1178  // Lastname
1179  if (!empty($arrayfields['d.lastname']['checked'])) {
1180  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">';
1181  print $memberstatic->getNomUrl(0, 0, 'card', 'lastname');
1182  //print $obj->lastname;
1183  print "</td>\n";
1184  if (!$i) {
1185  $totalarray['nbfield']++;
1186  }
1187  }
1188  // Gender
1189  if (!empty($arrayfields['d.gender']['checked'])) {
1190  print '<td>';
1191  if ($obj->gender) {
1192  print $langs->trans("Gender".$obj->gender);
1193  }
1194  print '</td>';
1195  if (!$i) {
1196  $totalarray['nbfield']++;
1197  }
1198  }
1199  // Company
1200  if (!empty($arrayfields['d.company']['checked'])) {
1201  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companyname).'">';
1202  print $companynametoshow;
1203  print "</td>\n";
1204  }
1205  // Login
1206  if (!empty($arrayfields['d.login']['checked'])) {
1207  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->login).'">'.$obj->login."</td>\n";
1208  if (!$i) {
1209  $totalarray['nbfield']++;
1210  }
1211  }
1212  // Nature (Moral/Physical)
1213  if (!empty($arrayfields['d.morphy']['checked'])) {
1214  print '<td class="center">';
1215  print $memberstatic->getmorphylib('', 2);
1216  print "</td>\n";
1217  if (!$i) {
1218  $totalarray['nbfield']++;
1219  }
1220  }
1221  // Type label
1222  if (!empty($arrayfields['t.libelle']['checked'])) {
1223  $membertypestatic->id = $obj->type_id;
1224  $membertypestatic->label = $obj->type;
1225  print '<td class="nowraponall">';
1226  print $membertypestatic->getNomUrl(1, 32);
1227  print '</td>';
1228  if (!$i) {
1229  $totalarray['nbfield']++;
1230  }
1231  }
1232  // Address
1233  if (!empty($arrayfields['d.address']['checked'])) {
1234  print '<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->address).'">';
1235  print $obj->address;
1236  print '</td>';
1237  if (!$i) {
1238  $totalarray['nbfield']++;
1239  }
1240  }
1241  // Zip
1242  if (!empty($arrayfields['d.zip']['checked'])) {
1243  print '<td class="nocellnopadd">';
1244  print $obj->zip;
1245  print '</td>';
1246  if (!$i) {
1247  $totalarray['nbfield']++;
1248  }
1249  }
1250  // Town
1251  if (!empty($arrayfields['d.town']['checked'])) {
1252  print '<td class="nocellnopadd">';
1253  print $obj->town;
1254  print '</td>';
1255  if (!$i) {
1256  $totalarray['nbfield']++;
1257  }
1258  }
1259  // State / County / Departement
1260  if (!empty($arrayfields['state.nom']['checked'])) {
1261  print "<td>".$obj->state_name."</td>\n";
1262  if (!$i) {
1263  $totalarray['nbfield']++;
1264  }
1265  }
1266  // Country
1267  if (!empty($arrayfields['country.code_iso']['checked'])) {
1268  $tmparray = getCountry($obj->country, 'all');
1269  print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($tmparray['label']).'">';
1270  print dol_escape_htmltag($tmparray['label']);
1271  print '</td>';
1272  if (!$i) {
1273  $totalarray['nbfield']++;
1274  }
1275  }
1276  // Phone pro
1277  if (!empty($arrayfields['d.phone']['checked'])) {
1278  print '<td class="nocellnopadd">';
1279  print $obj->phone;
1280  print '</td>';
1281  if (!$i) {
1282  $totalarray['nbfield']++;
1283  }
1284  }
1285  // Phone perso
1286  if (!empty($arrayfields['d.phone_perso']['checked'])) {
1287  print '<td class="nocellnopadd">';
1288  print $obj->phone_perso;
1289  print '</td>';
1290  if (!$i) {
1291  $totalarray['nbfield']++;
1292  }
1293  }
1294  // Phone mobile
1295  if (!empty($arrayfields['d.phone_mobile']['checked'])) {
1296  print '<td class="nocellnopadd">';
1297  print $obj->phone_mobile;
1298  print '</td>';
1299  if (!$i) {
1300  $totalarray['nbfield']++;
1301  }
1302  }
1303  // EMail
1304  if (!empty($arrayfields['d.email']['checked'])) {
1305  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->email).'">';
1306  print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1);
1307  print "</td>\n";
1308  if (!$i) {
1309  $totalarray['nbfield']++;
1310  }
1311  }
1312  // End of subscription date
1313  $datefin = $db->jdate($obj->datefin);
1314  if (!empty($arrayfields['d.datefin']['checked'])) {
1315  print '<td class="nowrap center">';
1316  if ($datefin) {
1317  print dol_print_date($datefin, 'day');
1318  if ($memberstatic->hasDelay()) {
1319  $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").')';
1320  print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
1321  }
1322  } else {
1323  if (!empty($obj->subscription)) {
1324  print '<span class="opacitymedium">'.$langs->trans("SubscriptionNotReceived").'</span>';
1325  if ($obj->statut > 0) {
1326  print " ".img_warning();
1327  }
1328  } else {
1329  print '&nbsp;';
1330  }
1331  }
1332  print '</td>';
1333  if (!$i) {
1334  $totalarray['nbfield']++;
1335  }
1336  }
1337  // Extra fields
1338  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1339  // Fields from hook
1340  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1341  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1342  print $hookmanager->resPrint;
1343  // Date creation
1344  if (!empty($arrayfields['d.datec']['checked'])) {
1345  print '<td class="nowrap center">';
1346  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1347  print '</td>';
1348  if (!$i) {
1349  $totalarray['nbfield']++;
1350  }
1351  }
1352  // Birth
1353  if (!empty($arrayfields['d.birth']['checked'])) {
1354  print '<td class="nowrap center">';
1355  print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
1356  print '</td>';
1357  if (!$i) {
1358  $totalarray['nbfield']++;
1359  }
1360  }
1361  // Date modification
1362  if (!empty($arrayfields['d.tms']['checked'])) {
1363  print '<td class="nowrap center">';
1364  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1365  print '</td>';
1366  if (!$i) {
1367  $totalarray['nbfield']++;
1368  }
1369  }
1370  // Status
1371  if (!empty($arrayfields['d.statut']['checked'])) {
1372  print '<td class="nowrap right">';
1373  print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
1374  print '</td>';
1375  if (!$i) {
1376  $totalarray['nbfield']++;
1377  }
1378  }
1379  if (!empty($arrayfields['d.import_key']['checked'])) {
1380  print '<td class="tdoverflowmax100 center" title="'.dol_escape_htmltag($obj->import_key).'">';
1381  print dol_escape_htmltag($obj->import_key);
1382  print "</td>\n";
1383  if (!$i) {
1384  $totalarray['nbfield']++;
1385  }
1386  }
1387  // Action column
1388  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1389  print '<td class="center">';
1390  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1391  $selected = 0;
1392  if (in_array($obj->rowid, $arrayofselected)) {
1393  $selected = 1;
1394  }
1395  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1396  }
1397  print '</td>';
1398  if (!$i) {
1399  $totalarray['nbfield']++;
1400  }
1401  }
1402 
1403  print '</tr>'."\n";
1404  }
1405  $i++;
1406 }
1407 
1408 // Show total line
1409 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1410 
1411 
1412 // If no record found
1413 if ($num == 0) {
1414  $colspan = 1;
1415  foreach ($arrayfields as $key => $val) {
1416  if (!empty($val['checked'])) {
1417  $colspan++;
1418  }
1419  }
1420  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1421 }
1422 
1423 $db->free($resql);
1424 
1425 $parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql);
1426 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1427 print $hookmanager->resPrint;
1428 
1429 print '</table>'."\n";
1430 print '</div>'."\n";
1431 
1432 print '</form>'."\n";
1433 
1434 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1435  $hidegeneratedfilelistifempty = 1;
1436  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1437  $hidegeneratedfilelistifempty = 0;
1438  }
1439 
1440  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1441  $formfile = new FormFile($db);
1442 
1443  // Show list of available documents
1444  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1445  $urlsource .= str_replace('&amp;', '&', $param);
1446 
1447  $filedir = $diroutputmassaction;
1448  $genallowed = $permissiontoread;
1449  $delallowed = $permissiontoadd;
1450 
1451  print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1452 }
1453 
1454 // End of page
1455 llxFooter();
1456 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage members of a foundation.
const STATUS_EXCLUDED
Excluded.
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
const STATUS_VALIDATED
Validated status.
Class to manage members type.
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage Dolibarr users.
Definition: user.class.php:48
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
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...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.