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 foreach my $dat (sort {$b->{'dateaccessioned'} cmp $a->{'dateaccessioned'}} @data) {
75 my @barcodes = barcodes($dat->{'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 $dat->{'dewey'}="" if ($dat->{'dewey'} == 0);
86 $dat->{'volumeddesc'} = " " unless $dat->{'volumeddesc'};
87 $dat->{'dewey'}=~ s/\.0000$//;
88 $dat->{'dewey'}=~ s/00$//;
89 my $class="$dat->{'classification'}$dat->{'dewey'}$dat->{'subclass'}";
91 if (($dat->{'notforloan'})
92 || ($dat->{'itemlost'} == 1)) {
93 $select = "Cannot be reserved.";
95 $select = " <input type=checkbox name=reqbib value=$dat->{'biblioitemnumber'}><input type=hidden name=biblioitem value=$dat->{'biblioitemnumber'}>";
97 $bibitemrows .= <<"EOF";
100 <TD>$dat->{'description'}</td>
102 <td>$dat->{'volumeddesc'}</td>
103 <td>$dat->{'publicationyear'}</td>
104 <td>$barcodestext</td>
112 my $existingreserves = "";
113 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
114 my $prioropt = priorityoptions($count, $res->{'priority'});
115 my $bropt = branchoptions($res->{'branchcode'});
116 my $bor=$res->{'borrowernumber'};
117 $date = slashifyDate($res->{'reservedate'});
119 my $type=$res->{'constrainttype'};
121 $type='Next Available';
122 } elsif ($type eq 'o'){
123 $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}";
126 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 $wbra = $branches->{$res->{'branchcode'}}->{'branchname'};
136 $rank = "Item waiting";
138 $pickup = "at <b>".$wbra."</b>";
139 $change = "<input type=checkbox name=rank-request value=del>delete";
141 $rank = "<select name=rank-request>$prioropt<option value=del>Del</select>";
142 $pickup = "<select name=pickup>$bropt</select>";
144 $existingreserves .= <<"EOF";
145 <input type=hidden name=borrower value=$res->{'borrowernumber'}>
146 <input type=hidden name=biblio value=$res->{'biblionumber'}>
150 <a href=/cgi-bin/koha/moremember.pl?bornum=$bor>$res->{'firstname'} $res->{'surname'}</a>
162 sub priorityoptions {
163 my ($count, $sel) = @_;
165 for (my $i=1; $i<=$count; $i++){
166 $out .= "<option value=$i";
175 # make branch selection options...
179 foreach my $br (keys %$branches) {
180 (next) unless $branches->{$br}->{'IS'};
183 $selected = "selected";
185 $out .= "<option value=$br $selected>$branches->{$br}->{'branchname'}\n";
195 print $input->header;
200 print startmenu('catalogue');
207 <form action="placerequest.pl" method=post>
208 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=187 BORDER=0 src="/images/place-request.gif" align=right >
209 <input type=hidden name=biblio value=$bib>
210 <input type=hidden name=type value=str8>
211 <input type=hidden name=title value="$dat->{'title'}">
212 <FONT SIZE=6><em>Requesting: <br>
213 <a href=/cgi-bin/koha/detail.pl?bib=$bib>$dat->{'title'}</a>
214 ($dat->{'author'})</em></FONT><P>
218 <!----------------BIBLIO RESERVE TABLE-------------->
221 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
223 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
224 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member Number</b></TD>
225 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
226 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
227 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
228 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
231 <td><select name=rank-request>
234 <td><input type=text size=10 name=member></td>
235 <td><input type=text size=20 name=notes></td>
237 <td><select name=pickup>
240 <td><input type=checkbox name=request value=any>Next Available,
241 <br>(or choose from list below)</td>
246 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
249 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
250 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Item Type</b></TD>
251 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Classification</b></TD>
252 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Volume</b></TD>
253 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pubdate</b></TD>
254 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Copies</b></TD>
264 <!-----------MODIFY EXISTING REQUESTS----------------->
266 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
270 <td bgcolor="99cc33" background="/images/background-mem.gif" colspan=7><B>MODIFY EXISTING REQUESTS </b></TD>
272 <form action=modrequest.pl method=post>
275 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
276 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Member</b></TD>
277 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
278 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
279 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
280 <td bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
284 <TD colspan=6 align=right>
285 Delete a request by selecting "del" from the rank list.
286 <INPUT TYPE="image" name="submit" VALUE="request" height=42 WIDTH=64 BORDER=0 src="/images/ok.gif"></td>