4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
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
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.
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
22 use CGI qw/:standard/;
23 use C4::Circulation::Circ2;
31 # this is a reorganisation of circulationold.pl
32 # dividing it up into three scripts......
33 # this will be the first one that chooses branch and printer settings....
35 #general design stuff...
36 my $headerbackgroundcolor='#99cc33';
37 my $circbackgroundcolor='#ffffcc';
38 my $circbackgroundcolor='white';
39 my $linecolor1='#ffffcc';
40 my $linecolor2='white';
41 my $backgroundimage="/images/background-mem.gif";
43 # try to get the branch and printer settings from the http....
46 my $branches=getbranches(\%env);
47 my $printers=getprinters(\%env);
48 my $branch=$query->param('branch');
49 my $printer=$query->param('printer');
51 ($branch) || ($branch=$query->cookie('branch'));
52 ($printer) || ($printer=$query->cookie('printer'));
54 ($branches->{$branch}) || ($branch=(keys %$branches)[0]);
55 ($printers->{$printer}) || ($printer=(keys %$printers)[0]);
58 # is you force a selection....
59 my $oldbranch = $branch;
60 my $oldprinter = $printer;
66 $env{'branchcode'}=$branch;
67 $env{'printer'}=$printer;
68 $env{'queue'}=$printer;
70 # set up select options....
74 foreach (keys %$branches) {
76 (next) unless ($branches->{$_}->{'IS'});
79 $branch{selected}=($_ eq $oldbranch);
80 $branch{name}=$branches->{$_}->{'branchname'};
82 push(@branchloop,\%branch);
85 foreach (keys %$printers) {
89 $printer{selected}=($_ eq $oldprinter);
90 $printer{name}=$printers->{$_}->{'printername'};
92 push(@printerloop,\%printer);
95 # if there is only one....
99 my $oneprinter=($printercount==1) ;
100 my $onebranch=($branchcount==1) ;
101 if ($printercount==1) {
102 ($printer)=keys %$printers;
103 $printername=$printers->{$printer}->{printername};
105 if ($branchcount==1) {
106 ($branch)=keys %$branches;
107 $branchname=$branches->{$branch}->{branchname};
111 #############################################################################################
112 # Start writing page....
113 # set header with cookie....
115 my ($template, $borrowernumber, $cookie)
116 = get_template_and_user({template_name => "circ/selectbranchprinter.tmpl",
119 authnotrequired => 0,
120 flagsrequired => {parameters => 1},
122 $template->param(headerbackgroundcolor => $headerbackgroundcolor,
123 backgroundimage => $backgroundimage,
124 oneprinter => $oneprinter,
125 onebranch => $onebranch,
126 printername => $printername,
127 branchname => $branchname,
128 printerloop => \@printerloop,
129 branchloop => \@branchloop
132 print $query->header(), $template->output;