view_log.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <?php
  2. /* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
  4. * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * Displays the log of actions performed in the module.
  21. *
  22. * \file htdocs/holiday/view_log.php
  23. * \ingroup holiday
  24. */
  25. // Load Dolibarr environment
  26. require '../main.inc.php';
  27. // Security check (access forbidden for external user too)
  28. if (!$user->hasRight('holiday', 'define_holiday') || $user->socid > 0) {
  29. accessforbidden();
  30. }
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  35. $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
  36. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  37. $mode = GETPOST('mode', 'alpha');
  38. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  39. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  40. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  41. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  42. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search
  43. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  44. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  45. $search_id = GETPOST('search_id', 'alphanohtml');
  46. $search_month = GETPOST('search_month', 'int');
  47. $search_year = GETPOST('search_year', 'int');
  48. $search_employee = GETPOST('search_employee', 'int');
  49. $search_validator = GETPOST('search_validator', 'int');
  50. $search_description = GETPOST('search_description', 'alphanohtml');
  51. $search_type = GETPOST('search_type', 'int');
  52. $search_prev_solde = GETPOST('search_prev_solde', 'alphanohtml');
  53. $search_new_solde = GETPOST('search_new_solde', 'alphanohtml');
  54. // Load variable for pagination
  55. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  56. $sortfield = GETPOST('sortfield', 'aZ09comma');
  57. $sortorder = GETPOST('sortorder', 'aZ09comma');
  58. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  59. if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
  60. $page = 0;
  61. } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
  62. $offset = $limit * $page;
  63. $pageprev = $page - 1;
  64. $pagenext = $page + 1;
  65. if (!$sortfield) {
  66. $sortfield = "cpl.rowid";
  67. }
  68. if (!$sortorder) {
  69. $sortorder = "DESC";
  70. }
  71. // Load translation files required by the page
  72. $langs->loadLangs(array('users', 'other', 'holiday'));
  73. // Initialize technical objects
  74. $object = new Holiday($db);
  75. $extrafields = new ExtraFields($db);
  76. //$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
  77. $hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_modules contains array
  78. $arrayfields = array();
  79. $arrayofmassactions = array();
  80. if (empty($conf->holiday->enabled)) {
  81. accessforbidden('Module not enabled');
  82. }
  83. // Si l'utilisateur n'a pas le droit de lire cette page
  84. if (!$user->hasRight('holiday', 'readall')) {
  85. accessforbidden();
  86. }
  87. /*
  88. * Actions
  89. */
  90. if (GETPOST('cancel', 'alpha')) {
  91. $action = 'list';
  92. $massaction = '';
  93. }
  94. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  95. $massaction = '';
  96. }
  97. $parameters = array();
  98. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  99. if ($reshook < 0) {
  100. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  101. }
  102. if (empty($reshook)) {
  103. // Selection of new fields
  104. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  105. // Purge search criteria
  106. 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
  107. $search_id = '';
  108. $search_month = '';
  109. $search_year = '';
  110. $search_employee = '';
  111. $search_validator = '';
  112. $search_description = '';
  113. $search_type = '';
  114. $search_prev_solde = '';
  115. $search_new_solde = '';
  116. $toselect = array();
  117. $search_array_options = array();
  118. }
  119. if (GETPOST('button_removefilter_x', 'alpha')
  120. || GETPOST('button_removefilter.x', 'alpha')
  121. || GETPOST('button_removefilter', 'alpha')
  122. || GETPOST('button_search_x', 'alpha')
  123. || GETPOST('button_search.x', 'alpha')
  124. || GETPOST('button_search', 'alpha')) {
  125. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  126. }
  127. // Mass actions
  128. /*$objectclass='MyObject';
  129. $objectlabel='MyObject';
  130. $permissiontoread = $user->rights->mymodule->read;
  131. $permissiontodelete = $user->rights->mymodule->delete;
  132. $uploaddir = $conf->mymodule->dir_output;
  133. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  134. */
  135. }
  136. // Definition of fields for lists
  137. $arrayfields = array(
  138. 'cpl.rowid'=>array('label'=>"ID", 'checked'=>1),
  139. 'cpl.date_action'=>array('label'=>"Date", 'checked'=>1),
  140. 'cpl.fk_user_action'=>array('label'=>"ActionByCP", 'checked'=>1),
  141. 'cpl.fk_user_update'=>array('label'=>"UserUpdateCP", 'checked'=>1),
  142. 'cpl.type_action'=>array('label'=>"Description", 'checked'=>1),
  143. 'cpl.fk_type'=>array('label'=>"Type", 'checked'=>1),
  144. 'cpl.prev_solde'=>array('label'=>"PrevSoldeCP", 'checked'=>1),
  145. 'variation'=>array('label'=>"Variation", 'checked'=>1),
  146. 'cpl.new_solde'=>array('label'=>"NewSoldeCP", 'checked'=>1),
  147. );
  148. /*
  149. * View
  150. */
  151. $form = new Form($db);
  152. $formother = new FormOther($db);
  153. $holidaylogstatic = new stdClass();
  154. $alltypeleaves = $object->getTypes(1, -1); // To have labels
  155. $title = $langs->trans('CPTitreMenu');
  156. llxHeader('', $title);
  157. $sqlwhere = '';
  158. if (!empty($search_year) && $search_year > 0) {
  159. if (!empty($search_month) && $search_month > 0) {
  160. $from_date = dol_get_first_day($search_year, $search_month, 1);
  161. $to_date = dol_get_last_day($search_year, $search_month, 1);
  162. } else {
  163. $from_date = dol_get_first_day($search_year, 1, 1);
  164. $to_date = dol_get_last_day($search_year, 12, 1);
  165. }
  166. $sqlwhere .= "AND date_action BETWEEN '".$db->idate($from_date)."' AND '".$db->idate($to_date)."'";
  167. }
  168. if (!empty($search_id) && $search_id > 0) {
  169. $sqlwhere .= natural_search('rowid', $search_id, 1);
  170. }
  171. if (!empty($search_validator) && $search_validator > 0) {
  172. $sqlwhere .= natural_search('fk_user_action', $search_validator, 1);
  173. }
  174. if (!empty($search_employee) && $search_employee > 0) {
  175. $sqlwhere .= natural_search('fk_user_update', $search_employee, 1);
  176. }
  177. if (!empty($search_description)) {
  178. $sqlwhere .= natural_search('type_action', $search_description);
  179. }
  180. if (!empty($search_type) && $search_type > 0) {
  181. $sqlwhere .= natural_search('fk_type', $search_type, 1);
  182. }
  183. if (!empty($search_prev_solde)) {
  184. $sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1);
  185. }
  186. if (!empty($search_new_solde)) {
  187. $sqlwhere .= natural_search('new_solde', $search_new_solde, 1);
  188. }
  189. $sqlorder = $db->order($sortfield, $sortorder);
  190. // Recent changes are more important than old changes
  191. $log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs
  192. // Count total nb of records
  193. $nbtotalofrecords = '';
  194. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  195. //TODO: $result = $db->query($sql);
  196. //TODO: $nbtotalofrecords = $db->num_rows($result);
  197. $nbtotalofrecords = is_array($object->logs) ? count($object->logs) : 0;
  198. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  199. $page = 0;
  200. $offset = 0;
  201. }
  202. }
  203. // TODO: $num = $db->num_rows($resql);
  204. $num = is_array($object->logs) ? count($object->logs) : 0;
  205. $param = '';
  206. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  207. $param .= '&contextpage='.urlencode($contextpage);
  208. }
  209. if ($limit > 0 && $limit != $conf->liste_limit) {
  210. $param .= '&limit='.((int) $limit);
  211. }
  212. if (!empty($search_id)) {
  213. $param .= '&search_statut='.urlencode($search_statut);
  214. }
  215. if (!empty($search_month) && $search_month > 0) {
  216. $param .= '&search_month='.urlencode($search_month);
  217. }
  218. if (!empty($search_year) && $search_year > 0) {
  219. $param .= '&search_year='.urlencode($search_year);
  220. }
  221. if (!empty($search_validator) && $search_validator > 0) {
  222. $param .= '&search_validator='.urlencode($search_validator);
  223. }
  224. if (!empty($search_employee) && $search_employee > 0) {
  225. $param .= '&search_employee='.urlencode($search_employee);
  226. }
  227. if (!empty($search_description)) {
  228. $param .= '&search_description='.urlencode($search_description);
  229. }
  230. if (!empty($search_type) && $search_type > 0) {
  231. $param .= '&search_type='.urlencode($search_type);
  232. }
  233. if (!empty($search_prev_solde)) {
  234. $param .= '&search_prev_solde='.urlencode($search_prev_solde);
  235. }
  236. if (!empty($search_new_solde)) {
  237. $param .= '&search_new_solde='.urlencode($search_new_solde);
  238. }
  239. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  240. if ($optioncss != '') {
  241. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  242. }
  243. print '<input type="hidden" name="token" value="'.newToken().'">';
  244. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  245. print '<input type="hidden" name="action" value="list">';
  246. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  247. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  248. print '<input type="hidden" name="page" value="'.$page.'">';
  249. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  250. $newcardbutton = dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->rights->holiday->write);
  251. print_barre_liste($langs->trans('LogCP'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1);
  252. print '<div class="info">'.$langs->trans('LastUpdateCP').': ';
  253. $lastUpdate = $object->getConfCP('lastUpdate');
  254. if ($lastUpdate) {
  255. $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
  256. $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
  257. print '<strong>'.dol_print_date($db->jdate($object->getConfCP('lastUpdate')), 'dayhour', 'tzuser').'</strong>';
  258. print '<br>';
  259. print $langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>';
  260. } else {
  261. print $langs->trans('None');
  262. }
  263. print '</div>';
  264. print '<br>';
  265. $moreforfilter = '';
  266. $morefilter = '';
  267. $disabled = 0;
  268. $include = '';
  269. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  270. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  271. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  272. print '<div class="div-table-responsive">';
  273. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">';
  274. print '<tr class="liste_titre_filter">';
  275. // Action column
  276. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  277. print '<td class="liste_titre maxwidthsearch">';
  278. $searchpicto = $form->showFilterButtons();
  279. print $searchpicto;
  280. print '</td>';
  281. }
  282. // Filter Id
  283. if (!empty($arrayfields['cpl.rowid']['checked'])) {
  284. print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
  285. }
  286. // Filter: Date
  287. if (!empty($arrayfields['cpl.date_action']['checked'])) {
  288. print '<td class="liste_titre center">';
  289. print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
  290. print $formother->selectyear($search_year, 'search_year', 1, 10, 5, 0, 0, '', 'valignmiddle width75', true);
  291. print '</td>';
  292. }
  293. // Filter: Validator
  294. if (!empty($arrayfields['cpl.fk_user_action']['checked'])) {
  295. $validator = new UserGroup($db);
  296. $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id;
  297. $valideurobjects = $validator->listUsersForGroup($excludefilter, 1);
  298. $valideurarray = array();
  299. foreach ($valideurobjects as $val) {
  300. $valideurarray[$val] = $val;
  301. }
  302. print '<td class="liste_titre">';
  303. print $form->select_dolusers($search_validator, "search_validator", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
  304. print '</td>';
  305. }
  306. // Filter: User
  307. if (!empty($arrayfields['cpl.fk_user_update']['checked'])) {
  308. print '<td class="liste_titre">';
  309. print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
  310. print '</td>';
  311. }
  312. // Filter: Description
  313. if (!empty($arrayfields['cpl.type_action']['checked'])) {
  314. print '<td class="liste_titre">';
  315. print '<input type="text" class="maxwidth50" name="search_description" value="'.$search_description.'">';
  316. print '</td>';
  317. }
  318. // Filter: Type
  319. if (!empty($arrayfields['cpl.fk_type']['checked'])) {
  320. foreach ($alltypeleaves as $key => $val) {
  321. $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
  322. $arraytypeleaves[$val['rowid']] = $labeltoshow;
  323. }
  324. print '<td class="liste_titre">';
  325. print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1);
  326. print '</td>';
  327. }
  328. // Filter: Previous balance
  329. if (!empty($arrayfields['cpl.prev_solde']['checked'])) {
  330. print '<td class="liste_titre right">';
  331. print '<input type="text" class="maxwidth50" name="search_prev_solde" value="'.$search_prev_solde.'">';
  332. print '</td>';
  333. }
  334. // Filter: Variation (only placeholder)
  335. if (!empty($arrayfields['variation']['checked'])) {
  336. print '<td class="liste_titre"></td>';
  337. }
  338. // Filter: New Balance
  339. if (!empty($arrayfields['cpl.new_solde']['checked'])) {
  340. print '<td class="liste_titre right">';
  341. print '<input type="text" class="maxwidth50" name="search_new_solde" value="'.$search_new_solde.'">';
  342. print '</td>';
  343. }
  344. // Action column
  345. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  346. print '<td class="liste_titre maxwidthsearch">';
  347. $searchpicto = $form->showFilterButtons();
  348. print $searchpicto;
  349. print '</td>';
  350. }
  351. print '</tr>';
  352. print '<tr class="liste_titre">';
  353. // Action column
  354. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  355. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  356. }
  357. if (!empty($arrayfields['cpl.rowid']['checked'])) {
  358. print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'cpl.rowid', '', '', '', $sortfield, $sortorder);
  359. }
  360. if (!empty($arrayfields['cpl.date_action']['checked'])) {
  361. print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center ');
  362. }
  363. if (!empty($arrayfields['cpl.fk_user_action']['checked'])) {
  364. print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder);
  365. }
  366. if (!empty($arrayfields['cpl.fk_user_update']['checked'])) {
  367. print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder);
  368. }
  369. if (!empty($arrayfields['cpl.type_action']['checked'])) {
  370. print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder);
  371. }
  372. if (!empty($arrayfields['cpl.fk_type']['checked'])) {
  373. print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder);
  374. }
  375. if (!empty($arrayfields['cpl.prev_solde']['checked'])) {
  376. print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right ');
  377. }
  378. if (!empty($arrayfields['variation']['checked'])) {
  379. print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right ');
  380. }
  381. if (!empty($arrayfields['cpl.new_solde']['checked'])) {
  382. print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right ');
  383. }
  384. // Action column
  385. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  386. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  387. }
  388. print '</tr>';
  389. $j = 0;
  390. while ($j < ($page * $limit)) {
  391. $obj = next($object->logs);
  392. $j++;
  393. }
  394. $i = 0;
  395. while ($i < min($num, $limit)) {
  396. //TODO: $obj = $db->fetch_object($resql);
  397. $obj = current($object->logs);
  398. if (empty($obj)) {
  399. break;
  400. }
  401. $holidaylogstatic->id = $obj['rowid'];
  402. $holidaylogstatic->date = $obj['date_action'];
  403. $holidaylogstatic->validator = $obj['fk_user_action'];
  404. $holidaylogstatic->employee = $obj['fk_user_update'];
  405. $holidaylogstatic->description = $obj['type_action'];
  406. $holidaylogstatic->type = $obj['fk_type'];
  407. $holidaylogstatic->balance_previous = $obj['prev_solde'];
  408. $holidaylogstatic->balance_new = $obj['new_solde'];
  409. print '<tr class="oddeven">';
  410. // Action column
  411. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  412. print '<td></td>';
  413. }
  414. // Id
  415. if (!empty($arrayfields['cpl.rowid']['checked'])) {
  416. print '<td>'.$holidaylogstatic->id.'</td>';
  417. }
  418. // Date
  419. if (!empty($arrayfields['cpl.date_action']['checked'])) {
  420. print '<td style="text-align: center">'.$holidaylogstatic->date.'</td>';
  421. }
  422. // Validator
  423. if (!empty($arrayfields['cpl.fk_user_action']['checked'])) {
  424. $user_action = new User($db);
  425. $user_action->fetch($holidaylogstatic->validator);
  426. print '<td>'.$user_action->getNomUrl(-1).'</td>';
  427. }
  428. // Emloyee
  429. if (!empty($arrayfields['cpl.fk_user_update']['checked'])) {
  430. $user_update = new User($db);
  431. $user_update->fetch($holidaylogstatic->employee);
  432. print '<td>'.$user_update->getNomUrl(-1).'</td>';
  433. }
  434. // Description
  435. if (!empty($arrayfields['cpl.type_action']['checked'])) {
  436. print '<td class="tdoverflowmax400" title="'.dol_escape_htmltag($holidaylogstatic->description).'">'.dol_escape_htmltag($holidaylogstatic->description).'</td>';
  437. }
  438. // Type
  439. if (!empty($arrayfields['cpl.fk_type']['checked'])) {
  440. $label = '';
  441. if (!empty($alltypeleaves[$holidaylogstatic->type])) {
  442. if ($alltypeleaves[$holidaylogstatic->type]['code'] && $langs->trans($alltypeleaves[$holidaylogstatic->type]['code']) != $alltypeleaves[$holidaylogstatic->type]['code']) {
  443. $label = $langs->trans($alltypeleaves[$holidaylogstatic->type]['code']);
  444. } else {
  445. $label = $alltypeleaves[$holidaylogstatic->type]['label'];
  446. }
  447. }
  448. print '<td>';
  449. print $label ? $label : $holidaylogstatic->type;
  450. print '</td>';
  451. }
  452. // Previous balance
  453. if (!empty($arrayfields['cpl.prev_solde']['checked'])) {
  454. print '<td style="text-align: right;">'.price2num($holidaylogstatic->balance_previous, 5).' '.$langs->trans('days').'</td>';
  455. }
  456. // Variation
  457. if (!empty($arrayfields['variation']['checked'])) {
  458. $delta = price2num($holidaylogstatic->balance_new - $holidaylogstatic->balance_previous, 5);
  459. print '<td style="text-align: right;">';
  460. if ($delta > 0) {
  461. print '<span class="stockmovemententry fontsizeunset">+'.$delta.'</span>';
  462. } else {
  463. print '<span class="stockmovementexit fontsizeunset">'.$delta.'</span>';
  464. }
  465. print '</td>';
  466. }
  467. // New Balance
  468. if (!empty($arrayfields['cpl.new_solde']['checked'])) {
  469. print '<td style="text-align: right;">'.price2num($holidaylogstatic->balance_new, 5).' '.$langs->trans('days').'</td>';
  470. }
  471. // Action column
  472. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  473. print '<td></td>';
  474. }
  475. print '</tr>';
  476. $i++;
  477. next($object->logs);
  478. }
  479. if ($log_holiday == '2') {
  480. print '<tr class="opacitymedium">';
  481. print '<td colspan="10" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
  482. print '</tr>';
  483. }
  484. print '</table>';
  485. print '</div>';
  486. print '</form>';
  487. // End of page
  488. llxFooter();
  489. $db->close();