2 # WARNING: This file uses 4-character tabs!
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
23 use CGI qw/:standard/;
24 use C4::Circulation::Circ2;
28 use C4::Interface::CGI::Output;
33 # this is a reorganisation of circulationold.pl
34 # dividing it up into three scripts......
35 # this will be the first one that chooses branch and printer settings....
37 #general design stuff...
38 my $headerbackgroundcolor='#99cc33';
39 my $circbackgroundcolor='#ffffcc';
40 my $circbackgroundcolor='white';
41 my $linecolor1='#ffffcc';
42 my $linecolor2='white';
43 my $backgroundimage="/images/background-mem.gif";
45 # try to get the branch and printer settings from the http....
48 my $branches=getbranches(\%env);
49 my $printers=getprinters(\%env);
50 my $branch=$query->param('branch');
51 my $printer=$query->param('printer');
53 ($branch) || ($branch=$query->cookie('branch'));
54 ($printer) || ($printer=$query->cookie('printer'));
56 ($branches->{$branch}) || ($branch=(keys %$branches)[0]);
57 ($printers->{$printer}) || ($printer=(keys %$printers)[0]);
60 # is you force a selection....
61 my $oldbranch = $branch;
62 my $oldprinter = $printer;
68 $env{'branchcode'}=$branch;
69 $env{'printer'}=$printer;
70 $env{'queue'}=$printer;
72 # set up select options....
76 foreach my $br (keys %$branches) {
77 next unless $br =~ /\S/;
78 #(next) unless ($branches->{$_}->{'IS'}); # FIXME disabled to fix bug 202
81 $branch{selected}=($br eq $oldbranch);
82 $branch{name}=$branches->{$br}->{'branchname'};
84 push(@branchloop,\%branch);
87 foreach (keys %$printers) {
91 $printer{selected}=($_ eq $oldprinter);
92 $printer{name}=$printers->{$_}->{'printername'};
94 push(@printerloop,\%printer);
97 # if there is only one....
101 my $oneprinter=($printercount==1) ;
102 my $onebranch=($branchcount==1) ;
103 if ($printercount==1) {
104 ($printer)=keys %$printers;
105 $printername=$printers->{$printer}->{printername};
107 if ($branchcount==1) {
108 ($branch)=keys %$branches;
109 $branchname=$branches->{$branch}->{branchname};
113 #############################################################################################
114 # Start writing page....
115 # set header with cookie....
117 my ($template, $borrowernumber, $cookie)
118 = get_template_and_user({template_name => "circ/selectbranchprinter.tmpl",
121 authnotrequired => 0,
122 flagsrequired => {parameters => 1},
124 $template->param(headerbackgroundcolor => $headerbackgroundcolor,
125 backgroundimage => $backgroundimage,
126 oneprinter => $oneprinter,
127 onebranch => $onebranch,
128 printername => $printername,
129 branchname => $branchname,
130 printerloop => \@printerloop,
131 branchloop => \@branchloop
134 output_html_with_http_headers $query, $cookie, $template->output;