dolibarr 25.0.0-alpha
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-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
8 * Copyright (C) 2021-2026 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
11 * Copyright (C) 2026 Mélina Joum <melina.joum@altairis.fr>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
34// Load Dolibarr environment
35require '../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
45require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/phone.lib.php';
49
50// Load translation files required by the page
51$langs->loadLangs(array("members", "companies", "categories"));
52
53// Get parameters
54$action = GETPOST('action', 'aZ09');
55$massaction = GETPOST('massaction', 'alpha');
56$show_files = GETPOSTINT('show_files');
57$confirm = GETPOST('confirm', 'alpha');
58$cancel = GETPOST('cancel', 'alpha');
59$toselect = GETPOST('toselect', 'array:int');
60$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search
61$backtopage = GETPOST('backtopage', 'alpha');
62$optioncss = GETPOST('optioncss', 'aZ');
63$mode = GETPOST('mode', 'alpha');
64$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
65
66// Search fields
67$search = GETPOST("search", 'alpha');
68$search_id = GETPOST('search_id', 'int');
69$search_ref = GETPOST("search_ref", 'alpha');
70$search_lastname = GETPOST("search_lastname", 'alpha');
71$search_firstname = GETPOST("search_firstname", 'alpha');
72$search_gender = GETPOST("search_gender", 'alpha');
73$search_civility = GETPOST("search_civility", 'alpha');
74$search_company = GETPOST('search_company', 'alphanohtml');
75$search_login = GETPOST("search_login", 'alpha');
76$search_address = GETPOST("search_address", 'alpha');
77$search_zip = GETPOST("search_zip", 'alpha');
78$search_town = GETPOST("search_town", 'alpha');
79$search_state = GETPOST("search_state", 'alpha'); // county / departement / federal state
80$search_country = GETPOST("search_country", 'alpha');
81$search_phone = GETPOST("search_phone", 'alpha');
82$search_phone_perso = GETPOST("search_phone_perso", 'alpha');
83$search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
84$search_type = GETPOST("search_type", 'alpha');
85$search_amount = GETPOST("search_amount", 'alpha');
86$search_minimumamount = GETPOST("search_minimumamount", 'alpha');
87$search_email = GETPOST("search_email", 'alpha');
88if (isModEnabled('mailing')) {
89 $search_no_email = GETPOSTISSET("search_no_email") ? GETPOSTINT("search_no_email") : -1;
90} else {
91 $search_no_email = -1;
92}
93$search_categ = GETPOST("search_categ", 'intcomma');
94$search_morphy = GETPOST("search_morphy", 'alpha');
95$search_import_key = trim(GETPOST("search_import_key", 'alpha'));
96
97$socid = GETPOSTINT('socid');
98if (GETPOSTINT('catid') && empty($search_categ)) {
99 $search_categ = GETPOSTINT('catid');
100}
101
102$search_filter = GETPOST("search_filter", 'alpha');
103$search_status = GETPOST("search_status", 'intcomma'); // status
104$search_datec_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datec_start_month'), GETPOSTINT('search_datec_start_day'), GETPOSTINT('search_datec_start_year'));
105$search_datec_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datec_end_month'), GETPOSTINT('search_datec_end_day'), GETPOSTINT('search_datec_end_year'));
106$search_datem_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datem_start_month'), GETPOSTINT('search_datem_start_day'), GETPOSTINT('search_datem_start_year'));
107$search_datem_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datem_end_month'), GETPOSTINT('search_datem_end_day'), GETPOSTINT('search_datem_end_year'));
108
109$filter = GETPOST("filter", 'alpha');
110if ($filter) {
111 $search_filter = $filter; // For backward compatibility
112}
113
114$statut = GETPOST("statut", 'alpha');
115if ($statut != '') {
116 $search_status = $statut; // For backward compatibility
117}
118
119$search_all = trim(GETPOST('search_all', 'alphanohtml'));
120
121if ($search_status < -2) {
122 $search_status = '';
123}
124
125// Load variable for pagination
126$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
127$sortfield = GETPOST('sortfield', 'aZ09comma');
128$sortorder = GETPOST('sortorder', 'aZ09comma');
129$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
130if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
131 // If $page is not defined, or '' or -1 or if we click on clear filters
132 $page = 0;
133}
134$offset = $limit * $page;
135$pageprev = $page - 1;
136$pagenext = $page + 1;
137if (!$sortorder) {
138 $sortorder = ($filter == 'outofdate' ? "DESC" : "ASC");
139}
140if (!$sortfield) {
141 $sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname");
142}
143
144$object = new Adherent($db);
145
146// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
147$hookmanager->initHooks(array('memberlist'));
148
149$diroutputmassaction = $conf->member->dir_output.'/temp/massgeneration/'.$user->id;
150
151// Fetch optionals attributes and labels
152$extrafields->fetch_name_optionals_label($object->table_element);
153
154$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
155
156// List of fields to search into when doing a "search in all"
157$fieldstosearchall = array(
158 'd.ref' => 'Ref',
159 'd.login' => 'Login',
160 'd.lastname' => 'Lastname',
161 'd.firstname' => 'Firstname',
162 'd.societe' => "Company",
163 'd.email' => 'EMail',
164 'd.address' => 'Address',
165 'd.zip' => 'Zip',
166 'd.town' => 'Town',
167 'd.phone' => "Phone",
168 'd.phone_perso' => "PhonePerso",
169 'd.phone_mobile' => "PhoneMobile",
170 'd.note_public' => 'NotePublic',
171 'd.note_private' => 'NotePrivate',
172);
173
174$arrayfields = array(
175 'd.rowid' => array('label' => 'TechnicalID', 'checked' => -1, 'enabled' => 1, 'position' => 1),
176 'd.ref' => array('label' => "Ref", 'checked' => 1),
177 'd.civility' => array('label' => "Civility", 'checked' => 0),
178 'd.gender' => array('label' => "Gender", 'checked' => 0),
179 'd.societe' => array('label' => "Company", 'checked' => 1, 'position' => 70),
180 'd.login' => array('label' => "Login", 'checked' => 1),
181 'd.morphy' => array('label' => "MemberNature", 'checked' => 1),
182 't.libelle' => array('label' => "MemberType", 'checked' => 1, 'position' => 55),
183 't.amount' => array('label' => "RecommendedAmount", 'checked' => 1, 'position' => 55),
184 't.minimumamount' => array('label' => "MinimumAmountShort", 'checked' => 1, 'position' => 55),
185 'd.address' => array('label' => "Address", 'checked' => 0),
186 'd.zip' => array('label' => "Zip", 'checked' => 0),
187 'd.town' => array('label' => "Town", 'checked' => 0),
188 'd.phone' => array('label' => "Phone", 'checked' => 0),
189 'd.phone_perso' => array('label' => "PhonePerso", 'checked' => 0),
190 'd.phone_mobile' => array('label' => "PhoneMobile", 'checked' => 0),
191 'd.email' => array('label' => "Email", 'checked' => 1),
192 'unsubscribed' => array('label' => 'No_Email', 'checked' => '0', 'enabled' => (string) (int) isModEnabled('mailing'), 'position' => 126),
193 'state.nom' => array('label' => "State", 'checked' => 0, 'position' => 90),
194 'country.code_iso' => array('label' => "Country", 'checked' => 0, 'position' => 95),
195 /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
196 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
197 'd.datefin' => array('label' => "EndSubscription"),
198 'd.datec' => array('label' => "DateCreation"),
199 'd.birth' => array('label' => "Birthday"),
200 'd.tms' => array('label' => "DateModificationShort"),
201 'd.statut' => array('label' => "Status"),
202 'd.import_key' => array('label' => "ImportId"),
203);
204
205// Complete array of fields for columns
206$tableprefix = 'd';
207foreach ($object->fields as $key => $val) {
208 // If $val['visible']==0, then we never show the field
209 if (!empty($val['visible'])) {
210 // Special case already added
211 if (in_array($key, array('fk_adherent_type', 'state_id', 'country'))) { // Already managed by another field key in arrayfields
212 continue;
213 }
214 $visible = (int) dol_eval((string) $val['visible'], 1);
215 $arrayfields[$tableprefix.'.'.$key] = array(
216 'label' => $val['label'],
217 'checked' => (($visible < 0) ? '0' : '1'),
218 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
219 'position' => (int) $val['position'],
220 'help' => isset($val['help']) ? $val['help'] : ''
221 );
222 }
223}
224
225// Extra fields
226include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
227
228// Add hook to complete $arrayfields
229$parameters = array('arrayfields' => &$arrayfields);
230$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
231
232$object->fields = dol_sort_array($object->fields, 'position');
233//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
234
235$arrayfields = dol_sort_array($arrayfields, 'position');
236
237// Security check
238$result = restrictedArea($user, 'adherent');
239
240/*
241 * Actions
242 */
243
244if (GETPOST('cancel', 'alpha')) {
245 $action = 'list';
246 $massaction = '';
247}
248if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
249 $massaction = '';
250}
251
252$permissiontoread = $user->hasRight('adherent', 'lire');
253$permissiontodelete = $user->hasRight('adherent', 'supprimer');
254$permissiontoadd = $user->hasRight('adherent', 'creer');
255$uploaddir = $conf->member->dir_output;
256$error = 0;
257
258$parameters = array('socid' => isset($socid) ? $socid : null, 'arrayfields' => &$arrayfields);
259$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
260if ($reshook < 0) {
261 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
262}
263
264if (empty($reshook)) {
265 // Selection of new fields
266 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
267
268 // Purge search criteria
269 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
270 $statut = '';
271 $filter = '';
272
273 $search = "";
274 $search_id = '';
275 $search_ref = "";
276 $search_lastname = "";
277 $search_firstname = "";
278 $search_gender = "";
279 $search_civility = "";
280 $search_login = "";
281 $search_company = "";
282 $search_type = "";
283 $search_amount = "";
284 $search_minimumamount = "";
285 $search_email = "";
286 $search_no_email = -1;
287 $search_address = "";
288 $search_zip = "";
289 $search_town = "";
290 $search_state = "";
291 $search_country = '';
292 $search_phone = '';
293 $search_phone_perso = '';
294 $search_phone_mobile = '';
295 $search_morphy = "";
296 $search_categ = "";
297 $search_filter = "";
298 $search_status = "";
299 $search_import_key = '';
300 $search_all = "";
301 $toselect = array();
302 $search_datec_start = '';
303 $search_datec_end = '';
304 $search_datem_start = '';
305 $search_datem_end = '';
306 $search_array_options = array();
307 }
308
309 // Close
310 if ($massaction == 'close' && $user->hasRight('adherent', 'creer')) {
311 $tmpmember = new Adherent($db);
312 $nbclose = 0;
313
314 $db->begin();
315
316 foreach ($toselect as $idtoclose) {
317 $tmpmember->fetch($idtoclose);
318 $result = $tmpmember->resiliate($user);
319
320 if ($result < 0) {
321 $error++;
322 setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
323 } elseif ($result > 0) {
324 $nbclose++;
325 }
326 }
327
328 if (!$error) {
329 setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs');
330
331 $db->commit();
332 } else {
333 $db->rollback();
334 }
335 }
336
337 // Create external user
338 if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) {
339 $tmpmember = new Adherent($db);
340 $nbcreated = 0;
341
342 $db->begin();
343
344 foreach ($toselect as $idtoclose) {
345 $tmpmember->fetch($idtoclose);
346
347 if (!empty($tmpmember->socid)) {
348 $nuser = new User($db);
349 $tmpuser = dol_clone($tmpmember, 2);
350
351 $result = $nuser->create_from_member($tmpuser, $tmpmember->login);
352
353 if ($result < 0) {
354 $error++;
355 setEventMessages($nuser->error, $nuser->errors, 'errors');
356 } elseif ($result > 0) {
357 $nbcreated++;
358 }
359 }
360 }
361
362 if (!$error) {
363 setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs');
364
365 $db->commit();
366 } else {
367 $db->rollback();
368 }
369 }
370
371 // Create external user
372 if ($action == 'createsubscription_confirm' && $confirm == "yes" && $user->hasRight('adherent', 'creer')) {
373 $tmpmember = new Adherent($db);
374 $adht = new AdherentType($db);
375 $label = GETPOST("label");
376 $nbcreated = 0;
377 $now = dol_now();
378 $amount = price2num(GETPOST('amount', 'alpha'));
379 // Honour MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH and
380 // MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR the same way as the
381 // single subscription form (adherents/subscription.php), otherwise
382 // the mass action falls back to a one-year duration in
383 // Adherent::subscription() and ignores the global setting.
384 $datesubend = 0;
385 if (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH')) {
386 $datesubend = dol_get_last_day((int) dol_print_date($now, "%Y"), (int) dol_print_date($now, "%m"));
387 } elseif (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) {
388 $datesubend = dol_get_last_day((int) dol_print_date($now, "%Y"));
389 }
390 $db->begin();
391 foreach ($toselect as $id) {
392 $res = $tmpmember->fetch($id);
393 if ($res > 0) {
394 // Mirror the single subscription form (adherents/subscription.php): if no
395 // global EOM/EOY override was set, compute the end date from the member's
396 // AdherentType duration_value/duration_unit so a 6-month type does not
397 // silently fall back to the 1-year default in Adherent::subscription()
398 $datesubendthismember = $datesubend;
399 if (!$datesubendthismember && $tmpmember->typeid > 0) {
400 if ($adht->fetch($tmpmember->typeid) > 0) {
401 $delay = !empty($adht->duration_value) ? $adht->duration_value : 1;
402 $delayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y';
403 $datesubendthismember = dol_time_plus_duree(dol_time_plus_duree($now, $delay, $delayunit), -1, 'd');
404 }
405 }
406 $result = $tmpmember->subscription($now, (float) $amount, 0, '', '', '', '', '', $datesubendthismember);
407 if ($result < 0) {
408 $error++;
409 } else {
410 $nbcreated++;
411 }
412 } else {
413 $error++;
414 }
415 }
416
417 if (!$error) {
418 setEventMessages($langs->trans("XSubsriptionCreated", $nbcreated), null, 'mesgs');
419 $db->commit();
420 } else {
421 setEventMessages($langs->trans("XSubsriptionErrors", $error), null, 'mesgs');
422 $db->rollback();
423 }
424 }
425
426 // Mass actions
427 $objectclass = 'Adherent';
428 $objectlabel = 'Members';
429 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
430}
431
432
433/*
434 * View
435 */
436
437$form = new Form($db);
438$formother = new FormOther($db);
439$membertypestatic = new AdherentType($db);
440$memberstatic = new Adherent($db);
441
442$now = dol_now();
443
444// Page Header
445$title = $langs->trans("Members");
446$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
447$morejs = array();
448$morecss = array();
449
450
451// Build and execute select
452// --------------------------------------------------------------------
453$sql = "SELECT";
454$sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc as socid,";
455$sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
456$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,";
457$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut as status, d.datec as date_creation, d.tms as date_modification,";
458$sql .= " d.note_private, d.note_public, d.import_key,";
459$sql .= " s.nom,";
460$sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,";
461$sql .= " t.libelle as type, t.subscription, t.amount, t.minimumamount,";
462$sql .= " state.code_departement as state_code, state.nom as state_name";
463
464if (isModEnabled('mailing')) {
465 $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = d.email) as unsubscribed";
466}
467
468// Add fields from extrafields
469if (!empty($extrafields->attributes[$object->table_element]['label'])) {
470 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
471 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : "");
472 }
473}
474
475// Add fields from hooks
476$parameters = array();
477$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
478$sql .= $hookmanager->resPrint;
479$sql = preg_replace('/,\s*$/', '', $sql);
480
481$sqlfields = $sql; // $sql fields to remove for count total
482
483// SQL Alias adherent
484$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
485if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
486 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
487}
488$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
489$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
490$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
491
492// SQL Alias adherent_type
493$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
494$sql .= " WHERE d.fk_adherent_type = t.rowid";
495
496$searchCategoryContactList = $search_categ ? array($search_categ) : array();
497$searchCategoryContactOperator = 0;
498// Search for tag/category ($searchCategoryContactList is an array of ID)
499if (!empty($searchCategoryContactList)) {
500 $searchCategoryContactSqlList = array();
501 $listofcategoryid = '';
502 foreach ($searchCategoryContactList as $searchCategoryContact) {
503 if (intval($searchCategoryContact) == -2) {
504 $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member)";
505 } elseif (intval($searchCategoryContact) > 0) {
506 if ($searchCategoryContactOperator == 0) {
507 $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).")";
508 } else {
509 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
510 }
511 }
512 }
513 if ($listofcategoryid) {
514 $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)."))";
515 }
516 if ($searchCategoryContactOperator == 1) {
517 if (!empty($searchCategoryContactSqlList)) {
518 $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
519 }
520 } else {
521 if (!empty($searchCategoryContactSqlList)) {
522 $sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
523 }
524 }
525}
526
527$sql .= " AND d.entity IN (".getEntity('adherent').")";
528if ($search_all) {
529 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
530}
531if ($search_type > 0) {
532 $sql .= " AND t.rowid=".((int) $search_type);
533}
534if ($search_amount != '') {
535 $sql .= natural_search('t.amount', $search_amount, 1);
536}
537if ($search_minimumamount != '') {
538 $sql .= natural_search('t.minimumamount', $search_minimumamount, 1);
539}
540if ($search_filter == 'withoutsubscription') {
541 $sql .= " AND (datefin IS NULL)";
542}
543if ($search_filter == 'waitingsubscription') {
544 $sql .= " AND (datefin IS NULL AND t.subscription = '1')";
545}
546if ($search_filter == 'uptodate') {
547 //$sql .= " AND (datefin >= '".$db->idate($now)."')";
548 // Up to date subscription OR no subscription required
549 $sql .= " AND (datefin >= '".$db->idate($now)."' OR (datefin IS NULL AND t.subscription = '0'))";
550}
551if ($search_filter == 'outofdate') {
552 $sql .= " AND (datefin < '".$db->idate($now)."')";
553}
554if ($search_status != '') {
555 // Can be a number or comma separated list of numbers
556 $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
557}
558if ($search_morphy != '' && $search_morphy != '-1') {
559 $sql .= natural_search("d.morphy", $search_morphy);
560}
561if ($search_id) {
562 $sql .= natural_search("d.rowid", $search_id);
563}
564if ($search_ref) {
565 $sql .= natural_search("d.ref", $search_ref);
566}
567if ($search_civility) {
568 $sql .= natural_search("d.civility", $search_civility);
569}
570if ($search_firstname) {
571 $sql .= natural_search("d.firstname", $search_firstname);
572}
573if ($search_lastname) {
574 $sql .= natural_search("d.lastname", $search_lastname);
575}
576if ($search_gender != '' && $search_gender != '-1') {
577 $sql .= natural_search("d.gender", $search_gender);
578}
579if ($search_login) {
580 $sql .= natural_search("d.login", $search_login);
581}
582if ($search_company) {
583 $sql .= natural_search(array("s.nom", "d.societe"), $search_company);
584}
585if ($search_email) {
586 $sql .= natural_search("d.email", $search_email);
587}
588if ($search_no_email != -1 && $search_no_email > 0) {
589 $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = d.email) > 0";
590}
591if ($search_no_email != -1 && $search_no_email == 0) {
592 $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = d.email) = 0 AND d.email IS NOT NULL AND d.email <> ''";
593}
594if ($search_address) {
595 $sql .= natural_search("d.address", $search_address);
596}
597if ($search_town) {
598 $sql .= natural_search("d.town", $search_town);
599}
600if ($search_zip) {
601 $sql .= natural_search("d.zip", $search_zip);
602}
603if ($search_state) {
604 $sql .= natural_search("state.nom", $search_state);
605}
606if ($search_phone) {
607 $sql .= dol_natural_search_phone($db, "d.phone", $search_phone);
608}
609if ($search_phone_perso) {
610 $sql .= dol_natural_search_phone($db, "d.phone_perso", $search_phone_perso);
611}
612if ($search_phone_mobile) {
613 $sql .= dol_natural_search_phone($db, "d.phone_mobile", $search_phone_mobile);
614}
615if ($search_country) {
616 $sql .= " AND d.country IN (".$db->sanitize($search_country).')';
617}
618if ($search_import_key) {
619 $sql .= natural_search("d.import_key", $search_import_key);
620}
621if ($search_datec_start) {
622 $sql .= " AND d.datec >= '".$db->idate($search_datec_start)."'";
623}
624if ($search_datec_end) {
625 $sql .= " AND d.datec <= '".$db->idate($search_datec_end)."'";
626}
627if ($search_datem_start) {
628 $sql .= " AND d.tms >= '".$db->idate($search_datem_start)."'";
629}
630if ($search_datem_end) {
631 $sql .= " AND d.tms <= '".$db->idate($search_datem_end)."'";
632}
633// Add where from extra fields
634include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
635// Add where from hooks
636$parameters = array();
637$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
638$sql .= $hookmanager->resPrint;
639
640// Count total nb of records
641$nbtotalofrecords = '';
642if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
643 /* The fast and low memory method to get and count full list converts the sql into a sql count */
644 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
645 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
646 $resql = $db->query($sqlforcount);
647 if ($resql) {
648 $objforcount = $db->fetch_object($resql);
649 $nbtotalofrecords = $objforcount->nbtotalofrecords;
650 } else {
651 dol_print_error($db);
652 }
653
654 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
655 $page = 0;
656 $offset = 0;
657 }
658 $db->free($resql);
659}
660//print $sql;
661
662// Complete request and execute it with limit
663$sql .= $db->order($sortfield, $sortorder);
664if ($limit) {
665 $sql .= $db->plimit($limit + 1, $offset);
666}
667
668$resql = $db->query($sql);
669if (!$resql) {
670 dol_print_error($db);
671 exit;
672}
673
674$num = $db->num_rows($resql);
675
676
677// Direct jump if only one record found
678if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
679 $obj = $db->fetch_object($resql);
680 $id = $obj->rowid;
681 header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id);
682 exit;
683}
684
685// Output page
686// --------------------------------------------------------------------
687
688llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-member page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
689
690$arrayofselected = is_array($toselect) ? $toselect : array();
691
692
693if ($search_type > 0) {
694 $membertype = new AdherentType($db);
695 $result = $membertype->fetch((int) $search_type);
696 $title .= " (".$membertype->label.")";
697}
698
699// $parameters
700$query = [];
701if (!empty($mode)) {
702 $query += ['mode' => $mode];
703}
704if ($contextpage != $_SERVER["PHP_SELF"]) {
705 $query += ['contextpage' => $contextpage];
706}
707if ($limit > 0 && $limit != $conf->liste_limit) {
708 $query += ['limit' => $limit];
709}
710if ($optioncss != '') {
711 $query += ['optioncss' => $optioncss];
712}
713if ($groupby != '') {
714 $query += ['groupby' => $groupby];
715}
716if ($search_all != "") {
717 $query += ['search_all' => $search_all];
718}
719if ($search_ref) {
720 $query += ['search_ref' => $search_ref];
721}
722if ($search_civility) {
723 $query += ['search_civility' => $search_civility];
724}
725if ($search_firstname) {
726 $query += ['search_firstname' => $search_firstname];
727}
728if ($search_lastname) {
729 $query += ['search_lastname' => $search_lastname];
730}
731if ($search_gender) {
732 $query += ['search_gender' => $search_gender];
733}
734if ($search_morphy != '' && $search_morphy != '-1') {
735 $query += ['search_morphy' => $search_morphy];
736}
737if ($search_login) {
738 $query += ['search_login' => $search_login];
739}
740if ($search_email) {
741 $query += ['search_email' => $search_email];
742}
743if ($search_no_email != -1) {
744 $query += ['search_no_email' => $search_no_email];
745}
746if ($search_categ > 0 || $search_categ == -2) {
747 $query += ['search_categ' => $search_categ];
748}
749if ($search_company) {
750 $query += ['search_company' => $search_company];
751}
752if ($search_address != '') {
753 $query += ['search_address' => $search_address];
754}
755if ($search_town != '') {
756 $query += ['search_town' => $search_town];
757}
758if ($search_zip != '') {
759 $query += ['search_zip' => $search_zip];
760}
761if ($search_state != '') {
762 $query += ['search_state' => $search_state];
763}
764if ($search_country != '') {
765 $query += ['search_country' => $search_country];
766}
767if ($search_phone != '') {
768 $query += ['search_phone' => $search_phone];
769}
770if ($search_phone_perso != '') {
771 $query += ['search_phone_perso' => $search_phone_perso];
772}
773if ($search_phone_mobile != '') {
774 $query += ['search_phone_mobile' => $search_phone_mobile];
775}
776if ($search_filter && $search_filter != '-1') {
777 $query += ['search_filter' => $search_filter];
778}
779if ($search_status != "" && $search_status != -3) {
780 $query += ['search_status' => $search_status];
781}
782if ($search_import_key != '') {
783 $query += ['search_import_key' => $search_import_key];
784}
785if ($search_type > 0) {
786 $query += ['search_type' => $search_type];
787}
788if ($search_amount != '') {
789 $query += ['search_amount' => $search_amount];
790}
791if ($search_minimumamount != '') {
792 $query += ['search_minimumamount' => $search_minimumamount];
793}
794if ($search_datec_start) {
795 $query += [
796 'search_datec_start_day' => dol_print_date($search_datec_start, '%d'),
797 'search_datec_start_month' => dol_print_date($search_datec_start, '%m'),
798 'search_datec_start_year' => dol_print_date($search_datec_start, '%Y'),
799 ];
800}
801if ($search_datem_end) {
802 $query += [
803 'search_datem_end_day' => dol_print_date($search_datem_end, '%d'),
804 'search_datem_end_month' => dol_print_date($search_datem_end, '%m'),
805 'search_datem_end_year' => dol_print_date($search_datem_end, '%Y'),
806 ];
807}
808
809// Add $query from extra fields
810include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
811
812// Add $query from hooks
813$parameters = array('query' => &$query);
814$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
815
816// build $param
817$param = http_build_query($query);
818
819// List of mass actions available
820$arrayofmassactions = array(
821 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
822 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
823);
824if ($user->hasRight('adherent', 'creer')) {
825 $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Resiliate");
826}
827if ($user->hasRight('adherent', 'supprimer')) {
828 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
829}
830if (isModEnabled('category') && $user->hasRight('adherent', 'creer')) {
831 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
832}
833if ($user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) {
834 $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser");
835}
836if ($user->hasRight('adherent', 'creer')) {
837 $arrayofmassactions['createsubscription'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("CreateSubscription");
838}
839if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
840 $arrayofmassactions = array();
841}
842$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
843
844print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
845if ($optioncss != '') {
846 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
847}
848print '<input type="hidden" name="token" value="'.newToken().'">';
849print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
850print '<input type="hidden" name="action" value="list">';
851print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
852print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
853print '<input type="hidden" name="page" value="'.$page.'">';
854print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
855print '<input type="hidden" name="page_y" value="">';
856print '<input type="hidden" name="mode" value="'.$mode.'">';
857
858$newcardbutton = '';
859$argsforbutton = $query;
860$argsforbutton['mode'] = 'common';
861$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', dolBuildUrl($_SERVER["PHP_SELF"], $argsforbutton), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
862$argsforbutton['mode'] = 'kanban';
863$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', dolBuildUrl($_SERVER["PHP_SELF"], $argsforbutton), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
864$newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', dol_buildpath('/adherents/stats/geo.php', 1).'?mode=memberbycountry&objecttype=adherent@adherent'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
865$newcardbutton .= dolGetButtonTitleSeparator();
866$newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', dolBuildUrl(DOL_URL_ROOT.'/adherents/card.php', ['action' => 'create']), '', $user->hasRight('adherent', 'creer'));
867
868print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
869
870// Add code for pre mass action (confirmation or email presend form)
871$topicmail = "Information";
872$modelmail = "member";
873$objecttmp = new Adherent($db);
874$trackid = 'mem'.$object->id;
875if ($massaction == 'createsubscription') {
876 $tmpmember = new Adherent($db);
877 $adht = new AdherentType($db);
878 $amount = 0;
879 foreach ($toselect as $id) {
880 $now = dol_now();
881 $tmpmember->fetch($id);
882 $res = $adht->fetch($tmpmember->typeid);
883 if ($res > 0) {
884 $amounttmp = $adht->amount;
885 if (!empty($tmpmember->last_subscription_amount) && !GETPOSTISSET('newamount') && is_numeric($amounttmp)) {
886 $amounttmp = max($tmpmember->last_subscription_amount, $amount);
887 }
888 $amount = max(0, $amounttmp, $amount);
889 } else {
890 $error++;
891 }
892 }
893
894 $date = dol_print_date(dol_now(), "%d/%m/%Y");
895 $formquestion = array(
896 array('label' => $langs->trans("DateSubscription"), 'type' => 'other', 'value' => $date),
897 array('label' => $langs->trans("Amount"), 'type' => 'text', 'value' => price($amount, 0, '', 0), 'name' => 'amount'),
898 array('label' => $langs->trans("Label"), 'type' => 'text', 'value' => '', 'name' => 'label'),
899 array('type' => 'separator'),
900 array('label' => $langs->trans("MoreActions"), 'type' => 'other', 'value' => $langs->trans("None").' '.img_warning($langs->trans("WarningNoComplementaryActionDone"))),
901 );
902 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSubsriptionCreation"), $langs->trans("ConfirmMassSubsriptionCreationQuestion", count($toselect)), "createsubscription_confirm", $formquestion, '', 0, 200, 500, 1);
903}
904include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
905
906if ($search_all) {
907 $setupstring = '';
908 foreach ($fieldstosearchall as $key => $val) {
909 $fieldstosearchall[$key] = $langs->trans($val);
910 $setupstring .= $key."=".$val.";";
911 }
912 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
913 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
914}
915
916$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
917$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
918$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
919$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
920
921$moreforfilter = '';
922// Filter on categories
923if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
924 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
925 $moreforfilter .= '<div class="divsearchfield">';
926 $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1, $langs->trans("MembersCategoriesShort"));
927 $moreforfilter .= '</div>';
928}
929$parameters = array(
930 'arrayfields' => &$arrayfields,
931);
932$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
933if (empty($reshook)) {
934 $moreforfilter .= $hookmanager->resPrint;
935} else {
936 $moreforfilter = $hookmanager->resPrint;
937}
938if (!empty($moreforfilter)) {
939 print '<div class="liste_titre liste_titre_bydiv centpercent">';
940 print $moreforfilter;
941 print '</div>';
942}
943
944print '<div class="div-table-responsive">';
945print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
946
947// Fields title search
948// --------------------------------------------------------------------
949print '<tr class="liste_titre_filter">';
950
951// Action column
952if ($conf->main_checkbox_left_column) {
953 print '<td class="liste_titre center maxwidthsearch">';
954 $searchpicto = $form->showFilterButtons('left');
955 print $searchpicto;
956 print '</td>';
957}
958
959// Line numbering
960if (!empty($arrayfields['d.rowid']['checked'])) {
961 print '<td class="liste_titre center">';
962 print '<input class="width50" type="text" name="search_id" value="'.dol_escape_htmltag($search_id).'">';
963 print '</td>';
964}
965
966// Ref
967if (!empty($arrayfields['d.ref']['checked'])) {
968 print '<td class="liste_titre">';
969 print '<input type="text" class="flat maxwidth75imp" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
970 print '</td>';
971}
972
973// Civility
974if (!empty($arrayfields['d.civility']['checked'])) {
975 print '<td class="liste_titre left">';
976 print '<input class="flat maxwidth50imp" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>';
977}
978
979// Last Name
980if (!empty($arrayfields['d.lastname']['checked'])) {
981 print '<td class="liste_titre left">';
982 print '<input class="flat maxwidth75imp" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
983}
984
985// First Name
986if (!empty($arrayfields['d.firstname']['checked'])) {
987 print '<td class="liste_titre left">';
988 print '<input class="flat maxwidth75imp" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
989}
990
991// Gender
992if (!empty($arrayfields['d.gender']['checked'])) {
993 print '<td class="liste_titre">';
994 $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother"));
995 print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
996 print '</td>';
997}
998
999// Company
1000if (!empty($arrayfields['d.societe']['checked'])) {
1001 print '<td class="liste_titre left">';
1002 print '<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
1003}
1004
1005// Login
1006if (!empty($arrayfields['d.login']['checked'])) {
1007 print '<td class="liste_titre left">';
1008 print '<input class="flat maxwidth75imp" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
1009}
1010
1011// Nature
1012if (!empty($arrayfields['d.morphy']['checked'])) {
1013 print '<td class="liste_titre center">';
1014 $arraymorphy = array('mor' => $langs->trans("Moral"), 'phy' => $langs->trans("Physical"));
1015 print $form->selectarray('search_morphy', $arraymorphy, $search_morphy, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
1016 print '</td>';
1017}
1018
1019// Member Type
1020if (!empty($arrayfields['t.libelle']['checked'])) {
1021 print '<td class="liste_titre">';
1022 $listetype = $membertypestatic->liste_array();
1023 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1024 print $form->selectarray("search_type", $listetype, $search_type, 1, 0, 0, '', 0, 32, 0, '', 'minwidth75 maxwidth100');
1025 print '</td>';
1026}
1027
1028// Amount
1029if (!empty($arrayfields['t.amount']['checked'])) {
1030 print '<td class="liste_titre">';
1031 print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
1032 print '</td>';
1033}
1034
1035// Minimum amount
1036if (!empty($arrayfields['t.minimumamount']['checked'])) {
1037 print '<td class="liste_titre">';
1038 print '<input class="flat" type="text" size="4" name="search_minimumamount" value="'.dol_escape_htmltag($search_minimumamount).'">';
1039 print '</td>';
1040}
1041
1042// Address - Street
1043if (!empty($arrayfields['d.address']['checked'])) {
1044 print '<td class="liste_titre left">';
1045 print '<input class="flat maxwidth75imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'"></td>';
1046}
1047
1048// ZIP
1049if (!empty($arrayfields['d.zip']['checked'])) {
1050 print '<td class="liste_titre left">';
1051 print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1052}
1053
1054// Town/City
1055if (!empty($arrayfields['d.town']['checked'])) {
1056 print '<td class="liste_titre left">';
1057 print '<input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1058}
1059
1060// State / County / Departement
1061if (!empty($arrayfields['state.nom']['checked'])) {
1062 print '<td class="liste_titre">';
1063 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1064 print '</td>';
1065}
1066
1067// Country
1068if (!empty($arrayfields['country.code_iso']['checked'])) {
1069 print '<td class="liste_titre center">';
1070 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1071 print '</td>';
1072}
1073
1074// Phone pro
1075if (!empty($arrayfields['d.phone']['checked'])) {
1076 print '<td class="liste_titre left">';
1077 print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'"></td>';
1078}
1079
1080// Phone perso
1081if (!empty($arrayfields['d.phone_perso']['checked'])) {
1082 print '<td class="liste_titre left">';
1083 print '<input class="flat maxwidth75imp" type="text" name="search_phone_perso" value="'.dol_escape_htmltag($search_phone_perso).'"></td>';
1084}
1085
1086// Phone mobile
1087if (!empty($arrayfields['d.phone_mobile']['checked'])) {
1088 print '<td class="liste_titre left">';
1089 print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="'.dol_escape_htmltag($search_phone_mobile).'"></td>';
1090}
1091
1092// Email
1093if (!empty($arrayfields['d.email']['checked'])) {
1094 print '<td class="liste_titre left">';
1095 print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
1096}
1097
1098// No email (unsubscribe)
1099if (!empty($arrayfields['unsubscribed']['checked'])) {
1100 print '<td class="liste_titre center">';
1101 print $form->selectarray('search_no_email', array('-1' => '', '0' => $langs->trans('No'), '1' => $langs->trans('Yes')), $search_no_email);
1102 print '</td>';
1103}
1104
1105// Extra fields
1106include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1107
1108// Fields from hook
1109$parameters = array('arrayfields' => $arrayfields);
1110$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1111print $hookmanager->resPrint;
1112
1113// Date creation
1114if (!empty($arrayfields['d.datec']['checked'])) {
1115 print '<td class="liste_titre center">';
1116 print '<div class="nowrapfordate">';
1117 print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1118 print '</div>';
1119 print '<div class="nowrapfordate">';
1120 print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1121 print '</div>';
1122 print '</td>';
1123}
1124
1125// Birthday
1126if (!empty($arrayfields['d.birth']['checked'])) {
1127 print '<td class="liste_titre">';
1128 print '</td>';
1129}
1130
1131// Date modification
1132if (!empty($arrayfields['d.tms']['checked'])) {
1133 print '<td class="liste_titre">';
1134 print '<div class="nowrapfordate">';
1135 print $form->selectDate($search_datem_start ? $search_datem_start : -1, 'search_datem_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1136 print '</div>';
1137 print '<div class="nowrapfordate">';
1138 print $form->selectDate($search_datem_end ? $search_datem_end : -1, 'search_datem_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1139 print '</div>';
1140 print '</td>';
1141}
1142
1143// Import Key
1144if (!empty($arrayfields['d.import_key']['checked'])) {
1145 print '<td class="liste_titre center">';
1146 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1147 print '</td>';
1148}
1149
1150// End of subscription date
1151if (!empty($arrayfields['d.datefin']['checked'])) {
1152 print '<td class="liste_titre center">';
1153 //$selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
1154 $selectarray = array('-1' => '', 'waitingsubscription' => $langs->trans("WaitingSubscription"), 'uptodate' => $langs->trans("UpToDate"), 'outofdate' => $langs->trans("OutOfDate"));
1155 print $form->selectarray('search_filter', $selectarray, $search_filter);
1156 print '</td>';
1157}
1158
1159// Status
1160if (!empty($arrayfields['d.statut']['checked'])) {
1161 print '<td class="liste_titre center parentonrightofpage">';
1162 $liststatus = array(
1163 Adherent::STATUS_DRAFT => $langs->trans("Draft"),
1164 Adherent::STATUS_VALIDATED => $langs->trans("Validated"),
1165 Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"),
1166 Adherent::STATUS_EXCLUDED => $langs->trans("MemberStatusExcludedShort")
1167 );
1168 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1169 print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
1170 print '</td>';
1171}
1172
1173// Action column
1174if (!$conf->main_checkbox_left_column) {
1175 print '<td class="liste_titre center maxwidthsearch">';
1176 $searchpicto = $form->showFilterButtons();
1177 print $searchpicto;
1178 print '</td>';
1179}
1180print '</tr>'."\n";
1181
1182$totalarray = array();
1183$totalarray['nbfield'] = 0;
1184
1185// Fields title label
1186// --------------------------------------------------------------------
1187print '<tr class="liste_titre">';
1188// Action column
1189if ($conf->main_checkbox_left_column) {
1190 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');
1191 $totalarray['nbfield']++;
1192}
1193if (!empty($arrayfields['d.rowid']['checked'])) {
1194 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1195 print_liste_field_titre($arrayfields['d.rowid']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
1196 $totalarray['nbfield']++;
1197}
1198if (!empty($arrayfields['d.ref']['checked'])) {
1199 print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
1200 $totalarray['nbfield']++;
1201}
1202if (!empty($arrayfields['d.civility']['checked'])) {
1203 print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
1204 $totalarray['nbfield']++;
1205}
1206if (!empty($arrayfields['d.lastname']['checked'])) {
1207 print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
1208 $totalarray['nbfield']++;
1209}
1210if (!empty($arrayfields['d.firstname']['checked'])) {
1211 print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
1212 $totalarray['nbfield']++;
1213}
1214if (!empty($arrayfields['d.gender']['checked'])) {
1215 print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', '', $param, '', $sortfield, $sortorder);
1216 $totalarray['nbfield']++;
1217}
1218if (!empty($arrayfields['d.societe']['checked'])) {
1219 print_liste_field_titre($arrayfields['d.societe']['label'], $_SERVER["PHP_SELF"], 'companyname', '', $param, '', $sortfield, $sortorder);
1220 $totalarray['nbfield']++;
1221}
1222if (!empty($arrayfields['d.login']['checked'])) {
1223 print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder);
1224 $totalarray['nbfield']++;
1225}
1226if (!empty($arrayfields['d.morphy']['checked'])) {
1227 print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder, 'center ');
1228 $totalarray['nbfield']++;
1229}
1230if (!empty($arrayfields['t.libelle']['checked'])) {
1231 print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
1232 $totalarray['nbfield']++;
1233}
1234if (!empty($arrayfields['t.amount']['checked'])) {
1235 print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER["PHP_SELF"], 't.amount', '', $param, '', $sortfield, $sortorder);
1236 $totalarray['nbfield']++;
1237}
1238if (!empty($arrayfields['t.minimumamount']['checked'])) {
1239 print_liste_field_titre($arrayfields['t.minimumamount']['label'], $_SERVER["PHP_SELF"], 't.minimumamount', '', $param, '', $sortfield, $sortorder);
1240 $totalarray['nbfield']++;
1241}
1242if (!empty($arrayfields['d.address']['checked'])) {
1243 print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
1244 $totalarray['nbfield']++;
1245}
1246if (!empty($arrayfields['d.zip']['checked'])) {
1247 print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
1248 $totalarray['nbfield']++;
1249}
1250if (!empty($arrayfields['d.town']['checked'])) {
1251 print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder);
1252 $totalarray['nbfield']++;
1253}
1254if (!empty($arrayfields['state.nom']['checked'])) {
1255 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1256 $totalarray['nbfield']++;
1257}
1258if (!empty($arrayfields['country.code_iso']['checked'])) {
1259 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1260 $totalarray['nbfield']++;
1261}
1262if (!empty($arrayfields['d.phone']['checked'])) {
1263 print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
1264 $totalarray['nbfield']++;
1265}
1266if (!empty($arrayfields['d.phone_perso']['checked'])) {
1267 print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
1268 $totalarray['nbfield']++;
1269}
1270if (!empty($arrayfields['d.phone_mobile']['checked'])) {
1271 print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
1272 $totalarray['nbfield']++;
1273}
1274if (!empty($arrayfields['d.email']['checked'])) {
1275 print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
1276 $totalarray['nbfield']++;
1277}
1278if (!empty($arrayfields['unsubscribed']['checked'])) {
1279 print_liste_field_titre($arrayfields['unsubscribed']['label'], $_SERVER["PHP_SELF"], 'unsubscribed', '', $param, '', $sortfield, $sortorder, 'center ');
1280 $totalarray['nbfield']++;
1281}
1282// Extra fields
1283include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1284
1285// Hook fields
1286$parameters = array('arrayfields' => $arrayfields, 'totalarray' => &$totalarray, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1287$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1288print $hookmanager->resPrint;
1289
1290if (!empty($arrayfields['d.datec']['checked'])) {
1291 print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1292 $totalarray['nbfield']++;
1293}
1294if (!empty($arrayfields['d.birth']['checked'])) {
1295 print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1296 $totalarray['nbfield']++;
1297}
1298if (!empty($arrayfields['d.tms']['checked'])) {
1299 print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1300 $totalarray['nbfield']++;
1301}
1302if (!empty($arrayfields['d.import_key']['checked'])) {
1303 print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER["PHP_SELF"], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1304 $totalarray['nbfield']++;
1305}
1306if (!empty($arrayfields['d.datefin']['checked'])) {
1307 print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin,t.subscription', '', $param, '', $sortfield, $sortorder, 'center ');
1308 $totalarray['nbfield']++;
1309}
1310if (!empty($arrayfields['d.statut']['checked'])) {
1311 print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut,t.subscription,d.datefin", "", $param, '', $sortfield, $sortorder, 'center ');
1312 $totalarray['nbfield']++;
1313}
1314if (!$conf->main_checkbox_left_column) {
1315 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
1316 $totalarray['nbfield']++;
1317}
1318print "</tr>\n";
1319
1320// Loop on record
1321// --------------------------------------------------------------------
1322$i = 0;
1323$savnbfield = $totalarray['nbfield'];
1324$totalarray = array();
1325$totalarray['nbfield'] = 0;
1326$imaxinloop = ($limit ? min($num, $limit) : $num);
1327while ($i < $imaxinloop) {
1328 $obj = $db->fetch_object($resql);
1329 if (empty($obj)) {
1330 break; // Should not happen
1331 }
1332
1333 $datefin = $db->jdate($obj->datefin);
1334
1335 $memberstatic->id = $obj->rowid;
1336 $memberstatic->ref = $obj->ref;
1337 $memberstatic->civility_code = $obj->civility;
1338 $memberstatic->login = $obj->login;
1339 $memberstatic->lastname = $obj->lastname;
1340 $memberstatic->firstname = $obj->firstname;
1341 $memberstatic->gender = $obj->gender;
1342 $memberstatic->status = $obj->status;
1343 $memberstatic->datefin = $datefin;
1344 $memberstatic->socid = $obj->socid;
1345 $memberstatic->photo = $obj->photo;
1346 $memberstatic->email = $obj->email;
1347 $memberstatic->morphy = $obj->morphy;
1348 $memberstatic->note_public = $obj->note_public;
1349 $memberstatic->note_private = $obj->note_private;
1350 $memberstatic->need_subscription = $obj->subscription;
1351
1352 if (!empty($obj->socid)) {
1353 $memberstatic->fetch_thirdparty();
1354 if ($memberstatic->thirdparty->id > 0) {
1355 $companyname = $memberstatic->thirdparty->name;
1356 $companynametoshow = $memberstatic->thirdparty->getNomUrl(1);
1357 } else {
1358 $companyname = null;
1359 $companynametoshow = null;
1360 }
1361 } else {
1362 $companyname = $obj->company;
1363 $companynametoshow = $obj->company;
1364 }
1365 $memberstatic->company = (string) $companyname;
1366
1367 $object = $memberstatic;
1368
1369 if ($mode == 'kanban') {
1370 if ($i == 0) {
1371 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1372 print '<div class="box-flex-container kanban">';
1373 }
1374 $membertypestatic->id = $obj->type_id;
1375 $membertypestatic->label = $obj->type;
1376
1377 $memberstatic->type = $membertypestatic->label;
1378 $memberstatic->photo = $obj->photo;
1379
1380 // Output Kanban
1381 print $memberstatic->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
1382 if ($i == (min($num, $limit) - 1)) {
1383 print '</div>';
1384 print '</td></tr>';
1385 }
1386 } else {
1387 // Show line of result
1388 $j = 0;
1389 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
1390
1391 // Action column
1392 if ($conf->main_checkbox_left_column) {
1393 print '<td class="nowrap center">';
1394 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1395 $selected = 0;
1396 if (in_array($obj->rowid, $arrayofselected)) {
1397 $selected = 1;
1398 }
1399 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1400 }
1401 print '</td>';
1402 if (!$i) {
1403 $totalarray['nbfield']++;
1404 }
1405 }
1406 // Technical ID
1407 if (!empty($arrayfields['d.rowid']['checked'])) {
1408 print '<td class="center" data-key="id">'.dolPrintHTML($obj->rowid).'</td>';
1409 if (!$i) {
1410 $totalarray['nbfield']++;
1411 }
1412 }
1413 // Ref
1414 if (!empty($arrayfields['d.ref']['checked'])) {
1415 print '<td class="tdoverflowmax150">';
1416 print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
1417 print "</td>\n";
1418 if (!$i) {
1419 $totalarray['nbfield']++;
1420 }
1421 }
1422 // Title/Civility
1423 if (!empty($arrayfields['d.civility']['checked'])) {
1424 print "<td>";
1425 print dolPrintHTML($obj->civility);
1426 print "</td>\n";
1427 if (!$i) {
1428 $totalarray['nbfield']++;
1429 }
1430 }
1431 // Lastname
1432 if (!empty($arrayfields['d.lastname']['checked'])) {
1433 print '<td class="tdoverflowmax125">';
1434 print $memberstatic->getNomUrl(0, 0, 'card', 'lastname');
1435 //print $obj->lastname;
1436 print "</td>\n";
1437 if (!$i) {
1438 $totalarray['nbfield']++;
1439 }
1440 }
1441 // Firstname
1442 if (!empty($arrayfields['d.firstname']['checked'])) {
1443 print '<td class="tdoverflowmax125">';
1444 print $memberstatic->getNomUrl(0, 0, 'card', 'firstname');
1445 //print $obj->firstname;
1446 print "</td>\n";
1447 if (!$i) {
1448 $totalarray['nbfield']++;
1449 }
1450 }
1451 // Gender
1452 if (!empty($arrayfields['d.gender']['checked'])) {
1453 print '<td>';
1454 if ($obj->gender) {
1455 print $langs->trans("Gender".$obj->gender);
1456 }
1457 print '</td>';
1458 if (!$i) {
1459 $totalarray['nbfield']++;
1460 }
1461 }
1462 // Company
1463 if (!empty($arrayfields['d.societe']['checked'])) {
1464 print '<td class="tdoverflowmax125">';
1465 print $companynametoshow;
1466 print "</td>\n";
1467 }
1468 // Login
1469 if (!empty($arrayfields['d.login']['checked'])) {
1470 print '<td class="tdoverflowmax125" title="'.dolPrintHTMLForAttribute($obj->login).'">'.dolPrintHTML($obj->login)."</td>\n";
1471 if (!$i) {
1472 $totalarray['nbfield']++;
1473 }
1474 }
1475 // Nature (Moral/Physical)
1476 if (!empty($arrayfields['d.morphy']['checked'])) {
1477 print '<td class="center">';
1478 print $memberstatic->getmorphylib('', 2);
1479 print "</td>\n";
1480 if (!$i) {
1481 $totalarray['nbfield']++;
1482 }
1483 }
1484 // Type label
1485 if (!empty($arrayfields['t.libelle']['checked'])) {
1486 $membertypestatic->id = $obj->type_id;
1487 $membertypestatic->label = $obj->type;
1488 print '<td class="nowraponall tdoverflowmax100">';
1489 print $membertypestatic->getNomUrl(1, 32);
1490 print '</td>';
1491 if (!$i) {
1492 $totalarray['nbfield']++;
1493 }
1494 }
1495 // Amount
1496 if (!empty($arrayfields['t.amount']['checked'])) {
1497 print '<td class="nowraponall tdoverflowmax100">';
1498 print price($obj->amount);
1499 print '</td>';
1500 if (!$i) {
1501 $totalarray['nbfield']++;
1502 }
1503 }
1504 // Minimum amount
1505 if (!empty($arrayfields['t.minimumamount']['checked'])) {
1506 print '<td class="nowraponall tdoverflowmax100">';
1507 print price($obj->minimumamount);
1508 print '</td>';
1509 if (!$i) {
1510 $totalarray['nbfield']++;
1511 }
1512 }
1513 // Address
1514 if (!empty($arrayfields['d.address']['checked'])) {
1515 print '<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->address).'">';
1516 print dolPrintHTML($obj->address);
1517 print '</td>';
1518 if (!$i) {
1519 $totalarray['nbfield']++;
1520 }
1521 }
1522 // Zip
1523 if (!empty($arrayfields['d.zip']['checked'])) {
1524 print '<td class="nocellnopadd">';
1525 print dolPrintHTML($obj->zip);
1526 print '</td>';
1527 if (!$i) {
1528 $totalarray['nbfield']++;
1529 }
1530 }
1531 // Town
1532 if (!empty($arrayfields['d.town']['checked'])) {
1533 print '<td class="nocellnopadd">';
1534 print dolPrintHTML($obj->town);
1535 print '</td>';
1536 if (!$i) {
1537 $totalarray['nbfield']++;
1538 }
1539 }
1540 // State / County / Departement
1541 if (!empty($arrayfields['state.nom']['checked'])) {
1542 print "<td>";
1543 print dolPrintHTML($obj->state_name);
1544 print "</td>\n";
1545 if (!$i) {
1546 $totalarray['nbfield']++;
1547 }
1548 }
1549 // Country
1550 if (!empty($arrayfields['country.code_iso']['checked'])) {
1551 $tmparray = getCountry($obj->country, 'all');
1552 print '<td class="center tdoverflowmax100" title="'.dolPrintHTMLForAttribute($tmparray['label']).'">';
1553 print dolPrintHTML($tmparray['label']);
1554 print '</td>';
1555 if (!$i) {
1556 $totalarray['nbfield']++;
1557 }
1558 }
1559 // Phone pro
1560 if (!empty($arrayfields['d.phone']['checked'])) {
1561 print '<td class="nocellnopadd">';
1562 print dol_print_phone($obj->phone);
1563 print '</td>';
1564 if (!$i) {
1565 $totalarray['nbfield']++;
1566 }
1567 }
1568 // Phone perso
1569 if (!empty($arrayfields['d.phone_perso']['checked'])) {
1570 print '<td class="nocellnopadd">';
1571 print dol_print_phone($obj->phone_perso);
1572 print '</td>';
1573 if (!$i) {
1574 $totalarray['nbfield']++;
1575 }
1576 }
1577 // Phone mobile
1578 if (!empty($arrayfields['d.phone_mobile']['checked'])) {
1579 print '<td class="nocellnopadd">';
1580 print dol_print_phone($obj->phone_mobile);
1581 print '</td>';
1582 if (!$i) {
1583 $totalarray['nbfield']++;
1584 }
1585 }
1586 // EMail
1587 if (!empty($arrayfields['d.email']['checked'])) {
1588 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute((string) $obj->email).'">';
1589 $showinvalidemail = getDolGlobalInt('MAIN_SHOW_INVALID_EMAIL_IN_LIST', 1); // in list, we check only syntax of emails
1590 print dol_print_email((string) $obj->email, 0, 0, 1, 64, $showinvalidemail, 1);
1591 print "</td>\n";
1592 if (!$i) {
1593 $totalarray['nbfield']++;
1594 }
1595 }
1596 // Unsubscribe from mass mailing
1597 if (!empty($arrayfields['unsubscribed']['checked'])) {
1598 print '<td class="center">'.yn(($obj->unsubscribed > 0) ? 1 : 0)."</td>\n";
1599 if (!$i) {
1600 $totalarray['nbfield']++;
1601 }
1602 }
1603 // Extra fields
1604 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1605 // Fields from hook
1606 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1607 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1608 print $hookmanager->resPrint;
1609 // Date creation
1610 if (!empty($arrayfields['d.datec']['checked'])) {
1611 print '<td class="nowrap center">';
1612 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1613 print '</td>';
1614 if (!$i) {
1615 $totalarray['nbfield']++;
1616 }
1617 }
1618 // Birth
1619 if (!empty($arrayfields['d.birth']['checked'])) {
1620 print '<td class="nowrap center">';
1621 print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
1622 print '</td>';
1623 if (!$i) {
1624 $totalarray['nbfield']++;
1625 }
1626 }
1627 // Date modification
1628 if (!empty($arrayfields['d.tms']['checked'])) {
1629 print '<td class="nowrap center">';
1630 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1631 print '</td>';
1632 if (!$i) {
1633 $totalarray['nbfield']++;
1634 }
1635 }
1636 // Import key
1637 if (!empty($arrayfields['d.import_key']['checked'])) {
1638 print '<td class="tdoverflowmax100 center" title="'.dolPrintHTMLForAttribute($obj->import_key).'">';
1639 print dolPrintHTML($obj->import_key);
1640 print "</td>\n";
1641 if (!$i) {
1642 $totalarray['nbfield']++;
1643 }
1644 }
1645 // End of subscription date
1646 $datefin = $db->jdate($obj->datefin);
1647 if (!empty($arrayfields['d.datefin']['checked'])) {
1648 $s = '';
1649 if ($datefin) {
1650 $s .= dol_print_date($datefin, 'day');
1651 if ($memberstatic->hasDelay()) {
1652 $textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil(getWarningDelay('member', 'subscription') / 60 / 60 / 24) >= 0 ? '+' : '').ceil(getWarningDelay('member', 'subscription') / 60 / 60 / 24).' '.$langs->trans("days").')';
1653 $s .= " ".img_warning($langs->trans("SubscriptionLate").$textlate);
1654 }
1655 } else {
1656 if (!empty($obj->subscription)) {
1657 $s .= '<span class="opacitymedium">'.$langs->trans("SubscriptionNotReceived").'</span>';
1658 if ($obj->status > 0) {
1659 $s .= " ".img_warning();
1660 }
1661 } else {
1662 $s .= '<span class="opacitymedium">'.$langs->trans("SubscriptionNotNeeded").'</span>';
1663 }
1664 }
1665 print '<td class="nowraponall center tdoverflowmax150" title="'.dolPrintHTMLForAttribute(dol_string_nohtmltag($s)).'">';
1666 print $s;
1667 print '</td>';
1668 if (!$i) {
1669 $totalarray['nbfield']++;
1670 }
1671 }
1672 // Status
1673 if (!empty($arrayfields['d.statut']['checked'])) {
1674 print '<td class="nowrap center">';
1675 print $memberstatic->LibStatut($obj->status, $obj->subscription, $datefin, 5);
1676 print '</td>';
1677 if (!$i) {
1678 $totalarray['nbfield']++;
1679 }
1680 }
1681 // Action column
1682 if (!$conf->main_checkbox_left_column) {
1683 print '<td class="center">';
1684 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1685 $selected = 0;
1686 if (in_array($obj->rowid, $arrayofselected)) {
1687 $selected = 1;
1688 }
1689 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1690 }
1691 print '</td>';
1692 if (!$i) {
1693 $totalarray['nbfield']++;
1694 }
1695 }
1696
1697 print '</tr>'."\n";
1698 }
1699 $i++;
1700}
1701
1702// Show total line
1703include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1704
1705
1706// If no record found
1707if ($num == 0) {
1708 $colspan = 1;
1709 foreach ($arrayfields as $key => $val) {
1710 if (!empty($val['checked'])) {
1711 $colspan++;
1712 }
1713 }
1714 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1715}
1716
1717$db->free($resql);
1718
1719$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1720$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1721print $hookmanager->resPrint;
1722
1723print '</table>'."\n";
1724print '</div>'."\n";
1725
1726print '</form>'."\n";
1727
1728if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1729 $hidegeneratedfilelistifempty = 1;
1730 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1731 $hidegeneratedfilelistifempty = 0;
1732 }
1733
1734 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1735 $formfile = new FormFile($db);
1736
1737 // Show list of available documents
1738 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1739 $urlsource .= str_replace('&amp;', '&', $param);
1740
1741 $filedir = $diroutputmassaction;
1742 $genallowed = $permissiontoread;
1743 $delallowed = $permissiontoadd;
1744
1745 print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1746}
1747
1748// End of page
1749llxFooter();
1750$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage members of a foundation.
const STATUS_EXCLUDED
Excluded.
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated (membership end and was not renew)
const STATUS_VALIDATED
Validated status.
Class to manage members type.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:126
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:635
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=2, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dol_print_phone($phone, $countrycode='', $contactid=0, $socid=0, $addlink='', $separ="&nbsp;", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_natural_search_phone($db, $fields, $value, $nofirstand=0)
Build a natural_search() SQL fragment for a phone/fax field, tolerant of the international storage fo...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.