test.pl, contains a script to test the Catalogue.pm stuff.
[koha.git] / circ / circulation2.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI qw/:standard/;
5 use C4::Circulation::Circ2;
6 use C4::Output;
7 use C4::Print;
8 use DBI;
9
10
11 # this is a reorganisation of circulation.pl 
12 # dividing it up into three scripts......
13 # this will be the first one that chooses branch and printer settings....
14
15 my %env;
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";
22
23 my $query=new CGI;
24 my $branches=getbranches(\%env);
25 my $printers=getprinters(\%env);
26 my $branch=$query->param('branch');
27 my $printer=$query->param('printer');
28
29 ($branch) || ($branch=$query->cookie('branch'));
30 ($printer) || ($printer=$query->cookie('printer'));
31
32 my $oldbranch;
33 my $oldprinter;
34 if ($query->param('selectnewbranchprinter')) {
35     $oldbranch=$branch;
36     $oldprinter=$printer;
37     $branch='';
38     $printer='';
39 }
40
41 $env{'branchcode'}=$branch;
42 $env{'printer'}=$printer;
43 $env{'queue'}=$printer;
44
45 # set up select options....
46 my $branchcount=0;
47 my $printercount=0;
48 my $branchoptions;
49 my $printeroptions;
50 foreach (keys %$branches) {
51     (next) unless ($_);
52     (next) if (/^TR$/);
53     $branchcount++;
54     my $selected='';
55     ($selected='selected') if ($_ eq $oldbranch);
56     $branchoptions.="<option value=$_ $selected>$branches->{$_}->{'branchname'}\n";
57 }
58 foreach (keys %$printers) {
59     (next) unless ($_);
60     $printercount++;
61     my $selected='';
62     ($selected='selected') if ($_ eq $oldprinter);
63     $printeroptions.="<option value=$_ $selected>$printers->{$_}->{'printername'}\n";
64 }
65
66 # if there is only one....
67
68 if ($printercount==1) {
69     ($printer)=keys %$printers;
70 }
71 if ($branchcount==1) {
72     ($branch)=keys %$branches;
73 }
74
75 my $branchcookie=$query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
76 my $printercookie=$query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
77
78
79 my ($printerform, $branchform);
80 if ($printercount>1) {
81     $printerform=<<"EOF";
82 <table border=0 cellpadding=5 cellspacing=0 bgcolor='#dddddd' >
83 <tr><td><select name=printer> $printeroptions </select></td></tr>
84 </table>
85 <input type=hidden name=branch value=$printer>
86 EOF
87 } else {
88     my ($printer) = keys %$printers;
89     $printerform=<<"EOF";
90 <input type=hidden name=printer value=$printer>
91 EOF
92
93
94 if ($branchcount>1) {
95     $branchform=<<"EOF";
96 <table border=0 cellpadding=5 cellspacing=0 bgcolor='#dddddd' >
97 <tr><td> <select name=branch> $branchoptions </select> </td></tr>
98 </table>
99 <input type=hidden name=branch value=$branch>
100 EOF
101 } else {
102     my ($branch) = keys %$branches;
103     $branchform=<<"EOF";
104 <input type=hidden name=printer value=$printer>
105 EOF
106
107
108
109 # set header with cookie....
110 print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]);
111
112
113 print startpage();
114 print startmenu('circulation');
115
116 if ($branch and $printer) {
117     print << "EOF";
118 <p align=right>
119 <FONT SIZE=2  face="arial, helvetica">
120 <a href=circulation.pl?module=issues&branch=$branch&printer=$printer&print>Next Borrower</a> ||
121 <a href=circulation.pl?module=returns&branch=$branch&printer=$printer>Returns</a> ||
122 <a href=branchtransfers.pl>Transfer Book</a></font>
123 <input type=hidden name=module value=issues>
124 <input type=hidden name=branch value=$branch>
125 <input type=hidden name=printer value=$printer>
126 <input type=hidden name=barcode value=" ">
127 </p>
128
129 <table align=left border=0 cellpadding=5 cellspacing=0 >
130 <tr><td colspan=2 bgcolor=$headerbackgroundcolor align=center background=$backgroundimage>
131 <font color=black><b>Branch and Printer Settings<b></font>
132 </td></tr>
133 <tr><td>
134 <b>Branch:</b> $branches->{$branch}->{'branchname'} </td><td><b>Printer:</b>$printers->{$printer}->{'printername'} 
135 </td></tr>
136 <tr><td colspace=2>
137 <a href=circulation2.pl?selectnewbranchprinter=1>Select new branch and printer</a>
138 </td></tr>
139 </table>
140
141 <img src="/images/holder.gif" width=24 height=50 align=left>
142
143 <table border=0 cellpadding=5 cellspacing=0 bgcolor='#dddddd' align=right>
144 <form method=get>
145 <tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black>
146 <b>Enter borrower card number<br> or partial last name</b></font>
147 </td></tr>
148 <tr><td><input name=findborrower></td></tr>
149 </form>
150 </table>
151
152
153
154 EOF
155 } else {
156     print << "EOF";
157 <form method=post action=/cgi-bin/koha/circ/circulation2.pl>
158 <table border=0 cellpadding=5 cellspacing=0>
159 <tr><td colspan=2 bgcolor=$headerbackgroundcolor align=center background=$backgroundimage>
160 <font color=black><b>Please Set Branch and Printer</b></font></td></tr>
161 <tr><td>
162 $branchform
163 </td>
164 <td>
165 $printerform
166 </td></tr>
167 </table>
168 <input type="submit" value="Change Settings" type="changesettings">
169 </form>
170
171
172 EOF
173 }
174
175 print endmenu('circulation');
176 print endpage();
177