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
33 use C4::Circulation::Circ2;
39 # get biblio information....
40 my $bib = $input->param('bib');
41 my $dat = bibdata($bib);
43 # get existing reserves .....
44 my ($count,$reserves) = FindReserves($bib);
45 my $totalcount = $count;
46 foreach my $res (@$reserves) {
47 if ($res->{'found'} eq 'W') {
52 # make priorities options
55 #priorityoptions building
57 for (my $i=1; $i<=$num; $i++){
60 $option{selected}=($i==$num);
61 push(@optionloop, \%option);
65 # get branch information
66 my $branch = $input->cookie('branch');
67 ($branch) || ($branch = 'L');
68 my $branches = getbranches();
69 # make branch selection options...
71 foreach my $br (keys %$branches) {
72 (next) unless $branches->{$br}->{'IS'};
73 # Only branches with the 'IS' branchrelation
76 $abranch{'selected'}=($br eq $branch);
77 $abranch{'branch'}=$br;
78 $abranch{'branchname'}=$branches->{$br}->{'branchname'};
79 push(@branchloop,\%abranch);
84 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
87 my $date="$mday/$mon/$year";
90 # get biblioitem information and build rows for form
91 my ($count2,@data) = bibitems($bib);
94 foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) {
95 $dat->{'dewey'}="" if ($dat->{'dewey'} == 0);
96 $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'};
97 $dat->{'dewey'}=~ s/\.0000$//;
98 $dat->{'dewey'}=~ s/00$//;
102 my @barcodes = barcodes($dat->{'biblioitemnumber'});
103 foreach my $num (@barcodes) {
105 $barcode{'barcode'}=$num->{'barcode'};
106 $barcode{'message'}=$num->{'itemlost'} == 1 ? "(lost)" :
107 $num->{'itemlost'} == 2 ? "(long overdue)" : "";
108 push(@barcodeloop, \%barcode);
110 $abibitem{'barcodeloop'}=\@barcodeloop;
111 $abibitem{'class'}="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}";
113 $abibitem{'itemlost'}=(($dat->{'notforloan'})|| ($dat->{'itemlost'} == 1)) ;
114 $abibitem{'biblioitemnumber'}=$dat->{'biblioitemnumber'};
115 $abibitem{'description'}=$dat->{'description'};
116 $abibitem{'volumeddesc'}=$dat->{'volumeddesc'};
117 $abibitem{'publicationyear'}=$dat->{'publicationyear'};
118 push(@bibitemloop,\%abibitem);
123 #existingreserves building
125 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
127 # my $prioropt = priorityoptions($totalcount, $res->{'priority'});
129 for (my $i=1; $i<=$totalcount; $i++){
132 $option{selected}=($i==$res->{'priority'});
133 push(@optionloop, \%option);
135 # my $bropt = branchoptions($res->{'branchcode'});
137 foreach my $br (keys %$branches) {
138 (next) unless $branches->{$br}->{'IS'};
139 # Only branches with the 'IS' branchrelation
142 $abranch{'selected'}=($br eq $res->{'branchcode'});
143 $abranch{'branch'}=$br;
144 $abranch{'branchname'}=$branches->{$br}->{'branchname'};
145 push(@branchloop,\%abranch);
148 if ($res->{'found'} eq 'W') {
150 my $item = $res->{'itemnumber'};
151 $item = getiteminformation(\%env,$item);
152 $reserve{'barcode'}=$item->{'barcode'};
153 $reserve{'biblionumber'}=$item->{'biblionumber'};
154 $reserve{'wbrcode'} = $res->{'branchcode'};
155 $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
157 $reserve{'date'} = slashifyDate($res->{'reservedate'});
158 $reserve{'borrowernumber'}=$res->{'borrowernumber'};
159 $reserve{'biblionumber'}=$res->{'biblionumber'};
160 $reserve{'bornum'}=$res->{'borrowernumber'};
161 $reserve{'firstname'}=$res->{'firstname'};
162 $reserve{'bornum'}=$res->{'borrowernumber'};
163 $reserve{'notes'}=$res->{'reservenotes'};
164 $reserve{'wait'}=($res->{'found'} eq 'W');
165 $reserve{'constrainttypea'}=($res->{'constrainttype'} eq 'a');
166 $reserve{'constrainttypeo'}=($res->{'constrainttype'} eq 'o');
167 $reserve{'voldesc'}=$res->{'volumeddesc'};
168 $reserve{'itemtype'}=$res->{'itemtype'};
169 $reserve{'branchloop'}=\@branchloop;
170 $reserve{'optionloop'}=\@optionloop;
171 push(@reserveloop,\%reserve);
177 my ($count2,@branches)=branches();
178 for (my $i=0;$i<$count2;$i++){
179 push @select_branch, $branches[$i]->{'branchcode'};#
180 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
182 my $CGIbranch=CGI::scrolling_list( -name => 'pickup',
183 -values => \@select_branch,
184 -labels => \%select_branches,
188 #get the time for the form name...
192 my ($template, $borrowernumber, $cookie)
193 = get_template_and_user({template_name => "request.tmpl",
196 authnotrequired => 0,
197 flagsrequired => {parameters => 1},
199 $template->param( optionloop =>\@optionloop,
200 CGIbranch => $CGIbranch,
201 reserveloop => \@reserveloop,
203 bibitemloop => \@bibitemloop,
206 title =>$dat->{title});
208 print $input->header(-expires=>'now'), $template->output;