3 #written 11/3/2002 by Finlay
4 #script to execute branch transfers of books
8 use C4::Circulation::Circ2;
12 ###############################################
16 my $headerbackgroundcolor='#99cc33';
17 my $circbackgroundcolor='#ffffcc';
18 my $circbackgroundcolor='white';
19 my $linecolor1='#ffffcc';
20 my $linecolor2='white';
21 my $backgroundimage="/images/background-mem.gif";
23 my $branches = getbranches();
24 my $printers = getprinters(\%env);
27 ###############################################
33 my $branch = $query->param("branch");
34 my $printer = $query->param("printer");
37 ($branch) || ($branch=$query->cookie('branch')) ;
38 ($printer) || ($printer=$query->cookie('printer')) ;
40 my $request=$query->param('request');
43 my $tobranchcd=$query->param('tobranchcd');
46 # set up the branchselect options....
48 foreach my $br (keys %$branches) {
49 (next) unless $branches->{$br}->{'CU'};
51 ($selected='selected') if ($br eq $tobranchcd);
52 $tobranchoptions.="<option value=$br $selected>$branches->{$br}->{'branchname'}\n";
55 # collect the stack of books already transfered so they can printed...
60 foreach ($query->param){
61 (next) unless (/bc-(\d*)/);
63 my $barcode=$query->param("bc-$counter");
64 my $frbcd=$query->param("fb-$counter");
65 my $tobcd=$query->param("tb-$counter");
67 $transfereditems{$counter}=$barcode;
68 $frbranchcds{$counter}=$frbcd;
69 $tobranchcds{$counter}=$tobcd;
70 $ritext.="<input type=hidden name=bc-$counter value=$barcode>\n";
71 $ritext.="<input type=hidden name=fb-$counter value=$frbcd>\n";
72 $ritext.="<input type=hidden name=tb-$counter value=$tobcd>\n";
76 # Collect a few messages here...
80 # Deal with the requests....
81 if ($request eq "KillWaiting") {
82 my $item = $query->param('itemnumber');
83 my $borrnum = $query->param('borrowernumber');
84 CancelReserve(0, $item, $borrnum);
85 $messagetext .= "Reserve Cancelled<br>";
88 if ($request eq "SetWaiting") {
89 my $item = $query->param('itemnumber');
90 my $borrnum = $query->param('borrowernumber');
91 $tobranchcd = ReserveWaiting($item, $borrnum);
93 $messagetext .= "Item should now be waiting at branch: $branches->{$tobranchcd}->{'branchname'}<br>";
95 if ($request eq 'KillReserved'){
96 my $biblio = $query->param('biblionumber');
97 my $borrnum = $query->param('borrowernumber');
98 CancelReserve($biblio, 0, $borrnum);
99 $messagetext .= "Reserve Cancelled<br>";
105 # Warnings etc that get displayed at top of next page....
107 # if the barcode has been entered action that and write a message
108 # and put onto the top of the stack...
110 my $barcode = $query->param('barcode');
114 ($transfered, $messages, $iteminformation)
115 = transferbook($tobranchcd, $barcode, $ignoreRs);
117 my $frbranchcd = $iteminformation->{'holdingbranch'};
118 $ritext.="<input type=hidden name=bc-0 value=$barcode>\n";
119 $ritext.="<input type=hidden name=fb-0 value=$frbranchcd>\n";
120 $ritext.="<input type=hidden name=tb-0 value=$tobranchcd>\n";
121 $transfereditems{0}=$barcode;
122 $frbranchcds{0}=$frbranchcd;
123 $tobranchcds{0}=$tobranchcd;
128 #################################################################################
130 # collect together the various elements...
132 my $entrytext= << "EOF";
133 <form method=post action=/cgi-bin/koha/circ/branchtransfers.pl>
134 <table border=1 cellpadding=5 cellspacing=0 align=left>
135 <tr><td colspan=2 align=center background=$backgroundimage>
136 <font color=black><b>Select Branch</b></font></td></tr>
137 <tr><td>Destination Branch:</td>
138 <td><select name=tobranchcd> $tobranchoptions </select></td></tr></table>
140 <img src="/images/holder.gif" width=24 height=50 align=left>
142 <table border=1 cellpadding=5 cellspacing=0 ><tr>
143 <td colspan=2 align=center background=$backgroundimage>
144 <font color=black><b>Enter Book Barcode</b></font></td></tr>
145 <tr><td>Item Barcode:</td><td><input name=barcode size=10></td></tr>
147 <input type=hidden name=tobranchcd value=$tobranchcd>
154 #####################
156 my $reservefoundtext;
157 if ($messages->{'ResFound'}) {
158 my $res = $messages->{'ResFound'};
160 my $branchname = $branches->{$res->{'branchcode'}}->{'branchname'};
161 my ($borr) = getpatroninformation(\%env, $res->{'borrowernumber'}, 0);
162 my $name = $borr->{'surname'}." ".$borr->{'title'}." ".$borr->{'firstname'};
163 my $number = "<a href=/cgi-bin/koha/moremember.pl?bornum=$borr->{'borrowernumber'} onClick='openWindow(this,'Member', 480, 640)'>$borr->{'cardnumber'}</a>";
164 if ($res->{'ResFound'} eq "Waiting") {
165 $reservetext = <<"EOF";
166 <font color='red' size='+2'>Item marked Waiting:</font><br>
167 Item is marked waiting at $branchname for $name ($number).<br>
168 <table border=1 cellpadding=5 cellspacing=0>
169 <tr><td>Cancel reservation and then attempt transfer: </td>
171 <form method=post action='branchtransfers.pl'>
173 <input type=hidden name=itemnumber value=$res->{'itemnumber'}>
174 <input type=hidden name=borrowernumber value=$res->{'borrowernumber'}>
175 <input type=hidden name=tobranchcd value=$tobranchcd>
176 <input type=hidden name=barcode value=$barcode>
177 <input type=hidden name=request value='KillWaiting'>
178 <input type=submit value="Cancel">
181 <tr><td>Ignore and return to transfers: </td>
183 <form method=post action='branchtransfers.pl'>
185 <input type=hidden name=tobranchcd value=$tobranchcd>
186 <input type=hidden name=barcode value=0>
187 <input type=submit value="Ignore">
192 if ($res->{'ResFound'} eq "Reserved") {
193 $reservetext = <<"EOF";
194 <font color='red' size='+2'>Reserved:</font> reserve found for $name ($number).
195 <table border=1 cellpadding=5 cellspacing=0>
196 <tr><td>Set reserve to waiting and transfer book to <b>$branchname </b>: </td>
198 <form method=post action='branchtransfers.pl'>
200 <input type=hidden name=itemnumber value=$res->{'itemnumber'}>
201 <input type=hidden name=borrowernumber value=$res->{'borrowernumber'}>
202 <input type=hidden name=barcode value=$barcode>
203 <input type=hidden name=request value='SetWaiting'>
204 <input type=submit value="Waiting">
207 <tr><td>Cancel reservation and then attempt transfer: </td>
209 <form method=post action='branchtransfers.pl'>
211 <input type=hidden name=biblionumber value=$res->{'biblionumber'}>
212 <input type=hidden name=borrowernumber value=$res->{'borrowernumber'}>
213 <input type=hidden name=tobranchcd value=$tobranchcd>
214 <input type=hidden name=barcode value=$barcode>
215 <input type=hidden name=request value='KillReserved'>
216 <input type=submit value="Cancel">
218 </td></tr><tr><td>Ignore and return to transfers: </td>
220 <form method=post action='branchtransfers.pl'>
221 <input type=hidden name=tobranchcd value=$tobranchcd>
222 <input type=hidden name=barcode value=0>
224 <input type=submit value="Ignore">
229 $reservefoundtext = <<"EOF";
230 <table border=1 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
231 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font>Reserve Found</font></th></tr>
232 <tr><td> $reservetext </td></tr></table>
236 #####################
238 foreach my $code (keys %$messages) {
239 if ($code eq 'BadBarcode'){
240 $messagetext .= "<font color='red' size='+2'> No Item with barcode: $messages->{'BadBarcode'} </font> <br>";
242 if ($code eq 'IsPermanent'){
243 my $braname = $branches->{$messages->{'IsPermanent'}}->{'branchname'};
244 $messagetext .= "<font color='red' size='+2'> Please return item to home branch: $braname </font> <br>";
246 if ($code eq 'DestinationEqualsHolding'){
247 $messagetext .= "<font color='red' size='+2'> Item is already at destination branch. </font> <br>";
249 if ($code eq 'WasReturned') {
250 my ($borrowerinfo) = getpatroninformation(\%env, $messages->{'WasReturned'}, 0);
253 <a href=/cgi-bin/koha/moremember.pl?bornum=$borrowerinfo->{'borrowernumber'}
254 onClick="openWindow(this,'Member', 480, 640)">$borrowerinfo->{'cardnumber'}</a>
255 $borrowerinfo->{'surname'}, $borrowerinfo->{'title'} $borrowerinfo->{'firstname'}
257 $messagetext .= "Item was on loan to $binfo and has been returned. <br>";
259 if ($code eq 'WasTransfered'){
260 # Put code here if you want to notify the user that item was transfered...
263 $messagetext = substr($messagetext, 0, -4);
267 $messagetable = << "EOF";
268 <table border=1 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
269 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font>Messages</font></th></tr>
270 <tr><td> $messagetext </td></tr></table>
271 <img src="/images/holder.gif" width=24 height=24>
275 #######################################################################################
276 # Make the page .....
278 print $query->header;
280 print startmenu('circulation');
282 #foreach my $key (%$messages) {
283 # print $key." : ".$messages->{$key}."<br>";
288 <table border=0 cellpadding=5><tr>
289 <td align="left"><FONT SIZE=6><em>Circulation: Transfers</em></FONT><br>
290 <b>Branch:</b> $branches->{$branch}->{'branchname'}  
291 <b>Printer:</b> $printers->{$printer}->{'printername'}<br>
292 <a href=selectbranchprinter.pl>Change Settings</a>
294 <td align="left"><img src="/images/holder.gif" width=40 height=35>
296 <td align="right" valign="top">
297 <FONT SIZE=2 face="arial, helvetica">
298 <a href=circulation.pl>Next Borrower</a> ||
299 <a href=returns.pl>Returns</a> ||
300 <a href=branchtransfers.pl>Transfers</a></font><p>
302 <input type=hidden name=branch value=$branch>
303 <input type=hidden name=printer value=$printer>
307 if ($reservefoundtext) {
308 print $reservefoundtext;
313 if (%transfereditems) {
316 <table border=1 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
317 <tr><th colspan=6 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>Transfered Items</font></th></tr>
318 <tr><th>Bar Code</th><th>Title</th><th>Author</th><th>Type</th><th>From</th><th>To</th></tr>
321 foreach (sort keys %transfereditems) {
322 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
323 my $barcode=$transfereditems{$_};
324 my $frbcd=$frbranchcds{$_};
325 my $tobcd=$tobranchcds{$_};
326 my ($iteminformation) = getiteminformation(\%env, 0, $barcode);
328 <tr><td bgcolor=$color align=center>
329 <a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}
330 &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode</a></td>
331 <td bgcolor=$color>$iteminformation->{'title'}</td>
332 <td bgcolor=$color>$iteminformation->{'author'}</td>
333 <td bgcolor=$color align=center>$iteminformation->{'itemtype'}</td>
334 <td bgcolor=$color align=center>$branches->{$frbcd}->{'branchname'}</td>
335 <td bgcolor=$color align=center>$branches->{$tobcd}->{'branchname'}</td>
343 print endmenu('circulation');