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