Shows reserves for a given branch
[koha.git] / reports / reservereport.pl
1 #!/usr/bin/perl
2
3 #written 26/4/2000
4 #script to display reports
5
6 # Copyright 2000-2002 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 # script now takes a branchcode arg
24 # eg: http://koha.rangitikei.katipo.co.nz/cgi-bin/koha/reports/reservereport.pl?branch=BL
25
26 use strict;
27 use C4::Stats;
28 use C4::Date;
29 use CGI;
30 use C4::Output;
31 use HTML::Template;
32 use C4::Auth;
33 use C4::Interface::CGI::Output;
34 use C4::Koha;
35
36
37 my $input = new CGI;
38 my $time  = $input->param('time');
39 my $branch = $input->param('branch');
40 if (!$branch) {
41     $branch = "ALL";
42 }
43
44 my $branches=getbranches();
45
46 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
47     {
48         template_name   => "reports/reservereport.tmpl",
49         query           => $input,
50         type            => "intranet",
51         authnotrequired => 0,
52         flagsrequired   => { editcatalogue => 1 },
53         debug           => 1,
54     }
55 );
56
57 # building up branches dropdown box
58
59 my %branchall;
60 my $branchcount=0;
61 my @branchloop;
62
63 foreach my $br (keys %$branches) {
64         $branchcount++;
65             my %branch1;
66             $branch1{name}=$branches->{$br}->{'branchname'};
67             $branch1{value}=$br;
68         push(@branchloop,\%branch1);
69     }  
70
71 my ( $count, $data ) = unfilledreserves($branch);
72
73 my @dataloop;
74 my $toggle;
75 for ( my $i = 0 ; $i < $count ; $i++ ) {
76     my %line;
77         $toggle = $i%2 ? 0 : 1;
78         $line{'borrowernumber'} = $data->[$i]->{'borrowernumber'};
79         $line{'surname'} = $data->[$i]->{'surname'};
80         $line{'firstname'} = $data->[$i]->{'firstname'};
81         $line{'reservedate'}    = format_date($data->[$i]->{'reservedate'});
82         $line{'biblionumber'} = $data->[$i]->{'biblionumber'};
83         $line{'title'} = $data->[$i]->{'title'};
84         $line{'classification'} = $data->[$i]->{'classification'};
85         $line{'dewey'} = $data->[$i]->{'dewey'};
86         $line{'status'} = $data->[$i]->{'found'};
87         $line{'branchcode'} = $data->[$i]->{'branchcode'};
88         $line{'toggle'} = $toggle;
89
90     push( @dataloop, \%line );
91 }
92
93
94 $template->param(
95     count    => $count,
96     dataloop => \@dataloop,
97     branchcode => $branch,
98     branchloop => \@branchloop
99     
100 );
101
102 output_html_with_http_headers $input, $cookie, $template->output;