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;
34 # this is a reorganisation of circulationold.pl
35 # dividing it up into three scripts......
36 # this will be the first one that chooses branch and printer settings....
38 #general design stuff...
39 my $headerbackgroundcolor='#99cc33';
40 my $circbackgroundcolor='#ffffcc';
41 my $circbackgroundcolor='white';
42 my $linecolor1='#ffffcc';
43 my $linecolor2='white';
44 my $backgroundimage="/images/background-mem.gif";
46 # try to get the branch and printer settings from the http....
49 my $branches=getbranches(\%env);
50 my $printers=getprinters(\%env);
51 my $branch=$query->param('branch');
52 my $printer=$query->param('printer');
54 ($branch) || ($branch=$query->cookie('branch'));
55 ($printer) || ($printer=$query->cookie('printer'));
57 ($branches->{$branch}) || ($branch=(keys %$branches)[0]);
58 ($printers->{$printer}) || ($printer=(keys %$printers)[0]);
61 # is you force a selection....
62 my $oldbranch = $branch;
63 my $oldprinter = $printer;
69 $env{'branchcode'}=$branch;
70 $env{'printer'}=$printer;
71 $env{'queue'}=$printer;
73 # set up select options....
77 foreach my $br (keys %$branches) {
78 next unless $br =~ /\S/;
79 #(next) unless ($branches->{$_}->{'IS'}); # FIXME disabled to fix bug 202
82 $branch{selected}=($br eq $oldbranch);
83 $branch{name}=$branches->{$br}->{'branchname'};
85 push(@branchloop,\%branch);
88 foreach (keys %$printers) {
92 $printer{selected}=($_ eq $oldprinter);
93 $printer{name}=$printers->{$_}->{'printername'};
95 push(@printerloop,\%printer);
98 # if there is only one....
102 my $oneprinter=($printercount==1) ;
103 my $onebranch=($branchcount==1) ;
104 if ($printercount==1) {
105 ($printer)=keys %$printers;
106 $printername=$printers->{$printer}->{printername};
108 if ($branchcount==1) {
109 ($branch)=keys %$branches;
110 $branchname=$branches->{$branch}->{branchname};
114 #############################################################################################
115 # Start writing page....
116 # set header with cookie....
118 my ($template, $borrowernumber, $cookie)
119 = get_template_and_user({template_name => "circ/selectbranchprinter.tmpl",
122 authnotrequired => 0,
123 flagsrequired => {circulate => 1},
125 $template->param(headerbackgroundcolor => $headerbackgroundcolor,
126 backgroundimage => $backgroundimage,
127 oneprinter => $oneprinter,
128 onebranch => $onebranch,
129 printername => $printername,
130 branchname => $branchname,
131 printerloop => \@printerloop,
132 branchloop => \@branchloop
135 my $branchcookie=$query->cookie(-name => 'branch', -value => "$branch", -expires => '+1y');
136 my $printercookie=$query->cookie(-name => 'printer', -value => "$printer", -expires => '+1y');
138 my $cookies=[$cookie,$branchcookie, $printercookie];
139 output_html_with_http_headers $query, $cookies, $template->output;