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
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 # script now takes a branchcode arg
24 # eg: http://koha.rangitikei.katipo.co.nz/cgi-bin/koha/reports/reservereport.pl?branch=BL
27 #use warnings; FIXME - Bug 2505
29 use C4
::Dates qw
/format_date/;
32 use C4
::Branch
; # GetBranches
39 my $time = $input->param('time');
40 my $branch = $input->param('branch');
41 my $sort = $input->param('sort');
47 my $branches=GetBranches
();
49 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
51 template_name
=> "reports/reservereport.tt",
55 flagsrequired
=> { reports
=> '*' },
60 # building up branches dropdown box
66 foreach my $br (keys %$branches) {
69 $branch1{name
}=$branches->{$br}->{'branchname'};
71 push(@branchloop,\
%branch1);
74 my ( $count, $data ) = unfilledreserves
($branch);
78 for ( my $i = 0 ; $i < $count ; $i++ ) {
80 $toggle = $i%2 ?
0 : 1;
81 $line{'borrowernumber'} = $data->[$i]->{'borrowernumber'};
82 $line{'surname'} = $data->[$i]->{'surname'};
83 $line{'firstname'} = $data->[$i]->{'firstname'};
84 $line{'sortdate'} = $data->[$i]->{'reservedate'};
85 $line{'reservedate'} = format_date
($data->[$i]->{'reservedate'});
86 $line{'biblionumber'} = $data->[$i]->{'biblionumber'};
87 $line{'title'} = $data->[$i]->{'title'};
88 $line{'classification'} = $data->[$i]->{'classification'};
89 $line{'dewey'} = $data->[$i]->{'dewey'};
90 $line{'status'} = $data->[$i]->{'found'};
91 $line{'branchcode'} = $data->[$i]->{'branchcode'};
92 $line{'toggle'} = $toggle;
93 if ( $line{'status'} ne 'W' ) {
95 # its not waiting, we need to find if its on issue, or on the shelf
96 # FIXME still need to shift the text to the template so its translateable
98 # find if its on issue
99 my @items = GetItemsInfo
( $line{biblionumber
} );
101 foreach my $item (@items) {
102 if ( $item->{'datedue'} eq 'Reserved' ) {
104 if ($item->{'branchname'} eq ''){
105 $line{'status'}='In Transit';
108 $line{'status'} = "On shelf at $item->{'branchname'}";
118 $line{'status'} = 'On Issue';
122 $line{'status'}="Waiting for pickup";
126 push( @dataloop, \
%line );
129 if ($sort eq 'name'){
130 @dataloop = sort {$a->{'surname'} cmp $b->{'surname'}} @dataloop;
132 elsif ($sort eq 'date'){
133 @dataloop = sort {$a->{'sortdate'} cmp $b->{'sortdate'}} @dataloop;
135 elsif ($sort eq 'title'){
136 @dataloop = sort {$a->{'title'} cmp $b->{'title'}} @dataloop;
139 @dataloop = sort {$a->{'status'} cmp $b->{'status'}} @dataloop;
145 dataloop
=> \
@dataloop,
146 branchcode
=> $branch,
147 branchloop
=> \
@branchloop
151 output_html_with_http_headers
$input, $cookie, $template->output;