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
34 use C4::Circulation::Circ2;
40 # get biblio information....
41 my $bib = $input->param('bib');
42 my $dat = bibdata($bib);
44 # get existing reserves .....
45 my ($count,$reserves) = FindReserves($bib);
46 my $totalcount = $count;
47 foreach my $res (@$reserves) {
48 if ($res->{'found'} eq 'W') {
53 # make priorities options
56 #priorityoptions building
58 for (my $i=1; $i<=$num; $i++){
61 $option{selected}=($i==$num);
62 push(@optionloop, \%option);
66 # get branch information
67 my $branch = $input->cookie('branch');
68 ($branch) || ($branch = 'L');
69 my $branches = getbranches();
70 # make branch selection options...
72 foreach my $br (keys %$branches) {
73 (next) unless $branches->{$br}->{'IS'};
74 # Only branches with the 'IS' branchrelation
77 $abranch{'selected'}=($br eq $branch);
78 $abranch{'branch'}=$br;
79 $abranch{'branchname'}=$branches->{$br}->{'branchname'};
80 push(@branchloop,\%abranch);
85 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
88 my $date="$mday/$mon/$year";
91 # get biblioitem information and build rows for form
92 my ($count2,@data) = bibitems($bib);
95 foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) {
96 $dat->{'dewey'}="" if ($dat->{'dewey'} == 0);
97 $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'};
98 $dat->{'dewey'}=~ s/\.0000$//;
99 $dat->{'dewey'}=~ s/00$//;
103 my @barcodes = barcodes($dat->{'biblioitemnumber'});
104 foreach my $num (@barcodes) {
106 $barcode{'barcode'}=$num->{'barcode'};
107 $barcode{'message'}=$num->{'itemlost'} == 1 ? "(lost)" :
108 $num->{'itemlost'} == 2 ? "(long overdue)" : "";
109 push(@barcodeloop, \%barcode);
111 $abibitem{'barcodeloop'}=\@barcodeloop;
112 $abibitem{'class'}="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}";
114 $abibitem{'itemlost'}=(($dat->{'notforloan'})|| ($dat->{'itemlost'} == 1)) ;
115 $abibitem{'biblioitemnumber'}=$dat->{'biblioitemnumber'};
116 $abibitem{'description'}=$dat->{'description'};
117 $abibitem{'volumeddesc'}=$dat->{'volumeddesc'};
118 $abibitem{'publicationyear'}=$dat->{'publicationyear'};
119 push(@bibitemloop,\%abibitem);
124 #existingreserves building
126 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
128 # my $prioropt = priorityoptions($totalcount, $res->{'priority'});
130 for (my $i=1; $i<=$totalcount; $i++){
133 $option{selected}=($i==$res->{'priority'});
134 push(@optionloop, \%option);
136 # my $bropt = branchoptions($res->{'branchcode'});
138 foreach my $br (keys %$branches) {
139 (next) unless $branches->{$br}->{'IS'};
140 # Only branches with the 'IS' branchrelation
143 $abranch{'selected'}=($br eq $res->{'branchcode'});
144 $abranch{'branch'}=$br;
145 $abranch{'branchname'}=$branches->{$br}->{'branchname'};
146 push(@branchloop,\%abranch);
149 if ($res->{'found'} eq 'W') {
151 my $item = $res->{'itemnumber'};
152 $item = getiteminformation(\%env,$item);
153 $reserve{'barcode'}=$item->{'barcode'};
154 $reserve{'biblionumber'}=$item->{'biblionumber'};
155 $reserve{'wbrcode'} = $res->{'branchcode'};
156 $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
158 $reserve{'date'} = slashifyDate($res->{'reservedate'});
159 $reserve{'borrowernumber'}=$res->{'borrowernumber'};
160 $reserve{'biblionumber'}=$res->{'biblionumber'};
161 $reserve{'bornum'}=$res->{'borrowernumber'};
162 $reserve{'firstname'}=$res->{'firstname'};
163 $reserve{'bornum'}=$res->{'borrowernumber'};
164 $reserve{'notes'}=$res->{'reservenotes'};
165 $reserve{'wait'}=($res->{'found'} eq 'W');
166 $reserve{'constrainttypea'}=($res->{'constrainttype'} eq 'a');
167 $reserve{'constrainttypeo'}=($res->{'constrainttype'} eq 'o');
168 $reserve{'voldesc'}=$res->{'volumeddesc'};
169 $reserve{'itemtype'}=$res->{'itemtype'};
170 $reserve{'branchloop'}=\@branchloop;
171 $reserve{'optionloop'}=\@optionloop;
172 push(@reserveloop,\%reserve);
175 #get the time for the form name...
183 my ($template, $borrowernumber, $cookie)
184 = get_template_and_user({template_name => "request.tmpl",
187 authnotrequired => 0,
188 flagsrequired => {parameters => 1},
190 $template->param( optionloop =>\@optionloop,
191 branchloop => \@branchloop,
192 reserveloop => \@reserveloop,
194 bibitemloop => \@bibitemloop,
197 print $input->header(-expires=>'now'), $template->output;