fixing sort for pendingreserves report
[koha.git] / tools / viewlog.pl
blob0d5379eea1ac4ba7aa16083cb1455b8940fbe283
1 #!/usr/bin/perl
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
11 # version.
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
21 use strict;
22 use C4::Auth;
23 use CGI;
24 use C4::Context;
25 use C4::Koha;
26 use C4::Dates;
27 use C4::Output;
28 use C4::Log;
30 =head1 viewlog.pl
32 plugin that shows a stats on borrowers
34 =cut
36 my $input = new CGI;
37 my $do_it = $input->param('do_it');
38 my $module = $input->param("module");
39 my $user = $input->param("user");
40 my $action = $input->param("action");
41 my $object = $input->param("object");
42 my $info = $input->param("info");
43 my $datefrom = $input->param("from");
44 my $dateto = $input->param("to");
45 my $basename = $input->param("basename");
46 my $mime = $input->param("MIME");
47 my $del = $input->param("sep");
48 my $output = $input->param("output") || "screen";
50 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
52 template_name => "tools/viewlog.tmpl",
53 query => $input,
54 type => "intranet",
55 authnotrequired => 0,
56 flagsrequired => { tools => 1 },
57 debug => 1,
61 if ($do_it) {
63 my $results = GetLogs($datefrom,$dateto,$user,$module,$action,$object,$info);
64 my $total = scalar @$results;
66 if ( $output eq "screen" ) {
67 # Printing results to screen
68 $template->param (
69 total => $total,
70 $module => 1,
71 looprow => $results,
72 do_it => 1,
73 datefrom => $datefrom,
74 dateto => $dateto,
75 user => $user,
76 module => $module,
77 object => $object,
78 action => $action,
79 info => $info,
81 output_html_with_http_headers $input, $cookie, $template->output;
82 } else {
83 # Printing to a csv file
84 print $input->header(
85 -type => 'application/vnd.sun.xml.calc',
86 -attachment => "$basename.csv",
87 -filename => "$basename.csv"
89 my $sep = C4::Context->preference("delimiter");
90 foreach my $line (@$results) {
91 ($module eq "catalogue") or next;
92 foreach (qw(timestamp firstname surname action info title author)) {
93 print $line->{$_} . $sep;
97 exit;
98 } else {
99 my @values;
100 my %labels;
101 my %select;
102 my @mime = ( C4::Context->preference("MIME") );
103 my $CGIextChoice = CGI::scrolling_list(
104 -name => 'MIME',
105 -id => 'MIME',
106 -values => \@mime,
107 -size => 1,
108 -multiple => 0
110 my @dels = ( C4::Context->preference("delimiter") );
111 my $CGIsepChoice = CGI::scrolling_list(
112 -name => 'sep',
113 -id => 'sep',
114 -values => \@dels,
115 -size => 1,
116 -multiple => 0
118 $template->param(
119 total => 0,
120 CGIextChoice => $CGIextChoice,
121 CGIsepChoice => $CGIsepChoice,
122 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
124 output_html_with_http_headers $input, $cookie, $template->output;