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/;
26 use C4::Interface::CGI::Output;
28 use C4::Branch; # GetBranches
30 # this is a reorganisation of circulationold.pl
31 # dividing it up into three scripts......
32 # this will be the first one that chooses branch and printer settings....
34 #general design stuff...
36 # try to get the branch and printer settings from the http....
38 my $branches = GetBranches();
39 my $printers = GetPrinters();
40 my $branch = $query->param('branch');
41 my $printer = $query->param('printer');
43 my %cookie = $query->cookie('userenv');
44 ($branch) || ( $branch = $cookie{'branch'} );
45 ($printer) || ( $printer = $cookie{'printer'} );
47 ( $branches->{$branch} ) || ( $branch = ( keys %$branches )[0] );
48 ( $printers->{$printer} ) || ( $printer = ( keys %$printers )[0] );
50 # is you force a selection....
51 my $oldbranch = $branch;
52 my $oldprinter = $printer;
54 # set up select options....
58 foreach my $br ( keys %$branches ) {
59 next unless $br =~ /\S/; # next unless $br is not blank.
63 $branch{selected} = ( $br eq $oldbranch );
64 $branch{name} = $branches->{$br}->{'branchname'};
66 push( @branchloop, \%branch );
69 foreach ( keys %$printers ) {
70 (next) unless ($_); # next unless if this printer is blank.
73 $printer{selected} = ( $_ eq $oldprinter );
74 $printer{name} = $printers->{$_}->{'printername'};
76 push( @printerloop, \%printer );
79 # if there is only one....
83 my $oneprinter = ( $printercount == 1 );
84 my $onebranch = ( $branchcount == 1 );
85 if ( $printercount == 1 ) {
86 my ($tmpprinter) = keys %$printers;
87 $printername = $printers->{$tmpprinter}->{printername};
89 if ( $branchcount == 1 ) {
90 my ($tmpbranch) = keys %$branches;
91 $branchname = $branches->{$tmpbranch}->{branchname};
94 ################################################################################
95 # Start writing page....
96 # set header with cookie....
98 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
100 template_name => "circ/selectbranchprinter.tmpl",
103 authnotrequired => 0,
104 flagsrequired => { circulate => 1 },
108 oneprinter => $oneprinter,
109 onebranch => $onebranch,
110 printername => $printername,
111 branchname => $branchname,
112 printerloop => \@printerloop,
113 branchloop => \@branchloop,
114 intranetcolorstylesheet =>
115 C4::Context->preference("intranetcolorstylesheet"),
116 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
117 IntranetNav => C4::Context->preference("IntranetNav"),
120 output_html_with_http_headers $query, $cookie, $template->output;