adding a 'use ZOOM' to biblio.pm, needed for non-mod_perl install.
[koha.git] / admin / viewlog.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 use strict;
23 use C4::Auth;
24 use CGI;
25 use C4::Context;
26 use HTML::Template;
27 use C4::Koha;
28 use C4::Interface::CGI::Output;
29 use C4::Log;
30 use Date::Manip;
31
32 =head1 NAME
33
34 plugin that shows a stats on borrowers
35
36 =head1 DESCRIPTION
37
38
39 =over2
40
41 =cut
42
43 my $input = new CGI;
44 my $do_it=$input->param('do_it');
45 my $fullreportname = "parameters/viewlog.tmpl";
46 my $modulename = $input->param("module");
47 my $userfilter = $input->param("user");
48 my $actionfilter = $input->param("action");
49 my $fromfilter = $input->param("from");
50 my $tofilter = $input->param("to");
51 my $basename = $input->param("basename");
52 my $mime = $input->param("MIME");
53 my $del = $input->param("sep");
54 my $output = $input->param("output");
55
56 #warn "module : ".$modulename;
57 my ($template, $borrowernumber, $cookie)
58         = get_template_and_user({template_name => $fullreportname,
59                                 query => $input,
60                                 type => "intranet",
61                                 authnotrequired => 0,
62                                 flagsrequired => {editcatalogue => 1},
63                                 debug => 1,
64                                 });
65 $template->param(do_it => $do_it);
66 if ($do_it) {
67 # Displaying results
68         #building filters
69         my @filters;
70         push @filters, {name=> 'user', value=> $userfilter} if ($userfilter);
71         push @filters, {name=> 'action', value=> $actionfilter} if ($actionfilter);
72         push @filters, {name=> 'from', value=> $fromfilter} if ($fromfilter);
73         push @filters, {name=> 'to', value=> $tofilter} if ($tofilter);
74         if ($modulename eq "catalogue"){
75                 my $titlefilter = $input->param("title");
76                 my $authorfilter = $input->param("author");
77                 my $publisherfilter = $input->param("publisher");
78                 my $callnumberfilter = $input->param("itemcallnumber");
79                 
80                 push @filters, {name=> 'title', value=> $titlefilter} if ($titlefilter);
81                 push @filters, {name=> 'author', value=> $authorfilter} if ($authorfilter);
82                 push @filters, {name=> 'publisher', value=> $publisherfilter} if ($publisherfilter);
83                 push @filters, {name=> 'callnumber', value=> $callnumberfilter} if ($callnumberfilter);
84         }
85         
86         my ($count, $results) = displaylog( $modulename, @filters);
87         if ($output eq "screen"){
88 # Printing results to screen
89                 $template->param(modulename =>$modulename, $modulename => 1, looprow => $results);
90                 output_html_with_http_headers $input, $cookie, $template->output;
91                 exit(1);
92         } else {
93 # Printing to a csv file
94                 print $input->header(-type => 'application/vnd.sun.xml.calc',
95                         -attachment=>"$basename.csv",
96                         -filename=>"$basename.csv" );
97                 my $sep;
98                 $sep =C4::Context->preference("delimiter");
99 # header top-right
100 # Other header
101 # Table
102                 foreach my $line ( @$results ) {
103                         if ($modulename eq "catalogue"){
104                                 print $line->{timestamp}.$sep;
105                                 print $line->{firstname}.$sep;
106                                 print $line->{surname}.$sep;
107                                 print $line->{action}.$sep;
108                                 print $line->{info}.$sep;
109                                 print $line->{title}.$sep;
110                                 print $line->{author}.$sep;
111                         }
112                         print "\n";
113                 }
114 # footer
115                 exit(1);
116         }
117 } else {
118         my $dbh = C4::Context->dbh;
119         my @values;
120         my %labels;
121         my %select;
122         my $req;
123         
124         my @mime = ( C4::Context->preference("MIME") );
125 #       foreach my $mime (@mime){
126 #               warn "".$mime;
127 #       }
128         
129         my $CGIextChoice=CGI::scrolling_list(
130                                 -name     => 'MIME',
131                                 -id       => 'MIME',
132                                 -values   => \@mime,
133                                 -size     => 1,
134                                 -multiple => 0 );
135         
136         my @dels = ( C4::Context->preference("delimiter") );
137         my $CGIsepChoice=CGI::scrolling_list(
138                                 -name     => 'sep',
139                                 -id       => 'sep',
140                                 -values   => \@dels,
141                                 -size     => 1,
142                                 -multiple => 0 );
143         
144         $template->param(
145                                         CGIextChoice => $CGIextChoice,
146                                         CGIsepChoice => $CGIsepChoice
147                                         );
148 output_html_with_http_headers $input, $cookie, $template->output;
149 }