diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl index 2e51c22cfd..7c31db3ab0 100644 --- a/circ/selectbranchprinter.pl +++ b/circ/selectbranchprinter.pl @@ -22,7 +22,9 @@ use strict; use CGI qw/:standard/; use C4::Circulation::Circ2; use C4::Output; +use C4::Auth; use C4::Print; +use HTML::Template; use DBI; @@ -68,87 +70,62 @@ $env{'queue'}=$printer; # set up select options.... my $branchcount=0; my $printercount=0; -my $branchoptions; -my $printeroptions; +my @branchloop; foreach (keys %$branches) { (next) unless ($_); (next) unless ($branches->{$_}->{'IS'}); $branchcount++; - my $selected=''; - ($selected='selected') if ($_ eq $oldbranch); - $branchoptions.="$branches->{$_}->{'branchname'}\n"; + my %branch; + $branch{selected}=($_ eq $oldbranch); + $branch{name}=$branches->{$_}->{'branchname'}; + $branch{value}=$_; + push(@branchloop,\%branch); } +my @printerloop; foreach (keys %$printers) { (next) unless ($_); $printercount++; - my $selected=''; - ($selected='selected') if ($_ eq $oldprinter); - $printeroptions.="$printers->{$_}->{'printername'}\n"; + my %printer; + $printer{selected}=($_ eq $oldprinter); + $printer{name}=$printers->{$_}->{'printername'}; + $printer{value}=$_; + push(@printerloop,\%printer); } # if there is only one.... - +my $oneprinter=($printercount==1) ; +my $onebranch=($branchcount==1) ; if ($printercount==1) { ($printer)=keys %$printers; + $printername=$printers->{$printer}->{printername}; } if ($branchcount==1) { ($branch)=keys %$branches; + $branchname=$branches->{$branch}->{branchname}; } -# set up printer and branch selection forms.... -my ($printerform, $branchform); -if ($printercount>1) { - $printerform=<<"EOF"; - $printeroptions -EOF -} else { - my ($printer) = keys %$printers; - $printerform.="Printer: ".$printers->{$printer}->{printername}; -} - -if ($branchcount>1) { - $branchform=<<"EOF"; - $branchoptions -EOF -} else { - my ($branch) = keys %$branches; - $branchform.= "Branch: ".$branches->{$branch}->{branchname}; -} - - ############################################################################################# # Start writing page.... # set header with cookie.... -print $query->header(); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "circ/selectbranchprinter.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + }); +$template->param(headerbackgroundcolor => $headerbackgroundcolor, + backgroundimage => $backgroundimage, + oneprinter => $oneprinter, + onebranch => $onebranch, + printername => $printername, + branchname => $branchname, + printerloop => \@printerloop, + branchloop => \@branchloop + ); -print startpage(); -print startmenu('circulation'); - -print << "EOF"; -Circulation: Select Printer and Branch Settings - - - - - -Please Set Branch and Printer - -$branchform - - -$printerform - - - - - - - -EOF +print $query->header(), $template->output; -print endmenu('circulation'); -print endpage(); -