list.php 55 KB

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