X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Fselectbranchprinter.pl;h=17a89efb32b33fdd87d44f5162242f454cdffff4;hb=b9ecd6561057ea6551af4d9d84032568c50204a6;hp=130734039416c583ed2912ac9a8b52b853a5e678;hpb=efee891bca8109b23fdf608fb22a1f86efcf2120;p=koha_gimpoz
diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl
old mode 100644
new mode 100755
index 1307340394..17a89efb32
--- a/circ/selectbranchprinter.pl
+++ b/circ/selectbranchprinter.pl
@@ -1,128 +1,118 @@
#!/usr/bin/perl
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
use strict;
use CGI qw/:standard/;
-use C4::Circulation::Circ2;
+
+use C4::Context;
+use C4::Circulation;
use C4::Output;
+use C4::Auth;
use C4::Print;
-use DBI;
-
+use C4::Koha;
+use C4::Branch; # GetBranches
-# this is a reorganisation of circulationold.pl
+# this is a reorganisation of circulationold.pl
# dividing it up into three scripts......
# this will be the first one that chooses branch and printer settings....
#general design stuff...
-my $headerbackgroundcolor='#99cc33';
-my $circbackgroundcolor='#ffffcc';
-my $circbackgroundcolor='white';
-my $linecolor1='#ffffcc';
-my $linecolor2='white';
-my $backgroundimage="/images/background-mem.gif";
# try to get the branch and printer settings from the http....
-my %env;
-my $query=new CGI;
-my $branches=getbranches(\%env);
-my $printers=getprinters(\%env);
-my $branch=$query->param('branch');
-my $printer=$query->param('printer');
-
-($branch) || ($branch=$query->cookie('branch'));
-($printer) || ($printer=$query->cookie('printer'));
-
-# is you force a selection....
-my $oldbranch = $branch;
-my $oldprinter = $printer;
+my $query = new CGI;
+my $branches = GetBranches();
+my $printers = GetPrinters();
+my $branch = $query->param('branch');
+my $printer = $query->param('printer');
+
+# set header with cookie....
-$branch='';
-$printer='';
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+ {
+ template_name => "circ/selectbranchprinter.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { circulate => 1 },
+ }
+);
-$env{'branchcode'}=$branch;
-$env{'printer'}=$printer;
-$env{'queue'}=$printer;
+($branch) || ( $branch = C4::Context->userenv->{'branch'} );
+($printer) || ( $printer = C4::Context->userenv->{'branchprinter'} );
+( $branches->{$branch} ) || ( $branch = ( keys %$branches )[0] );
+( $printers->{$printer} ) || ( $printer = ( keys %$printers )[0] );
+
+# if you force a selection....
+my $oldbranch = $branch;
+my $oldprinter = $printer;
# set up select options....
-my $branchcount=0;
-my $printercount=0;
-my $branchoptions;
-my $printeroptions;
-foreach (keys %$branches) {
- (next) unless ($_);
+my $branchcount = 0;
+my $printercount = 0;
+my @branchloop;
+foreach my $br ( sort keys %$branches ) {
+ next unless $br =~ /\S/; # next unless $br is not blank.
+
$branchcount++;
- my $selected='';
- ($selected='selected') if ($_ eq $oldbranch);
- $branchoptions.="