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/;
27 use C4::Branch; # GetBranches
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....
33 #general design stuff...
35 # try to get the branch and printer settings from the http....
37 my $branches = GetBranches();
38 my $printers = GetPrinters();
39 my $branch = $query->param('branch');
40 my $printer = $query->param('printer');
42 my %cookie = $query->cookie('userenv');
43 ($branch) || ( $branch = $cookie{'branch'} );
44 ($printer) || ( $printer = $cookie{'printer'} );
46 ( $branches->{$branch} ) || ( $branch = ( keys %$branches )[0] );
47 ( $printers->{$printer} ) || ( $printer = ( keys %$printers )[0] );
49 # is you force a selection....
50 my $oldbranch = $branch;
51 my $oldprinter = $printer;
53 # set up select options....
57 foreach my $br ( keys %$branches ) {
58 next unless $br =~ /\S/; # next unless $br is not blank.
62 $branch{selected} = ( $br eq $oldbranch );
63 $branch{name} = $branches->{$br}->{'branchname'};
65 push( @branchloop, \%branch );
68 foreach ( keys %$printers ) {
69 (next) unless ($_); # next unless if this printer is blank.
72 $printer{selected} = ( $_ eq $oldprinter );
73 $printer{name} = $printers->{$_}->{'printername'};
75 push( @printerloop, \%printer );
78 # if there is only one....
82 my $oneprinter = ( $printercount == 1 );
83 my $onebranch = ( $branchcount == 1 );
84 if ( $printercount == 1 ) {
85 my ($tmpprinter) = keys %$printers;
86 $printername = $printers->{$tmpprinter}->{printername};
88 if ( $branchcount == 1 ) {
89 my ($tmpbranch) = keys %$branches;
90 $branchname = $branches->{$tmpbranch}->{branchname};
93 ################################################################################
94 # Start writing page....
95 # set header with cookie....
97 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
99 template_name => "circ/selectbranchprinter.tmpl",
102 authnotrequired => 0,
103 flagsrequired => { circulate => 1 },
107 oneprinter => $oneprinter,
108 onebranch => $onebranch,
109 printername => $printername,
110 branchname => $branchname,
111 printerloop => \@printerloop,
112 branchloop => \@branchloop,
113 intranetcolorstylesheet =>
114 C4::Context->preference("intranetcolorstylesheet"),
115 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
116 IntranetNav => C4::Context->preference("IntranetNav"),
119 output_html_with_http_headers $query, $cookie, $template->output;