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
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
28 use C4
::Dates qw
/format_date/;
31 use C4
::Branch
; # GetBranches
37 my $time = $input->param('time');
38 my $branch = $input->param('branch');
39 my $sort = $input->param('sort');
45 my $branches=GetBranches
();
47 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
49 template_name
=> "reports/reservereport.tmpl",
53 flagsrequired
=> { reports
=> 1 },
58 # building up branches dropdown box
64 foreach my $br (keys %$branches) {
67 $branch1{name
}=$branches->{$br}->{'branchname'};
69 push(@branchloop,\
%branch1);
72 my ( $count, $data ) = unfilledreserves
($branch);
76 for ( my $i = 0 ; $i < $count ; $i++ ) {
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
96 # find if its on issue
97 my @items = &GetItemsInfo
($line{'biblionumber'}, 'intra' );
99 foreach my $item (@items) {
100 if ( $item->{'datedue'} eq 'Reserved' ) {
102 if ($item->{'branchname'} eq ''){
103 $line{'status'}='In Transit';
106 $line{'status'} = "On shelf at $item->{'branchname'}";
116 $line{'status'} = 'On Issue';
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;
137 @dataloop = sort {$a->{'status'} cmp $b->{'status'}} @dataloop;
143 dataloop
=> \
@dataloop,
144 branchcode
=> $branch,
145 branchloop
=> \
@branchloop
149 output_html_with_http_headers
$input, $cookie, $template->output;