5 #script to place reserves/requests
6 #writen 2/1/00 by chris@katipo.oc.nz
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
29 use C4::Interface::CGI::Output;
34 use C4::Circulation::Circ2;
42 # get biblio information....
43 my $bib = $input->param('bib');
44 my $dat = bibdata($bib);
46 # get existing reserves .....
47 my ($count,$reserves) = FindReserves($bib);
48 my $totalcount = $count;
49 foreach my $res (@$reserves) {
50 if ($res->{'found'} eq 'W') {
55 # make priorities options
58 #priorityoptions building
60 for (my $i=1; $i<=$num; $i++){
63 $option{selected}=($i==$num);
64 push(@optionloop, \%option);
68 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
71 my $date=format_date("$year-$mon-$mday");
74 # get biblioitem information and build rows for form
75 my ($count2,@data) = bibitems($bib);
78 foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) {
79 $dat->{'dewey'}="" if ($dat->{'dewey'} == 0);
80 $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'};
81 $dat->{'dewey'}=~ s/\.0000$//;
82 $dat->{'dewey'}=~ s/00$//;
86 my @barcodes = barcodes($dat->{'biblioitemnumber'});
87 foreach my $num (@barcodes) {
89 $barcode{'barcode'}=$num->{'barcode'};
90 $barcode{'message'}=$num->{'itemlost'} == 1 ? "(lost)" :
91 $num->{'itemlost'} == 2 ? "(long overdue)" : "";
92 push(@barcodeloop, \%barcode);
94 $abibitem{'barcodeloop'}=\@barcodeloop;
95 $abibitem{'class'}="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}";
97 $abibitem{'itemlost'}=(($dat->{'notforloan'})|| ($dat->{'itemlost'} == 1)) ;
98 $abibitem{'biblioitemnumber'}=$dat->{'biblioitemnumber'};
99 $abibitem{'description'}=$dat->{'description'};
100 $abibitem{'volumeddesc'}=$dat->{'volumeddesc'};
101 $abibitem{'publicationyear'}=$dat->{'publicationyear'};
102 push(@bibitemloop,\%abibitem);
107 #existingreserves building
109 my $branches = getbranches();
110 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
112 # my $prioropt = priorityoptions($totalcount, $res->{'priority'});
114 for (my $i=1; $i<=$totalcount; $i++){
117 $option{selected}=($i==$res->{'priority'});
118 push(@optionloop, \%option);
121 foreach my $br (keys %$branches) {
122 # (next) unless $branches->{$br}->{'IS'};
123 # Only branches with the 'IS' branchrelation
126 $abranch{'selected'}=($br eq $res->{'branchcode'});
127 $abranch{'branch'}=$br;
128 $abranch{'branchname'}=$branches->{$br}->{'branchname'};
129 push(@branchloop,\%abranch);
132 if ($res->{'found'} eq 'W') {
134 my $item = $res->{'itemnumber'};
135 $item = getiteminformation(\%env,$item);
136 $reserve{'holdingbranch'}=$item->{'holdingbranch'};
137 $reserve{'barcode'}=$item->{'barcode'};
138 $reserve{'biblionumber'}=$item->{'biblionumber'};
139 $reserve{'wbrcode'} = $res->{'branchcode'};
140 $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
141 if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){
142 $reserve{'atdestination'} = 1;
146 $reserve{'date'} = format_date($res->{'reservedate'});
147 $reserve{'borrowernumber'}=$res->{'borrowernumber'};
148 $reserve{'biblionumber'}=$res->{'biblionumber'};
149 $reserve{'bornum'}=$res->{'borrowernumber'};
150 $reserve{'firstname'}=$res->{'firstname'};
151 $reserve{'surname'}=$res->{'surname'};
152 $reserve{'bornum'}=$res->{'borrowernumber'};
153 $reserve{'notes'}=$res->{'reservenotes'};
154 $reserve{'wait'}=($res->{'found'} eq 'W');
155 $reserve{'constrainttypea'}=($res->{'constrainttype'} eq 'a');
156 $reserve{'constrainttypeo'}=($res->{'constrainttype'} eq 'o');
157 $reserve{'voldesc'}=$res->{'volumeddesc'};
158 $reserve{'itemtype'}=$res->{'itemtype'};
159 $reserve{'branchloop'}=\@branchloop;
160 $reserve{'optionloop'}=\@optionloop;
161 push(@reserveloop,\%reserve);
167 my ($count2,@branches)=branches();
168 for (my $i=0;$i<$count2;$i++){
169 push @select_branch, $branches[$i]->{'branchcode'};#
170 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
172 my $CGIbranch=CGI::scrolling_list( -name => 'pickup',
173 -values => \@select_branch,
174 -labels => \%select_branches,
178 #get the time for the form name...
182 my ($template, $borrowernumber, $cookie)
183 = get_template_and_user({template_name => "request.tmpl",
186 authnotrequired => 0,
187 flagsrequired => {parameters => 1},
189 $template->param( optionloop =>\@optionloop,
190 CGIbranch => $CGIbranch,
191 reserveloop => \@reserveloop,
193 bibitemloop => \@bibitemloop,
196 title =>$dat->{title});
198 print $input->header(
199 -type => C4::Interface::CGI::Output::guesstype($template->output),
201 ), $template->output;