3 #script to place reserves/requests
4 #writen 2/1/00 by chris@katipo.oc.nz
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
31 use C4::Circulation::Circ2;
36 # get biblio information....
37 my $bib = $input->param('bib');
38 my $dat = bibdata($bib);
40 # get existing reserves .....
41 my ($count,$reserves) = FindReserves($bib);
42 foreach my $res (@$reserves) {
43 if ($res->{'found'} eq 'W') {
48 # make priorities options
50 my $priorityoptions = priorityoptions($num, $num);
53 # get branch information
54 my $branch = $input->cookie('branch');
55 ($branch) || ($branch = 'L');
56 my $branches = getbranches();
57 my $branchoptions = branchoptions($branch);
61 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
64 my $date="$mday/$mon/$year";
69 # get biblioitem information and build rows for form
70 my ($count2,@data) = bibitems($bib);
74 for (my $i=0; $i<$count2; $i++) {
75 my @barcodes = barcodes($data[$i]->{'biblioitemnumber'});
76 my $barcodestext = "";
77 foreach my $num (@barcodes) {
78 my $message = $num->{'itemlost'} == 1 ? "(lost)" :
79 $num->{'itemlost'} == 2 ? "(long overdue)" : "";
80 $barcodestext .= "$num->{'barcode'} $message <br>";
82 $barcodestext = substr($barcodestext, 0, -4);
84 $data[$i]->{'dewey'}="" if ($data[$i]->{'dewey'} == 0);
86 warn "Itemlost: $data[$i]->{itemlost} \n";
87 $data[$i]->{'volumeddesc'} = " " unless $data[$i]->{'volumeddesc'};
88 $data[$i]->{'dewey'}=~ s/\.0000$//;
89 $data[$i]->{'dewey'}=~ s/00$//;
90 my $class="$data[$i]->{'classification'}$data[$i]->{'dewey'}$data[$i]->{'subclass'}";
92 if (($data[$i]->{'notforloan'})
93 || ($data[$i]->{'itemlost'} == 1)
94 || ($data[$i]->{'itemlost'} == 2)) {
95 $select = "Cannot be reserved.";
97 $select = " <input type=checkbox name=reqbib value=$data[$i]->{'biblioitemnumber'}><input type=hidden name=biblioitem value=$data[$i]->{'biblioitemnumber'}>";
99 $bibitemrows .= <<"EOF";
102 <TD>$data[$i]->{'description'}</td>
104 <td>$data[$i]->{'volumeddesc'}</td>
105 <td>$data[$i]->{'publicationyear'}</td>
106 <td>$barcodestext</td>
114 my $existingreserves = "";
115 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
116 my $prioropt = priorityoptions($count, $res->{'priority'});
117 my $bropt = branchoptions($res->{'branchcode'});
118 my $bor=$res->{'borrowernumber'};
119 $date = slashifyDate($res->{'reservedate'});
121 my $type=$res->{'constrainttype'};
123 $type='Next Available';
124 } elsif ($type eq 'o'){
125 $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}";
128 my $notes = $res->{'reservenotes'}." ";
132 if ($res->{'found'} eq 'W') {
134 my $item = $res->{'itemnumber'};
135 $item = getiteminformation(\%env,$item);
136 $item = "<a href=/cgi-bin/koha/detail.pl?bib=$item->{'biblionumber'} &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$item->{'barcode'}</a>";
137 my $wbra = $branches->{$res->{'branchcode'}}->{'branchname'};
138 $rank = "Item waiting";
140 $pickup = "at <b>".$wbra."</b>";
141 $change = "<input type=checkbox name=rank-request value=del>delete";
143 $rank = "<select name=rank-request>$prioropt<option value=del>Del</select>";
144 $pickup = "<select name=pickup>$bropt</select>";
146 $existingreserves .= <<"EOF";
147 <input type=hidden name=borrower value=$res->{'borrowernumber'}>
148 <input type=hidden name=biblio value=$res->{'biblionumber'}>
152 <a href=/cgi-bin/koha/moremember.pl?bornum=$bor>$res->{'firstname'} $res->{'surname'}</a>
164 sub priorityoptions {
165 my ($count, $sel) = @_;
167 for (my $i=1; $i<=$count; $i++){
168 $out .= "<option value=$i";
177 # make branch selection options...
181 foreach my $br (keys %$branches) {
182 (next) unless $branches->{$br}->{'IS'};
185 $selected = "selected";
187 $out .= "<option value=$br $selected>$branches->{$br}->{'branchname'}\n";
197 print $input->header;
202 print startmenu('catalogue');
209 <form action="placerequest.pl" method=post>
210 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=187 BORDER=0 src="/images/place-request.gif" align=right >
211 <input type=hidden name=biblio value=$bib>
212 <input type=hidden name=type value=str8>
213 <input type=hidden name=title value="$dat->{'title'}">
214 <FONT SIZE=6><em>Requesting: <br>
215 <a href=/cgi-bin/koha/detail.pl?bib=$bib>$dat->{'title'}</a>
216 ($dat->{'author'})</em></FONT><P>
220 <!----------------BIBLIO RESERVE TABLE-------------->
223 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
225 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
226 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member Number</b></TD>
227 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
228 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
229 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
230 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
233 <td><select name=rank-request>
236 <td><input type=text size=10 name=member></td>
237 <td><input type=text size=20 name=notes></td>
239 <td><select name=pickup>
242 <td><input type=checkbox name=request value=any>Next Available,
243 <br>(or choose from list below)</td>
248 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
251 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
252 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Item Type</b></TD>
253 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Classification</b></TD>
254 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Volume</b></TD>
255 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pubdate</b></TD>
256 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Copies</b></TD>
266 <!-----------MODIFY EXISTING REQUESTS----------------->
268 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
272 <td bgcolor="99cc33" background="/images/background-mem.gif" colspan=7><B>MODIFY EXISTING REQUESTS </b></TD>
274 <form action=modrequest.pl method=post>
277 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
278 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member</b></TD>
279 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
280 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
281 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
282 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
286 <TD colspan=6 align=right>
287 Delete a request by selecting "del" from the rank list.
288 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=64 BORDER=0 src="/images/ok.gif"></td>