X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=circ%2Fselectbranchprinter.pl;h=8b83b884b2a644dced78a0cb33db819e80706c29;hb=36595bbf16504e2d65fad4d588b13554391493af;hp=e5feb6237ac99d341878c4d29dffdda12f81b606;hpb=5aa0fca7fac93241c07e3568ddc2c73ec54c8c3d;p=koha.git
diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl
old mode 100644
new mode 100755
index e5feb6237a..8b83b884b2
--- a/circ/selectbranchprinter.pl
+++ b/circ/selectbranchprinter.pl
@@ -1,6 +1,5 @@
#!/usr/bin/perl
-
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
@@ -20,135 +19,100 @@
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
# 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 ($_);
- # FIXME - What is this "IS" field? I suspect it's a leftover from
- # some previous iteration of the code, and means "this is a branch
- # that does issues". But it never gets set, so no branches ever
- # get selected, and the user can't choose a branch.
- # FIXME - Also, shouldn't librarians be able to select any branch,
- # not just ones that handle issues?
-# (next) unless ($branches->{$_}->{'IS'});
+my $branchcount = 0;
+my $printercount = 0;
+my @branchloop;
+foreach my $br ( keys %$branches ) {
+ next unless $br =~ /\S/; # next unless $br is not blank.
+
$branchcount++;
- my $selected='';
- ($selected='selected') if ($_ eq $oldbranch);
- $branchoptions.="