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