list.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <?php
  2. /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
  6. * Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
  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/group/list.php
  23. * \ingroup core
  24. * \brief Page of user groups
  25. */
  26. // Load Dolibarr environment
  27. require '../../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
  29. // Load translation files required by page
  30. $langs->loadLangs(array("users"));
  31. $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
  32. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  33. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  34. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  35. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  36. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  37. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  38. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  39. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  40. $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
  41. $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  42. $search_group = GETPOST('search_group');
  43. $search = array();
  44. // Load variable for pagination
  45. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  46. $sortfield = GETPOST('sortfield', 'aZ09comma');
  47. $sortorder = GETPOST('sortorder', 'aZ09comma');
  48. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  49. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  50. // If $page is not defined, or '' or -1 or if we click on clear filters
  51. $page = 0;
  52. }
  53. $offset = $limit * $page;
  54. $pageprev = $page - 1;
  55. $pagenext = $page + 1;
  56. // Initialize technical objects
  57. $object = new UserGroup($db);
  58. $extrafields = new ExtraFields($db);
  59. //$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
  60. $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
  61. // Fetch optionals attributes and labels
  62. $extrafields->fetch_name_optionals_label($object->table_element);
  63. //$extrafields->fetch_name_optionals_label($object->table_element_line);
  64. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  65. if (!$sortfield) {
  66. $sortfield = "g.nom";
  67. }
  68. if (!$sortorder) {
  69. $sortorder = "ASC";
  70. }
  71. // List of fields to search into when doing a "search in all"
  72. $fieldstosearchall = array();
  73. foreach ($object->fields as $key => $val) {
  74. if (!empty($val['searchall'])) {
  75. $fieldstosearchall['t.'.$key] = $val['label'];
  76. }
  77. }
  78. if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
  79. if (!$user->hasRight("user", "group_advance", "read") && !$user->admin) {
  80. accessforbidden();
  81. }
  82. }
  83. // Users/Groups management only in master entity if transverse mode
  84. if (isModEnabled('multicompany') && $conf->entity > 1 && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
  85. accessforbidden();
  86. }
  87. if (!$user->hasRight("user", "user", "read") && !$user->admin) {
  88. accessforbidden();
  89. }
  90. // Defini si peux lire/modifier utilisateurs et permisssions
  91. $caneditperms = ($user->admin || $user->hasRight("user", "user", "write"));
  92. $permissiontodelete = ($user->admin || $user->hasRight("user", "user", "write"));
  93. // Advanced permissions
  94. if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
  95. $caneditperms = ($user->admin || $user->hasRight("user", "group_advance", "write"));
  96. }
  97. /*
  98. * Actions
  99. */
  100. if (GETPOST('cancel', 'alpha')) {
  101. $action = 'list';
  102. $massaction = '';
  103. }
  104. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  105. $massaction = '';
  106. }
  107. $parameters = array();
  108. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  109. if ($reshook < 0) {
  110. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  111. }
  112. if (empty($reshook)) {
  113. // Selection of new fields
  114. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  115. // Purge search criteria
  116. 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
  117. foreach ($object->fields as $key => $val) {
  118. $search[$key] = '';
  119. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  120. $search[$key.'_dtstart'] = '';
  121. $search[$key.'_dtend'] = '';
  122. }
  123. }
  124. $toselect = array();
  125. $search_array_options = array();
  126. }
  127. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  128. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  129. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  130. }
  131. // Mass actions
  132. $objectclass = 'UserGroup';
  133. $objectlabel = 'UserGroup';
  134. $uploaddir = $conf->user->dir_output;
  135. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  136. }
  137. /*
  138. * View
  139. */
  140. $form = new Form($db);
  141. $now = dol_now();
  142. $title = $langs->trans("UserGroups");
  143. $help_url = '';
  144. $morejs = array();
  145. $morecss = array();
  146. // Build and execute select
  147. // --------------------------------------------------------------------
  148. $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";
  149. $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
  150. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
  151. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
  152. if (isModEnabled('multicompany') && $conf->entity == 1 && (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {
  153. $sql .= " WHERE g.entity IS NOT NULL";
  154. } else {
  155. $sql .= " WHERE g.entity IN (0,".$conf->entity.")";
  156. }
  157. if (!empty($search_group)) {
  158. natural_search(array("g.nom", "g.note"), $search_group);
  159. }
  160. if ($search_all) {
  161. $sql .= natural_search(array("g.nom", "g.note"), $search_all);
  162. }
  163. $sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
  164. // Complete request and execute it with limit
  165. $sql .= $db->order($sortfield, $sortorder);
  166. if ($limit) {
  167. $sql .= $db->plimit($limit + 1, $offset);
  168. }
  169. $resql = $db->query($sql);
  170. if (!$resql) {
  171. dol_print_error($db);
  172. exit;
  173. }
  174. $num = $db->num_rows($resql);
  175. $nbtotalofrecords = $num;
  176. $i = 0;
  177. // Output page
  178. // --------------------------------------------------------------------
  179. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
  180. $arrayofselected = is_array($toselect) ? $toselect : array();
  181. $param = "&search_group=".urlencode($search_group)."&search_all=".urlencode($search_all);
  182. if (!empty($mode)) {
  183. $param .= '&mode='.urlencode($mode);
  184. }
  185. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  186. $param .= '&contextpage='.urlencode($contextpage);
  187. }
  188. if ($limit > 0 && $limit != $conf->liste_limit) {
  189. $param .= '&limit='.((int) $limit);
  190. }
  191. foreach ($search as $key => $val) {
  192. if (is_array($search[$key])) {
  193. foreach ($search[$key] as $skey) {
  194. if ($skey != '') {
  195. $param .= '&search_'.$key.'[]='.urlencode($skey);
  196. }
  197. }
  198. } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
  199. $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
  200. $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
  201. $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
  202. } elseif ($search[$key] != '') {
  203. $param .= '&search_'.$key.'='.urlencode($search[$key]);
  204. }
  205. }
  206. if ($optioncss != '') {
  207. $param .= '&optioncss='.urlencode($optioncss);
  208. }
  209. // Add $param from extra fields
  210. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  211. // Add $param from hooks
  212. $parameters = array();
  213. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  214. $param .= $hookmanager->resPrint;
  215. // List of mass actions available
  216. $arrayofmassactions = array(
  217. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  218. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  219. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  220. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  221. );
  222. if (!empty($permissiontodelete)) {
  223. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  224. }
  225. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  226. $arrayofmassactions = array();
  227. }
  228. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  229. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  230. if ($optioncss != '') {
  231. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  232. }
  233. print '<input type="hidden" name="token" value="'.newToken().'">';
  234. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  235. print '<input type="hidden" name="action" value="list">';
  236. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  237. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  238. print '<input type="hidden" name="page" value="'.$page.'">';
  239. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  240. print '<input type="hidden" name="page_y" value="">';
  241. print '<input type="hidden" name="mode" value="'.$mode.'">';
  242. $newcardbutton = '';
  243. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  244. $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'));
  245. if ($caneditperms) {
  246. $newcardbutton .= dolGetButtonTitleSeparator();
  247. $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu=');
  248. }
  249. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  250. // Add code for pre mass action (confirmation or email presend form)
  251. $topicmail = "SendGroup";
  252. $modelmail = "group";
  253. $objecttmp = new UserGroup($db);
  254. $trackid = 'grp'.$object->id;
  255. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  256. if ($search_all) {
  257. $setupstring = '';
  258. foreach ($fieldstosearchall as $key => $val) {
  259. $fieldstosearchall[$key] = $langs->trans($val);
  260. $setupstring .= $key."=".$val.";";
  261. }
  262. print '<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  263. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
  264. }
  265. $moreforfilter = '';
  266. $parameters = array();
  267. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  268. if (empty($reshook)) {
  269. $moreforfilter .= $hookmanager->resPrint;
  270. } else {
  271. $moreforfilter = $hookmanager->resPrint;
  272. }
  273. if (!empty($moreforfilter)) {
  274. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  275. print $moreforfilter;
  276. $parameters = array();
  277. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  278. print $hookmanager->resPrint;
  279. print '</div>';
  280. }
  281. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  282. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  283. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  284. print '<div class="div-table-responsive">';
  285. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  286. // Fields title search
  287. // --------------------------------------------------------------------
  288. // ...
  289. $totalarray = array();
  290. $totalarray['nbfield'] = 0;
  291. // Fields title label
  292. // --------------------------------------------------------------------
  293. print '<tr class="liste_titre">';
  294. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  295. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  296. $totalarray['nbfield']++;
  297. }
  298. print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", $param, "", "", $sortfield, $sortorder);
  299. $totalarray['nbfield']++;
  300. //multicompany
  301. if (isModEnabled('multicompany') && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
  302. print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], "g.entity", $param, "", '', $sortfield, $sortorder, 'center ');
  303. $totalarray['nbfield']++;
  304. }
  305. print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", $param, "", '', $sortfield, $sortorder, 'center ');
  306. $totalarray['nbfield']++;
  307. print_liste_field_titre("NbOfPermissions", $_SERVER["PHP_SELF"], "nbpermissions", $param, "", '', $sortfield, $sortorder, 'center ');
  308. $totalarray['nbfield']++;
  309. print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "g.datec", $param, "", '', $sortfield, $sortorder, 'center ');
  310. $totalarray['nbfield']++;
  311. print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "g.tms", $param, "", '', $sortfield, $sortorder, 'center ');
  312. $totalarray['nbfield']++;
  313. // Extra fields
  314. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  315. // Hook fields
  316. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  317. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  318. print $hookmanager->resPrint;
  319. /*if (!empty($arrayfields['anotherfield']['checked'])) {
  320. print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';
  321. $totalarray['nbfield']++;
  322. }*/
  323. // Action column
  324. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  325. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  326. $totalarray['nbfield']++;
  327. }
  328. print '</tr>'."\n";
  329. // Loop on record
  330. // --------------------------------------------------------------------
  331. $i = 0;
  332. $savnbfield = $totalarray['nbfield'];
  333. $totalarray = array();
  334. $totalarray['nbfield'] = 0;
  335. $imaxinloop = ($limit ? min($num, $limit) : $num);
  336. while ($i < $imaxinloop) {
  337. $obj = $db->fetch_object($resql);
  338. if (empty($obj)) {
  339. break; // Should not happen
  340. }
  341. // Store properties in $object
  342. $object->setVarsFromFetchObj($obj);
  343. $object->name = $obj->name;
  344. $object->note = $obj->note;
  345. $object->nb_rights = $obj->nbpermissions;
  346. $object->nb_users = $obj->nb;
  347. if ($mode == 'kanban') {
  348. if ($i == 0) {
  349. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  350. print '<div class="box-flex-container kanban">';
  351. }
  352. // Output Kanban
  353. $selected = -1;
  354. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  355. $selected = 0;
  356. if (in_array($object->id, $arrayofselected)) {
  357. $selected = 1;
  358. }
  359. }
  360. print $object->getKanbanView('', array('selected' => $selected));
  361. if ($i == ($imaxinloop - 1)) {
  362. print '</div>';
  363. print '</td></tr>';
  364. }
  365. } else {
  366. // Show here line of result
  367. $j = 0;
  368. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  369. // Action column
  370. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  371. print '<td class="nowrap center">';
  372. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  373. $selected = 0;
  374. if (in_array($object->id, $arrayofselected)) {
  375. $selected = 1;
  376. }
  377. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  378. }
  379. print '</td>';
  380. if (!$i) {
  381. $totalarray['nbfield']++;
  382. }
  383. }
  384. print '<td class="tdoverflowmax125">';
  385. print $object->getNomUrl(1);
  386. if (isModEnabled('multicompany') && !$obj->entity) {
  387. print img_picto($langs->trans("GlobalGroup"), 'redstar');
  388. }
  389. print "</td>";
  390. if (!$i) {
  391. $totalarray['nbfield']++;
  392. }
  393. //multicompany
  394. if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
  395. $mc->getInfo($obj->entity);
  396. print '<td class="center">'.dol_escape_htmltag($mc->label).'</td>';
  397. if (!$i) {
  398. $totalarray['nbfield']++;
  399. }
  400. }
  401. print '<td class="center">'.dol_escape_htmltag($obj->nb).'</td>';
  402. if (!$i) {
  403. $totalarray['nbfield']++;
  404. }
  405. print '<td class="center">';
  406. print '<a href="'.DOL_URL_ROOT.'/user/group/perms.php?id='.$obj->rowid.'">'.dol_escape_htmltag($obj->nbpermissions).'</a>';
  407. print '</td>';
  408. if (!$i) {
  409. $totalarray['nbfield']++;
  410. }
  411. print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), "dayhour").'</td>';
  412. if (!$i) {
  413. $totalarray['nbfield']++;
  414. }
  415. print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->tms), "dayhour").'</td>';
  416. if (!$i) {
  417. $totalarray['nbfield']++;
  418. }
  419. // Extra fields
  420. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  421. // Fields from hook
  422. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  423. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  424. print $hookmanager->resPrint;
  425. // Action column
  426. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  427. print '<td class="nowrap center">';
  428. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  429. $selected = 0;
  430. if (in_array($object->id, $arrayofselected)) {
  431. $selected = 1;
  432. }
  433. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  434. }
  435. print '</td>';
  436. if (!$i) {
  437. $totalarray['nbfield']++;
  438. }
  439. }
  440. print '</tr>'."\n";
  441. }
  442. $i++;
  443. }
  444. // Show total line
  445. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  446. // If no record found
  447. if ($num == 0) {
  448. /*$colspan = 1;
  449. foreach ($arrayfields as $key => $val) {
  450. if (!empty($val['checked'])) {
  451. $colspan++;
  452. }
  453. }*/
  454. $colspan = $savnbfield;
  455. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  456. }
  457. $db->free($resql);
  458. print '</table>'."\n";
  459. print '</div>'."\n";
  460. print '</form>'."\n";
  461. // End of page
  462. llxFooter();
  463. $db->close();