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