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