dolibarr 23.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2021 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2024 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
6 * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
7 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
9 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
10 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.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
32// Load Dolibarr environment
33require '../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
42if (isModEnabled('category')) {
43 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
44}
45
46// Load translation files required by page
47$langs->loadLangs(array('users', 'companies', 'hrm', 'salaries'));
48
49$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
50$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
51$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
52$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
53$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
54$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
56$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
57$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
58$mode = GETPOST("mode", 'aZ');
59
60// Security check (for external users)
61$socid = 0;
62if ($user->socid > 0) {
63 $socid = $user->socid;
64}
65
66// Load variable for pagination
67$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
68$sortfield = GETPOST('sortfield', 'aZ09comma');
69$sortorder = GETPOST('sortorder', 'aZ09comma');
70$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
71if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
72 // If $page is not defined, or '' or -1 or if we click on clear filters
73 $page = 0;
74}
75$offset = $limit * $page;
76$pageprev = $page - 1;
77$pagenext = $page + 1;
78
79// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
80$object = new User($db);
81$extrafields = new ExtraFields($db);
82$diroutputmassaction = $conf->user->dir_output.'/temp/massgeneration/'.$user->id;
83$hookmanager->initHooks(array('userlist'));
84
85// Fetch optionals attributes and labels
86$extrafields->fetch_name_optionals_label($object->table_element);
87
88$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
89
90if (!$sortfield) {
91 $sortfield = "u.login";
92}
93if (!$sortorder) {
94 $sortorder = "ASC";
95}
96
97// Initialize array of search criteria
98$search_all = trim(GETPOST('search_all', 'alphanohtml'));
99$search = array();
100foreach ($object->fields as $key => $val) {
101 if (GETPOST('search_'.$key, 'alpha') !== '') {
102 $search[$key] = GETPOST('search_'.$key, 'alpha');
103 }
104 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
105 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
106 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
107 }
108}
109
110$userstatic = new User($db);
111$companystatic = new Societe($db);
112$form = new Form($db);
113
114// List of fields to search into when doing a "search in all"
115$fieldstosearchall = array(
116 'u.login' => "Login",
117 'u.lastname' => "Lastname",
118 'u.firstname' => "Firstname",
119 'u.accountancy_code' => "AccountancyCode",
120 'u.office_phone' => "PhonePro",
121 'u.user_mobile' => "PhoneMobile",
122 'u.email' => "EMail",
123 'co.label' => "Country",
124 'u.note_public' => "NotePublic",
125 'u.note_private' => "NotePrivate"
126);
127if (isModEnabled('api')) {
128 $fieldstosearchall['u.api_key'] = "ApiKey";
129}
130
131$permissiontoreadhr = $user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write');
132$permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write');
133
134// Definition of fields for list
135$arrayfields = array(
136 'u.rowid' => array('label' => "TechnicalID", 'checked' => '-1', 'position' => 5),
137 'u.login' => array('label' => "Login", 'checked' => '1', 'position' => 10),
138 'u.lastname' => array('label' => "Lastname", 'checked' => '1', 'position' => 15),
139 'u.firstname' => array('label' => "Firstname", 'checked' => '1', 'position' => 20),
140 'u.entity' => array('label' => "Entity", 'checked' => '1', 'position' => 50, 'enabled' => (string) (int) (isModEnabled('multicompany') && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE'))),
141 'u.gender' => array('label' => "Gender", 'checked' => '0', 'position' => 22),
142 'u.employee' => array('label' => "Employee", 'checked' => ($contextpage == 'employeelist' ? '1' : '0'), 'position' => 25),
143 'u.fk_user' => array('label' => "HierarchicalResponsible", 'checked' => '1', 'position' => 27, 'csslist' => 'maxwidth150'),
144 'u.accountancy_code' => array('label' => "AccountancyCode", 'checked' => '0', 'position' => 30),
145 'u.office_phone' => array('label' => "PhonePro", 'checked' => '1', 'position' => 31),
146 'u.user_mobile' => array('label' => "PhoneMobile", 'checked' => '1', 'position' => 32),
147 'u.email' => array('label' => "EMail", 'checked' => '1', 'position' => 35),
148 'co.label' => array('label' => "Country", 'checked' => '0', 'position' => 37),
149 'u.api_key' => array('label' => "ApiKey", 'checked' => '0', 'position' => 40, "enabled" => (string) (int) (isModEnabled('api') && $user->admin)),
150 'u.fk_soc' => array('label' => "Company", 'checked' => ($contextpage == 'employeelist' ? '0' : '1'), 'position' => 45),
151 'u.ref_employee' => array('label' => "RefEmployee", 'checked' => '-1', 'position' => 50, 'enabled' => (string) (int) (isModEnabled('hrm') && $permissiontoreadhr)),
152 'u.national_registration_number' => array('label' => "NationalRegistrationNumber", 'checked' => '-1', 'position' => 51, 'enabled' => (string) (int) (isModEnabled('hrm') && $permissiontoreadhr)),
153 'u.job' => array('label' => "PostOrFunction", 'checked' => '-1', 'position' => 60),
154 'u.salary' => array('label' => "Salary", 'checked' => '-1', 'position' => 80, 'enabled' => (string) (int) (isModEnabled('salaries') && $user->hasRight("salaries", "readall")), 'isameasure' => 1),
155 'u.thm' => array('label' => "THM", 'langs' => 'salaries', 'checked' => '-1', 'position' => 82, 'enabled' => '1', 'isameasure' => 1),
156 'u.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 500),
157 'date_modification' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 500),
158 'u.import_key' => array('label' => "ImportId", 'checked' => '-1', 'position' => 800, 'enabled' => '1'),
159 'u.statut' => array('label' => "Status", 'checked' => '1', 'position' => 1000),
160);
161
162if (getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
163 $arrayfields['u.datelastlogin'] = array('label' => "LastConnexion", 'checked' => '1', 'position' => 100);
164 $arrayfields['u.datepreviouslogin'] = array('label' => "PreviousConnexion", 'checked' => '0', 'position' => 110);
165}
166
167// Extra fields
168include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
169
170$object->fields = dol_sort_array($object->fields, 'position');
171$arrayfields = dol_sort_array($arrayfields, 'position');
172
173// Init search fields
174$search_all = trim(GETPOST('search_all', 'alphanohtml'));
175$search_user = GETPOST('search_user', 'alpha');
176$search_rowid = GETPOST('search_rowid', 'alpha');
177$search_login = GETPOST('search_login', 'alpha');
178$search_lastname = GETPOST('search_lastname', 'alpha');
179$search_firstname = GETPOST('search_firstname', 'alpha');
180$search_gender = GETPOST('search_gender', 'alpha');
181$search_employee = GETPOST('search_employee', 'alpha');
182$search_accountancy_code = GETPOST('search_accountancy_code', 'alpha');
183$search_phonepro = GETPOST('search_phonepro', 'alpha');
184$search_phonemobile = GETPOST('search_phonemobile', 'alpha');
185$search_email = GETPOST('search_email', 'alpha');
186$search_country = GETPOST('search_country', 'alpha');
187$search_api_key = GETPOST('search_api_key', 'alphanohtml');
188$search_status = GETPOST('search_status', 'intcomma');
189$search_thirdparty = GETPOST('search_thirdparty', 'alpha');
190$search_job = GETPOST('search_job', 'alpha');
191$search_warehouse = GETPOST('search_warehouse', 'alpha');
192$search_supervisor = GETPOST('search_supervisor', 'intcomma');
193$search_categ = GETPOST("search_categ", 'intcomma');
194$search_datelastlogin = GETPOSTDATE('search_datelastlogin', '', 'tzuserrel');
195$search_datepreviouslogin = GETPOSTDATE('search_datepreviouslogin', '', 'tzuserrel');
196
197$searchCategoryUserOperator = 0;
198if (GETPOSTISSET('formfilteraction')) {
199 $searchCategoryUserOperator = GETPOSTINT('search_category_user_operator');
200} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
201 $searchCategoryUserOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
202}
203$searchCategoryUserList = GETPOST('search_category_user_list', 'array:int');
204$catid = GETPOSTINT('catid');
205if (!empty($catid) && empty($searchCategoryUserList)) {
206 $searchCategoryUserList = array($catid);
207}
208$catid = GETPOSTINT('catid');
209if (!empty($catid) && empty($search_categ)) {
210 $search_categ = $catid;
211}
212
213// Default search
214if ($search_status == '' && empty($search_all)) {
215 $search_status = '1';
216}
217if ($contextpage == 'employeelist' && !GETPOSTISSET('search_employee')) {
218 $search_employee = 1;
219}
220
221// Define value to know what current user can do on users
222$permissiontoadd = (isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight("user", "user", "write")));
223$canreaduser = (!empty($user->admin) || $user->hasRight("user", "user", "read"));
224$canedituser = $permissiontoadd;
225$candisableuser = (isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight("user", "user", "delete")));
226$canreadgroup = $canreaduser;
227$caneditgroup = $canedituser;
228if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
229 $canreadgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "read"));
230 $caneditgroup = (isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight("user", "group_advance", "write")));
231}
232
233$error = 0;
234
235// Permission to list
236if (isModEnabled('salaries') && $contextpage == 'employeelist' && $search_employee == 1) {
237 if (!$user->hasRight("salaries", "read")) {
239 }
240} else {
241 if (!$user->hasRight("user", "user", "read") && empty($user->admin)) {
243 }
244}
245
246$childids = $user->getAllChildIds(1);
247
248
249/*
250 * Actions
251 */
252
253if (GETPOST('cancel', 'alpha')) {
254 $action = 'list';
255 $massaction = '';
256}
257if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
258 $massaction = '';
259}
260
261$parameters = array('arrayfields' => &$arrayfields);
262$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
263if ($reshook < 0) {
264 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
265}
266
267if (empty($reshook)) {
268 // Selection of new fields
269 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
270
271 // Purge search criteria
272 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
273 $search_user = "";
274 $search_rowid = "";
275 $search_login = "";
276 $search_lastname = "";
277 $search_firstname = "";
278 $search_gender = "";
279 $search_employee = "";
280 $search_accountancy_code = "";
281 $search_phonepro = "";
282 $search_phonemobile = "";
283 $search_email = "";
284 $search_country = "";
285 $search_status = "";
286 $search_thirdparty = "";
287 $search_job = "";
288 $search_warehouse = "";
289 $search_supervisor = "";
290 $search_api_key = "";
291 $search_categ = 0;
292 $search_all = '';
293 $toselect = array();
294 $search_array_options = array();
295 if (getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
296 $search_datelastlogin = "";
297 $search_datepreviouslogin = "";
298 }
299 }
300 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
301 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
302 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
303 }
304
305 // Mass actions
306 $objectclass = 'User';
307 $objectlabel = 'User';
308 $uploaddir = $conf->user->dir_output;
309
310 global $error;
311
312 // Disable or Enable records
313 if (!$error && ($massaction == 'disable' || $massaction == 'reactivate') && $permissiontoadd) {
314 $objecttmp = new User($db);
315
316 $db->begin();
317
318 $nbok = 0;
319 foreach ($toselect as $toselectid) {
320 if ($toselectid == $user->id) {
321 setEventMessages($langs->trans($massaction == 'disable' ? 'CantDisableYourself' : 'CanEnableYourself'), null, 'errors');
322 $error++;
323 break;
324 }
325
326 $result = $objecttmp->fetch($toselectid);
327 if ($result > 0) {
328 if ($objecttmp->admin) {
329 setEventMessages($langs->trans($massaction == 'disable' ? 'CantDisableAnAdminUserWithMassActions' : 'CantEnableAnAdminUserWithMassActions', $objecttmp->login), null, 'errors');
330 $error++;
331 break;
332 }
333
334 $result = $objecttmp->setstatus($massaction == 'disable' ? 0 : 1);
335 if ($result == 0) {
336 // Nothing is done
337 } elseif ($result < 0) {
338 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
339 $error++;
340 break;
341 } else {
342 $nbok++;
343 }
344 } else {
345 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
346 $error++;
347 break;
348 }
349 }
350
351 if (!$error && !empty($conf->file->main_limit_users)) {
352 $nb = $object->getNbOfUsers("active");
353 if ($nb >= $conf->file->main_limit_users) {
354 $error++;
355 setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors');
356 }
357 }
358
359 if (!$error) {
360 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
361 $db->commit();
362 } else {
363 $db->rollback();
364 }
365
366 $massaction = '';
367 }
368
369 // Generic mass actions
370 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
371}
372
373
374/*
375 * View
376 */
377
378$formother = new FormOther($db);
379$user2 = new User($db);
380
381$help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios|DE:Modul_Benutzer';
382if ($contextpage == 'employeelist' && $search_employee == 1) {
383 $title = $langs->trans("Employees");
384} else {
385 $title = $langs->trans("Users");
386}
387$morejs = array();
388$morecss = array();
389$morehtmlright = "";
390
391// Build and execute select
392// --------------------------------------------------------------------
393$sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.office_phone, u.user_mobile, u.email, u.api_key, u.accountancy_code, u.gender, u.employee, u.photo,";
394$sql .= " u.fk_user,";
395$sql .= " u.ref_employee, u.national_registration_number, u.job, u.salary, u.thm, u.datelastlogin, u.datepreviouslogin,";
396$sql .= " u.datestartvalidity, u.dateendvalidity,";
397$sql .= " u.ldap_sid, u.statut as status, u.entity, u.import_key,";
398$sql .= " GREATEST(u.tms, ef.tms) as date_modification, u.datec as date_creation,";
399$sql .= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.office_phone as ofice_phone2, u2.user_mobile as user_mobile2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2, u2.statut as status2,";
400$sql .= " s.nom as name, s.canvas,";
401$sql .= " co.code as country_code, co.label as country_label";
402// Add fields from extrafields
403if (!empty($extrafields->attributes[$object->table_element]['label'])) {
404 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
405 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
406 }
407}
408// Add fields from hooks
409$parameters = array();
410$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
411$sql .= $hookmanager->resPrint;
412$sql = preg_replace('/,\s*$/', '', $sql);
413
414$sqlfields = $sql; // $sql fields to remove for count total
415
416$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as u";
417$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (u.rowid = ef.fk_object)";
418$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
419$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
420$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON u.fk_country = co.rowid";
421// Add table from hooks
422$parameters = array();
423$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
424$sql .= $hookmanager->resPrint;
425if ($reshook > 0) {
426 $sql .= $hookmanager->resPrint;
427}
428$sql .= " WHERE u.entity IN (".getEntity($object->element).")";
429if ($socid > 0) {
430 $sql .= " AND u.fk_soc = ".((int) $socid);
431}
432//if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
433if ($search_supervisor > 0) {
434 $sql .= " AND u.fk_user IN (".$db->sanitize($search_supervisor).")";
435}
436if ($search_thirdparty != '') {
437 $sql .= natural_search(array('s.nom'), $search_thirdparty);
438}
439if ($search_warehouse > 0) {
440 $sql .= natural_search(array('u.fk_warehouse'), $search_warehouse);
441}
442if ($search_rowid != '') {
443 $sql .= natural_search("u.rowid", $search_rowid, 1);
444}
445if ($search_login != '') {
446 $sql .= natural_search("u.login", $search_login);
447}
448if ($search_lastname != '') {
449 $sql .= natural_search("u.lastname", $search_lastname);
450}
451if ($search_firstname != '') {
452 $sql .= natural_search("u.firstname", $search_firstname);
453}
454if ($search_gender != '' && $search_gender != '-1') {
455 $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman
456}
457if (is_numeric($search_employee) && $search_employee >= 0) {
458 $sql .= ' AND u.employee = '.(int) $search_employee;
459}
460if ($search_accountancy_code != '') {
461 $sql .= natural_search("u.accountancy_code", $search_accountancy_code);
462}
463if ($search_phonepro != '') {
464 $sql .= natural_search("u.office_phone", $search_phonepro);
465}
466if ($search_phonemobile != '') {
467 $sql .= natural_search("u.user_mobile", $search_phonemobile);
468}
469if ($search_email != '') {
470 $sql .= natural_search("u.email", $search_email);
471}
472if ($search_country != '') {
473 $sql .= " AND u.fk_country IN (".$db->sanitize($search_country).')';
474}
475if ($search_api_key != '') {
476 $sql .= natural_search("u.api_key", $search_api_key);
477}
478if ($search_job != '') {
479 $sql .= natural_search(array('u.job'), $search_job);
480}
481if ($search_status != '' && $search_status >= 0) {
482 $sql .= " AND u.statut IN (".$db->sanitize($search_status).")";
483}
484if ($search_all) {
485 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
486}
487// Search for tag/category ($searchCategoryUserList is an array of ID)
488$searchCategoryUserList = array($search_categ);
489if (!empty($searchCategoryUserList)) {
490 $searchCategoryUserSqlList = array();
491 $listofcategoryid = '';
492 foreach ($searchCategoryUserList as $searchCategoryUser) {
493 if (intval($searchCategoryUser) == -2) {
494 $searchCategoryUserSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)";
495 } elseif (intval($searchCategoryUser) > 0) {
496 if ($searchCategoryUserOperator == 0) {
497 $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie = ".((int) $searchCategoryUser).")";
498 } else {
499 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryUser);
500 }
501 }
502 }
503 if ($listofcategoryid) {
504 $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
505 }
506 if ($searchCategoryUserOperator == 1) {
507 if (!empty($searchCategoryUserSqlList)) {
508 $sql .= " AND (".implode(' OR ', $searchCategoryUserSqlList).")";
509 }
510 } else {
511 if (!empty($searchCategoryUserSqlList)) {
512 $sql .= " AND (".implode(' AND ', $searchCategoryUserSqlList).")";
513 }
514 }
515}
516if ($search_warehouse > 0) {
517 $sql .= " AND u.fk_warehouse = ".((int) $search_warehouse);
518}
519if (isModEnabled('salaries') && $contextpage == 'employeelist' && !$user->hasRight("salaries", "readall")) {
520 $sql .= " AND u.rowid IN (".$db->sanitize(implode(',', $childids)).")";
521}
522// Add where from extra fields
523include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
524// Add where from hooks
525$parameters = array();
526$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
527$sql .= $hookmanager->resPrint;
528
529// Count total nb of records
530$nbtotalofrecords = '';
531if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
532 /* The fast and low memory method to get and count full list converts the sql into a sql count */
533 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
534 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
535 $resql = $db->query($sqlforcount);
536 if ($resql) {
537 $objforcount = $db->fetch_object($resql);
538 $nbtotalofrecords = $objforcount->nbtotalofrecords;
539 } else {
540 dol_print_error($db);
541 }
542
543 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
544 $page = 0;
545 $offset = 0;
546 }
547 $db->free($resql);
548}
549
550// Complete request and execute it with limit
551$sql .= $db->order($sortfield, $sortorder);
552if ($limit) {
553 $sql .= $db->plimit($limit + 1, $offset);
554}
555
556$resql = $db->query($sql);
557if (!$resql) {
558 dol_print_error($db);
559 exit;
560}
561
562$num = $db->num_rows($resql);
563
564// Direct jump if only one record found
565if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
566 $obj = $db->fetch_object($resql);
567 $id = $obj->rowid;
568 header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id);
569 exit;
570}
571
572// Output page
573// --------------------------------------------------------------------
574
575llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-user page-list');
576
577$arrayofselected = is_array($toselect) ? $toselect : array();
578
579$param = '';
580if (!empty($mode)) {
581 $param .= '&mode='.urlencode($mode);
582}
583if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
584 $param .= '&contextpage='.urlencode($contextpage);
585}
586if ($limit > 0 && $limit != $conf->liste_limit) {
587 $param .= '&limit='.((int) $limit);
588}
589if ($optioncss != '') {
590 $param .= '&optioncss='.urlencode($optioncss);
591}
592if ($search_all != '') {
593 $param .= '&search_all='.urlencode($search_all);
594}
595if ($search_user != '') {
596 $param .= "&search_user=".urlencode($search_user);
597}
598if ($search_rowid != '') {
599 $param .= "&search_rowid=".urlencode($search_rowid);
600}
601if ($search_login != '') {
602 $param .= "&search_login=".urlencode($search_login);
603}
604if ($search_lastname != '') {
605 $param .= "&search_lastname=".urlencode($search_lastname);
606}
607if ($search_firstname != '') {
608 $param .= "&search_firstname=".urlencode($search_firstname);
609}
610if ($search_gender != '' && $search_gender != '-1') {
611 $param .= "&search_gender=".urlencode($search_gender);
612}
613if ($search_employee != '' && $search_employee != '-1') {
614 $param .= "&search_employee=".urlencode($search_employee);
615}
616if ($search_accountancy_code != '') {
617 $param .= "&search_accountancy_code=".urlencode($search_accountancy_code);
618}
619if ($search_phonepro != '') {
620 $param .= "&search_phonepro=".urlencode($search_phonepro);
621}
622if ($search_phonemobile != '') {
623 $param .= "&search_phonemobile=".urlencode($search_phonemobile);
624}
625if ($search_email != '') {
626 $param .= "&search_email=".urlencode($search_email);
627}
628if ($search_country != '') {
629 $param .= "&search_country=".urlencode($search_country);
630}
631if ($search_api_key != '') {
632 $param .= "&search_api_key=".urlencode($search_api_key);
633}
634if ($search_supervisor > 0) {
635 $param .= "&search_supervisor=".urlencode($search_supervisor);
636}
637if ($search_status != '') {
638 $param .= "&search_status=".urlencode($search_status);
639}
640if ($search_categ > 0) {
641 $param .= '&search_categ='.urlencode((string) ($search_categ));
642}
643if ($search_warehouse > 0) {
644 $param .= '&search_warehouse='.urlencode($search_warehouse);
645}
646// Add $param from extra fields
647include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
648
649// List of mass actions available
650$arrayofmassactions = array();
651if ($permissiontoadd) {
652 $arrayofmassactions['disable'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("DisableUser");
653}
654if ($permissiontoadd) {
655 $arrayofmassactions['reactivate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Reactivate");
656}
657if (isModEnabled('category') && $permissiontoadd) {
658 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
659}
660if ($permissiontoadd) {
661 $arrayofmassactions['presetsupervisor'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("SetSupervisor");
662}
663//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
664
665if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'presetsupervisor'))) {
666 $arrayofmassactions = array();
667}
668$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
669
670print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
671if ($optioncss != '') {
672 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
673}
674print '<input type="hidden" name="token" value="'.newToken().'">';
675print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
676print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
677print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
678print '<input type="hidden" name="page" value="'.$page.'">';
679print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
680print '<input type="hidden" name="page_y" value="">';
681print '<input type="hidden" name="mode" value="'.$mode.'">';
682
683$url = DOL_URL_ROOT.'/user/card.php?action=create'.($contextpage == 'employeelist' ? '&search_employee=1' : '').'&leftmenu=';
684if (!empty($socid)) {
685 $url .= '&socid='.urlencode((string) ($socid));
686}
687
688$newcardbutton = '';
689$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
690$newcardbutton .= dolGetButtonTitle($langs->trans('HierarchicView'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/user/hierarchy.php?mode=hierarchy'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', (($mode == 'hierarchy') ? 2 : 1), array('morecss' => 'reposition'));
691$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
692$newcardbutton .= dolGetButtonTitleSeparator();
693$newcardbutton .= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', $url, '', (int) $permissiontoadd);
694
695/*$moreparam = array('morecss'=>'btnTitleSelected');
696$morehtmlright = dolGetButtonTitle($langs->trans("List"), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php'.(($search_status != '' && $search_status >= 0) ? '?search_status='.$search_status : ''), '', 1, $moreparam);
697$moreparam = array('morecss'=>'marginleftonly');
698$morehtmlright .= dolGetButtonTitle($langs->trans("HierarchicView"), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/user/hierarchy.php'.(($search_status != '' && $search_status >= 0) ? '?search_status='.$search_status : ''), '', 1, $moreparam);
699*/
700print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, $morehtmlright.' '.$newcardbutton, '', $limit, 0, 0, 1);
701
702
703
704// Add code for pre mass action (confirmation or email presend form)
705$topicmail = "SendUserRef";
706$modelmail = "user";
707$objecttmp = new User($db);
708$trackid = 'use'.$object->id;
709include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
710
711if (!empty($catid)) {
712 print "<div id='ways'>";
713 $c = new Categorie($db);
714 $ways = $c->print_all_ways('auto', 'user/list.php');
715 print " &gt; ".$ways[0]."<br>\n";
716 print "</div><br>";
717}
718
719if ($search_all) {
720 $setupstring = '';
721 foreach ($fieldstosearchall as $key => $val) {
722 $fieldstosearchall[$key] = $langs->trans($val);
723 $setupstring .= $key."=".$val.";";
724 }
725 print '<!-- Search done like if USER_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
726 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
727}
728
729$moreforfilter = '';
730/*$moreforfilter.='<div class="divsearchfield">';
731 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
732 $moreforfilter.= '</div>';*/
733
734// Filter on categories
735if (isModEnabled('category') && $user->hasRight("categorie", "read")) {
736 $moreforfilter .= '<div class="divsearchfield">';
737 $tmptitle = $langs->trans('Category');
738 $moreforfilter .= img_picto($langs->trans("Category"), 'category', 'class="pictofixedwidth"').$formother->select_categories(Categorie::TYPE_USER, $search_categ, 'search_categ', 1, $tmptitle);
739 $moreforfilter .= '</div>';
740}
741// Filter on warehouse
742if (isModEnabled('stock') && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE_USER')) {
743 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
744 $formproduct = new FormProduct($db);
745 $moreforfilter .= '<div class="divsearchfield">';
746 $tmptitle = $langs->trans('Warehouse');
747 $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle);
748 $moreforfilter .= '</div>';
749}
750
751$parameters = array();
752$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
753if (empty($reshook)) {
754 $moreforfilter .= $hookmanager->resPrint;
755} else {
756 $moreforfilter = $hookmanager->resPrint;
757}
758
759if (!empty($moreforfilter)) {
760 print '<div class="liste_titre liste_titre_bydiv centpercent">';
761 print $moreforfilter;
762 print '</div>';
763}
764
765$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
766$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
767$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
768$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
769
770print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
771print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
772
773// Fields title search
774// --------------------------------------------------------------------
775print '<tr class="liste_titre_filter">';
776// Action column
777if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
778 print '<td class="liste_titre center maxwidthsearch">';
779 $searchpicto = $form->showFilterButtons('left');
780 print $searchpicto;
781 print '</td>';
782}
783if (!empty($arrayfields['u.rowid']['checked'])) {
784 print '<td class="liste_titre"><input type="text" name="search_rowid" class="maxwidth50" value="'.$search_rowid.'"></td>';
785}
786if (!empty($arrayfields['u.login']['checked'])) {
787 print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
788}
789if (!empty($arrayfields['u.lastname']['checked'])) {
790 print '<td class="liste_titre"><input type="text" name="search_lastname" class="maxwidth50" value="'.$search_lastname.'"></td>';
791}
792if (!empty($arrayfields['u.firstname']['checked'])) {
793 print '<td class="liste_titre"><input type="text" name="search_firstname" class="maxwidth50" value="'.$search_firstname.'"></td>';
794}
795if (!empty($arrayfields['u.gender']['checked'])) {
796 print '<td class="liste_titre center">';
797 $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother"));
798 print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
799 print '</td>';
800}
801if (!empty($arrayfields['u.employee']['checked'])) {
802 print '<td class="liste_titre">';
803 print $form->selectyesno('search_employee', $search_employee, 1, false, 1);
804 print '</td>';
805}
806// Supervisor
807if (!empty($arrayfields['u.fk_user']['checked'])) {
808 print '<td class="liste_titre">';
809 print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth125');
810 print '</td>';
811}
812if (!empty($arrayfields['u.accountancy_code']['checked'])) {
813 print '<td class="liste_titre"><input type="text" name="search_accountancy_code" class="maxwidth50" value="'.$search_accountancy_code.'"></td>';
814}
815if (!empty($arrayfields['u.office_phone']['checked'])) {
816 print '<td class="liste_titre"><input type="text" name="search_phonepro" class="maxwidth50" value="'.$search_phonepro.'"></td>';
817}
818if (!empty($arrayfields['u.user_mobile']['checked'])) {
819 print '<td class="liste_titre"><input type="text" name="search_phonemobile" class="maxwidth50" value="'.$search_phonemobile.'"></td>';
820}
821if (!empty($arrayfields['u.email']['checked'])) {
822 print '<td class="liste_titre"><input type="text" name="search_email" class="maxwidth75" value="'.$search_email.'"></td>';
823}
824if (!empty($arrayfields['co.label']['checked'])) {
825 print '<td class="liste_titre">';
826 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
827 print '</td>';
828}
829if (!empty($arrayfields['u.api_key']['checked'])) {
830 print '<td class="liste_titre"><input type="text" name="search_api_key" class="maxwidth50" value="'.$search_api_key.'"></td>';
831}
832if (!empty($arrayfields['u.fk_soc']['checked'])) {
833 print '<td class="liste_titre"><input type="text" name="search_thirdparty" class="maxwidth75" value="'.$search_thirdparty.'"></td>';
834}
835if (!empty($arrayfields['u.entity']['checked'])) {
836 print '<td class="liste_titre"></td>';
837}
838if (!empty($arrayfields['u.ref_employee']['checked'])) {
839 print '<td class="liste_titre"></td>';
840}
841if (!empty($arrayfields['u.national_registration_number']['checked'])) {
842 print '<td class="liste_titre"></td>';
843}
844if (!empty($arrayfields['u.job']['checked'])) {
845 print '<td class="liste_titre"><input type="text" name="search_job" class="maxwidth75" value="'.$search_job.'"></td>';
846}
847if (!empty($arrayfields['u.salary']['checked'])) {
848 print '<td class="liste_titre"></td>';
849}
850if (!empty($arrayfields['u.thm']['checked'])) {
851 print '<td class="liste_titre"></td>';
852}
853if (!empty($arrayfields['u.datelastlogin']['checked']) && getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
854 print '<td class="liste_titre"></td>';
855}
856if (!empty($arrayfields['u.datepreviouslogin']['checked']) && getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
857 print '<td class="liste_titre"></td>';
858}
859// Extra fields
860include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
861// Fields from hook
862$parameters = array('arrayfields' => $arrayfields);
863$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
864print $hookmanager->resPrint;
865if (!empty($arrayfields['u.datec']['checked'])) {
866 // Date creation
867 print '<td class="liste_titre">';
868 print '</td>';
869}
870if (!empty($arrayfields['date_modification']['checked'])) {
871 // Date modification
872 print '<td class="liste_titre">';
873 print '</td>';
874}
875if (!empty($arrayfields['u.import_key']['checked'])) {
876 // Import ID
877 print '<td class="liste_titre">';
878 print '</td>';
879}
880if (!empty($arrayfields['u.statut']['checked'])) {
881 // Status
882 print '<td class="liste_titre center parentonrightofpage">';
883 print $form->selectarray('search_status', array('-1' => '', '0' => $langs->trans('Disabled'), '1' => $langs->trans('Enabled')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
884 print '</td>';
885}
886// Action column
887if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
888 print '<td class="liste_titre maxwidthsearch">';
889 $searchpicto = $form->showFilterButtons();
890 print $searchpicto;
891 print '</td>';
892}
893print '</tr>'."\n";
894
895$totalarray = array();
896$totalarray['nbfield'] = 0;
897
898// Fields title label
899// --------------------------------------------------------------------
900print '<tr class="liste_titre">';
901if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
902 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
903 $totalarray['nbfield']++;
904}
905if (!empty($arrayfields['u.rowid']['checked'])) {
906 // @phan-suppress-next-line PhanTypeInvalidDimOffset
907 print_liste_field_titre($arrayfields['u.rowid']['label'], $_SERVER['PHP_SELF'], "u.rowid", "", $param, "", $sortfield, $sortorder);
908 $totalarray['nbfield']++;
909}
910if (!empty($arrayfields['u.login']['checked'])) {
911 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER['PHP_SELF'], "u.login", "", $param, "", $sortfield, $sortorder);
912 $totalarray['nbfield']++;
913}
914if (!empty($arrayfields['u.lastname']['checked'])) {
915 print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", "", $param, "", $sortfield, $sortorder);
916 $totalarray['nbfield']++;
917}
918if (!empty($arrayfields['u.firstname']['checked'])) {
919 print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", "", $param, "", $sortfield, $sortorder);
920 $totalarray['nbfield']++;
921}
922if (!empty($arrayfields['u.gender']['checked'])) {
923 print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", "", $param, "", $sortfield, $sortorder, 'center ');
924 $totalarray['nbfield']++;
925}
926if (!empty($arrayfields['u.employee']['checked'])) {
927 print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", "", $param, "", $sortfield, $sortorder, 'center ');
928 $totalarray['nbfield']++;
929}
930if (!empty($arrayfields['u.fk_user']['checked'])) {
931 print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", "", $param, "", $sortfield, $sortorder);
932 $totalarray['nbfield']++;
933}
934if (!empty($arrayfields['u.accountancy_code']['checked'])) {
935 print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", "", $param, "", $sortfield, $sortorder);
936 $totalarray['nbfield']++;
937}
938if (!empty($arrayfields['u.office_phone']['checked'])) {
939 print_liste_field_titre("PhonePro", $_SERVER['PHP_SELF'], "u.office_phone", "", $param, "", $sortfield, $sortorder);
940 $totalarray['nbfield']++;
941}
942if (!empty($arrayfields['u.user_mobile']['checked'])) {
943 print_liste_field_titre("PhoneMobile", $_SERVER['PHP_SELF'], "u.user_mobile", "", $param, "", $sortfield, $sortorder);
944 $totalarray['nbfield']++;
945}
946if (!empty($arrayfields['u.email']['checked'])) {
947 print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", "", $param, "", $sortfield, $sortorder);
948 $totalarray['nbfield']++;
949}
950if (!empty($arrayfields['co.label']['checked'])) {
951 print_liste_field_titre("Country", $_SERVER['PHP_SELF'], "co.label", "", $param, "", $sortfield, $sortorder);
952 $totalarray['nbfield']++;
953}
954if (!empty($arrayfields['u.api_key']['checked'])) {
955 print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", "", $param, "", $sortfield, $sortorder);
956 $totalarray['nbfield']++;
957}
958if (!empty($arrayfields['u.fk_soc']['checked'])) {
959 print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", "", $param, "", $sortfield, $sortorder);
960 $totalarray['nbfield']++;
961}
962if (!empty($arrayfields['u.entity']['checked'])) {
963 print_liste_field_titre($arrayfields['u.entity']['label'], $_SERVER['PHP_SELF'], "u.entity", "", $param, "", $sortfield, $sortorder);
964 $totalarray['nbfield']++;
965}
966if (!empty($arrayfields['u.ref_employee']['checked'])) {
967 print_liste_field_titre("RefEmployee", $_SERVER['PHP_SELF'], "u.ref_employee", "", $param, "", $sortfield, $sortorder);
968 $totalarray['nbfield']++;
969}
970if (!empty($arrayfields['u.national_registration_number']['checked'])) {
971 print_liste_field_titre("NationalRegistrationNumber", $_SERVER['PHP_SELF'], "u.national_registration_number", "", $param, "", $sortfield, $sortorder);
972 $totalarray['nbfield']++;
973}
974if (!empty($arrayfields['u.job']['checked'])) {
975 print_liste_field_titre($arrayfields['u.job']['label'], $_SERVER['PHP_SELF'], "u.job", "", $param, "", $sortfield, $sortorder);
976 $totalarray['nbfield']++;
977}
978if (!empty($arrayfields['u.salary']['checked'])) {
979 print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", "", $param, "", $sortfield, $sortorder, 'right ');
980 $totalarray['nbfield']++;
981}
982if (!empty($arrayfields['u.thm']['checked'])) {
983 print_liste_field_titre("THM", $_SERVER['PHP_SELF'], "u.thm", '', $param, "", $sortfield, $sortorder, 'right ');
984 $totalarray['nbfield']++;
985}
986if (!empty($arrayfields['u.datelastlogin']['checked']) && getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
987 print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", "", $param, '', $sortfield, $sortorder, 'center ');
988 $totalarray['nbfield']++;
989}
990if (!empty($arrayfields['u.datepreviouslogin']['checked']) && getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
991 print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", "", $param, '', $sortfield, $sortorder, 'center ');
992 $totalarray['nbfield']++;
993}
994// Extra fields
995include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
996// Hook fields
997$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
998$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
999print $hookmanager->resPrint;
1000if (!empty($arrayfields['u.datec']['checked'])) {
1001 print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1002 $totalarray['nbfield']++;
1003}
1004if (!empty($arrayfields['date_modification']['checked'])) {
1005 print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "date_modification", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1006 $totalarray['nbfield']++;
1007}
1008if (!empty($arrayfields['import_key']['checked'])) {
1009 print_liste_field_titre("ImportId", $_SERVER["PHP_SELF"], "u.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1010 $totalarray['nbfield']++;
1011}
1012if (!empty($arrayfields['u.import_key']['checked'])) {
1013 print_liste_field_titre("ImportId", $_SERVER["PHP_SELF"], "u.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1014 $totalarray['nbfield']++;
1015}
1016if (!empty($arrayfields['u.statut']['checked'])) {
1017 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center ');
1018 $totalarray['nbfield']++;
1019}
1020// Action column
1021if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1022 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1023 $totalarray['nbfield']++;
1024}
1025print '</tr>'."\n";
1026
1027
1028// Detect if we need a fetch on each output line
1029$needToFetchEachLine = 0;
1030if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
1031 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
1032 if (!is_null($val) && preg_match('/\$object/', $val)) {
1033 $needToFetchEachLine++; // There is at least one compute field that use $object
1034 }
1035 }
1036}
1037
1038
1039// Loop on record
1040// --------------------------------------------------------------------
1041$i = 0;
1042$savnbfield = $totalarray['nbfield'];
1043$totalarray = array('val' => array('u.salary' => 0));
1044$totalarray['nbfield'] = 0;
1045$imaxinloop = ($limit ? min($num, $limit) : $num);
1046while ($i < $imaxinloop) {
1047 $obj = $db->fetch_object($resql);
1048 if (empty($obj)) {
1049 break; // Should not happen
1050 }
1051
1052 // Store properties in $object
1053 $object->setVarsFromFetchObj($obj);
1054
1055 $object->id = $obj->rowid;
1056 $object->admin = $obj->admin;
1057 $object->ref = (string) $obj->rowid;
1058 $object->login = $obj->login;
1059 $object->statut = $obj->status;
1060 $object->status = $obj->status;
1061 $object->office_phone = $obj->office_phone;
1062 $object->user_mobile = $obj->user_mobile;
1063 $object->job = $obj->job;
1064 $object->email = $obj->email;
1065 $object->gender = $obj->gender;
1066 $object->socid = $obj->fk_soc;
1067 $object->firstname = $obj->firstname;
1068 $object->lastname = $obj->lastname;
1069 $object->employee = $obj->employee;
1070 $object->photo = $obj->photo;
1071 $object->datestartvalidity = $db->jdate($obj->datestartvalidity);
1072 $object->dateendvalidity = $db->jdate($obj->dateendvalidity);
1073 $object->country_code = $obj->country_code;
1074 $object->country = $obj->country_label;
1075
1076 $li = $object->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
1077
1078 $canreadhrmdata = 0;
1079 if ((isModEnabled('salaries') && $user->hasRight("salaries", "read") && in_array($obj->rowid, $childids))
1080 || (isModEnabled('salaries') && $user->hasRight("salaries", "readall"))
1081 || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
1082 $canreadhrmdata = 1;
1083 }
1084 $canreadsecretapi = 0;
1085 if ($user->id == $obj->rowid || !empty($user->admin)) { // Current user or admin
1086 $canreadsecretapi = 1;
1087 }
1088
1089 if ($mode == 'kanban') {
1090 if ($i == 0) {
1091 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1092 print '<div class="box-flex-container kanban">';
1093 }
1094
1095 // Output Kanban
1096 $selected = -1;
1097 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1098 $selected = 0;
1099 if (in_array($object->id, $arrayofselected)) {
1100 $selected = 1;
1101 }
1102 }
1103 print $object->getKanbanView('', array('selected' => $selected));
1104 if ($i == ($imaxinloop - 1)) {
1105 print '</div>';
1106 print '</td></tr>';
1107 }
1108 } else {
1109 // Show here line of result
1110 $j = 0;
1111 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
1112 // Action column
1113 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1114 print '<td class="nowrap center">';
1115 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1116 $selected = 0;
1117 if (in_array($object->id, $arrayofselected)) {
1118 $selected = 1;
1119 }
1120 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1121 }
1122 print '</td>';
1123 if (!$i) {
1124 $totalarray['nbfield']++;
1125 }
1126 }
1127 // TechnicalID
1128 if (!empty($arrayfields['u.rowid']['checked'])) {
1129 print '<td class="nowraponall">'.dolPrintHTML((string) $obj->rowid).'</td>';
1130 if (!$i) {
1131 $totalarray['nbfield']++;
1132 }
1133 }
1134 // Login
1135 if (!empty($arrayfields['u.login']['checked'])) {
1136 print '<td class="nowraponall tdoverflowmax150">';
1137 print $li;
1138 if (isModEnabled('multicompany') && $obj->admin && !$obj->entity) {
1139 print img_picto($langs->trans("SuperAdministratorDesc"), 'superadmin', 'class="valignmiddle paddingright paddingleft"');
1140 } elseif ($obj->admin) {
1141 print img_picto($langs->trans("AdministratorDesc"), 'admin', 'class="valignmiddle paddingright paddingleft"');
1142 }
1143 print '</td>';
1144 if (!$i) {
1145 $totalarray['nbfield']++;
1146 }
1147 }
1148 // Lastname
1149 if (!empty($arrayfields['u.lastname']['checked'])) {
1150 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">'.dol_escape_htmltag($obj->lastname).'</td>';
1151 if (!$i) {
1152 $totalarray['nbfield']++;
1153 }
1154 }
1155 // Fistname
1156 if (!empty($arrayfields['u.firstname']['checked'])) {
1157 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">'.dol_escape_htmltag($obj->firstname).'</td>';
1158 if (!$i) {
1159 $totalarray['nbfield']++;
1160 }
1161 }
1162 // Gender
1163 if (!empty($arrayfields['u.gender']['checked'])) {
1164 print '<td class="center">';
1165 if ($obj->gender) {
1166 // Preparing gender's display if there is one
1167 $addgendertxt = '';
1168 switch ($obj->gender) {
1169 case 'man':
1170 $addgendertxt .= '<i class="fas fa-mars" title="'.dol_escape_htmltag($langs->trans("Gender".$obj->gender)).'"></i>';
1171 break;
1172 case 'woman':
1173 $addgendertxt .= '<i class="fas fa-venus" title="'.dol_escape_htmltag($langs->trans("Gender".$obj->gender)).'"></i>';
1174 break;
1175 case 'other':
1176 $addgendertxt .= '<i class="fas fa-transgender" title="'.dol_escape_htmltag($langs->trans("Gender".$obj->gender)).'"></i>';
1177 break;
1178 }
1179 print $addgendertxt;
1180 //print $langs->trans("Gender".$obj->gender);
1181 }
1182 print '</td>';
1183 if (!$i) {
1184 $totalarray['nbfield']++;
1185 }
1186 }
1187 // Employee yes/no
1188 if (!empty($arrayfields['u.employee']['checked'])) {
1189 print '<td class="center">'.yn($obj->employee).'</td>';
1190 if (!$i) {
1191 $totalarray['nbfield']++;
1192 }
1193 }
1194
1195 // Supervisor
1196 if (!empty($arrayfields['u.fk_user']['checked'])) {
1197 print '<td class="tdoverflowmax125">';
1198 if ($obj->login2) {
1199 $user2->id = $obj->id2;
1200 $user2->login = $obj->login2;
1201 $user2->lastname = $obj->lastname2;
1202 $user2->firstname = $obj->firstname2;
1203 $user2->gender = $obj->gender2;
1204 $user2->photo = $obj->photo2;
1205 $user2->admin = $obj->admin2;
1206 $user2->office_phone = $obj->office_phone;
1207 $user2->user_mobile = $obj->user_mobile;
1208 $user2->email = $obj->email2;
1209 $user2->socid = $obj->fk_soc2;
1210 $user2->statut = $obj->status2;
1211 $user2->status = $obj->status2;
1212 if (isModEnabled('multicompany') && $obj->admin2 && !$obj->entity2) {
1213 print img_picto($langs->trans("SuperAdministratorDesc"), 'superadmin', 'class="valignmiddle paddingright"');
1214 } elseif ($obj->admin2) {
1215 print img_picto($langs->trans("AdministratorDesc"), 'admin', 'class="valignmiddle paddingright"');
1216 }
1217 print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1);
1218 }
1219 print '</td>';
1220 if (!$i) {
1221 $totalarray['nbfield']++;
1222 }
1223 }
1224
1225 // Accountancy code
1226 if (!empty($arrayfields['u.accountancy_code']['checked'])) {
1227 print '<td>'.$obj->accountancy_code.'</td>';
1228 if (!$i) {
1229 $totalarray['nbfield']++;
1230 }
1231 }
1232
1233 // Phone
1234 if (!empty($arrayfields['u.office_phone']['checked'])) {
1235 print '<td class="tdoverflowmax125">'.dol_print_phone($obj->office_phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
1236 if (!$i) {
1237 $totalarray['nbfield']++;
1238 }
1239 }
1240 // Phone mobile
1241 if (!empty($arrayfields['u.user_mobile']['checked'])) {
1242 print '<td class="tdoverflowmax125">'.dol_print_phone($obj->user_mobile, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'mobile')."</td>\n";
1243 if (!$i) {
1244 $totalarray['nbfield']++;
1245 }
1246 }
1247 // Email
1248 if (!empty($arrayfields['u.email']['checked'])) {
1249 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->email).'">'.dol_print_email($obj->email, $obj->rowid, $obj->fk_soc, 1, 0, 0, 1)."</td>\n";
1250 if (!$i) {
1251 $totalarray['nbfield']++;
1252 }
1253 }
1254 // Country
1255 if (!empty($arrayfields['co.label']['checked'])) {
1256 print '<td class="tdoverflowmax150">'.$obj->country_label."</td>\n";
1257 if (!$i) {
1258 $totalarray['nbfield']++;
1259 }
1260 }
1261 // Api key
1262 if (!empty($arrayfields['u.api_key']['checked'])) {
1263 $api_key = dolDecrypt($obj->api_key);
1264 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($api_key).'">';
1265 if ($api_key) {
1266 if ($canreadsecretapi) {
1267 print '<span class="opacitymedium">';
1268 print showValueWithClipboardCPButton($object->api_key, 1, dol_trunc($api_key, 3)); // TODO Add an option to also reveal the hash, not only copy paste
1269 print '</span>';
1270 } else {
1271 print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1272 }
1273 }
1274 print '</td>';
1275 if (!$i) {
1276 $totalarray['nbfield']++;
1277 }
1278 }
1279 // User
1280 if (!empty($arrayfields['u.fk_soc']['checked'])) {
1281 print '<td class="tdoverflowmax150">';
1282 if ($obj->fk_soc > 0) {
1283 $companystatic->id = $obj->fk_soc;
1284 $companystatic->name = $obj->name;
1285 $companystatic->canvas = $obj->canvas;
1286 print $companystatic->getNomUrl(1);
1287 } elseif ($obj->ldap_sid) {
1288 print '<span class="opacitymedium">'.$langs->trans("DomainUser").'</span>';
1289 } else {
1290 print '<span class="opacitymedium">'.$langs->trans("InternalUser").'</span>';
1291 }
1292 print '</td>';
1293 if (!$i) {
1294 $totalarray['nbfield']++;
1295 }
1296 }
1297 // Multicompany enabled
1298 if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
1299 if (!empty($arrayfields['u.entity']['checked'])) {
1300 if (!$obj->entity) {
1301 $labeltouse = $langs->trans("AllEntities");
1302 } else {
1303 $mc->getInfo($obj->entity);
1304 $labeltouse = $mc->label;
1305 }
1306 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltouse).'">';
1307 print $labeltouse;
1308 print '</td>';
1309 if (!$i) {
1310 $totalarray['nbfield']++;
1311 }
1312 }
1313 }
1314
1315 // Ref employee
1316 if (!empty($arrayfields['u.ref_employee']['checked'])) {
1317 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->ref_employee).'">';
1318 print dol_escape_htmltag($obj->ref_employee);
1319 print '</td>';
1320 if (!$i) {
1321 $totalarray['nbfield']++;
1322 }
1323 }
1324 // National number
1325 if (!empty($arrayfields['u.national_registration_number']['checked'])) {
1326 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->national_registration_number).'">';
1327 print dol_escape_htmltag($obj->national_registration_number);
1328 print '</td>';
1329 if (!$i) {
1330 $totalarray['nbfield']++;
1331 }
1332 }
1333 // Job position
1334 if (!empty($arrayfields['u.job']['checked'])) {
1335 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->job).'">';
1336 print dol_escape_htmltag($obj->job);
1337 print '</td>';
1338 if (!$i) {
1339 $totalarray['nbfield']++;
1340 }
1341 }
1342
1343 // Salary
1344 if (!empty($arrayfields['u.salary']['checked'])) {
1345 print '<td class="nowraponall right amount">';
1346 if ($obj->salary) {
1347 if ($canreadhrmdata) {
1348 print price($obj->salary);
1349 } else {
1350 print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1351 }
1352 }
1353 print '</td>';
1354 if (!$i) {
1355 $totalarray['nbfield']++;
1356 }
1357 if (!$i) {
1358 $totalarray['pos'][$totalarray['nbfield']] = 'u.salary';
1359 }
1360 if (!isset($totalarray['val'])) {
1361 $totalarray['val'] = array();
1362 }
1363 if (!isset($totalarray['val']['u.salary'])) {
1364 $totalarray['val']['u.salary'] = 0;
1365 }
1366 $totalarray['val']['u.salary'] += $obj->salary;
1367 }
1368
1369 // Hourly rate
1370 if (!empty($arrayfields['u.thm']['checked'])) {
1371 print '<td class="nowraponall right amount">';
1372 if (!is_null($obj->thm)) {
1373 print price($obj->thm);
1374 }
1375 print '</td>';
1376 if (!$i) {
1377 $totalarray['nbfield']++;
1378 }
1379 }
1380
1381 // Date last login
1382 if (!empty($arrayfields['u.datelastlogin']['checked']) && getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
1383 print '<td class="nowraponall center">'.dol_print_date($db->jdate($obj->datelastlogin), "dayhour").'</td>';
1384 if (!$i) {
1385 $totalarray['nbfield']++;
1386 }
1387 }
1388 // Date previous login
1389 if (!empty($arrayfields['u.datepreviouslogin']['checked']) && getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) {
1390 print '<td class="nowraponall center">'.dol_print_date($db->jdate($obj->datepreviouslogin), "dayhour").'</td>';
1391 if (!$i) {
1392 $totalarray['nbfield']++;
1393 }
1394 }
1395
1396 // Extra fields
1397 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1398 // Fields from hook
1399 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1400 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1401 print $hookmanager->resPrint;
1402 // Date creation
1403 if (!empty($arrayfields['u.datec']['checked'])) {
1404 print '<td class="center nowraponall">';
1405 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1406 print '</td>';
1407 if (!$i) {
1408 $totalarray['nbfield']++;
1409 }
1410 }
1411 // Date modification
1412 if (!empty($arrayfields['date_modification']['checked'])) {
1413 print '<td class="center nowraponall">';
1414 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1415 print '</td>';
1416 if (!$i) {
1417 $totalarray['nbfield']++;
1418 }
1419 }
1420 // Import
1421 if (!empty($arrayfields['u.import_key']['checked'])) {
1422 print '<td class="center">'.dolPrintHTML($obj->import_key).'</td>';
1423 if (!$i) {
1424 $totalarray['nbfield']++;
1425 }
1426 }
1427 // Status
1428 if (!empty($arrayfields['u.statut']['checked'])) {
1429 print '<td class="center">'.$object->getLibStatut(5).'</td>';
1430 if (!$i) {
1431 $totalarray['nbfield']++;
1432 }
1433 }
1434 // Action column
1435 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1436 print '<td class="nowrap center">';
1437 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1438 $selected = 0;
1439 if (in_array($object->id, $arrayofselected)) {
1440 $selected = 1;
1441 }
1442 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1443 }
1444 print '</td>';
1445 if (!$i) {
1446 $totalarray['nbfield']++;
1447 }
1448 }
1449
1450 print '</tr>'."\n";
1451 }
1452
1453 $i++;
1454}
1455
1456// Show total line
1457include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1458
1459// If no record found
1460if ($num == 0) {
1461 $colspan = 1;
1462 foreach ($arrayfields as $key => $val) {
1463 if (!empty($val['checked'])) {
1464 $colspan++;
1465 }
1466 }
1467 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1468}
1469
1470
1471$db->free($resql);
1472
1473$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1474$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1475print $hookmanager->resPrint;
1476
1477print '</table>'."\n";
1478print '</div>'."\n";
1479
1480print '</form>'."\n";
1481
1482
1483// End of page
1484llxFooter();
1485$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 export.php:1216
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
$c
Definition line.php:331
Class to manage categories.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.