3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
21 use CGI qw
/:standard/;
29 use C4
::Branch
; # GetBranches
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...
37 # try to get the branch and printer settings from the http....
39 my $branches = GetBranches
();
40 my $printers = GetPrinters
();
41 my $branch = $query->param('branch');
42 my $printer = $query->param('printer');
44 # set header with cookie....
46 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
48 template_name
=> "circ/selectbranchprinter.tmpl",
52 flagsrequired
=> { circulate
=> 1 },
57 ($branch) || ( $branch = C4
::Context
->userenv->{'branch'} );
58 ($printer) || ( $printer = C4
::Context
->userenv->{'branchprinter'} );
59 ( $branches->{$branch} ) || ( $branch = ( keys %$branches )[0] );
60 ( $printers->{$printer} ) || ( $printer = ( keys %$printers )[0] );
62 # if you force a selection....
63 my $oldbranch = $branch;
64 my $oldprinter = $printer;
66 # set up select options....
70 for my $br (sort { $branches->{$a}->{branchname
} cmp $branches->{$b}->{branchname
} } keys %$branches) {
71 next unless $br =~ /\S/; # next unless $br is not blank.
75 $branch{selected
} = ( $br eq $oldbranch );
76 $branch{name
} = $branches->{$br}->{'branchname'};
78 push( @branchloop, \
%branch );
81 foreach ( keys %$printers ) {
82 (next) unless ($_); # next unless if this printer is blank.
85 $printer{selected
} = ( $_ eq $oldprinter );
86 $printer{name
} = $printers->{$_}->{'printername'};
88 push( @printerloop, \
%printer );
91 # if there is only one....
95 my $oneprinter = ( $printercount == 1 );
96 my $onebranch = ( $branchcount == 1 );
97 if ( $printercount == 1 ) {
98 my ($tmpprinter) = keys %$printers;
99 $printername = $printers->{$tmpprinter}->{printername
};
101 if ( $branchcount == 1 ) {
102 my ($tmpbranch) = keys %$branches;
103 $branchname = $branches->{$tmpbranch}->{branchname
};
106 ################################################################################
107 # Start writing page....
110 oneprinter
=> $oneprinter,
111 onebranch
=> $onebranch,
112 printername
=> $printername,
113 branchname
=> $branchname,
114 printerloop
=> \
@printerloop,
115 branchloop
=> \
@branchloop,
118 output_html_with_http_headers
$query, $cookie, $template->output;