4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
36 $debug = $ENV{DEBUG} || 0;
41 plugin that shows a stats on borrowers
47 $debug or $debug = $input->param('debug') || 0;
48 my $do_it = $input->param('do_it');
49 my $module = $input->param("module");
50 my $user = $input->param("user");
51 my $action = $input->param("action");
52 my $object = $input->param("object");
53 my $info = $input->param("info");
54 my $datefrom = $input->param("from");
55 my $dateto = $input->param("to");
56 my $basename = $input->param("basename");
57 my $mime = $input->param("MIME");
58 my $del = $input->param("sep");
59 my $output = $input->param("output") || "screen";
60 my $src = $input->param("src"); # this param allows us to be told where we were called from -fbcit
62 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
64 template_name => "tools/viewlog.tmpl",
68 flagsrequired => { tools => 'view_system_logs' },
73 if ($src eq 'circ') { # if we were called from circulation, use the circulation menu and get data to populate it -fbcit
75 my $borrowernumber = $object;
76 my $data = GetMember($borrowernumber,'borrowernumber');
77 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
78 $template->param( picture => 1 ) if $picture;
79 $template->param( menu => 1,
80 title => $data->{'title'},
81 initials => $data->{'initials'},
82 surname => $data->{'surname'},
83 borrowernumber => $borrowernumber,
84 firstname => $data->{'firstname'},
85 cardnumber => $data->{'cardnumber'},
86 categorycode => $data->{'categorycode'},
87 categoryname => $data->{'description'},
88 address => $data->{'address'},
89 address2 => $data->{'address2'},
90 city => $data->{'city'},
91 phone => $data->{'phone'},
92 phonepro => $data->{'phonepro'},
93 email => $data->{'email'},
94 branchcode => $data->{'branchcode'},
95 branchname => GetBranchName($data->{'branchcode'}),
100 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
101 dateformat => C4::Dates->new()->format(),
107 my $results = GetLogs($datefrom,$dateto,$user,$module,$action,$object,$info);
108 my $total = scalar @$results;
109 warn "Total records retrieved = $total";
110 foreach my $result (@$results){
111 if ($result->{'info'} eq 'item'){
112 # get item information so we can create a working link
113 my $item=GetItem($result->{'object'});
114 $result->{'biblionumber'}=$item->{'biblionumber'};
115 $result->{'biblioitemnumber'}=$item->{'biblionumber'};
119 if ( $output eq "screen" ) {
120 # Printing results to screen
127 datefrom => $datefrom,
136 output_html_with_http_headers $input, $cookie, $template->output;
138 # Printing to a csv file
139 print $input->header(
140 -type => 'application/vnd.sun.xml.calc',
141 -attachment => "$basename.csv",
142 -filename => "$basename.csv"
144 my $sep = C4::Context->preference("delimiter");
145 foreach my $line (@$results) {
146 ($module eq "catalogue") or next;
147 foreach (qw(timestamp firstname surname action info title author)) {
148 print $line->{$_} . $sep;
157 my @mime = ( C4
::Context
->preference("MIME") );
158 my $CGIextChoice = CGI
::scrolling_list
(
165 my @dels = ( C4
::Context
->preference("delimiter") );
166 my $CGIsepChoice = CGI
::scrolling_list
(
175 CGIextChoice
=> $CGIextChoice,
176 CGIsepChoice
=> $CGIsepChoice,
178 output_html_with_http_headers
$input, $cookie, $template->output;