Added copyright statement to all .pl and .pm files
[koha.git] / circ / selectbranchprinter.pl
1 #!/usr/bin/perl
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA  02111-1307 USA
20
21 use strict;
22 use CGI qw/:standard/;
23 use C4::Circulation::Circ2;
24 use C4::Output;
25 use C4::Print;
26 use DBI;
27
28
29 # this is a reorganisation of circulationold.pl 
30 # dividing it up into three scripts......
31 # this will be the first one that chooses branch and printer settings....
32
33 #general design stuff...
34 my $headerbackgroundcolor='#99cc33';
35 my $circbackgroundcolor='#ffffcc';
36 my $circbackgroundcolor='white';
37 my $linecolor1='#ffffcc';
38 my $linecolor2='white';
39 my $backgroundimage="/images/background-mem.gif";
40
41 # try to get the branch and printer settings from the http....
42 my %env;
43 my $query=new CGI;
44 my $branches=getbranches(\%env);
45 my $printers=getprinters(\%env);
46 my $branch=$query->param('branch');
47 my $printer=$query->param('printer');
48
49 ($branch) || ($branch=$query->cookie('branch'));
50 ($printer) || ($printer=$query->cookie('printer'));
51
52 # is you force a selection....
53 my $oldbranch = $branch;
54 my $oldprinter = $printer;
55
56 $branch='';
57 $printer='';
58
59
60 $env{'branchcode'}=$branch;
61 $env{'printer'}=$printer;
62 $env{'queue'}=$printer;
63
64 # set up select options....
65 my $branchcount=0;
66 my $printercount=0;
67 my $branchoptions;
68 my $printeroptions;
69 foreach (keys %$branches) {
70     (next) unless ($_);
71     (next) unless ($branches->{$_}->{'IS'});
72     $branchcount++;
73     my $selected='';
74     ($selected='selected') if ($_ eq $oldbranch);
75     $branchoptions.="<option value=$_ $selected>$branches->{$_}->{'branchname'}\n";
76 }
77 foreach (keys %$printers) {
78     (next) unless ($_);
79     $printercount++;
80     my $selected='';
81     ($selected='selected') if ($_ eq $oldprinter);
82     $printeroptions.="<option value=$_ $selected>$printers->{$_}->{'printername'}\n";
83 }
84
85 # if there is only one....
86
87 if ($printercount==1) {
88     ($printer)=keys %$printers;
89 }
90 if ($branchcount==1) {
91     ($branch)=keys %$branches;
92 }
93
94 # set up printer and branch selection forms....
95 my ($printerform, $branchform);
96 if ($printercount>1) {
97     $printerform=<<"EOF";
98 <select name=printer> $printeroptions </select>
99 EOF
100 } else {
101     my ($printer) = keys %$printers;
102
103
104 if ($branchcount>1) {
105     $branchform=<<"EOF";
106 <select name=branch> $branchoptions </select>
107 EOF
108 } else {
109     my ($branch) = keys %$branches;
110
111
112
113
114 #############################################################################################
115 # Start writing page....
116 # set header with cookie....
117
118 print $query->header();
119
120 print startpage();
121 print startmenu('circulation');
122
123 print << "EOF";
124 <FONT SIZE=6><em>Circulation: Select Printer and Branch Settings</em></FONT><br>
125
126 <center>
127 <form method=post action=/cgi-bin/koha/circ/circulation.pl>
128 <table border=1 cellpadding=5 cellspacing=0>
129 <tr><td colspan=2 bgcolor=$headerbackgroundcolor align=center background=$backgroundimage>
130 <font color=black><b>Please Set Branch and Printer</b></font></td></tr>
131 <tr><td>
132 $branchform
133 </td>
134 <td>
135 $printerform
136 </td></tr>
137 </table>
138 <input type="hidden" name="setcookies" value=1>
139 <input type="submit" value="Submit" type="changesettings">
140 </form>
141 </center>
142
143 EOF
144
145
146 print endmenu('circulation');
147 print endpage();
148