New framework handling. New koha_attr table for mapping MARC to koha
[koha-ffzg.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 C4::Koha;
27 use C4::Interface::CGI::Output;
28 use C4::Log;
29 use Date::Manip;
30
31 =head1 NAME
32
33 plugin that shows a stats on catalogers
34
35 =head1 DESCRIPTION
36
37
38 =over2
39
40 =cut
41
42 my $input = new CGI;
43 my $do_it=$input->param('do_it');
44 my $fullreportname = "parameters/viewlog.tmpl";
45 my $modulename = $input->param("module");
46 my $userfilter = $input->param("user");
47 my $actionfilter = $input->param("action");
48 my $fromfilter = $input->param("from");
49 my $tofilter = $input->param("to");
50 my $basename = $input->param("basename");
51 my $mime = $input->param("MIME");
52 my $del = $input->param("sep");
53 my $output = $input->param("output");
54
55
56 my ($template, $borrowernumber, $cookie)
57         = get_template_and_user({template_name => $fullreportname,
58                                 query => $input,
59                                 type => "intranet",
60                                 authnotrequired => 0,
61                                 flagsrequired => {editcatalogue => 1},
62                                 debug => 1,
63                                 });
64 $template->param(do_it => $do_it);
65 if ($do_it) {
66 # Displaying results
67         #building filters
68         my @filters;
69         push @filters, {name=> 'user', value=> $userfilter} if ($userfilter);
70         push @filters, {name=> 'action', value=> $actionfilter} if ($actionfilter);
71         push @filters, {name=> 'from', value=> $fromfilter} if ($fromfilter);
72         push @filters, {name=> 'to', value=> $tofilter} if ($tofilter);
73         if ($modulename eq "catalogue"){
74                 my $titlefilter = $input->param("title");
75                 my $authorfilter = $input->param("author");
76                 my $publisherfilter = $input->param("publisher");
77                 my $callnumberfilter = $input->param("itemcallnumber");
78                 
79                 push @filters, {name=> 'title', value=> $titlefilter} if ($titlefilter);
80                 push @filters, {name=> 'author', value=> $authorfilter} if ($authorfilter);
81                 push @filters, {name=> 'publisher', value=> $publisherfilter} if ($publisherfilter);
82                 push @filters, {name=> 'callnumber', value=> $callnumberfilter} if ($callnumberfilter);
83         }
84         
85         my ($count, $results) = displaylog( $modulename, @filters);
86         if ($output eq "screen"){
87 # Printing results to screen
88                 $template->param(modulename =>$modulename, $modulename => 1, looprow => $results,counter=>$count);
89                 output_html_with_http_headers $input, $cookie, $template->output;
90                 exit(1);
91         } else {
92 # Printing to a csv file
93                 print $input->header(-type => 'application/vnd.sun.xml.calc',
94                         -attachment=>"$basename.csv",
95                         -filename=>"$basename.csv" );
96                 my $sep;
97                 $sep =C4::Context->preference("delimiter");
98 # header top-right
99 # Other header
100 # Table
101                 foreach my $line ( @$results ) {
102                         if ($modulename eq "catalogue"){
103                                 print $line->{timestamp}.$sep;
104                                 print $line->{firstname}.$sep;
105                                 print $line->{surname}.$sep;
106                                 print $line->{action}.$sep;
107                                 print $line->{info}.$sep;
108                                 print $line->{title}.$sep;
109                                 print $line->{author}.$sep;
110                         }
111                         print "\n";
112                 }
113 # footer
114                 exit(1);
115         }
116 } else {
117         my $dbh = C4::Context->dbh;
118         my @values;
119         my %labels;
120         my %select;
121         my $req;
122         
123         my @mime = ( C4::Context->preference("MIME") );
124 #       foreach my $mime (@mime){
125 #               warn "".$mime;
126 #       }
127         
128         my $CGIextChoice=CGI::scrolling_list(
129                                 -name     => 'MIME',
130                                 -id       => 'MIME',
131                                 -values   => \@mime,
132                                 -size     => 1,
133                                 -multiple => 0 );
134         
135         my @dels = ( C4::Context->preference("delimiter") );
136         my $CGIsepChoice=CGI::scrolling_list(
137                                 -name     => 'sep',
138                                 -id       => 'sep',
139                                 -values   => \@dels,
140                                 -size     => 1,
141                                 -multiple => 0 );
142         
143         $template->param(
144                                         CGIextChoice => $CGIextChoice,
145                                         CGIsepChoice => $CGIsepChoice
146                                         );
147 output_html_with_http_headers $input, $cookie, $template->output;
148 }