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;
41 # get biblio information....
42 my $bib = $input->param('bib');
43 my $dat = bibdata($bib);
45 # get existing reserves .....
46 my ($count,$reserves) = FindReserves($bib);
47 my $totalcount = $count;
48 foreach my $res (@$reserves) {
49 if ($res->{'found'} eq 'W') {
54 # make priorities options
57 #priorityoptions building
59 for (my $i=1; $i<=$num; $i++){
62 $option{selected}=($i==$num);
63 push(@optionloop, \%option);
67 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
70 my $date=format_date("$year-$mon-$mday");
73 # get biblioitem information and build rows for form
74 my ($count2,@data) = bibitems($bib);
77 foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) {
78 $dat->{'dewey'}="" if ($dat->{'dewey'} == 0);
79 $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'};
80 $dat->{'dewey'}=~ s/\.0000$//;
81 $dat->{'dewey'}=~ s/00$//;
85 my @barcodes = barcodes($dat->{'biblioitemnumber'});
86 foreach my $num (@barcodes) {
88 $barcode{'barcode'}=$num->{'barcode'};
89 $barcode{'message'}=$num->{'itemlost'} == 1 ? "(lost)" :
90 $num->{'itemlost'} == 2 ? "(long overdue)" : "";
91 push(@barcodeloop, \%barcode);
93 $abibitem{'barcodeloop'}=\@barcodeloop;
94 $abibitem{'class'}="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}";
96 $abibitem{'itemlost'}=(($dat->{'notforloan'})|| ($dat->{'itemlost'} == 1)) ;
97 $abibitem{'biblioitemnumber'}=$dat->{'biblioitemnumber'};
98 $abibitem{'description'}=$dat->{'description'};
99 $abibitem{'volumeddesc'}=$dat->{'volumeddesc'};
100 $abibitem{'publicationyear'}=$dat->{'publicationyear'};
101 push(@bibitemloop,\%abibitem);
106 #existingreserves building
108 my $branches = getbranches();
109 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
111 # my $prioropt = priorityoptions($totalcount, $res->{'priority'});
113 for (my $i=1; $i<=$totalcount; $i++){
116 $option{selected}=($i==$res->{'priority'});
117 push(@optionloop, \%option);
120 foreach my $br (keys %$branches) {
121 # (next) unless $branches->{$br}->{'IS'};
122 # Only branches with the 'IS' branchrelation
125 $abranch{'selected'}=($br eq $res->{'branchcode'});
126 $abranch{'branch'}=$br;
127 $abranch{'branchname'}=$branches->{$br}->{'branchname'};
128 push(@branchloop,\%abranch);
131 if ($res->{'found'} eq 'W') {
133 my $item = $res->{'itemnumber'};
134 $item = getiteminformation(\%env,$item);
135 $reserve{'barcode'}=$item->{'barcode'};
136 $reserve{'biblionumber'}=$item->{'biblionumber'};
137 $reserve{'wbrcode'} = $res->{'branchcode'};
138 $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
140 $reserve{'date'} = format_date($res->{'reservedate'});
141 $reserve{'borrowernumber'}=$res->{'borrowernumber'};
142 $reserve{'biblionumber'}=$res->{'biblionumber'};
143 $reserve{'bornum'}=$res->{'borrowernumber'};
144 $reserve{'firstname'}=$res->{'firstname'};
145 $reserve{'bornum'}=$res->{'borrowernumber'};
146 $reserve{'notes'}=$res->{'reservenotes'};
147 $reserve{'wait'}=($res->{'found'} eq 'W');
148 $reserve{'constrainttypea'}=($res->{'constrainttype'} eq 'a');
149 $reserve{'constrainttypeo'}=($res->{'constrainttype'} eq 'o');
150 $reserve{'voldesc'}=$res->{'volumeddesc'};
151 $reserve{'itemtype'}=$res->{'itemtype'};
152 $reserve{'branchloop'}=\@branchloop;
153 $reserve{'optionloop'}=\@optionloop;
154 push(@reserveloop,\%reserve);
160 my ($count2,@branches)=branches();
161 for (my $i=0;$i<$count2;$i++){
162 push @select_branch, $branches[$i]->{'branchcode'};#
163 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
165 my $CGIbranch=CGI::scrolling_list( -name => 'pickup',
166 -values => \@select_branch,
167 -labels => \%select_branches,
171 #get the time for the form name...
175 my ($template, $borrowernumber, $cookie)
176 = get_template_and_user({template_name => "request.tmpl",
179 authnotrequired => 0,
180 flagsrequired => {parameters => 1},
182 $template->param( optionloop =>\@optionloop,
183 CGIbranch => $CGIbranch,
184 reserveloop => \@reserveloop,
186 bibitemloop => \@bibitemloop,
189 title =>$dat->{title});
191 print $input->header(-expires=>'now'), $template->output;