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 my $totalcount = $count;
43 foreach my $res (@$reserves) {
44 if ($res->{'found'} eq 'W') {
49 # make priorities options
51 my $priorityoptions = priorityoptions($num, $num);
54 # get branch information
55 my $branch = $input->cookie('branch');
56 ($branch) || ($branch = 'L');
57 my $branches = getbranches();
58 my $branchoptions = branchoptions($branch);
62 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
65 my $date="$mday/$mon/$year";
70 # get biblioitem information and build rows for form
71 my ($count2,@data) = bibitems($bib);
75 foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) {
76 my @barcodes = barcodes($dat->{'biblioitemnumber'});
77 my $barcodestext = "";
78 foreach my $num (@barcodes) {
79 my $message = $num->{'itemlost'} == 1 ? "(lost)" :
80 $num->{'itemlost'} == 2 ? "(long overdue)" : "";
81 $barcodestext .= "$num->{'barcode'} $message <br>";
83 $barcodestext = substr($barcodestext, 0, -4);
85 $dat->{'dewey'}="" if ($dat->{'dewey'} == 0);
87 $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'};
88 $dat->{'dewey'}=~ s/\.0000$//;
89 $dat->{'dewey'}=~ s/00$//;
90 my $class="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}";
92 if (($dat->{'notforloan'})
93 || ($dat->{'itemlost'} == 1)) {
94 $select = "Cannot be reserved.";
96 $select = " <input type=checkbox name=reqbib value=$dat->{'biblioitemnumber'}><input type=hidden name=biblioitem value=$dat->{'biblioitemnumber'}>";
98 $bibitemrows .= <<"EOF";
101 <TD>$dat->{'description'}</td>
103 <td>$dat->{'volumeddesc'}</td>
104 <td>$dat->{'publicationyear'}</td>
105 <td>$barcodestext</td>
113 my $existingreserves = "";
114 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
115 my $prioropt = priorityoptions($totalcount, $res->{'priority'});
116 my $bropt = branchoptions($res->{'branchcode'});
117 my $bor=$res->{'borrowernumber'};
118 $date = slashifyDate($res->{'reservedate'});
120 my $type=$res->{'constrainttype'};
122 $type='Next Available';
123 } elsif ($type eq 'o'){
124 $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}";
127 my $notes = $res->{'reservenotes'}." ";
130 if ($res->{'found'} eq 'W') {
132 my $item = $res->{'itemnumber'};
133 $item = getiteminformation(\%env,$item);
134 $item = "<a href=/cgi-bin/koha/detail.pl?bib=$item->{'biblionumber'} &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$item->{'barcode'}</a>";
135 my $wbrcd = $res->{'branchcode'};
136 my $wbra = $branches->{$wbrcd}->{'branchname'};
138 $rank = "<select name=rank-request><option value=W selected>Waiting</option>$prioropt<option value=del>Del</option></select>";
139 $pickup = "Item waiting at <b>".$wbra."</b> <input type=hidden name=pickup value=$wbrcd>";
141 $rank = "<select name=rank-request>$prioropt<option value=del>Del</option></select>";
142 $pickup = "<select name=pickup>$bropt</select>";
144 $existingreserves .= <<"EOF";
147 <input type=hidden name=borrower value=$res->{'borrowernumber'}>
148 <input type=hidden name=biblio value=$res->{'biblionumber'}>
151 <a href=/cgi-bin/koha/moremember.pl?bornum=$bor>$res->{'firstname'} $res->{'surname'}</a>
163 sub priorityoptions {
164 my ($count, $sel) = @_;
166 for (my $i=1; $i<=$count; $i++){
167 $out .= "<option value=$i";
171 $out .= ">$i</option>\n";
176 # make branch selection options...
180 foreach my $br (keys %$branches) {
181 (next) unless $branches->{$br}->{'IS'};
184 $selected = "selected";
186 $out .= "<option value=$br $selected>$branches->{$br}->{'branchname'}</option>\n";
192 #get the time for the form name...
201 print $input->header(-expires=>'now');
205 print startmenu('catalogue');
212 <form action="placerequest.pl" method=post>
213 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=187 BORDER=0 src="/images/place-request.gif" align=right >
214 <input type=hidden name=biblio value=$bib>
215 <input type=hidden name=type value=str8>
216 <input type=hidden name=title value="$dat->{'title'}">
217 <FONT SIZE=6><em>Requesting: <br>
218 <a href=/cgi-bin/koha/detail.pl?bib=$bib>$dat->{'title'}</a>
219 ($dat->{'author'})</em></FONT><P>
226 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
228 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
229 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member Number</b></TD>
230 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
231 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
232 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
233 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
236 <td><select name=rank-request>
239 <td><input type=text size=10 name=member></td>
240 <td><input type=text size=20 name=notes></td>
242 <td><select name=pickup>
245 <td><input type=checkbox name=request value=any>Next Available,
246 <br>(or choose from list below)</td>
251 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
254 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
255 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Item Type</b></TD>
256 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Classification</b></TD>
257 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Volume</b></TD>
258 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pubdate</b></TD>
259 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Copies</b></TD>
271 <form name=T$time action=modrequest.pl method=post>
273 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
277 <td bgcolor="99cc33" background="/images/background-mem.gif" colspan=7><B>MODIFY EXISTING REQUESTS </b></TD>
281 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
282 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member</b></TD>
283 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
284 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
285 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
286 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
290 <TD colspan=6 align=right>
291 Delete a request by selecting "del" from the rank list.
292 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=64 BORDER=0 src="/images/ok.gif"></td>