view_log.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * Displays the log of actions performed in the module.
  20. *
  21. * \file htdocs/holiday/view_log.php
  22. * \ingroup holiday
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  28. // Protection if external user
  29. if ($user->societe_id > 0) accessforbidden();
  30. // Si l'utilisateur n'a pas le droit de lire cette page
  31. if(!$user->rights->holiday->read_all) accessforbidden();
  32. $year=GETPOST('year');
  33. if (empty($year))
  34. {
  35. $tmpdate=dol_getdate(dol_now());
  36. $year=$tmpdate['year'];
  37. }
  38. // Load translation files required by the page
  39. $langs->load('users');
  40. /*
  41. * View
  42. */
  43. $cp = new Holiday($db);
  44. $alltypeleaves=$cp->getTypes(1,-1); // To have labels
  45. llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')');
  46. // Recent changes are more important than old changes
  47. $log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year,1,1))."' AND '".$db->idate(dol_get_last_day($year,12,1))."'"); // Load $cp->logs
  48. $pagination='<div class="pagination"><ul><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'"><i class="fa fa-chevron-left" title="Previous"></i></a><li class="pagination"><span class="active">'.$langs->trans("Year").' '.$year.'</span></li><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'"><i class="fa fa-chevron-right" title="Next"></i></a></li></lu></div>';
  49. print load_fiche_titre($langs->trans('LogCP'), $pagination, 'title_hrm.png');
  50. print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n";
  51. $lastUpdate = $cp->getConfCP('lastUpdate');
  52. if ($lastUpdate)
  53. {
  54. $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
  55. $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
  56. print '<strong>'.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')),'dayhour','tzuser').'</strong>';
  57. print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>'."\n";
  58. }
  59. else print $langs->trans('None');
  60. print "</div><br>\n";
  61. $moreforfilter='';
  62. print '<div class="div-table-responsive">';
  63. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
  64. print '<tbody>';
  65. print '<tr class="liste_titre">';
  66. print '<td class="liste_titre"></td>';
  67. print '<td class="liste_titre"></td>';
  68. print '<td class="liste_titre"></td>';
  69. print '<td class="liste_titre"></td>';
  70. print '<td class="liste_titre"></td>';
  71. print '<td class="liste_titre"></td>';
  72. print '<td class="liste_titre"></td>';
  73. print '<td class="liste_titre"></td>';
  74. print '</tr>';
  75. print '<tr class="liste_titre">';
  76. print_liste_field_titre('ID');
  77. print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', '', '', 'align="center"');
  78. print_liste_field_titre('ActionByCP');
  79. print_liste_field_titre('UserUpdateCP');
  80. print_liste_field_titre('Description');
  81. print_liste_field_titre('Type');
  82. print_liste_field_titre('PrevSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"');
  83. print_liste_field_titre('NewSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"');
  84. print '</tr>';
  85. foreach($cp->logs as $logs_CP)
  86. {
  87. $user_action = new User($db);
  88. $user_action->fetch($logs_CP['fk_user_action']);
  89. $user_update = new User($db);
  90. $user_update->fetch($logs_CP['fk_user_update']);
  91. print '<tr class="oddeven">';
  92. print '<td>'.$logs_CP['rowid'].'</td>';
  93. print '<td style="text-align: center;">'.$logs_CP['date_action'].'</td>';
  94. print '<td>'.$user_action->getNomUrl(-1).'</td>';
  95. print '<td>'.$user_update->getNomUrl(-1).'</td>';
  96. print '<td>'.$logs_CP['type_action'].'</td>';
  97. print '<td>';
  98. $label = (($alltypeleaves[$logs_CP['fk_type']]['code'] && $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code'])!=$alltypeleaves[$logs_CP['fk_type']]['code']) ? $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) : $alltypeleaves[$logs_CP['fk_type']]['label']);
  99. print $label?$label:$logs_CP['fk_type'];
  100. print '</td>';
  101. print '<td style="text-align: right;">'.price2num($logs_CP['prev_solde'],5).' '.$langs->trans('days').'</td>';
  102. print '<td style="text-align: right;">'.price2num($logs_CP['new_solde'],5).' '.$langs->trans('days').'</td>';
  103. print '</tr>'."\n";
  104. }
  105. if ($log_holiday == '2')
  106. {
  107. print '<tr '.$bc[false].'>';
  108. print '<td colspan="8" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
  109. print '</tr>';
  110. }
  111. print '</tbody>'."\n";
  112. print '</table>'."\n";
  113. print '</div>';
  114. // End of page
  115. llxFooter();
  116. $db->close();