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