view_log.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. $langs->load('users');
  39. /*
  40. * View
  41. */
  42. $cp = new Holiday($db);
  43. $alltypeleaves=$cp->getTypes(1,-1); // To have labels
  44. llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')');
  45. // Recent changes are more important than old changes
  46. $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
  47. print load_fiche_titre($langs->trans('LogCP'), '<div class="pagination"><ul><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'">&lt;</a><li class="pagination"><a href="">'.$langs->trans("Year").' '.$year.'</a></li><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'">&gt;</a></li></lu></div>', 'title_hrm.png');
  48. print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n";
  49. $lastUpdate = $cp->getConfCP('lastUpdate');
  50. if ($lastUpdate)
  51. {
  52. $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
  53. $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
  54. print '<strong>'.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')),'dayhour','tzuser').'</strong>';
  55. print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>'."\n";
  56. }
  57. else print $langs->trans('None');
  58. print "</div><br>\n";
  59. print '<table class="noborder" width="100%">';
  60. print '<tbody>';
  61. print '<tr class="liste_titre">';
  62. print '<td class="liste_titre">'.$langs->trans('ID').'</td>';
  63. print '<td class="liste_titre" align="center">'.$langs->trans('Date').'</td>';
  64. print '<td class="liste_titre">'.$langs->trans('ActionByCP').'</td>';
  65. print '<td class="liste_titre">'.$langs->trans('UserUpdateCP').'</td>';
  66. print '<td class="liste_titre">'.$langs->trans('Description').'</td>';
  67. print '<td class="liste_titre">'.$langs->trans('Type').'</td>';
  68. print '<td class="liste_titre" align="right">'.$langs->trans('PrevSoldeCP').'</td>';
  69. print '<td class="liste_titre" align="right">'.$langs->trans('NewSoldeCP').'</td>';
  70. print '</tr>';
  71. $var=true;
  72. foreach($cp->logs as $logs_CP)
  73. {
  74. $var=!$var;
  75. $user_action = new User($db);
  76. $user_action->fetch($logs_CP['fk_user_action']);
  77. $user_update = new User($db);
  78. $user_update->fetch($logs_CP['fk_user_update']);
  79. print '<tr '.$bc[$var].'>';
  80. print '<td>'.$logs_CP['rowid'].'</td>';
  81. print '<td style="text-align: center;">'.$logs_CP['date_action'].'</td>';
  82. print '<td>'.$user_action->getNomUrl(1).'</td>';
  83. print '<td>'.$user_update->getNomUrl(1).'</td>';
  84. print '<td>'.$logs_CP['type_action'].'</td>';
  85. print '<td>';
  86. $label=$alltypeleaves[$logs_CP['fk_type']]['label'];
  87. print $label?$label:$logs_CP['fk_type'];
  88. print '</td>';
  89. print '<td style="text-align: right;">'.price2num($logs_CP['prev_solde'],5).' '.$langs->trans('days').'</td>';
  90. print '<td style="text-align: right;">'.price2num($logs_CP['new_solde'],5).' '.$langs->trans('days').'</td>';
  91. print '</tr>'."\n";
  92. }
  93. if ($log_holiday == '2')
  94. {
  95. print '<tr '.$bc[false].'>';
  96. print '<td colspan="8" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
  97. print '</tr>';
  98. }
  99. print '</tbody>'."\n";
  100. print '</table>'."\n";
  101. llxFooter();
  102. $db->close();