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();
24 ###############################################
29 my $tobranchcd=$query->param('tobranchcd');
33 # set up the branchselect options....
35 foreach my $br (keys %$branches) {
36 (next) unless $branches->{$br}->{'CU'};
38 ($selected='selected') if ($br eq $tobranchcd);
39 $tobranchoptions.="<option value=$br $selected>$branches->{$br}->{'branchname'}\n";
42 # collect the stack of books already transfered so they can printed...
47 foreach ($query->param){
48 (next) unless (/bc-(\d*)/);
50 my $barcode=$query->param("bc-$counter");
51 my $frbcd=$query->param("fb-$counter");
52 my $tobcd=$query->param("tb-$counter");
54 $transfereditems{$counter}=$barcode;
55 $frbranchcds{$counter}=$frbcd;
56 $tobranchcds{$counter}=$tobcd;
57 $ritext.="<input type=hidden name=bc-$counter value=$barcode>\n";
58 $ritext.="<input type=hidden name=fb-$counter value=$frbcd>\n";
59 $ritext.="<input type=hidden name=tb-$counter value=$tobcd>\n";
62 # Warnings etc that get displayed at top of next page....
65 #if the barcode has been entered action that and write a message and onto the top of the stack...
67 if (my $barcode=$query->param('barcode')) {
68 my $iteminformation = getiteminformation(\%env,0 ,$barcode);
69 my ($transfered, $message, $iteminformation) = transferbook($tobranchcd, $barcode);
70 if (not $transfered) {
71 push(@messages, $message);
74 my $frbranchcd = $iteminformation->{'holdingbranch'};
75 $ritext.="<input type=hidden name=bc-0 value=$barcode>\n";
76 $ritext.="<input type=hidden name=fb-0 value=$frbranchcd>\n";
77 $ritext.="<input type=hidden name=tb-0 value=$tobranchcd>\n";
78 $transfereditems{0}=$barcode;
79 $frbranchcds{0}=$frbranchcd;
80 $tobranchcds{0}=$tobranchcd;
81 push(@messages, "Book: $barcode has been transfered");
85 #################################################################################
88 my $entrytext= << "EOF";
89 <form method=post action=/cgi-bin/koha/circ/branchtransfers.pl>
90 <table border=1 cellpadding=5 cellspacing=0 align=left>
91 <tr><td colspan=2 align=center background=$backgroundimage>
92 <font color=black><b>Select Branch</b></font></td></tr>
93 <tr><td>Destination Branch:</td>
94 <td><select name=tobranchcd> $tobranchoptions </select></td></tr></table>
96 <img src="/images/holder.gif" width=24 height=50 align=left>
98 <table border=1 cellpadding=5 cellspacing=0 ><tr>
99 <td colspan=2 align=center background=$backgroundimage>
100 <font color=black><b>Enter Book Barcode</b></font></td></tr>
101 <tr><td>Item Barcode:</td><td><input name=barcode size=10></td></tr>
103 <input type=hidden name=tobranchcd value=$tobranchcd>
111 foreach (@messages) {
112 $messagetext.="$_<br>";
114 $messagetext = substr($messagetext, 0, -4);
115 $messagetable = << "EOF";
116 <table border=1 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
117 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font>Messages</font></th></tr>
118 <tr><td> $messagetext </td></tr></table>
122 #######################################################################################
123 # Make the page .....
125 print $query->header;
127 print startmenu('circulation');
130 <FONT SIZE=2 face="arial, helvetica">
131 <a href=circulationold.pl?module=issues>Next Borrower</a> ||
132 <a href=returns.pl>Returns</a> ||
133 <a href=branchtransfers.pl>Transfers</a></font></p><FONT SIZE=6><em>Circulation: Transfers</em></FONT><br>
140 if (%transfereditems) {
143 <table border=1 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
144 <tr><th colspan=6 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>Transfered Items</font></th></tr>
145 <tr><th>Bar Code</th><th>Title</th><th>Author</th><th>Type</th><th>From</th><th>To</th></tr>
148 foreach (keys %transfereditems) {
149 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
150 my $barcode=$transfereditems{$_};
151 my $frbcd=$frbranchcds{$_};
152 my $tobcd=$tobranchcds{$_};
153 my ($iteminformation) = getiteminformation(\%env, 0, $barcode);
155 <tr><td bgcolor=$color align=center>
156 <a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}
157 &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode</a></td>
158 <td bgcolor=$color>$iteminformation->{'title'}</td>
159 <td bgcolor=$color>$iteminformation->{'author'}</td>
160 <td bgcolor=$color align=center>$iteminformation->{'itemtype'}</td>
161 <td bgcolor=$color align=center>$branches->{$frbcd}->{'branchname'}</td>
162 <td bgcolor=$color align=center>$branches->{$tobcd}->{'branchname'}</td>
169 print endmenu('circulation');