Continuing work on Z39.50 search tool. Daemon now forks up to 12 processes
[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 use strict;
7 #use DBI;
8 use C4::Search;
9 use CGI;
10 use C4::Output;
11 use C4::Reserves2;
12 use C4::Acquisitions;
13 my $input = new CGI;
14 print $input->header;
15
16
17 #setup colours
18 print startpage();
19 print startmenu();
20 my $blah;
21 my $bib=$input->param('bib');
22 my $dat=bibdata($bib);
23 my ($count,$reserves)=FindReserves($bib);
24 #print $count;
25 #print $input->dump;
26
27
28 print <<printend
29 <form action="placerequest.pl" method=post>
30 <INPUT TYPE="image" name="submit"  VALUE="request" height=42  WIDTH=187 BORDER=0 src="/images/place-request.gif" align=right >
31 <input type=hidden name=biblio value=$bib>
32 <input type=hidden name=type value=str8>
33 <input type=hidden name=title value="$dat->{'title'}">
34 <FONT SIZE=6><em>Requesting: <a href=/cgi-bin/koha/detail.pl?bib=$bib>$dat->{'title'}</a> ($dat->{'author'})</em></FONT><P>
35 <p>
36
37 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left >
38
39 <!----------------BIBLIO RESERVE TABLE-------------->
40
41
42
43 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
44 <TR VALIGN=TOP>
45 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
46 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Member Number</b></TD>
47 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
48 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
49 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
50 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
51 </TR>
52 <tr VALIGN=TOP  >
53 <TD><select name=rank-request>
54 printend
55 ;
56 $count++;
57 my $i;
58 for ($i=1;$i<$count;$i++){
59   print "<option value=$i>$i\n";
60 }
61 print "<option value=$i selected>$i\n";
62 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
63 $year=$year+1900;
64 $mon++;
65 my $date="$mday/$mon/$year";
66 print <<printend
67 </select>
68 </td>
69 <TD><input type=text size=10 name=member></td>
70 <TD><input type=text size=20 name=notes></td>
71 <TD>$date</td>
72 <TD><select name=pickup>
73 printend
74 ;
75 my ($count2,@branches)=branches;                                                                         
76 for (my $i=0;$i<$count2;$i++){                                                                           
77   print "<option value=$branches[$i]->{'branchcode'}";                                                   
78   print ">$branches[$i]->{'branchname'}";                                                                
79 }   
80 print <<printend
81 </select>
82 </td>
83 <td><input type=checkbox name=request value=any>Next Available, <br>(or choose from list below)</td>
84 </tr>
85
86
87 </table>
88 </p>
89
90
91 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
92 <TR VALIGN=TOP>
93
94 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
95 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Item Type</b></TD>
96 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Classification</b></TD>
97 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Volume</b></TD>
98 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>ISBN</b></TD>
99 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Copyright</b></TD>
100 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Pubdate</b></TD>
101 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Copies</b></TD>
102 </TR>
103 printend
104 ;
105 my $blah;
106 my ($count2,@data)=bibitems($bib);
107 for ($i=0;$i<$count2;$i++){
108   my @barcodes=barcodes($data[$i]->{'biblioitemnumber'});
109   if ($data[$i]->{'dewey'} == 0){
110     $data[$i]->{'dewey'}="";
111   }
112   $data[$i]->{'dewey'}=~ s/\.0000$//;
113   $data[$i]->{'dewey'}=~ s/00$//;
114   my $class="$data[$i]->{'classification'}$data[$i]->{'dewey'}$data[$i]->{'subclass'}";
115   print "<tr VALIGN=TOP  >
116   <TD><input type=checkbox name=reqbib value=$data[$i]->{'biblioitemnumber'}>
117   <input type=hidden name=biblioitem value=$data[$i]->{'biblioitemnumber'}>
118   </td>
119   <TD>$data[$i]->{'description'}</td>
120   <TD>$class</td>                                                                                                                                                                                               
121   <td>$data[$i]->{'volumeddesc'}</td>
122   <td>$data[$i]->{'isbn'}</td>
123   <td>$dat->{'copyrightdate'}</td>
124   <td>$data[$i]->{'publicationyear'}</td>
125   <td>@barcodes</td>
126   </tr>";
127 }
128 print <<printend
129 </table>
130 </p>
131 </form>
132 <p>&nbsp; </p>
133 <!-----------MODIFY EXISTING REQUESTS----------------->
134
135 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
136
137 <TR VALIGN=TOP>
138
139 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=7><B>MODIFY EXISTING REQUESTS </b></TD>
140 </TR>
141 <form action=modrequest.pl method=post>
142 <TR VALIGN=TOP>
143
144 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Rank</b></TD>
145 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Member</b></TD>
146 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Notes</b></TD>
147 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Date</b></TD>
148 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Pickup</b></TD>
149 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Request</b></TD>
150 <td  bgcolor="99cc33" background="/images/background-mem.gif"><B>Change To</b></TD>
151 </TR>
152 printend
153 ;
154 $count--;
155
156 for ($i=0;$i<$count;$i++){
157 print "<input type=hidden name=borrower value=$reserves->[$i]{'borrowernumber'}>";
158 print "<input type=hidden name=biblio value=$reserves->[$i]{'biblionumber'}>";
159 #my $bor=$reserves->[$i]{'firstname'}."%20".$reserves->[$i]{'surname'};
160 #$bor=~ s/ /%20/g;
161 my $bor=$reserves->[$i]{'borrowernumber'};
162 my @temp=split('-',$reserves->[$i]{'reservedate'});
163 $date="$temp[2]/$temp[1]/$temp[0]";
164 my $type=$reserves->[$i]{'constrainttype'};
165 #print "test";
166 if ($type eq 'a'){
167   $type='Next Available';
168 } elsif ($type eq 'o'){
169 # print "test";
170   my $res=getreservetitle($reserves->[$i]{'biblionumber'},$reserves->[$i]{'borrowernumber'},$reserves->[$i]{'reservedate'},$reserves->[$i]{'timestamp'});
171   $type="This type only $res->{'volumeddesc'} $res->{'itemtype'}";
172 #  my @data=ItemInfo(\$blah,$reserves->[$i]{'borrowernumber'});
173   
174 }
175 print "<tr VALIGN=TOP  >
176 <TD><select name=rank-request>
177 ";
178 for (my $i2=1;$i2<=$count;$i2++){
179   print "<option value=$i2";
180   if ($reserves->[$i]{'priority'} eq $i2){
181     print " selected";
182   }
183   print">$i2";
184 }
185 print "<option value=del>Del";
186 print "</select>
187 </td>
188 <TD><a href=/cgi-bin/koha/moremember.pl?bornum=$bor>$reserves->[$i]{'firstname'} $reserves->[$i]{'surname'}</a></td>
189 <td>$reserves->[$i]{'reservenotes'}</td>
190 <TD>$date</td>
191 <TD><select name=pickup>
192 ";
193 my ($count2,@branches)=branches;                                                                         
194 for (my $i2=0;$i2<$count2;$i2++){                                                                           
195   print "<option value=$branches[$i2]->{'branchcode'}";                                                   
196   if ($reserves->[$i]{'branchcode'} eq $branches[$i2]->{'branchcode'}){                                           
197     print " Selected";                                                                                   
198   }
199   print ">$branches[$i2]->{'branchname'}\n";                                                                
200 }   
201 print "
202 </select>
203 </td>
204 <TD>$type</td>
205 <TD><select name=itemtype>
206 <option value=next>Next Available
207 <option value=change>Change Selection
208 <option value=nc >No Change
209 </select>
210 </td>
211 </tr>
212 ";
213 }
214 print <<printend
215
216
217 <tr VALIGN=TOP  >
218
219 <TD colspan=6 align=right>
220 Delete a request by selecting "del" from the rank list.
221
222 <INPUT TYPE="image" name="submit"  VALUE="request" height=42  WIDTH=64 BORDER=0 src="/images/ok.gif"></td>
223
224
225 </tr>
226
227
228 </table>
229 <P>
230
231 <br>
232
233
234
235
236 </form>
237 printend
238 ;
239
240 print endmenu();
241 print endpage();