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