autocomplete.css - unclosed comment error removed
[koha.git] / reports / reservereport.pl
blobd67320b5964c3e2b3c59fe5fba1c4aab3bd10e92
1 #!/usr/bin/perl
3 #written 26/4/2000
4 #script to display reports
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
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.
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.
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
23 # script now takes a branchcode arg
24 # eg: http://koha.rangitikei.katipo.co.nz/cgi-bin/koha/reports/reservereport.pl?branch=BL
26 use strict;
27 use C4::Stats;
28 use C4::Dates qw/format_date/;
29 use CGI;
30 use C4::Output;
31 use C4::Branch; # GetBranches
32 use C4::Auth;
33 use C4::Koha;
36 my $input = new CGI;
37 my $time = $input->param('time');
38 my $branch = $input->param('branch');
39 my $sort = $input->param('sort');
41 if (!$branch) {
42 $branch = "ALL";
45 my $branches=GetBranches();
47 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
49 template_name => "reports/reservereport.tmpl",
50 query => $input,
51 type => "intranet",
52 authnotrequired => 0,
53 flagsrequired => { reports => 1 },
54 debug => 1,
58 # building up branches dropdown box
60 my %branchall;
61 my $branchcount=0;
62 my @branchloop;
64 foreach my $br (keys %$branches) {
65 $branchcount++;
66 my %branch1;
67 $branch1{name}=$branches->{$br}->{'branchname'};
68 $branch1{value}=$br;
69 push(@branchloop,\%branch1);
72 my ( $count, $data ) = unfilledreserves($branch);
74 my @dataloop;
75 my $toggle;
76 for ( my $i = 0 ; $i < $count ; $i++ ) {
77 my %line;
78 $toggle = $i%2 ? 0 : 1;
79 $line{'borrowernumber'} = $data->[$i]->{'borrowernumber'};
80 $line{'surname'} = $data->[$i]->{'surname'};
81 $line{'firstname'} = $data->[$i]->{'firstname'};
82 $line{'sortdate'} = $data->[$i]->{'reservedate'};
83 $line{'reservedate'} = format_date($data->[$i]->{'reservedate'});
84 $line{'biblionumber'} = $data->[$i]->{'biblionumber'};
85 $line{'title'} = $data->[$i]->{'title'};
86 $line{'classification'} = $data->[$i]->{'classification'};
87 $line{'dewey'} = $data->[$i]->{'dewey'};
88 $line{'status'} = $data->[$i]->{'found'};
89 $line{'branchcode'} = $data->[$i]->{'branchcode'};
90 $line{'toggle'} = $toggle;
91 if ( $line{'status'} ne 'W' ) {
93 # its not waiting, we need to find if its on issue, or on the shelf
94 # FIXME still need to shift the text to the template so its translateable
95 if ( $data->[$i]) {
96 # find if its on issue
97 my @items = &GetItemsInfo($line{'biblionumber'}, 'intra' );
98 my $onissue = 0;
99 foreach my $item (@items) {
100 if ( $item->{'datedue'} eq 'Reserved' ) {
101 $onissue = 0;
102 if ($item->{'branchname'} eq ''){
103 $line{'status'}='In Transit';
105 else {
106 $line{'status'} = "On shelf at $item->{'branchname'}";
111 else {
112 $onissue = 1;
115 if ($onissue) {
116 $line{'status'} = 'On Issue';
119 else {
120 $line{'status'}="Waiting for pickup";
124 push( @dataloop, \%line );
127 if ($sort eq 'name'){
128 @dataloop = sort {$a->{'surname'} cmp $b->{'surname'}} @dataloop;
130 elsif ($sort eq 'date'){
131 @dataloop = sort {$a->{'sortdate'} cmp $b->{'sortdate'}} @dataloop;
133 elsif ($sort eq 'title'){
134 @dataloop = sort {$a->{'title'} cmp $b->{'title'}} @dataloop;
136 else {
137 @dataloop = sort {$a->{'status'} cmp $b->{'status'}} @dataloop;
141 $template->param(
142 count => $count,
143 dataloop => \@dataloop,
144 branchcode => $branch,
145 branchloop => \@branchloop
149 output_html_with_http_headers $input, $cookie, $template->output;