3 #written 11/3/2002 by Finlay
4 #script to execute branch transfers of books
8 use C4::Circulation::Circ2;
11 ###############################################
15 my $headerbackgroundcolor='#99cc33';
16 my $circbackgroundcolor='#ffffcc';
17 my $circbackgroundcolor='white';
18 my $linecolor1='#ffffcc';
19 my $linecolor2='white';
20 my $backgroundimage="/images/background-mem.gif";
22 my $branches = getbranches();
23 my $printers = getprinters(\%env);
26 ###############################################
32 my $branch = $query->param("branch");
33 my $printer = $query->param("printer");
36 ($branch) || ($branch=$query->cookie('branch')) ;
37 ($printer) || ($printer=$query->cookie('printer')) ;
40 my $tobranchcd=$query->param('tobranchcd');
44 # set up the branchselect options....
46 foreach my $br (keys %$branches) {
47 (next) unless $branches->{$br}->{'CU'};
49 ($selected='selected') if ($br eq $tobranchcd);
50 $tobranchoptions.="<option value=$br $selected>$branches->{$br}->{'branchname'}\n";
53 # collect the stack of books already transfered so they can printed...
58 foreach ($query->param){
59 (next) unless (/bc-(\d*)/);
61 my $barcode=$query->param("bc-$counter");
62 my $frbcd=$query->param("fb-$counter");
63 my $tobcd=$query->param("tb-$counter");
65 $transfereditems{$counter}=$barcode;
66 $frbranchcds{$counter}=$frbcd;
67 $tobranchcds{$counter}=$tobcd;
68 $ritext.="<input type=hidden name=bc-$counter value=$barcode>\n";
69 $ritext.="<input type=hidden name=fb-$counter value=$frbcd>\n";
70 $ritext.="<input type=hidden name=tb-$counter value=$tobcd>\n";
73 # Warnings etc that get displayed at top of next page....
75 #if the barcode has been entered action that and write a message and onto the top of the stack...
77 if (my $barcode=$query->param('barcode')) {
80 ($transfered, $messages, $iteminformation) = transferbook($tobranchcd, $barcode);
82 my $frbranchcd = $iteminformation->{'holdingbranch'};
83 $ritext.="<input type=hidden name=bc-0 value=$barcode>\n";
84 $ritext.="<input type=hidden name=fb-0 value=$frbranchcd>\n";
85 $ritext.="<input type=hidden name=tb-0 value=$tobranchcd>\n";
86 $transfereditems{0}=$barcode;
87 $frbranchcds{0}=$frbranchcd;
88 $tobranchcds{0}=$tobranchcd;
93 #################################################################################
96 my $entrytext= << "EOF";
97 <form method=post action=/cgi-bin/koha/circ/branchtransfers.pl>
98 <table border=1 cellpadding=5 cellspacing=0 align=left>
99 <tr><td colspan=2 align=center background=$backgroundimage>
100 <font color=black><b>Select Branch</b></font></td></tr>
101 <tr><td>Destination Branch:</td>
102 <td><select name=tobranchcd> $tobranchoptions </select></td></tr></table>
104 <img src="/images/holder.gif" width=24 height=50 align=left>
106 <table border=1 cellpadding=5 cellspacing=0 ><tr>
107 <td colspan=2 align=center background=$backgroundimage>
108 <font color=black><b>Enter Book Barcode</b></font></td></tr>
109 <tr><td>Item Barcode:</td><td><input name=barcode size=10></td></tr>
111 <input type=hidden name=tobranchcd value=$tobranchcd>
118 #####################
120 my $reservefoundtext;
121 if ($messages->{'ResFound'}) {
122 my $resrec = $messages->{'ResFound'};
123 my ($borr) = getpatroninformation(\%env, $resrec->{'borrowernumber'}, 0);
124 my $name = $borr->{'surname'}." ".$borr->{'title'}." ".$borr->{'firstname'};
125 my $number = "<a href=/cgi-bin/koha/moremember.pl?bornum=$borr->{'borrowernumber'} onClick='openWindow(this,'Member', 480, 640)'>$borr->{'cardnumber'}</a>";
126 my $branch = $branches->{$resrec->{'branchcode'}}->{'branchname'};
127 my $reservetext = "<font size='+2' color='red'>RESERVED</font><font size='+2'> for collection by $name ($number) at $branch </font>";
128 $reservefoundtext = <<"EOF";
129 <table border=1 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
130 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font>Reserve Found</font></th></tr>
131 <tr><td> $reservetext </td></tr></table>
135 #####################
138 foreach my $code (keys %$messages) {
139 if ($code eq 'BadBarcode'){
140 $messagetext .= "<font color='red' size='+2'> No Item with barcode: $messages->{'BadBarcode'} </font> <br>";
142 if ($code eq 'IsPermanent'){
143 my $braname = $branches->{$messages->{'IsPermanent'}}->{'branchname'};
144 $messagetext .= "<font color='red' size='+2'> Please return item to home branch: $braname </font> <br>";
146 if ($code eq 'DestinationEqualsHolding'){
147 $messagetext .= "<font color='red' size='+2'> Item is already at destination branch. </font> <br>";
149 if ($code eq 'WasReturned') {
150 my ($borrowerinfo) = getpatroninformation(\%env, $messages->{'WasReturned'}, 0);
153 <a href=/cgi-bin/koha/moremember.pl?bornum=$borrowerinfo->{'borrowernumber'}
154 onClick="openWindow(this,'Member', 480, 640)">$borrowerinfo->{'cardnumber'}</a>
155 $borrowerinfo->{'surname'}, $borrowerinfo->{'title'} $borrowerinfo->{'firstname'}
157 $messagetext .= "Item was on loan to $binfo and has been returned. <br>";
159 if ($code eq 'WasTransfered'){
162 $messagetext = substr($messagetext, 0, -4);
166 $messagetable = << "EOF";
167 <table border=1 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
168 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font>Messages</font></th></tr>
169 <tr><td> $messagetext </td></tr></table>
173 #######################################################################################
174 # Make the page .....
176 print $query->header;
178 print startmenu('circulation');
181 <table border=0 cellpadding=5 width=90%><tr>
182 <td align="left"><FONT SIZE=6><em>Circulation: Transfers</em></FONT><br>
183 <b>Branch:</b> $branches->{$branch}->{'branchname'}  
184 <b>Printer:</b> $printers->{$printer}->{'printername'}<br>
185 <a href=selectbranchprinter.pl>Change Settings</a>
188 <FONT SIZE=2 face="arial, helvetica">
189 <a href=circulation.pl>Next Borrower</a> ||
190 <a href=returns.pl>Returns</a> ||
191 <a href=branchtransfers.pl>Transfers</a></font><p>
193 <input type=hidden name=branch value=$branch>
194 <input type=hidden name=printer value=$printer>
198 print $reservefoundtext;
204 if (%transfereditems) {
207 <table border=1 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
208 <tr><th colspan=6 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>Transfered Items</font></th></tr>
209 <tr><th>Bar Code</th><th>Title</th><th>Author</th><th>Type</th><th>From</th><th>To</th></tr>
212 foreach (keys %transfereditems) {
213 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
214 my $barcode=$transfereditems{$_};
215 my $frbcd=$frbranchcds{$_};
216 my $tobcd=$tobranchcds{$_};
217 my ($iteminformation) = getiteminformation(\%env, 0, $barcode);
219 <tr><td bgcolor=$color align=center>
220 <a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}
221 &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode</a></td>
222 <td bgcolor=$color>$iteminformation->{'title'}</td>
223 <td bgcolor=$color>$iteminformation->{'author'}</td>
224 <td bgcolor=$color align=center>$iteminformation->{'itemtype'}</td>
225 <td bgcolor=$color align=center>$branches->{$frbcd}->{'branchname'}</td>
226 <td bgcolor=$color align=center>$branches->{$tobcd}->{'branchname'}</td>
233 print endmenu('circulation');