list.php 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  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-2017 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
  6. * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/user/list.php
  23. * \ingroup core
  24. * \brief Page of users
  25. */
  26. // Load Dolibarr environment
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  29. if (isModEnabled('categorie')) {
  30. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  31. }
  32. // Load translation files required by page
  33. $langs->loadLangs(array('users', 'companies', 'hrm', 'salaries'));
  34. $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
  35. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  36. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  37. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  38. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  39. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  40. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search
  41. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  42. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  43. $mode = GETPOST("mode", 'aZ');
  44. // Security check (for external users)
  45. $socid = 0;
  46. if ($user->socid > 0) {
  47. $socid = $user->socid;
  48. }
  49. // Load variable for pagination
  50. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  51. $sortfield = GETPOST('sortfield', 'aZ09comma');
  52. $sortorder = GETPOST('sortorder', 'aZ09comma');
  53. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  54. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  55. // If $page is not defined, or '' or -1 or if we click on clear filters
  56. $page = 0;
  57. }
  58. $offset = $limit * $page;
  59. $pageprev = $page - 1;
  60. $pagenext = $page + 1;
  61. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  62. $object = new User($db);
  63. $extrafields = new ExtraFields($db);
  64. $diroutputmassaction = $conf->user->dir_output.'/temp/massgeneration/'.$user->id;
  65. $hookmanager->initHooks(array('userlist'));
  66. // Fetch optionals attributes and labels
  67. $extrafields->fetch_name_optionals_label($object->table_element);
  68. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  69. if (!$sortfield) {
  70. $sortfield = "u.login";
  71. }
  72. if (!$sortorder) {
  73. $sortorder = "ASC";
  74. }
  75. // Initialize array of search criterias
  76. $search_all = GETPOST('search_all', 'alphanohtml');
  77. $search = array();
  78. foreach ($object->fields as $key => $val) {
  79. if (GETPOST('search_'.$key, 'alpha') !== '') {
  80. $search[$key] = GETPOST('search_'.$key, 'alpha');
  81. }
  82. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  83. $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
  84. $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
  85. }
  86. }
  87. $userstatic = new User($db);
  88. $companystatic = new Societe($db);
  89. $form = new Form($db);
  90. // List of fields to search into when doing a "search in all"
  91. $fieldstosearchall = array(
  92. 'u.login'=>"Login",
  93. 'u.lastname'=>"Lastname",
  94. 'u.firstname'=>"Firstname",
  95. 'u.accountancy_code'=>"AccountancyCode",
  96. 'u.office_phone'=>"PhonePro",
  97. 'u.user_mobile'=>"PhoneMobile",
  98. 'u.email'=>"EMail",
  99. 'u.note_public'=>"NotePublic",
  100. 'u.note_private'=>"NotePrivate"
  101. );
  102. if (isModEnabled('api')) {
  103. $fieldstosearchall['u.api_key'] = "ApiKey";
  104. }
  105. $permissiontoreadhr = $user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write');
  106. $permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write');
  107. // Definition of fields for list
  108. $arrayfields = array(
  109. 'u.login'=>array('label'=>"Login", 'checked'=>1, 'position'=>10),
  110. 'u.lastname'=>array('label'=>"Lastname", 'checked'=>1, 'position'=>15),
  111. 'u.firstname'=>array('label'=>"Firstname", 'checked'=>1, 'position'=>20),
  112. 'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
  113. 'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22),
  114. 'u.employee'=>array('label'=>"Employee", 'checked'=>($contextpage == 'employeelist' ? 1 : 0), 'position'=>25),
  115. 'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27, 'csslist'=>'maxwidth150'),
  116. 'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30),
  117. 'u.office_phone'=>array('label'=>"PhonePro", 'checked'=>1, 'position'=>31),
  118. 'u.user_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1, 'position'=>32),
  119. 'u.email'=>array('label'=>"EMail", 'checked'=>1, 'position'=>35),
  120. 'u.api_key'=>array('label'=>"ApiKey", 'checked'=>0, 'position'=>40, "enabled"=>(isModEnabled('api') && $user->admin)),
  121. 'u.fk_soc'=>array('label'=>"Company", 'checked'=>($contextpage == 'employeelist' ? 0 : 1), 'position'=>45),
  122. 'u.ref_employee'=>array('label'=>"RefEmployee", 'checked'=>-1, 'position'=>60, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)),
  123. 'u.national_registration_number'=>array('label'=>"NationalRegistrationNumber", 'checked'=>-1, 'position'=>61, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)),
  124. 'u.job'=>array('label'=>"PostOrFunction", 'checked'=>-1, 'position'=>50),
  125. 'u.salary'=>array('label'=>"Salary", 'checked'=>-1, 'position'=>80, 'enabled'=>(isModEnabled('salaries') && $user->hasRight("salaries", "readall")), 'isameasure'=>1),
  126. 'u.datelastlogin'=>array('label'=>"LastConnexion", 'checked'=>1, 'position'=>100),
  127. 'u.datepreviouslogin'=>array('label'=>"PreviousConnexion", 'checked'=>0, 'position'=>110),
  128. 'u.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
  129. 'u.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  130. 'u.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  131. );
  132. // Extra fields
  133. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
  134. $object->fields = dol_sort_array($object->fields, 'position');
  135. $arrayfields = dol_sort_array($arrayfields, 'position');
  136. // Init search fields
  137. $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  138. $search_user = GETPOST('search_user', 'alpha');
  139. $search_login = GETPOST('search_login', 'alpha');
  140. $search_lastname = GETPOST('search_lastname', 'alpha');
  141. $search_firstname = GETPOST('search_firstname', 'alpha');
  142. $search_gender = GETPOST('search_gender', 'alpha');
  143. $search_employee = GETPOST('search_employee', 'alpha');
  144. $search_accountancy_code = GETPOST('search_accountancy_code', 'alpha');
  145. $search_phonepro = GETPOST('search_phonepro', 'alpha');
  146. $search_phonemobile = GETPOST('search_phonemobile', 'alpha');
  147. $search_email = GETPOST('search_email', 'alpha');
  148. $search_api_key = GETPOST('search_api_key', 'alphanohtml');
  149. $search_statut = GETPOST('search_statut', 'intcomma');
  150. $search_thirdparty = GETPOST('search_thirdparty', 'alpha');
  151. $search_job = GETPOST('search_job', 'alpha');
  152. $search_warehouse = GETPOST('search_warehouse', 'alpha');
  153. $search_supervisor = GETPOST('search_supervisor', 'intcomma');
  154. $search_categ = GETPOST("search_categ", 'int');
  155. $searchCategoryUserOperator = 0;
  156. if (GETPOSTISSET('formfilteraction')) {
  157. $searchCategoryUserOperator = GETPOSTINT('search_category_user_operator');
  158. } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
  159. $searchCategoryUserOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
  160. }
  161. $searchCategoryUserList = GETPOST('search_category_user_list', 'array');
  162. $catid = GETPOST('catid', 'int');
  163. if (!empty($catid) && empty($searchCategoryUserList)) {
  164. $searchCategoryUserList = array($catid);
  165. }
  166. $catid = GETPOST('catid', 'int');
  167. if (!empty($catid) && empty($search_categ)) {
  168. $search_categ = $catid;
  169. }
  170. // Default search
  171. if ($search_statut == '') {
  172. $search_statut = '1';
  173. }
  174. if ($contextpage == 'employeelist' && !GETPOSTISSET('search_employee')) {
  175. $search_employee = 1;
  176. }
  177. // Define value to know what current user can do on users
  178. $permissiontoadd = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
  179. $canreaduser = (!empty($user->admin) || $user->hasRight("user", "user", "read"));
  180. $canedituser = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
  181. $candisableuser = (!empty($user->admin) || $user->hasRight("user", "user", "delete"));
  182. $canreadgroup = $canreaduser;
  183. $caneditgroup = $canedituser;
  184. if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
  185. $canreadgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "read"));
  186. $caneditgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "write"));
  187. }
  188. $error = 0;
  189. // Permission to list
  190. if (isModEnabled('salaries') && $contextpage == 'employeelist' && $search_employee == 1) {
  191. if (!$user->hasRight("salaries", "read")) {
  192. accessforbidden();
  193. }
  194. } else {
  195. if (!$user->hasRight("user", "user", "read") && empty($user->admin)) {
  196. accessforbidden();
  197. }
  198. }
  199. $childids = $user->getAllChildIds(1);
  200. /*
  201. * Actions
  202. */
  203. if (GETPOST('cancel', 'alpha')) {
  204. $action = 'list';
  205. $massaction = '';
  206. }
  207. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  208. $massaction = '';
  209. }
  210. $parameters = array();
  211. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  212. if ($reshook < 0) {
  213. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  214. }
  215. if (empty($reshook)) {
  216. // Selection of new fields
  217. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  218. // Purge search criteria
  219. 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
  220. $search_user = "";
  221. $search_login = "";
  222. $search_lastname = "";
  223. $search_firstname = "";
  224. $search_gender = "";
  225. $search_employee = "";
  226. $search_accountancy_code = "";
  227. $search_phonepro = "";
  228. $search_phonemobile = "";
  229. $search_email = "";
  230. $search_statut = "";
  231. $search_thirdparty = "";
  232. $search_job = "";
  233. $search_warehouse = "";
  234. $search_supervisor = "";
  235. $search_api_key = "";
  236. $search_datelastlogin = "";
  237. $search_datepreviouslogin = "";
  238. $search_date_creation = "";
  239. $search_date_update = "";
  240. $search_categ = 0;
  241. $toselect = array();
  242. $search_array_options = array();
  243. }
  244. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  245. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  246. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  247. }
  248. // Mass actions
  249. $objectclass = 'User';
  250. $objectlabel = 'User';
  251. $uploaddir = $conf->user->dir_output;
  252. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  253. // Disable or Enable records
  254. if (!$error && ($massaction == 'disable' || $massaction == 'reactivate') && $permissiontoadd) {
  255. $objecttmp = new User($db);
  256. if (!$error) {
  257. $db->begin();
  258. $nbok = 0;
  259. foreach ($toselect as $toselectid) {
  260. if ($toselectid == $user->id) {
  261. setEventMessages($langs->trans($massaction == 0 ? 'CantDisableYourself' : 'CanEnableYourself'), null, 'errors');
  262. $error++;
  263. break;
  264. }
  265. $result = $objecttmp->fetch($toselectid);
  266. if ($result > 0) {
  267. if ($objecttmp->admin) {
  268. setEventMessages($langs->trans($massaction == 0 ? 'CantDisableAnAdminUserWithMassActions' : 'CantEnableAnAdminUserWithMassActions', $objecttmp->login), null, 'errors');
  269. $error++;
  270. break;
  271. }
  272. $result = $objecttmp->setstatus($massaction == 'disable' ? 0 : 1);
  273. if ($result == 0) {
  274. // Nothing is done
  275. } elseif ($result < 0) {
  276. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  277. $error++;
  278. break;
  279. } else {
  280. $nbok++;
  281. }
  282. } else {
  283. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  284. $error++;
  285. break;
  286. }
  287. }
  288. if (!$error && !empty($conf->file->main_limit_users)) {
  289. $nb = $object->getNbOfUsers("active");
  290. if ($nb >= $conf->file->main_limit_users) {
  291. $error++;
  292. setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors');
  293. }
  294. }
  295. if (!$error) {
  296. if ($nbok > 1) {
  297. setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
  298. } else {
  299. setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
  300. }
  301. $db->commit();
  302. } else {
  303. $db->rollback();
  304. }
  305. }
  306. }
  307. }
  308. /*
  309. * View
  310. */
  311. $formother = new FormOther($db);
  312. $user2 = new User($db);
  313. $now = dol_now();
  314. $help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios|DE:Modul_Benutzer';
  315. if ($contextpage == 'employeelist' && $search_employee == 1) {
  316. $title = $langs->trans("Employees");
  317. } else {
  318. $title = $langs->trans("Users");
  319. }
  320. $morejs = array();
  321. $morecss = array();
  322. $morehtmlright = "";
  323. // Build and execute select
  324. // --------------------------------------------------------------------
  325. $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,";
  326. $sql .= " u.fk_user,";
  327. $sql .= " u.ref_employee, u.national_registration_number, u.job, u.salary, u.datelastlogin, u.datepreviouslogin,";
  328. $sql .= " u.ldap_sid, u.statut as status, u.entity,";
  329. $sql .= " u.tms as date_update, u.datec as date_creation,";
  330. $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,";
  331. $sql .= " s.nom as name, s.canvas";
  332. // Add fields from extrafields
  333. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  334. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  335. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  336. }
  337. }
  338. // Add fields from hooks
  339. $parameters = array();
  340. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  341. $sql .= $hookmanager->resPrint;
  342. $sql = preg_replace('/,\s*$/', '', $sql);
  343. $sqlfields = $sql; // $sql fields to remove for count total
  344. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as u";
  345. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  346. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (u.rowid = ef.fk_object)";
  347. }
  348. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
  349. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
  350. // Add table from hooks
  351. $parameters = array();
  352. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  353. $sql .= $hookmanager->resPrint;
  354. if ($reshook > 0) {
  355. $sql .= $hookmanager->resPrint;
  356. }
  357. $sql .= " WHERE u.entity IN (".getEntity($object->element).")";
  358. if ($socid > 0) {
  359. $sql .= " AND u.fk_soc = ".((int) $socid);
  360. }
  361. //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
  362. if ($search_supervisor > 0) {
  363. $sql .= " AND u.fk_user IN (".$db->sanitize($search_supervisor).")";
  364. }
  365. if ($search_thirdparty != '') {
  366. $sql .= natural_search(array('s.nom'), $search_thirdparty);
  367. }
  368. if ($search_warehouse > 0) {
  369. $sql .= natural_search(array('u.fk_warehouse'), $search_warehouse);
  370. }
  371. if ($search_login != '') {
  372. $sql .= natural_search("u.login", $search_login);
  373. }
  374. if ($search_lastname != '') {
  375. $sql .= natural_search("u.lastname", $search_lastname);
  376. }
  377. if ($search_firstname != '') {
  378. $sql .= natural_search("u.firstname", $search_firstname);
  379. }
  380. if ($search_gender != '' && $search_gender != '-1') {
  381. $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman
  382. }
  383. if (is_numeric($search_employee) && $search_employee >= 0) {
  384. $sql .= ' AND u.employee = '.(int) $search_employee;
  385. }
  386. if ($search_accountancy_code != '') {
  387. $sql .= natural_search("u.accountancy_code", $search_accountancy_code);
  388. }
  389. if ($search_phonepro != '') {
  390. $sql .= natural_search("u.office_phone", $search_phonepro);
  391. }
  392. if ($search_phonemobile != '') {
  393. $sql .= natural_search("u.user_mobile", $search_phonemobile);
  394. }
  395. if ($search_email != '') {
  396. $sql .= natural_search("u.email", $search_email);
  397. }
  398. if ($search_api_key != '') {
  399. $sql .= natural_search("u.api_key", $search_api_key);
  400. }
  401. if ($search_job != '') {
  402. $sql .= natural_search(array('u.job'), $search_job);
  403. }
  404. if ($search_statut != '' && $search_statut >= 0) {
  405. $sql .= " AND u.statut IN (".$db->sanitize($search_statut).")";
  406. }
  407. if ($search_all) {
  408. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  409. }
  410. // Search for tag/category ($searchCategoryUserList is an array of ID)
  411. $searchCategoryUserList = array($search_categ);
  412. if (!empty($searchCategoryUserList)) {
  413. $searchCategoryUserSqlList = array();
  414. $listofcategoryid = '';
  415. foreach ($searchCategoryUserList as $searchCategoryUser) {
  416. if (intval($searchCategoryUser) == -2) {
  417. $searchCategoryUserSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)";
  418. } elseif (intval($searchCategoryUser) > 0) {
  419. if ($searchCategoryUserOperator == 0) {
  420. $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).")";
  421. } else {
  422. $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryUser);
  423. }
  424. }
  425. }
  426. if ($listofcategoryid) {
  427. $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)."))";
  428. }
  429. if ($searchCategoryUserOperator == 1) {
  430. if (!empty($searchCategoryUserSqlList)) {
  431. $sql .= " AND (".implode(' OR ', $searchCategoryUserSqlList).")";
  432. }
  433. } else {
  434. if (!empty($searchCategoryUserSqlList)) {
  435. $sql .= " AND (".implode(' AND ', $searchCategoryUserSqlList).")";
  436. }
  437. }
  438. }
  439. if ($search_warehouse > 0) {
  440. $sql .= " AND u.fk_warehouse = ".((int) $search_warehouse);
  441. }
  442. if (isModEnabled('salaries') && $contextpage == 'employeelist' && !$user->hasRight("salaries", "readall")) {
  443. $sql .= " AND u.rowid IN (".$db->sanitize(join(',', $childids)).")";
  444. }
  445. // Add where from extra fields
  446. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  447. // Add where from hooks
  448. $parameters = array();
  449. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  450. $sql .= $hookmanager->resPrint;
  451. // Count total nb of records
  452. $nbtotalofrecords = '';
  453. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  454. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  455. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  456. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  457. $resql = $db->query($sqlforcount);
  458. if ($resql) {
  459. $objforcount = $db->fetch_object($resql);
  460. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  461. } else {
  462. dol_print_error($db);
  463. }
  464. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  465. $page = 0;
  466. $offset = 0;
  467. }
  468. $db->free($resql);
  469. }
  470. // Complete request and execute it with limit
  471. $sql .= $db->order($sortfield, $sortorder);
  472. if ($limit) {
  473. $sql .= $db->plimit($limit + 1, $offset);
  474. }
  475. $resql = $db->query($sql);
  476. if (!$resql) {
  477. dol_print_error($db);
  478. exit;
  479. }
  480. $num = $db->num_rows($resql);
  481. // Direct jump if only one record found
  482. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  483. $obj = $db->fetch_object($resql);
  484. $id = $obj->rowid;
  485. header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id);
  486. exit;
  487. }
  488. // Output page
  489. // --------------------------------------------------------------------
  490. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
  491. $arrayofselected = is_array($toselect) ? $toselect : array();
  492. $param = '';
  493. if (!empty($mode)) {
  494. $param .= '&amp;mode='.urlencode($mode);
  495. }
  496. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  497. $param .= '&amp;contextpage='.urlencode($contextpage);
  498. }
  499. if ($limit > 0 && $limit != $conf->liste_limit) {
  500. $param .= '&amp;limit='.((int) $limit);
  501. }
  502. if ($search_all != '') {
  503. $param .= '&amp;search_all='.urlencode($search_all);
  504. }
  505. if ($search_user != '') {
  506. $param .= "&amp;search_user=".urlencode($search_user);
  507. }
  508. if ($search_login != '') {
  509. $param .= "&amp;search_login=".urlencode($search_login);
  510. }
  511. if ($search_lastname != '') {
  512. $param .= "&amp;search_lastname=".urlencode($search_lastname);
  513. }
  514. if ($search_firstname != '') {
  515. $param .= "&amp;search_firstname=".urlencode($search_firstname);
  516. }
  517. if ($search_gender != '' && $search_gender != '-1') {
  518. $param .= "&amp;search_gender=".urlencode($search_gender);
  519. }
  520. if ($search_employee != '' && $search_employee != '-1') {
  521. $param .= "&amp;search_employee=".urlencode($search_employee);
  522. }
  523. if ($search_accountancy_code != '') {
  524. $param .= "&amp;search_accountancy_code=".urlencode($search_accountancy_code);
  525. }
  526. if ($search_phonepro != '') {
  527. $param .= "&amp;search_phonepro=".urlencode($search_phonepro);
  528. }
  529. if ($search_phonemobile != '') {
  530. $param .= "&amp;search_phonemobile=".urlencode($search_phonemobile);
  531. }
  532. if ($search_email != '') {
  533. $param .= "&amp;search_email=".urlencode($search_email);
  534. }
  535. if ($search_api_key != '') {
  536. $param .= "&amp;search_api_key=".urlencode($search_api_key);
  537. }
  538. if ($search_supervisor > 0) {
  539. $param .= "&amp;search_supervisor=".urlencode($search_supervisor);
  540. }
  541. if ($search_statut != '') {
  542. $param .= "&amp;search_statut=".urlencode($search_statut);
  543. }
  544. if ($optioncss != '') {
  545. $param .= '&amp;optioncss='.urlencode($optioncss);
  546. }
  547. if ($search_categ > 0) {
  548. $param .= '&amp;search_categ='.urlencode($search_categ);
  549. }
  550. if ($search_warehouse > 0) {
  551. $param .= '&amp;search_warehouse='.urlencode($search_warehouse);
  552. }
  553. // Add $param from extra fields
  554. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  555. // List of mass actions available
  556. $arrayofmassactions = array();
  557. if ($permissiontoadd) {
  558. $arrayofmassactions['disable'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("DisableUser");
  559. }
  560. if ($permissiontoadd) {
  561. $arrayofmassactions['reactivate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Reactivate");
  562. }
  563. if (isModEnabled('category') && $permissiontoadd) {
  564. $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
  565. }
  566. if ($permissiontoadd) {
  567. $arrayofmassactions['presetsupervisor'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("SetSupervisor");
  568. }
  569. //if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  570. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'presetsupervisor'))) {
  571. $arrayofmassactions = array();
  572. }
  573. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  574. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  575. if ($optioncss != '') {
  576. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  577. }
  578. print '<input type="hidden" name="token" value="'.newToken().'">';
  579. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  580. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  581. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  582. print '<input type="hidden" name="page" value="'.$page.'">';
  583. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  584. print '<input type="hidden" name="page_y" value="">';
  585. print '<input type="hidden" name="mode" value="'.$mode.'">';
  586. $url = DOL_URL_ROOT.'/user/card.php?action=create'.($contextpage == 'employeelist' ? '&search_employee=1' : '').'&leftmenu=';
  587. if (!empty($socid)) {
  588. $url .= '&socid='.urlencode($socid);
  589. }
  590. $newcardbutton = '';
  591. $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'));
  592. $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'));
  593. $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'));
  594. $newcardbutton .= dolGetButtonTitleSeparator();
  595. $newcardbutton .= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
  596. /*$moreparam = array('morecss'=>'btnTitleSelected');
  597. $morehtmlright = dolGetButtonTitle($langs->trans("List"), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php'.(($search_statut != '' && $search_statut >= 0) ? '?search_statut='.$search_statut : ''), '', 1, $moreparam);
  598. $moreparam = array('morecss'=>'marginleftonly');
  599. $morehtmlright .= dolGetButtonTitle($langs->trans("HierarchicView"), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/user/hierarchy.php'.(($search_statut != '' && $search_statut >= 0) ? '?search_statut='.$search_statut : ''), '', 1, $moreparam);
  600. */
  601. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, $morehtmlright.' '.$newcardbutton, '', $limit, 0, 0, 1);
  602. // Add code for pre mass action (confirmation or email presend form)
  603. $topicmail = "SendUserRef";
  604. $modelmail = "user";
  605. $objecttmp = new User($db);
  606. $trackid = 'use'.$object->id;
  607. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  608. if (!empty($catid)) {
  609. print "<div id='ways'>";
  610. $c = new Categorie($db);
  611. $ways = $c->print_all_ways(' &gt; ', 'user/list.php');
  612. print " &gt; ".$ways[0]."<br>\n";
  613. print "</div><br>";
  614. }
  615. if ($search_all) {
  616. foreach ($fieldstosearchall as $key => $val) {
  617. $fieldstosearchall[$key] = $langs->trans($val);
  618. }
  619. print '<!-- Search done like if USER_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  620. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  621. }
  622. $moreforfilter = '';
  623. /*$moreforfilter.='<div class="divsearchfield">';
  624. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  625. $moreforfilter.= '</div>';*/
  626. // Filter on categories
  627. if (isModEnabled('categorie') && $user->hasRight("categorie", "read")) {
  628. $moreforfilter .= '<div class="divsearchfield">';
  629. $tmptitle = $langs->trans('Category');
  630. $moreforfilter .= img_picto($langs->trans("Category"), 'category', 'class="pictofixedwidth"').$formother->select_categories(Categorie::TYPE_USER, $search_categ, 'search_categ', 1, $tmptitle);
  631. $moreforfilter .= '</div>';
  632. }
  633. // Filter on warehouse
  634. if (isModEnabled('stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
  635. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  636. $formproduct = new FormProduct($db);
  637. $moreforfilter .= '<div class="divsearchfield">';
  638. $tmptitle = $langs->trans('Warehouse');
  639. $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', $tmptitle, 0, 0, $tmptitle);
  640. $moreforfilter .= '</div>';
  641. }
  642. $parameters = array();
  643. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  644. if (empty($reshook)) {
  645. $moreforfilter .= $hookmanager->resPrint;
  646. } else {
  647. $moreforfilter = $hookmanager->resPrint;
  648. }
  649. if (!empty($moreforfilter)) {
  650. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  651. print $moreforfilter;
  652. print '</div>';
  653. }
  654. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  655. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
  656. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  657. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  658. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  659. // Fields title search
  660. // --------------------------------------------------------------------
  661. print '<tr class="liste_titre_filter">';
  662. // Action column
  663. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  664. print '<td class="liste_titre center maxwidthsearch">';
  665. $searchpicto = $form->showFilterButtons('left');
  666. print $searchpicto;
  667. print '</td>';
  668. }
  669. if (!empty($arrayfields['u.login']['checked'])) {
  670. print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
  671. }
  672. if (!empty($arrayfields['u.lastname']['checked'])) {
  673. print '<td class="liste_titre"><input type="text" name="search_lastname" class="maxwidth50" value="'.$search_lastname.'"></td>';
  674. }
  675. if (!empty($arrayfields['u.firstname']['checked'])) {
  676. print '<td class="liste_titre"><input type="text" name="search_firstname" class="maxwidth50" value="'.$search_firstname.'"></td>';
  677. }
  678. if (!empty($arrayfields['u.gender']['checked'])) {
  679. print '<td class="liste_titre center">';
  680. $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
  681. print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
  682. print '</td>';
  683. }
  684. if (!empty($arrayfields['u.employee']['checked'])) {
  685. print '<td class="liste_titre">';
  686. print $form->selectyesno('search_employee', $search_employee, 1, false, 1);
  687. print '</td>';
  688. }
  689. // Supervisor
  690. if (!empty($arrayfields['u.fk_user']['checked'])) {
  691. print '<td class="liste_titre">';
  692. print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth125');
  693. print '</td>';
  694. }
  695. if (!empty($arrayfields['u.accountancy_code']['checked'])) {
  696. print '<td class="liste_titre"><input type="text" name="search_accountancy_code" class="maxwidth50" value="'.$search_accountancy_code.'"></td>';
  697. }
  698. if (!empty($arrayfields['u.office_phone']['checked'])) {
  699. print '<td class="liste_titre"><input type="text" name="search_phonepro" class="maxwidth50" value="'.$search_phonepro.'"></td>';
  700. }
  701. if (!empty($arrayfields['u.user_mobile']['checked'])) {
  702. print '<td class="liste_titre"><input type="text" name="search_phonemobile" class="maxwidth50" value="'.$search_phonemobile.'"></td>';
  703. }
  704. if (!empty($arrayfields['u.email']['checked'])) {
  705. print '<td class="liste_titre"><input type="text" name="search_email" class="maxwidth75" value="'.$search_email.'"></td>';
  706. }
  707. if (!empty($arrayfields['u.api_key']['checked'])) {
  708. print '<td class="liste_titre"><input type="text" name="search_api_key" class="maxwidth50" value="'.$search_api_key.'"></td>';
  709. }
  710. if (!empty($arrayfields['u.fk_soc']['checked'])) {
  711. print '<td class="liste_titre"><input type="text" name="search_thirdparty" class="maxwidth75" value="'.$search_thirdparty.'"></td>';
  712. }
  713. if (!empty($arrayfields['u.entity']['checked'])) {
  714. print '<td class="liste_titre"></td>';
  715. }
  716. if (!empty($arrayfields['u.ref_employee']['checked'])) {
  717. print '<td class="liste_titre"></td>';
  718. }
  719. if (!empty($arrayfields['u.national_registration_number']['checked'])) {
  720. print '<td class="liste_titre"></td>';
  721. }
  722. if (!empty($arrayfields['u.job']['checked'])) {
  723. print '<td class="liste_titre"><input type="text" name="search_job" class="maxwidth75" value="'.$search_job.'"></td>';
  724. }
  725. if (!empty($arrayfields['u.salary']['checked'])) {
  726. print '<td class="liste_titre"></td>';
  727. }
  728. if (!empty($arrayfields['u.datelastlogin']['checked'])) {
  729. print '<td class="liste_titre"></td>';
  730. }
  731. if (!empty($arrayfields['u.datepreviouslogin']['checked'])) {
  732. print '<td class="liste_titre"></td>';
  733. }
  734. // Extra fields
  735. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  736. // Fields from hook
  737. $parameters = array('arrayfields'=>$arrayfields);
  738. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
  739. print $hookmanager->resPrint;
  740. if (!empty($arrayfields['u.datec']['checked'])) {
  741. // Date creation
  742. print '<td class="liste_titre">';
  743. print '</td>';
  744. }
  745. if (!empty($arrayfields['u.tms']['checked'])) {
  746. // Date modification
  747. print '<td class="liste_titre">';
  748. print '</td>';
  749. }
  750. if (!empty($arrayfields['u.statut']['checked'])) {
  751. // Status
  752. print '<td class="liste_titre center parentonrightofpage">';
  753. print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
  754. print '</td>';
  755. }
  756. // Action column
  757. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  758. print '<td class="liste_titre maxwidthsearch">';
  759. $searchpicto = $form->showFilterButtons();
  760. print $searchpicto;
  761. print '</td>';
  762. }
  763. print '</tr>'."\n";
  764. $totalarray = array();
  765. $totalarray['nbfield'] = 0;
  766. // Fields title label
  767. // --------------------------------------------------------------------
  768. print '<tr class="liste_titre">';
  769. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  770. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  771. $totalarray['nbfield']++;
  772. }
  773. if (!empty($arrayfields['u.login']['checked'])) {
  774. print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
  775. $totalarray['nbfield']++;
  776. }
  777. if (!empty($arrayfields['u.lastname']['checked'])) {
  778. print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", $param, "", "", $sortfield, $sortorder);
  779. $totalarray['nbfield']++;
  780. }
  781. if (!empty($arrayfields['u.firstname']['checked'])) {
  782. print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder);
  783. $totalarray['nbfield']++;
  784. }
  785. if (!empty($arrayfields['u.gender']['checked'])) {
  786. print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder, 'center ');
  787. $totalarray['nbfield']++;
  788. }
  789. if (!empty($arrayfields['u.employee']['checked'])) {
  790. print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder, 'center ');
  791. $totalarray['nbfield']++;
  792. }
  793. if (!empty($arrayfields['u.fk_user']['checked'])) {
  794. print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder);
  795. $totalarray['nbfield']++;
  796. }
  797. if (!empty($arrayfields['u.accountancy_code']['checked'])) {
  798. print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder);
  799. $totalarray['nbfield']++;
  800. }
  801. if (!empty($arrayfields['u.office_phone']['checked'])) {
  802. print_liste_field_titre("PhonePro", $_SERVER['PHP_SELF'], "u.office_phone", $param, "", "", $sortfield, $sortorder);
  803. $totalarray['nbfield']++;
  804. }
  805. if (!empty($arrayfields['u.user_mobile']['checked'])) {
  806. print_liste_field_titre("PhoneMobile", $_SERVER['PHP_SELF'], "u.user_mobile", $param, "", "", $sortfield, $sortorder);
  807. $totalarray['nbfield']++;
  808. }
  809. if (!empty($arrayfields['u.email']['checked'])) {
  810. print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder);
  811. $totalarray['nbfield']++;
  812. }
  813. if (!empty($arrayfields['u.api_key']['checked'])) {
  814. print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder);
  815. $totalarray['nbfield']++;
  816. }
  817. if (!empty($arrayfields['u.fk_soc']['checked'])) {
  818. print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder);
  819. $totalarray['nbfield']++;
  820. }
  821. if (!empty($arrayfields['u.entity']['checked'])) {
  822. print_liste_field_titre($arrayfields['u.entity']['label'], $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder);
  823. $totalarray['nbfield']++;
  824. }
  825. if (!empty($arrayfields['u.job']['checked'])) {
  826. print_liste_field_titre($arrayfields['u.job']['label'], $_SERVER['PHP_SELF'], "u.job", $param, "", "", $sortfield, $sortorder);
  827. $totalarray['nbfield']++;
  828. }
  829. if (!empty($arrayfields['u.ref_employee']['checked'])) {
  830. print_liste_field_titre("RefEmployee", $_SERVER['PHP_SELF'], "u.ref_employee", $param, "", "", $sortfield, $sortorder);
  831. $totalarray['nbfield']++;
  832. }
  833. if (!empty($arrayfields['u.national_registration_number']['checked'])) {
  834. print_liste_field_titre("NationalRegistrationNumber", $_SERVER['PHP_SELF'], "u.national_registration_number", $param, "", "", $sortfield, $sortorder);
  835. $totalarray['nbfield']++;
  836. }
  837. if (!empty($arrayfields['u.salary']['checked'])) {
  838. print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right ');
  839. $totalarray['nbfield']++;
  840. }
  841. if (!empty($arrayfields['u.datelastlogin']['checked'])) {
  842. print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center ');
  843. $totalarray['nbfield']++;
  844. }
  845. if (!empty($arrayfields['u.datepreviouslogin']['checked'])) {
  846. print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center ');
  847. $totalarray['nbfield']++;
  848. }
  849. // Extra fields
  850. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  851. // Hook fields
  852. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  853. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  854. print $hookmanager->resPrint;
  855. if (!empty($arrayfields['u.datec']['checked'])) {
  856. print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  857. $totalarray['nbfield']++;
  858. }
  859. if (!empty($arrayfields['u.tms']['checked'])) {
  860. print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "u.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  861. $totalarray['nbfield']++;
  862. }
  863. if (!empty($arrayfields['u.statut']['checked'])) {
  864. print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center ');
  865. $totalarray['nbfield']++;
  866. }
  867. // Action column
  868. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  869. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  870. $totalarray['nbfield']++;
  871. }
  872. print '</tr>'."\n";
  873. // Detect if we need a fetch on each output line
  874. $needToFetchEachLine = 0;
  875. if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  876. foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  877. if (preg_match('/\$object/', $val)) {
  878. $needToFetchEachLine++; // There is at least one compute field that use $object
  879. }
  880. }
  881. }
  882. // Loop on record
  883. // --------------------------------------------------------------------
  884. $i = 0;
  885. $savnbfield = $totalarray['nbfield'];
  886. $totalarray = array('val'=>array('u.salary'=>0));
  887. $totalarray['nbfield'] = 0;
  888. $imaxinloop = ($limit ? min($num, $limit) : $num);
  889. while ($i < $imaxinloop) {
  890. $obj = $db->fetch_object($resql);
  891. if (empty($obj)) {
  892. break; // Should not happen
  893. }
  894. if (empty($obj->country_code)) {
  895. $obj->country_code = ''; // TODO Add join in select with country table to get country_code
  896. }
  897. // Store properties in $object
  898. $object->setVarsFromFetchObj($obj);
  899. $object->id = $obj->rowid;
  900. $object->admin = $obj->admin;
  901. $object->ref = $obj->rowid;
  902. $object->login = $obj->login;
  903. $object->statut = $obj->status;
  904. $object->status = $obj->status;
  905. $object->office_phone = $obj->office_phone;
  906. $object->user_mobile = $obj->user_mobile;
  907. $object->job = $obj->job;
  908. $object->email = $obj->email;
  909. $object->gender = $obj->gender;
  910. $object->socid = $obj->fk_soc;
  911. $object->firstname = $obj->firstname;
  912. $object->lastname = $obj->lastname;
  913. $object->employee = $obj->employee;
  914. $object->photo = $obj->photo;
  915. $li = $object->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
  916. $canreadhrmdata = 0;
  917. if ((!empty($conf->salaries->enabled) && $user->hasRight("salaries", "read") && in_array($obj->rowid, $childids))
  918. || (!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))
  919. || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
  920. $canreadhrmdata = 1;
  921. }
  922. $canreadsecretapi = 0;
  923. if ($user->id == $obj->rowid || !empty($user->admin)) { // Current user or admin
  924. $canreadsecretapi = 1;
  925. }
  926. if ($mode == 'kanban') {
  927. if ($i == 0) {
  928. print '<tr><td colspan="'.$savnbfield.'">';
  929. print '<div class="box-flex-container kanban">';
  930. }
  931. // Output Kanban
  932. print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
  933. if ($i == ($imaxinloop - 1)) {
  934. print '</div>';
  935. print '</td></tr>';
  936. }
  937. } else {
  938. // Show here line of result
  939. $j = 0;
  940. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  941. // Action column
  942. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  943. print '<td class="nowrap center">';
  944. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  945. $selected = 0;
  946. if (in_array($object->id, $arrayofselected)) {
  947. $selected = 1;
  948. }
  949. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  950. }
  951. print '</td>';
  952. if (!$i) {
  953. $totalarray['nbfield']++;
  954. }
  955. }
  956. // Login
  957. if (!empty($arrayfields['u.login']['checked'])) {
  958. print '<td class="nowraponall tdoverflowmax150">';
  959. print $li;
  960. if (isModEnabled('multicompany') && $obj->admin && !$obj->entity) {
  961. print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingright paddingleft"');
  962. } elseif ($obj->admin) {
  963. print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingright paddingleft"');
  964. }
  965. print '</td>';
  966. if (!$i) {
  967. $totalarray['nbfield']++;
  968. }
  969. }
  970. if (!empty($arrayfields['u.lastname']['checked'])) {
  971. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">'.dol_escape_htmltag($obj->lastname).'</td>';
  972. if (!$i) {
  973. $totalarray['nbfield']++;
  974. }
  975. }
  976. if (!empty($arrayfields['u.firstname']['checked'])) {
  977. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">'.dol_escape_htmltag($obj->firstname).'</td>';
  978. if (!$i) {
  979. $totalarray['nbfield']++;
  980. }
  981. }
  982. if (!empty($arrayfields['u.gender']['checked'])) {
  983. print '<td class="center">';
  984. if ($obj->gender) {
  985. // Preparing gender's display if there is one
  986. $addgendertxt = '';
  987. switch ($obj->gender) {
  988. case 'man':
  989. $addgendertxt .= '<i class="fas fa-mars" title="'.dol_escape_htmltag($langs->trans("Gender".$obj->gender)).'"></i>';
  990. break;
  991. case 'woman':
  992. $addgendertxt .= '<i class="fas fa-venus" title="'.dol_escape_htmltag($langs->trans("Gender".$obj->gender)).'"></i>';
  993. break;
  994. case 'other':
  995. $addgendertxt .= '<i class="fas fa-transgender" title="'.dol_escape_htmltag($langs->trans("Gender".$obj->gender)).'"></i>';
  996. break;
  997. }
  998. print $addgendertxt;
  999. //print $langs->trans("Gender".$obj->gender);
  1000. }
  1001. print '</td>';
  1002. if (!$i) {
  1003. $totalarray['nbfield']++;
  1004. }
  1005. }
  1006. // Employee yes/no
  1007. if (!empty($arrayfields['u.employee']['checked'])) {
  1008. print '<td class="center">'.yn($obj->employee).'</td>';
  1009. if (!$i) {
  1010. $totalarray['nbfield']++;
  1011. }
  1012. }
  1013. // Supervisor
  1014. if (!empty($arrayfields['u.fk_user']['checked'])) {
  1015. print '<td class="tdoverflowmax125">';
  1016. if ($obj->login2) {
  1017. $user2->id = $obj->id2;
  1018. $user2->login = $obj->login2;
  1019. $user2->lastname = $obj->lastname2;
  1020. $user2->firstname = $obj->firstname2;
  1021. $user2->gender = $obj->gender2;
  1022. $user2->photo = $obj->photo2;
  1023. $user2->admin = $obj->admin2;
  1024. $user2->office_phone = $obj->office_phone;
  1025. $user2->user_mobile = $obj->user_mobile;
  1026. $user2->email = $obj->email2;
  1027. $user2->socid = $obj->fk_soc2;
  1028. $user2->statut = $obj->status2;
  1029. $user2->status = $obj->status2;
  1030. if (isModEnabled('multicompany') && $obj->admin2 && !$obj->entity2) {
  1031. print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingright"');
  1032. } elseif ($obj->admin2) {
  1033. print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingright"');
  1034. }
  1035. print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1);
  1036. }
  1037. print '</td>';
  1038. if (!$i) {
  1039. $totalarray['nbfield']++;
  1040. }
  1041. }
  1042. if (!empty($arrayfields['u.accountancy_code']['checked'])) {
  1043. print '<td>'.$obj->accountancy_code.'</td>';
  1044. if (!$i) {
  1045. $totalarray['nbfield']++;
  1046. }
  1047. }
  1048. // Phone
  1049. if (!empty($arrayfields['u.office_phone']['checked'])) {
  1050. print '<td class="tdoverflowmax125">'.dol_print_phone($obj->office_phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
  1051. if (!$i) {
  1052. $totalarray['nbfield']++;
  1053. }
  1054. }
  1055. if (!empty($arrayfields['u.user_mobile']['checked'])) {
  1056. print '<td class="tdoverflowmax125">'.dol_print_phone($obj->user_mobile, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'mobile')."</td>\n";
  1057. if (!$i) {
  1058. $totalarray['nbfield']++;
  1059. }
  1060. }
  1061. if (!empty($arrayfields['u.email']['checked'])) {
  1062. print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->fk_soc, 'AC_EMAIL', 0, 0, 1)."</td>\n";
  1063. if (!$i) {
  1064. $totalarray['nbfield']++;
  1065. }
  1066. }
  1067. if (!empty($arrayfields['u.api_key']['checked'])) {
  1068. $api_key = dolDecrypt($obj->api_key);
  1069. print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($api_key).'">';
  1070. if ($api_key) {
  1071. if ($canreadsecretapi) {
  1072. print '<span class="opacitymedium">';
  1073. print showValueWithClipboardCPButton($object->api_key, 1, dol_trunc($api_key, 3)); // TODO Add an option to also reveal the hash, not only copy paste
  1074. print '</span>';
  1075. } else {
  1076. print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
  1077. }
  1078. }
  1079. print '</td>';
  1080. if (!$i) {
  1081. $totalarray['nbfield']++;
  1082. }
  1083. }
  1084. if (!empty($arrayfields['u.fk_soc']['checked'])) {
  1085. print '<td class="tdoverflowmax150">';
  1086. if ($obj->fk_soc > 0) {
  1087. $companystatic->id = $obj->fk_soc;
  1088. $companystatic->name = $obj->name;
  1089. $companystatic->canvas = $obj->canvas;
  1090. print $companystatic->getNomUrl(1);
  1091. } elseif ($obj->ldap_sid) {
  1092. print '<span class="opacitymedium">'.$langs->trans("DomainUser").'</span>';
  1093. } else {
  1094. print '<span class="opacitymedium">'.$langs->trans("InternalUser").'</span>';
  1095. }
  1096. print '</td>';
  1097. if (!$i) {
  1098. $totalarray['nbfield']++;
  1099. }
  1100. }
  1101. // Multicompany enabled
  1102. if (isModEnabled('multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
  1103. if (!empty($arrayfields['u.entity']['checked'])) {
  1104. if (!$obj->entity) {
  1105. $labeltouse = $langs->trans("AllEntities");
  1106. } else {
  1107. $mc->getInfo($obj->entity);
  1108. $labeltouse = $mc->label;
  1109. }
  1110. print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltouse).'">';
  1111. print $labeltouse;
  1112. print '</td>';
  1113. if (!$i) {
  1114. $totalarray['nbfield']++;
  1115. }
  1116. }
  1117. }
  1118. // Ref employee
  1119. if (!empty($arrayfields['u.ref_employee']['checked'])) {
  1120. print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->ref_employee).'">';
  1121. print dol_escape_htmltag($obj->ref_employee);
  1122. print '</td>';
  1123. if (!$i) {
  1124. $totalarray['nbfield']++;
  1125. }
  1126. }
  1127. // National number
  1128. if (!empty($arrayfields['u.national_registration_number']['checked'])) {
  1129. print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->national_registration_number).'">';
  1130. print dol_escape_htmltag($obj->national_registration_number);
  1131. print '</td>';
  1132. if (!$i) {
  1133. $totalarray['nbfield']++;
  1134. }
  1135. }
  1136. // Job position
  1137. if (!empty($arrayfields['u.job']['checked'])) {
  1138. print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->job).'">';
  1139. print dol_escape_htmltag($obj->job);
  1140. print '</td>';
  1141. if (!$i) {
  1142. $totalarray['nbfield']++;
  1143. }
  1144. }
  1145. // Salary
  1146. if (!empty($arrayfields['u.salary']['checked'])) {
  1147. print '<td class="nowraponall right amount">';
  1148. if ($obj->salary) {
  1149. if ($canreadhrmdata) {
  1150. print price($obj->salary);
  1151. } else {
  1152. print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
  1153. }
  1154. }
  1155. print '</td>';
  1156. if (!$i) {
  1157. $totalarray['nbfield']++;
  1158. }
  1159. if (!$i) {
  1160. $totalarray['pos'][$totalarray['nbfield']] = 'u.salary';
  1161. }
  1162. if (!isset($totalarray['val'])) {
  1163. $totalarray['val'] = array();
  1164. }
  1165. if (!isset($totalarray['val']['u.salary'])) {
  1166. $totalarray['val']['u.salary'] = 0;
  1167. }
  1168. $totalarray['val']['u.salary'] += $obj->salary;
  1169. }
  1170. // Date last login
  1171. if (!empty($arrayfields['u.datelastlogin']['checked'])) {
  1172. print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datelastlogin), "dayhour").'</td>';
  1173. if (!$i) {
  1174. $totalarray['nbfield']++;
  1175. }
  1176. }
  1177. // Date previous login
  1178. if (!empty($arrayfields['u.datepreviouslogin']['checked'])) {
  1179. print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datepreviouslogin), "dayhour").'</td>';
  1180. if (!$i) {
  1181. $totalarray['nbfield']++;
  1182. }
  1183. }
  1184. // Extra fields
  1185. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1186. // Fields from hook
  1187. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1188. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  1189. print $hookmanager->resPrint;
  1190. // Date creation
  1191. if (!empty($arrayfields['u.datec']['checked'])) {
  1192. print '<td class="center nowraponall">';
  1193. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1194. print '</td>';
  1195. if (!$i) {
  1196. $totalarray['nbfield']++;
  1197. }
  1198. }
  1199. // Date modification
  1200. if (!empty($arrayfields['u.tms']['checked'])) {
  1201. print '<td class="center nowraponall">';
  1202. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1203. print '</td>';
  1204. if (!$i) {
  1205. $totalarray['nbfield']++;
  1206. }
  1207. }
  1208. // Status
  1209. if (!empty($arrayfields['u.statut']['checked'])) {
  1210. print '<td class="center">'.$object->getLibStatut(5).'</td>';
  1211. if (!$i) {
  1212. $totalarray['nbfield']++;
  1213. }
  1214. }
  1215. // Action column
  1216. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  1217. print '<td class="nowrap center">';
  1218. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1219. $selected = 0;
  1220. if (in_array($object->id, $arrayofselected)) {
  1221. $selected = 1;
  1222. }
  1223. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  1224. }
  1225. print '</td>';
  1226. if (!$i) {
  1227. $totalarray['nbfield']++;
  1228. }
  1229. }
  1230. print '</tr>'."\n";
  1231. }
  1232. $i++;
  1233. }
  1234. // Show total line
  1235. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1236. // If no record found
  1237. if ($num == 0) {
  1238. $colspan = 1;
  1239. foreach ($arrayfields as $key => $val) {
  1240. if (!empty($val['checked'])) {
  1241. $colspan++;
  1242. }
  1243. }
  1244. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  1245. }
  1246. $db->free($resql);
  1247. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  1248. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  1249. print $hookmanager->resPrint;
  1250. print '</table>'."\n";
  1251. print '</div>'."\n";
  1252. print '</form>'."\n";
  1253. // End of page
  1254. llxFooter();
  1255. $db->close();