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
35 $debug = $ENV{DEBUG} || 0;
40 plugin that shows a stats on borrowers
46 $debug or $debug = $input->param('debug') || 0;
47 my $do_it = $input->param('do_it');
48 my $module = $input->param("module");
49 my $user = $input->param("user");
50 my $action = $input->param("action");
51 my $object = $input->param("object");
52 my $info = $input->param("info");
53 my $datefrom = $input->param("from");
54 my $dateto = $input->param("to");
55 my $basename = $input->param("basename");
56 my $mime = $input->param("MIME");
57 my $del = $input->param("sep");
58 my $output = $input->param("output") || "screen";
59 my $src = $input->param("src"); # this param allows us to be told where we were called from -fbcit
61 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
63 template_name => "tools/viewlog.tmpl",
67 flagsrequired => { tools => 'view_system_logs' },
72 if ($src eq 'circ') { # if we were called from circulation, use the circulation menu and get data to populate it -fbcit
74 my $borrowernumber = $object;
75 my $data = GetMember($borrowernumber,'borrowernumber');
76 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
77 $template->param( picture => 1 ) if $picture;
78 $template->param( menu => 1,
79 title => $data->{'title'},
80 initials => $data->{'initials'},
81 surname => $data->{'surname'},
82 borrowernumber => $borrowernumber,
83 firstname => $data->{'firstname'},
84 cardnumber => $data->{'cardnumber'},
85 categorycode => $data->{'categorycode'},
86 address => $data->{'address'},
87 address2 => $data->{'address2'},
88 city => $data->{'city'},
89 phone => $data->{'phone'},
90 phonepro => $data->{'phonepro'},
91 email => $data->{'email'},
92 branchcode => $data->{'branchcode'},
97 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
98 dateformat => C4::Dates->new()->format(),
104 my $results = GetLogs($datefrom,$dateto,$user,$module,$action,$object,$info);
105 my $total = scalar @$results;
106 warn "Total records retrieved = $total";
107 foreach my $result (@$results){
108 if ($result->{'info'} eq 'item'){
109 # get item information so we can create a working link
110 my $item=GetItem($result->{'object'});
111 $result->{'biblionumber'}=$item->{'biblionumber'};
112 $result->{'biblioitemnumber'}=$item->{'biblionumber'};
116 if ( $output eq "screen" ) {
117 # Printing results to screen
124 datefrom => $datefrom,
133 output_html_with_http_headers $input, $cookie, $template->output;
135 # Printing to a csv file
136 print $input->header(
137 -type => 'application/vnd.sun.xml.calc',
138 -attachment => "$basename.csv",
139 -filename => "$basename.csv"
141 my $sep = C4::Context->preference("delimiter");
142 foreach my $line (@$results) {
143 ($module eq "catalogue") or next;
144 foreach (qw(timestamp firstname surname action info title author)) {
145 print $line->{$_} . $sep;
154 my @mime = ( C4
::Context
->preference("MIME") );
155 my $CGIextChoice = CGI
::scrolling_list
(
162 my @dels = ( C4
::Context
->preference("delimiter") );
163 my $CGIsepChoice = CGI
::scrolling_list
(
172 CGIextChoice
=> $CGIextChoice,
173 CGIsepChoice
=> $CGIsepChoice,
175 output_html_with_http_headers
$input, $cookie, $template->output;