3 #written 11/3/2002 by Finlay
4 #script to execute branch transfers of books
8 use C4::Circulation::Circ2;
14 my $headerbackgroundcolor='#99cc33';
15 my $circbackgroundcolor='#ffffcc';
16 my $circbackgroundcolor='white';
17 my $linecolor1='#ffffcc';
18 my $linecolor2='white';
19 my $backgroundimage="/images/background-mem.gif";
22 my $branches=getbranches(\%env);
24 my $tobranchcd=$query->param('tobranchcd');
27 $env{'tobranchcd'}=$tobranchcd;
31 foreach (keys %$branches) {
35 ($selected='selected') if ($_ eq $tobranchcd);
36 $tobranchoptions.="<option value=$_ $selected>$branches->{$_}->{'branchname'}\n";
39 # collect the stack of books already transfered so they can printed...
45 foreach ($query->param){
46 (next) unless (/bc-(\d*)/);
48 my $barcode=$query->param("bc-$counter");
49 my $frbcd=$query->param("fb-$counter");
50 my $tobcd=$query->param("tb-$counter");
52 $transfereditems{$counter}=$barcode;
53 $frbranchcds{$counter}=$frbcd;
54 $tobranchcds{$counter}=$tobcd;
55 $ritext.="<input type=hidden name=bc-$counter value=$barcode>\n";
56 $ritext.="<input type=hidden name=fb-$counter value=$frbcd>\n";
57 $ritext.="<input type=hidden name=tb-$counter value=$tobcd>\n";
60 #if the barcode has been entered action that and write a message and onto the top of the stack...
64 if (my $barcode=$query->param('barcode')) {
65 my $iteminformation = getiteminformation(\%env,0, $barcode);
67 if (not $iteminformation) {
69 @messages = ("There is no book with barcode: $barcode ", @messages);
71 $frbranchcd = $iteminformation->{'holdingbranch'};
72 %env->{'frbranchcd'} = $frbranchcd;
73 if ($frbranchcd eq $tobranchcd) {
75 @messages = ("You can't transfer the book to the branch it is already at!", @messages);
77 # should add some more tests ... like is the book already out, maybe it cant be moved....
79 my ($transfered, $message) = transferbook(\%env, $iteminformation, $barcode);
80 if (not $transfered) {@messages = ($message, @messages);}
82 $ritext.="<input type=hidden name=bc-0 value=$barcode>\n";
83 $ritext.="<input type=hidden name=fb-0 value=$frbranchcd>\n";
84 $ritext.="<input type=hidden name=tb-0 value=$tobranchcd>\n";
85 $transfereditems{0}=$barcode;
86 $frbranchcds{0}=$frbranchcd;
87 $tobranchcds{0}=$tobranchcd;
88 @messages = ("Book: $barcode has been transfered", @messages);
93 my $entrytext= << "EOF";
94 <form method=post action=/cgi-bin/koha/circ/branchtransfers.pl>
95 <table border=0 cellpadding=5 cellspacing=0 bgcolor='#dddddd' >
96 <tr><td colspan=2 bgcolor=$headerbackgroundcolor align=center background=$backgroundimage>
97 <font color=black><b>Select Branch</b></font></td></tr>
98 <tr><td>Destination Branch:</td>
99 <td><select name=tobranchcd> $tobranchoptions </select></td></tr></table>
100 <table border=0 cellpadding=5 cellspacing=0 bgcolor='#dddddd' ><tr>
101 <td colspan=2 bgcolor=$headerbackgroundcolor align=center background=$backgroundimage>
102 <font color=black><b>Enter Book Barcode</b></font></td></tr>
103 <tr><td>Item Barcode:</td><td><input name=barcode size=10></td></tr>
105 <input type=hidden name=tobranchcd value=$tobranchcd>
113 foreach (@messages) {
114 $messagetext.="$_<p>\n";
116 $messagetable = << "EOF";
117 <table border=0 cellpadding=5 cellspacing=0 bgcolor='#dddddd'>
118 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>Messages</font></th></tr>
119 <tr><td> $messagetext </td></tr></table>
125 print $query->header;
127 print startmenu('circulation');
128 print "<h3>Branch Transfers</h3>";
131 print $messagetable if (@messages);
136 if (%transfereditems) {
139 <table border=0 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
140 <tr><th colspan=6 bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>Transfered Items</font></th></tr>
141 <tr><th>Bar Code</th><th>Title</th><th>Author</th><th>Type</th><th>From</th><th>To</th></tr>
144 foreach (keys %transfereditems) {
145 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
146 my $barcode=$transfereditems{$_};
147 my $frbcd=$frbranchcds{$_};
148 my $tobcd=$tobranchcds{$_};
149 my ($iteminformation) = getiteminformation(\%env, 0, $barcode);
151 <tr><td bgcolor=$color align=center>
152 <a href=/cgi-bin/koha/detail.pl?bib=$iteminformation->{'biblionumber'}
153 &type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode</a></td>
154 <td bgcolor=$color>$iteminformation->{'title'}</td>
155 <td bgcolor=$color>$iteminformation->{'author'}</td>
156 <td bgcolor=$color align=center>$iteminformation->{'itemtype'}</td>
157 <td bgcolor=$color align=center>$branches->{$frbcd}->{'branchname'}</td>
158 <td bgcolor=$color align=center>$branches->{$tobcd}->{'branchname'}</td>
165 print endmenu('circulation');