dolibarr  7.0.0-beta
view_log.php
Go to the documentation of this file.
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 
26 require('../main.inc.php');
27 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
30 
31 // Protection if external user
32 if ($user->societe_id > 0) accessforbidden();
33 
34 // Si l'utilisateur n'a pas le droit de lire cette page
35 if(!$user->rights->holiday->read_all) accessforbidden();
36 
37 $year=GETPOST('year');
38 if (empty($year))
39 {
40  $tmpdate=dol_getdate(dol_now());
41  $year=$tmpdate['year'];
42 }
43 
44 $langs->load('users');
45 
46 
47 /*
48  * View
49  */
50 
51 $cp = new Holiday($db);
52 
53 $alltypeleaves=$cp->getTypes(1,-1); // To have labels
54 
55 llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')');
56 
57 // Recent changes are more important than old changes
58 $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
59 
60 $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>';
61 print load_fiche_titre($langs->trans('LogCP'), $pagination, 'title_hrm.png');
62 
63 print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n";
64 $lastUpdate = $cp->getConfCP('lastUpdate');
65 if ($lastUpdate)
66 {
67  $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
68  $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
69  print '<strong>'.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')),'dayhour','tzuser').'</strong>';
70  print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>'."\n";
71 }
72 else print $langs->trans('None');
73 print "</div><br>\n";
74 
75 $moreforfilter='';
76 
77 print '<div class="div-table-responsive">';
78 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
79 
80 print '<tbody>';
81 
82 print '<tr class="liste_titre">';
83 print '<td class="liste_titre"></td>';
84 print '<td class="liste_titre"></td>';
85 print '<td class="liste_titre"></td>';
86 print '<td class="liste_titre"></td>';
87 print '<td class="liste_titre"></td>';
88 print '<td class="liste_titre"></td>';
89 print '<td class="liste_titre"></td>';
90 print '<td class="liste_titre"></td>';
91 print '</tr>';
92 
93 print '<tr class="liste_titre">';
95 print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', '', '', 'align="center"');
96 print_liste_field_titre('ActionByCP');
97 print_liste_field_titre('UserUpdateCP');
98 print_liste_field_titre('Description');
100 print_liste_field_titre('PrevSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"');
101 print_liste_field_titre('NewSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"');
102 print '</tr>';
103 
104 
105 foreach($cp->logs as $logs_CP)
106 {
107  $user_action = new User($db);
108  $user_action->fetch($logs_CP['fk_user_action']);
109 
110  $user_update = new User($db);
111  $user_update->fetch($logs_CP['fk_user_update']);
112 
113  print '<tr class="oddeven">';
114  print '<td>'.$logs_CP['rowid'].'</td>';
115  print '<td style="text-align: center;">'.$logs_CP['date_action'].'</td>';
116  print '<td>'.$user_action->getNomUrl(-1).'</td>';
117  print '<td>'.$user_update->getNomUrl(-1).'</td>';
118  print '<td>'.$logs_CP['type_action'].'</td>';
119  print '<td>';
120  $label=$alltypeleaves[$logs_CP['fk_type']]['label'];
121  print $label?$label:$logs_CP['fk_type'];
122  print '</td>';
123  print '<td style="text-align: right;">'.price2num($logs_CP['prev_solde'],5).' '.$langs->trans('days').'</td>';
124  print '<td style="text-align: right;">'.price2num($logs_CP['new_solde'],5).' '.$langs->trans('days').'</td>';
125  print '</tr>'."\n";
126 
127 }
128 
129 if ($log_holiday == '2')
130 {
131  print '<tr '.$bc[false].'>';
132  print '<td colspan="8" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
133  print '</tr>';
134 }
135 
136 print '</tbody>'."\n";
137 print '</table>'."\n";
138 print '</div>';
139 
140 llxFooter();
141 
142 $db->close();
Class of the module paid holiday.
llxFooter()
Empty footer.
Definition: wrapper.php:58
Class to manage Dolibarr users.
Definition: user.class.php:39
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:445
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
dol_now($mode='gmt')
Return date for now.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:459
print
Draft customers invoices.
Definition: index.php:91
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.