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;
38 # get biblio information....
39 my $bib = $input->param('bib');
40 my $dat = bibdata($bib);
42 # get existing reserves .....
43 my ($count,$reserves) = FindReserves($bib);
44 my $totalcount = $count;
45 foreach my $res (@$reserves) {
46 if ($res->{'found'} eq 'W') {
51 # make priorities options
53 my $priorityoptions = priorityoptions($num, $num);
56 # get branch information
57 my $branch = $input->cookie('branch');
58 ($branch) || ($branch = 'L');
59 my $branches = getbranches();
60 my $branchoptions = branchoptions($branch);
64 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
67 my $date="$mday/$mon/$year";
72 # get biblioitem information and build rows for form
73 my ($count2,@data) = bibitems($bib);
77 foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) {
78 my @barcodes = barcodes($dat->{'biblioitemnumber'});
79 my $barcodestext = "";
80 foreach my $num (@barcodes) {
81 my $message = $num->{'itemlost'} == 1 ? "(lost)" :
82 $num->{'itemlost'} == 2 ? "(long overdue)" : "";
83 $barcodestext .= "$num->{'barcode'} $message <br>";
85 $barcodestext = substr($barcodestext, 0, -4);
87 $dat->{'dewey'}="" if ($dat->{'dewey'} == 0);
89 $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'};
90 $dat->{'dewey'}=~ s/\.0000$//;
91 $dat->{'dewey'}=~ s/00$//;
92 my $class="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}";
94 if (($dat->{'notforloan'})
95 || ($dat->{'itemlost'} == 1)) {
96 $select = "Cannot be reserved.";
98 $select = " <input type=checkbox name=reqbib value=$dat->{'biblioitemnumber'}><input type=hidden name=biblioitem value=$dat->{'biblioitemnumber'}>";
100 $bibitemrows .= <<"EOF";
103 <TD>$dat->{'description'}</td>
105 <td>$dat->{'volumeddesc'}</td>
106 <td>$dat->{'publicationyear'}</td>
107 <td>$barcodestext</td>
115 my $existingreserves = "";
116 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
117 my $prioropt = priorityoptions($totalcount, $res->{'priority'});
118 my $bropt = branchoptions($res->{'branchcode'});
119 my $bor=$res->{'borrowernumber'};
120 $date = slashifyDate($res->{'reservedate'});
122 my $type=$res->{'constrainttype'};
124 $type='Next Available';
125 } elsif ($type eq 'o'){
126 $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}";
129 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 $wbrcd = $res->{'branchcode'};
138 my $wbra = $branches->{$wbrcd}->{'branchname'};
140 $rank = "<select name=rank-request><option value=W selected>Waiting</option>$prioropt<option value=del>Del</option></select>";
141 $pickup = "Item waiting at <b>".$wbra."</b> <input type=hidden name=pickup value=$wbrcd>";
143 $rank = "<select name=rank-request>$prioropt<option value=del>Del</option></select>";
144 $pickup = "<select name=pickup>$bropt</select>";
146 $existingreserves .= <<"EOF";
149 <input type=hidden name=borrower value=$res->{'borrowernumber'}>
150 <input type=hidden name=biblio value=$res->{'biblionumber'}>
153 <a href=/cgi-bin/koha/moremember.pl?bornum=$bor>$res->{'firstname'} $res->{'surname'}</a>
165 sub priorityoptions {
166 my ($count, $sel) = @_;
168 for (my $i=1; $i<=$count; $i++){
169 $out .= "<option value=$i";
173 $out .= ">$i</option>\n";
178 # make branch selection options...
182 foreach my $br (keys %$branches) {
183 (next) unless $branches->{$br}->{'IS'};
184 # Only branches with the 'IS' branchrelation
188 $selected = "selected";
190 $out .= "<option value=$br $selected>$branches->{$br}->{'branchname'}</option>\n";
196 #get the time for the form name...
205 print $input->header(-expires=>'now');
209 print startmenu('catalogue');
216 <form action="placerequest.pl" method=post>
217 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=187 BORDER=0 src="/images/place-request.gif" align=right >
218 <input type=hidden name=biblio value=$bib>
219 <input type=hidden name=type value=str8>
220 <input type=hidden name=title value="$dat->{'title'}">
221 <FONT SIZE=6><em>Requesting: <br>
222 <a href=/cgi-bin/koha/detail.pl?bib=$bib>$dat->{'title'}</a>
223 ($dat->{'author'})</em></FONT><P>
230 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
232 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
233 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member Number</b></TD>
234 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
235 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
236 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
237 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
240 <td><select name=rank-request>
243 <td><input type=text size=10 name=member></td>
244 <td><input type=text size=20 name=notes></td>
246 <td><select name=pickup>
249 <td><input type=checkbox name=request value=any>Next Available,
250 <br>(or choose from list below)</td>
255 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
258 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
259 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Item Type</b></TD>
260 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Classification</b></TD>
261 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Volume</b></TD>
262 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pubdate</b></TD>
263 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Copies</b></TD>
275 <form name=T$time action=modrequest.pl method=post>
277 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
281 <td bgcolor="99cc33" background="/images/background-mem.gif" colspan=7><B>MODIFY EXISTING REQUESTS </b></TD>
285 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
286 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member</b></TD>
287 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
288 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
289 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
290 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
294 <TD colspan=6 align=right>
295 Delete a request by selecting "del" from the rank list.
296 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=64 BORDER=0 src="/images/ok.gif"></td>