define_holiday.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <?php
  2. /* Copyright (C) 2007-2022 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
  4. * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
  5. * Copyright (C) 2016 Regis Houssin <regis.houssin@inodbox.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * File that defines the balance of paid holiday of users.
  22. *
  23. * \file htdocs/holiday/define_holiday.php
  24. * \ingroup holiday
  25. * \brief File that defines the balance of paid holiday of users.
  26. */
  27. // Load Dolibarr environment
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  31. // Load translation files required by the page
  32. $langs->loadlangs(array('users', 'other', 'holiday', 'hrm'));
  33. $action = GETPOST('action', 'aZ09');
  34. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'defineholidaylist';
  35. $massaction = GETPOST('massaction', 'alpha');
  36. $optioncss = GETPOST('optioncss', 'alpha');
  37. $mode = GETPOST('optioncss', 'aZ');
  38. $search_name = GETPOST('search_name', 'alpha');
  39. $search_supervisor = GETPOST('search_supervisor', 'int');
  40. // Load variable for pagination
  41. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  42. $sortfield = GETPOST('sortfield', 'aZ09comma');
  43. $sortorder = GETPOST('sortorder', 'aZ09comma');
  44. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  45. $confirm = GETPOST('confirm', 'alpha');
  46. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  47. if (empty($page) || $page == -1) {
  48. $page = 0;
  49. } // If $page is not defined, or '' or -1
  50. $offset = $limit * $page;
  51. $pageprev = $page - 1;
  52. $pagenext = $page + 1;
  53. if (!$sortfield) {
  54. $sortfield = "t.rowid"; // Set here default search field
  55. }
  56. if (!$sortorder) {
  57. $sortorder = "ASC";
  58. }
  59. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
  60. $hookmanager->initHooks(array('defineholidaylist'));
  61. $extrafields = new ExtraFields($db);
  62. $holiday = new Holiday($db);
  63. if (empty($conf->holiday->enabled)) {
  64. accessforbidden('Module not enabled');
  65. }
  66. // Protection if external user
  67. if ($user->socid > 0) {
  68. accessforbidden();
  69. }
  70. // If the user does not have perm to read the page
  71. if (!$user->hasRight('holiday', 'read')) {
  72. accessforbidden();
  73. }
  74. $arrayfields = array(
  75. 'cp.rowid'=>array('label'=>$langs->trans("Employee"), 'checked'=>1, 'position'=>20),
  76. 'cp.fk_user'=>array('label'=>$langs->trans("Supervisor"), 'checked'=>1, 'position'=>30),
  77. 'cp.nbHoliday'=>array('label'=>$langs->trans("MenuConfCP"), 'checked'=>1, 'position'=>40),
  78. 'cp.note_public'=>array('label'=>$langs->trans("Note"), 'checked'=>1, 'position'=>50),
  79. );
  80. /*
  81. * Actions
  82. */
  83. if (GETPOST('cancel', 'alpha')) {
  84. $action = 'list';
  85. $massaction = '';
  86. }
  87. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  88. $massaction = '';
  89. }
  90. $parameters = array();
  91. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  92. if ($reshook < 0) {
  93. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  94. }
  95. if (empty($reshook)) {
  96. // Selection of new fields
  97. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  98. // Purge search criteria
  99. 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
  100. $search_name = '';
  101. $search_supervisor = '';
  102. $toselect = array();
  103. $search_array_options = array();
  104. }
  105. // Mass actions
  106. $objectclass = 'Holiday';
  107. $objectlabel = 'Holiday';
  108. $permissiontoread = $user->hasRight('holiday', 'read');
  109. $permissiontodelete = $user->hasRight('holiday', 'delete');
  110. $permissiontoapprove = $user->hasRight('holiday', 'approve');
  111. $uploaddir = $conf->holiday->dir_output;
  112. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  113. // If there is an update action
  114. if ($action == 'update' && GETPOSTISSET('update_cp')) {
  115. $error = 0;
  116. $nbok = 0;
  117. $typeleaves = $holiday->getTypes(1, 1);
  118. $userID = array_keys(GETPOST('update_cp'));
  119. $userID = $userID[0];
  120. $db->begin();
  121. foreach ($typeleaves as $key => $val) {
  122. $userValue = GETPOST('nb_holiday_'.$val['rowid']);
  123. $userValue = $userValue[$userID];
  124. if (!empty($userValue) || (string) $userValue == '0') {
  125. $userValue = price2num($userValue, 5);
  126. } else {
  127. $userValue = '';
  128. }
  129. //If the user set a comment, we add it to the log comment
  130. $note_holiday = GETPOST('note_holiday');
  131. $comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ? ' ('.$note_holiday[$userID].')' : '');
  132. //print 'holiday: '.$val['rowid'].'-'.$userValue;exit;
  133. if ($userValue != '') {
  134. // We add the modification to the log (must be done before the update of balance because we read current value of balance inside this method)
  135. $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
  136. if ($result < 0) {
  137. setEventMessages($holiday->error, $holiday->errors, 'errors');
  138. $error++;
  139. }
  140. // Update of the days of the employee
  141. if ($result > 0) {
  142. $nbok++;
  143. $result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
  144. if ($result < 0) {
  145. setEventMessages($holiday->error, $holiday->errors, 'errors');
  146. $error++;
  147. }
  148. }
  149. // If it first update of balance, we set date to avoid to have sold incremented by new month
  150. /*
  151. $now=dol_now();
  152. $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
  153. $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
  154. $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
  155. dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
  156. $result = $db->query($sql);
  157. */
  158. }
  159. }
  160. if (!$error && !$nbok) {
  161. setEventMessages($langs->trans("HolidayQtyNotModified", $user->login), null, 'warnings');
  162. }
  163. if (!$error) {
  164. $db->commit();
  165. if ($nbok > 0) {
  166. setEventMessages('UpdateConfCPOK', null, 'mesgs');
  167. }
  168. } else {
  169. $db->rollback();
  170. }
  171. }
  172. }
  173. /*
  174. * View
  175. */
  176. $form = new Form($db);
  177. $userstatic = new User($db);
  178. $title = $langs->trans('CPTitreMenu');
  179. llxHeader('', $title);
  180. $typeleaves = $holiday->getTypes(1, 1);
  181. $result = $holiday->updateBalance(); // Create users into table holiday if they don't exists. TODO Remove this whif we use field into table user.
  182. if ($result < 0) {
  183. setEventMessages($holiday->error, $holiday->errors, 'errors');
  184. }
  185. // List of mass actions available
  186. $arrayofmassactions = array(
  187. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  188. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  189. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  190. );
  191. if ($user->hasRight("holiday", "approve")) {
  192. $arrayofmassactions['preincreaseholiday'] = img_picto('', 'add', 'class="pictofixedwidth"').$langs->trans("IncreaseHolidays");
  193. }
  194. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  195. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  196. if ($optioncss != '') {
  197. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  198. }
  199. print '<input type="hidden" name="token" value="'.newToken().'">';
  200. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  201. print '<input type="hidden" name="action" value="update">';
  202. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  203. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  204. print '<input type="hidden" name="page" value="'.$page.'">';
  205. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  206. $title = $langs->trans("MenuConfCP");
  207. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $massactionbutton, '', '', 'title_hrm', 0, '', '', $limit, 0, 0, 1);
  208. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  209. if ($massaction == 'preincreaseholiday') {
  210. $langs->load("holiday", "hrm");
  211. require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  212. $staticholiday = new Holiday($db);
  213. $arraytypeholidays = $staticholiday->getTypes(1, 1);
  214. $formquestion[] = array();
  215. $labeltypes = array();
  216. foreach ($typeleaves as $key => $val) {
  217. $labeltypes[$val['id']] = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']);
  218. }
  219. $formquestion [] = array( 'type' => 'other',
  220. 'name' => 'typeofholiday',
  221. 'label' => $langs->trans("Type"),
  222. 'value' => $form->selectarray('typeholiday', $labeltypes, GETPOST('typeholiday', 'alpha'), 1)
  223. );
  224. $formquestion [] = array( 'type' => 'other',
  225. 'name' => 'nbdaysholydays',
  226. 'label' => $langs->trans("NumberDayAddMass"),
  227. 'value' => '<input name="nbdaysholidays" class="maxwidth75" id="nbdaysholidays" value="'.GETPOST('nbdaysholidays', 'int').'">'
  228. );
  229. print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassIncreaseHoliday"), $langs->trans("ConfirmMassIncreaseHolidayQuestion", count($toselect)), "increaseholiday", $formquestion, 1, 0, 200, 500, 1);
  230. }
  231. print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n";
  232. $lastUpdate = $holiday->getConfCP('lastUpdate');
  233. if ($lastUpdate) {
  234. print '<strong>'.dol_print_date($db->jdate($lastUpdate), 'dayhour').'</strong>';
  235. print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$langs->trans('Month'.substr($lastUpdate, 4, 2)).' '.substr($lastUpdate, 0, 4).'</strong>'."\n";
  236. } else {
  237. print $langs->trans('None');
  238. }
  239. print "</div><br>\n";
  240. $filters = '';
  241. // Filter on array of ids of all childs
  242. $userchilds = array();
  243. if (!$user->hasRight('holiday', 'readall')) {
  244. $userchilds = $user->getAllChildIds(1);
  245. $filters .= ' AND u.rowid IN ('.$db->sanitize(join(', ', $userchilds)).')';
  246. }
  247. if (!empty($search_name)) {
  248. $filters .= natural_search(array('u.firstname', 'u.lastname'), $search_name);
  249. }
  250. if ($search_supervisor > 0) {
  251. $filters .= natural_search(array('u.fk_user'), $search_supervisor, 2);
  252. }
  253. $filters .= ' AND employee = 1'; // Only employee users are visible
  254. $listUsers = $holiday->fetchUsers(false, true, $filters);
  255. if (is_numeric($listUsers) && $listUsers < 0) {
  256. setEventMessages($holiday->error, $holiday->errors, 'errors');
  257. }
  258. $i = 0;
  259. if (count($typeleaves) == 0) {
  260. //print '<div class="info">';
  261. print $langs->trans("NoLeaveWithCounterDefined")."<br>\n";
  262. print $langs->trans("GoIntoDictionaryHolidayTypes");
  263. //print '</div>';
  264. } else {
  265. $canedit = 0;
  266. if ($user->hasRight('holiday', 'define_holiday')) {
  267. $canedit = 1;
  268. }
  269. $moreforfilter = '';
  270. $selectedfields = '';
  271. if ($massactionbutton) {
  272. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  273. $selectedfields .= ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  274. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  275. }
  276. print '<div class="div-table-responsive">';
  277. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
  278. print '<tr class="liste_titre_filter">';
  279. // Action column
  280. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  281. print '<td class="liste_titre maxwidthsearch center">';
  282. $searchpicto = $form->showFilterButtons();
  283. print $searchpicto;
  284. print '</td>';
  285. }
  286. // User
  287. if (!empty($arrayfields['cp.rowid']['checked'])) {
  288. print '<td class="liste_titre">';
  289. print '<input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).'" class="maxwidth100">';
  290. print '</td>';
  291. }
  292. // Supervisor
  293. if (!empty($arrayfields['cp.fk_user']['checked'])) {
  294. print '<td class="liste_titre">';
  295. print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, null, null, 0, 0, 0, '', 0, '', 'maxwidth150');
  296. print '</td>';
  297. }
  298. // Type of leave request
  299. if (!empty($arrayfields['cp.nbHoliday']['checked'])) {
  300. if (count($typeleaves)) {
  301. foreach ($typeleaves as $key => $val) {
  302. print '<td class="liste_titre" style="text-align:center"></td>';
  303. }
  304. } else {
  305. print '<td class="liste_titre"></td>';
  306. }
  307. }
  308. if (!empty($arrayfields['cp.note_public']['checked'])) {
  309. print '<td class="liste_titre"></td>';
  310. }
  311. print '<td class="liste_titre"></td>';
  312. // Action column
  313. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  314. print '<td class="liste_titre maxwidthsearch center">';
  315. $searchpicto = $form->showFilterButtons();
  316. print $searchpicto;
  317. print '</td>';
  318. }
  319. print '</tr>';
  320. print '<tr class="liste_titre">';
  321. // Action column
  322. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  323. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  324. }
  325. if (!empty($arrayfields['cp.rowid']['checked'])) {
  326. print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]);
  327. }
  328. if (!empty($arrayfields['cp.fk_user']['checked'])) {
  329. print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]);
  330. }
  331. if (!empty($arrayfields['cp.nbHoliday']['checked'])) {
  332. if (count($typeleaves)) {
  333. foreach ($typeleaves as $key => $val) {
  334. $labeltype = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']);
  335. print_liste_field_titre($labeltype, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center ');
  336. }
  337. } else {
  338. print_liste_field_titre('NoLeaveWithCounterDefined', $_SERVER["PHP_SELF"], '', '', '', '');
  339. }
  340. }
  341. if (!empty($arrayfields['cp.note_public']['checked'])) {
  342. print_liste_field_titre((!$user->hasRight('holiday', 'define_holiday') ? '' : 'Note'), $_SERVER["PHP_SELF"]);
  343. }
  344. print_liste_field_titre('');
  345. // Action column
  346. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  347. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  348. }
  349. print '</tr>';
  350. $usersupervisor = new User($db);
  351. foreach ($listUsers as $users) {
  352. $arrayofselected = is_array($toselect) ? $toselect : array();
  353. // If user has not permission to edit/read all, we must see only subordinates
  354. if (!$user->hasRight('holiday', 'readall')) {
  355. if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) {
  356. continue; // This user is not into hierarchy of current user, we hide it.
  357. }
  358. }
  359. $userstatic->id = $users['rowid'];
  360. $userstatic->lastname = $users['lastname'];
  361. $userstatic->firstname = $users['firstname'];
  362. $userstatic->gender = $users['gender'];
  363. $userstatic->photo = $users['photo'];
  364. $userstatic->statut = $users['status'];
  365. $userstatic->employee = $users['employee'];
  366. $userstatic->fk_user = $users['fk_user'];
  367. if ($userstatic->fk_user > 0) {
  368. $usersupervisor->fetch($userstatic->fk_user);
  369. }
  370. print '<tr class="oddeven">';
  371. // Action column
  372. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  373. print '<td class="nowrap center">';
  374. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  375. $selected = 0;
  376. if (in_array($userstatic->id, $arrayofselected)) {
  377. $selected = 1;
  378. }
  379. print '<input id="cb'.$userstatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
  380. }
  381. print '</td>';
  382. }
  383. // User
  384. if (!empty($arrayfields['cp.rowid']['checked'])) {
  385. print '<td>';
  386. print $userstatic->getNomUrl(-1);
  387. print '</td>';
  388. }
  389. // Supervisor
  390. if (!empty($arrayfields['cp.fk_user']['checked'])) {
  391. print '<td>';
  392. if ($userstatic->fk_user > 0) {
  393. print $usersupervisor->getNomUrl(-1);
  394. }
  395. print '</td>';
  396. }
  397. // Amount for each type
  398. if (!empty($arrayfields['cp.nbHoliday']['checked'])) {
  399. if (count($typeleaves)) {
  400. foreach ($typeleaves as $key => $val) {
  401. $nbtoshow = '';
  402. if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') {
  403. $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
  404. }
  405. //var_dump($users['rowid'].' - '.$val['rowid']);
  406. print '<td style="text-align:center">';
  407. if ($canedit) {
  408. print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" class="width75 center" />';
  409. } else {
  410. print $nbtoshow;
  411. }
  412. //print ' '.$langs->trans('days');
  413. print '</td>'."\n";
  414. }
  415. } else {
  416. print '<td></td>';
  417. }
  418. }
  419. // Note
  420. if (!empty($arrayfields['cp.note_public']['checked'])) {
  421. print '<td>';
  422. if ($canedit) {
  423. print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
  424. }
  425. print '</td>';
  426. }
  427. // Button modify
  428. print '<td class="center">';
  429. if ($user->hasRight('holiday', 'define_holiday')) { // Allowed to set the balance of any user
  430. print '<input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Save")).'" class="button smallpaddingimp"/>';
  431. }
  432. print '</td>'."\n";
  433. // Action column
  434. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  435. print '<td class="nowrap center">';
  436. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  437. $selected = 0;
  438. if (in_array($userstatic->id, $arrayofselected)) {
  439. $selected = 1;
  440. }
  441. print '<input id="cb'.$userstatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
  442. }
  443. print '</td>';
  444. }
  445. print '</tr>';
  446. $i++;
  447. }
  448. if (count($listUsers) <= 0) {
  449. $colspan = 2;
  450. foreach ($arrayfields as $key => $val) {
  451. if (!empty($val['checked'])) {
  452. if ($key == 'cp.nbHoliday') {
  453. foreach ($typeleaves as $leave_key => $leave_val) {
  454. $colspan++;
  455. }
  456. } else {
  457. $colspan++;
  458. }
  459. }
  460. }
  461. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  462. }
  463. print '</table>';
  464. print '</div>';
  465. }
  466. print '</form>';
  467. // End of page
  468. llxFooter();
  469. $db->close();