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....
39 my $branches = GetBranches();
40 my $printers = GetPrinters( \%env );
41 my $branch = $query->param('branch');
42 my $printer = $query->param('printer');
44 my %cookie = $query->cookie('userenv');
45 ($branch) || ( $branch = $cookie{'branch'} );
46 ($printer) || ( $printer = $cookie{'printer'} );
48 ( $branches->{$branch} ) || ( $branch = ( keys %$branches )[0] );
49 ( $printers->{$printer} ) || ( $printer = ( keys %$printers )[0] );
51 # is you force a selection....
52 my $oldbranch = $branch;
53 my $oldprinter = $printer;
55 $env{'branchcode'} = $branch;
56 $env{'printer'} = $printer;
57 $env{'queue'} = $printer;
59 # set up select options....
63 foreach my $br ( keys %$branches ) {
64 next unless $br =~ /\S/; # next unless $br is not blank.
68 $branch{selected} = ( $br eq $oldbranch );
69 $branch{name} = $branches->{$br}->{'branchname'};
71 push( @branchloop, \%branch );
74 foreach ( keys %$printers ) {
75 (next) unless ($_); # next unless if this printer is blank.
78 $printer{selected} = ( $_ eq $oldprinter );
79 $printer{name} = $printers->{$_}->{'printername'};
81 push( @printerloop, \%printer );
84 # if there is only one....
88 my $oneprinter = ( $printercount == 1 );
89 my $onebranch = ( $branchcount == 1 );
90 if ( $printercount == 1 ) {
91 my ($tmpprinter) = keys %$printers;
92 $printername = $printers->{$tmpprinter}->{printername};
94 if ( $branchcount == 1 ) {
95 my ($tmpbranch) = keys %$branches;
96 $branchname = $branches->{$tmpbranch}->{branchname};
99 ################################################################################
100 # Start writing page....
101 # set header with cookie....
103 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
105 template_name => "circ/selectbranchprinter.tmpl",
108 authnotrequired => 0,
109 flagsrequired => { circulate => 1 },
113 oneprinter => $oneprinter,
114 onebranch => $onebranch,
115 printername => $printername,
116 branchname => $branchname,
117 printerloop => \@printerloop,
118 branchloop => \@branchloop,
119 intranetcolorstylesheet =>
120 C4::Context->preference("intranetcolorstylesheet"),
121 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
122 IntranetNav => C4::Context->preference("IntranetNav"),
125 output_html_with_http_headers $query, $cookie, $template->output;