Changed the display of lost, long overdue, reference, and cancelled items.
[koha.git] / request.pl
1 #!/usr/bin/perl
2
3 #script to place reserves/requests
4 #writen 2/1/00 by chris@katipo.oc.nz
5
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
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
14 # version.
15 #
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.
19 #
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
23
24 use strict;
25 #use DBI;
26 use C4::Search;
27 use C4::Output;
28 use C4::Reserves2;
29 use C4::Acquisitions;
30 use C4::Koha;
31 use C4::Circulation::Circ2;
32
33 use CGI;
34 my $input = new CGI;
35
36 # get biblio information....
37 my $bib = $input->param('bib');
38 my $dat = bibdata($bib);
39
40 # get existing reserves .....
41 my ($count,$reserves) = FindReserves($bib);
42 foreach my $res (@$reserves) {
43     if ($res->{'found'} eq 'W') {
44         $count--;
45     }
46 }
47
48 # make priorities options
49 my $num = $count + 1;
50 my $priorityoptions = priorityoptions($num, $num);
51
52
53 # get branch information
54 my $branch = $input->cookie('branch');
55 ($branch) || ($branch = 'L');
56 my $branches = getbranches();
57 my $branchoptions = branchoptions($branch);
58
59
60 # todays date
61 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
62 $year=$year+1900;
63 $mon++;
64 my $date="$mday/$mon/$year";
65
66
67
68
69 # get biblioitem information and build rows for form
70 my ($count2,@data) = bibitems($bib);
71 my $bibitemrows = "";
72 for (my $i=0; $i<$count2; $i++) {
73     my @barcodes = barcodes($data[$i]->{'biblioitemnumber'});
74     if ($data[$i]->{'dewey'} == 0){
75         $data[$i]->{'dewey'}="";
76     }
77     $data[$i]->{'volumeddesc'} = "&nbsp;" unless $data[$i]->{'volumeddesc'};
78     $data[$i]->{'dewey'}=~ s/\.0000$//;
79     $data[$i]->{'dewey'}=~ s/00$//;
80     my $class="$data[$i]->{'classification'}$data[$i]->{'dewey'}$data[$i]->{'subclass'}";
81     my $select;
82     if ($data[$i]->{'notforloan'}) {
83         $select = "Reference Item.";
84     } elsif ($data[$i]->{'itemlost'} == 1) {
85         $select = "Item Lost";
86     } elsif ($data[$i]->{'itemlost'} == 2) {
87         $select = "Long Overdue";
88     } elsif ($data[$i]->{'wthdrawn'}) {
89         $select = "Item Cancelled";
90     } else {
91         $select = " <input type=checkbox name=reqbib value=$data[$i]->{'biblioitemnumber'}><input type=hidden name=biblioitem value=$data[$i]->{'biblioitemnumber'}>";
92     }
93     $bibitemrows .= <<"EOF";
94 <tr VALIGN=TOP>
95 <TD>$select</td>
96 <TD>$data[$i]->{'description'}</td>
97 <TD>$class</td>
98 <td>$data[$i]->{'volumeddesc'}</td>
99 <td>$data[$i]->{'isbn'}</td>
100 <td>$dat->{'copyrightdate'}</td>
101 <td>$data[$i]->{'publicationyear'}</td>
102 <td>@barcodes</td>
103 </tr>
104 EOF
105 }
106
107
108
109
110 my $existingreserves = "";
111 foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){
112     my $prioropt = priorityoptions($count, $res->{'priority'});
113     my $bropt = branchoptions($res->{'branchcode'});
114     my $bor=$res->{'borrowernumber'};
115     $date = slashifyDate($res->{'reservedate'});
116
117     my $type=$res->{'constrainttype'};
118     if ($type eq 'a'){
119         $type='Next Available';
120     } elsif ($type eq 'o'){
121         $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}";
122     }
123
124     my $notes = $res->{'reservenotes'}." ";
125     my $rank;
126     my $pickup;
127     my $change;
128     if ($res->{'found'} eq 'W') {
129         my %env;
130         my $item = $res->{'itemnumber'};
131         $item = getiteminformation(\%env,$item);
132         $item = "<a href=/cgi-bin/koha/detail.pl?bib=$item->{'biblionumber'} &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$item->{'barcode'}</a>";
133         my $wbra = $branches->{$res->{'branchcode'}}->{'branchname'};
134         $rank = "Item waiting";
135         $type = $item;
136         $pickup = "at <b>".$wbra."</b>";
137         $change = "<input type=checkbox name=rank-request value=del>delete";
138     } else {
139         $rank = "<select name=rank-request>$prioropt<option value=del>Del</select>";
140         $pickup = "<select name=pickup>$bropt</select>";
141         $change = "<select name=itemtype>
142                    <option value=next>Next Available
143                    <option value=change>Change Selection
144                    <option value=nc >No Change</select>";
145     }
146     $existingreserves .= <<"EOF";
147 <input type=hidden name=borrower value=$res->{'borrowernumber'}>
148 <input type=hidden name=biblio value=$res->{'biblionumber'}>
149 <tr VALIGN=TOP>
150 <TD>$rank</td>
151 <TD>
152 <a href=/cgi-bin/koha/moremember.pl?bornum=$bor>$res->{'firstname'} $res->{'surname'}</a>
153 </td>
154 <td>$notes</td>
155 <TD>$date</td>
156 <TD>$pickup</td>
157 <TD>$type</td>
158 <TD>$change</td>
159 </tr>
160 EOF
161 }
162
163
164
165 sub priorityoptions {
166     my ($count, $sel) = @_;
167     my $out = "";
168     for (my $i=1; $i<=$count; $i++){
169         $out .= "<option value=$i";
170         if ($sel == $i){
171             $out .= " selected";
172         }
173         $out .= ">$i\n";
174     }
175     return $out;
176 }
177
178 # make branch selection options...
179 sub branchoptions {
180     my ($selbr) = @_;
181     my $out = "";
182     foreach my $br (keys %$branches) {
183         (next) unless $branches->{$br}->{'IS'};
184         my $selected = "";
185         if ($br eq $selbr) {
186             $selected = "selected";
187         }
188         $out .= "<option value=$br $selected>$branches->{$br}->{'branchname'}\n";
189     }
190     return $out;
191 }
192
193
194
195 # printout the page
196
197
198 print $input->header;
199
200
201 #setup colours
202 print startpage();
203 print startmenu('catalogue');
204
205
206
207
208 print <<printend
209
210 <form action="placerequest.pl" method=post>
211 <INPUT TYPE="image" name="submit"  VALUE="request" height=42  WIDTH=187 BORDER=0 src="/images/place-request.gif" align=right >
212 <input type=hidden name=biblio value=$bib>
213 <input type=hidden name=type value=str8>
214 <input type=hidden name=title value="$dat->{'title'}">
215 <FONT SIZE=6><em>Requesting: <br>
216 <a href=/cgi-bin/koha/detail.pl?bib=$bib>$dat->{'title'}</a> 
217 ($dat->{'author'})</em></FONT><P>
218 <p>
219
220
221 <!----------------BIBLIO RESERVE TABLE-------------->
222
223
224 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
225 <TR VALIGN=TOP>
226 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
227 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Member Number</b></TD>
228 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
229 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
230 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
231 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
232 </TR>
233 <tr VALIGN=TOP  >
234 <td><select name=rank-request>
235 $priorityoptions
236 </select></td>
237 <td><input type=text size=10 name=member></td>
238 <td><input type=text size=20 name=notes></td>
239 <td>$date</td>
240 <td><select name=pickup>
241 $branchoptions
242 </select></td>
243 <td><input type=checkbox name=request value=any>Next Available, 
244 <br>(or choose from list below)</td>
245 </tr></table>
246 </p>
247
248
249 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
250 <TR VALIGN=TOP>
251
252 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
253 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Item Type</b></TD>
254 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Classification</b></TD>
255 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Volume</b></TD>
256 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>ISBN</b></TD>
257 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Copyright</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>
260 </TR>
261 $bibitemrows
262 </table>
263 </p>
264 </form>
265 <p>&nbsp;</p>
266
267
268
269 <!-----------MODIFY EXISTING REQUESTS----------------->
270
271 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
272
273 <TR VALIGN=TOP>
274
275 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=7><B>MODIFY EXISTING REQUESTS </b></TD>
276 </TR>
277 <form action=modrequest.pl method=post>
278 <TR VALIGN=TOP>
279
280 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
281 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Member</b></TD>
282 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
283 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
284 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
285 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
286 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Change To</b></TD>
287 </TR>
288 $existingreserves
289 <tr VALIGN=TOP>
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>
293 </tr>
294 </table>
295 <P>
296 <br>
297 </form>
298
299 printend
300 ;
301
302 print endmenu();
303 print endpage();