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