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
27 use C4::Print; # GetPrinters
29 use C4::Branch; # GetBranches GetBranchesLoop
31 # this will be the script that chooses branch and printer settings....
33 my $query = CGI->new();
34 my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
35 template_name => "circ/selectbranchprinter.tmpl",
40 flagsrequired => { circulate => "circulate_remaining_permissions" },
43 # try to get the branch and printer settings from http, fallback to userenv
44 my $branches = GetBranches();
45 my $printers = GetPrinters();
46 my $branch = $query->param('branch' ) || C4::Context->userenv->{'branch'};
47 my $printer = $query->param('printer') || C4::Context->userenv->{'branchprinter'};
49 unless ($branches->{$branch}) {
50 $branch = (keys %$branches)[0]; # if branch didn't really exist, then replace it w/ one that does
53 my @printkeys = sort keys %$printers;
54 if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
55 $printer = $printkeys[0];
59 foreach ( @printkeys ) {
60 next unless ($_); # skip printer if blank.
62 selected => ( $_ eq $printer ),
63 name => $printers->{$_}->{'printername'},
69 foreach ($query->param()) {
70 /^branch(printer)?$/ and next; # disclude branch and branchprinter
73 value => $query->param($_),
78 referer => $ENV{HTTP_REFERER},
79 printerloop => \@printerloop,
80 branchloop => GetBranchesLoop($branch),
81 recycle_loop=> \@recycle_loop,
84 output_html_with_http_headers $query, $cookie, $template->output;