2012-09-05 03:26:57 +02:00
< ? php
2016-01-09 01:18:53 +01:00
/* Copyright ( C ) 2007 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-09-05 03:57:26 +02:00
* Copyright ( C ) 2011 Dimitri Mouillard < dmouillard @ teclib . com >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-09-05 03:57:26 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
2012-09-05 03:26:57 +02:00
/**
* Displays the log of actions performed in the module .
*
2012-12-20 20:16:10 +01:00
* \file htdocs / holiday / view_log . php
2012-09-05 03:26:57 +02:00
* \ingroup holiday
*/
2012-09-06 10:39:25 +02:00
require ( '../main.inc.php' );
2012-09-07 17:23:16 +02:00
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/holiday/common.inc.php' ;
2014-08-06 03:09:59 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2012-09-05 03:26:57 +02:00
// Protection if external user
if ( $user -> societe_id > 0 ) accessforbidden ();
// Si l'utilisateur n'a pas le droit de lire cette page
2015-06-27 11:45:23 +02:00
if ( ! $user -> rights -> holiday -> read_all ) accessforbidden ();
2012-09-05 03:26:57 +02:00
2014-08-06 03:09:59 +02:00
$year = GETPOST ( 'year' );
if ( empty ( $year ))
{
$tmpdate = dol_getdate ( dol_now ());
$year = $tmpdate [ 'year' ];
}
2012-09-05 03:26:57 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2015-06-27 11:45:23 +02:00
$langs -> load ( 'users' );
2012-09-05 03:26:57 +02:00
/*
* View
2014-08-05 17:45:41 +02:00
*/
2012-09-05 03:26:57 +02:00
2015-06-27 11:45:23 +02:00
$cp = new Holiday ( $db );
2013-04-30 00:26:37 +02:00
2016-07-01 17:53:16 +02:00
$alltypeleaves = $cp -> getTypes ( 1 , - 1 ); // To have labels
2016-04-09 16:04:07 +02:00
llxHeader ( '' , $langs -> trans ( 'CPTitreMenu' ) . ' (' . $langs -> trans ( " Year " ) . ' ' . $year . ')' );
2012-09-05 03:26:57 +02:00
2014-08-05 17:45:41 +02:00
// Recent changes are more important than old changes
2014-08-06 03:09:59 +02:00
$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
2012-09-05 03:26:57 +02:00
2017-06-10 22:57:25 +02:00
$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>' ;
print load_fiche_titre ( $langs -> trans ( 'LogCP' ), $pagination , 'title_hrm.png' );
2012-09-05 03:26:57 +02:00
2015-06-27 11:45:23 +02:00
print '<div class="info">' . $langs -> trans ( 'LastUpdateCP' ) . ': ' . " \n " ;
2016-07-14 15:31:56 +02:00
$lastUpdate = $cp -> getConfCP ( 'lastUpdate' );
if ( $lastUpdate )
{
$monthLastUpdate = $lastUpdate [ 4 ] . $lastUpdate [ 5 ];
$yearLastUpdate = $lastUpdate [ 0 ] . $lastUpdate [ 1 ] . $lastUpdate [ 2 ] . $lastUpdate [ 3 ];
print '<strong>' . dol_print_date ( $db -> jdate ( $cp -> getConfCP ( 'lastUpdate' )), 'dayhour' , 'tzuser' ) . '</strong>' ;
print '<br>' . $langs -> trans ( " MonthOfLastMonthlyUpdate " ) . ': <strong>' . $yearLastUpdate . '-' . $monthLastUpdate . '</strong>' . " \n " ;
}
2015-06-27 11:45:23 +02:00
else print $langs -> trans ( 'None' );
print " </div><br> \n " ;
2016-11-27 13:49:46 +01:00
$moreforfilter = '' ;
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '" id="tablelines3">' . " \n " ;
2012-09-05 03:26:57 +02:00
print '<tbody>' ;
2016-12-22 16:09:12 +01:00
print '<tr class="liste_titre">' ;
print '<td class="liste_titre"></td>' ;
print '<td class="liste_titre"></td>' ;
print '<td class="liste_titre"></td>' ;
print '<td class="liste_titre"></td>' ;
print '<td class="liste_titre"></td>' ;
print '<td class="liste_titre"></td>' ;
print '<td class="liste_titre"></td>' ;
print '<td class="liste_titre"></td>' ;
2012-09-05 03:26:57 +02:00
print '</tr>' ;
2016-12-22 16:09:12 +01:00
2017-06-10 22:57:25 +02:00
print '<tr class="liste_titre">' ;
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( 'ID' );
print_liste_field_titre ( 'Date' , $_SERVER [ " PHP_SELF " ], '' , '' , '' , 'align="center"' );
print_liste_field_titre ( 'ActionByCP' );
print_liste_field_titre ( 'UserUpdateCP' );
print_liste_field_titre ( 'Description' );
print_liste_field_titre ( 'Type' );
print_liste_field_titre ( 'PrevSoldeCP' , $_SERVER [ " PHP_SELF " ], '' , '' , '' , 'align="right"' );
print_liste_field_titre ( 'NewSoldeCP' , $_SERVER [ " PHP_SELF " ], '' , '' , '' , 'align="right"' );
2017-06-10 22:57:25 +02:00
print '</tr>' ;
2016-12-22 16:09:12 +01:00
2012-09-05 03:26:57 +02:00
foreach ( $cp -> logs as $logs_CP )
{
$user_action = new User ( $db );
$user_action -> fetch ( $logs_CP [ 'fk_user_action' ]);
$user_update = new User ( $db );
$user_update -> fetch ( $logs_CP [ 'fk_user_update' ]);
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2012-09-05 03:26:57 +02:00
print '<td>' . $logs_CP [ 'rowid' ] . '</td>' ;
print '<td style="text-align: center;">' . $logs_CP [ 'date_action' ] . '</td>' ;
2016-09-01 11:29:30 +02:00
print '<td>' . $user_action -> getNomUrl ( - 1 ) . '</td>' ;
print '<td>' . $user_update -> getNomUrl ( - 1 ) . '</td>' ;
2012-09-05 03:26:57 +02:00
print '<td>' . $logs_CP [ 'type_action' ] . '</td>' ;
2016-07-01 17:53:16 +02:00
print '<td>' ;
2018-03-19 13:55:26 +01:00
$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' ]);
2016-07-01 17:53:16 +02:00
print $label ? $label : $logs_CP [ 'fk_type' ];
print '</td>' ;
2015-06-21 03:19:15 +02:00
print '<td style="text-align: right;">' . price2num ( $logs_CP [ 'prev_solde' ], 5 ) . ' ' . $langs -> trans ( 'days' ) . '</td>' ;
print '<td style="text-align: right;">' . price2num ( $logs_CP [ 'new_solde' ], 5 ) . ' ' . $langs -> trans ( 'days' ) . '</td>' ;
2012-09-05 03:26:57 +02:00
print '</tr>' . " \n " ;
}
2016-01-09 01:18:53 +01:00
if ( $log_holiday == '2' )
2012-09-05 03:26:57 +02:00
{
2016-07-14 15:31:56 +02:00
print '<tr ' . $bc [ false ] . '>' ;
print '<td colspan="8" class="opacitymedium">' . $langs -> trans ( 'NoRecordFound' ) . '</td>' ;
2012-09-05 03:26:57 +02:00
print '</tr>' ;
}
print '</tbody>' . " \n " ;
print '</table>' . " \n " ;
2016-11-27 13:49:46 +01:00
print '</div>' ;
2012-09-05 03:26:57 +02:00
llxFooter ();
2015-06-27 11:45:23 +02:00
$db -> close ();