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