diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl new file mode 100644 index 0000000000..1307340394 --- /dev/null +++ b/circ/selectbranchprinter.pl @@ -0,0 +1,128 @@ +#!/usr/bin/perl + +use strict; +use CGI qw/:standard/; +use C4::Circulation::Circ2; +use C4::Output; +use C4::Print; +use DBI; + + +# 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; + +$branch=''; +$printer=''; + + +$env{'branchcode'}=$branch; +$env{'printer'}=$printer; +$env{'queue'}=$printer; + +# set up select options.... +my $branchcount=0; +my $printercount=0; +my $branchoptions; +my $printeroptions; +foreach (keys %$branches) { + (next) unless ($_); + $branchcount++; + my $selected=''; + ($selected='selected') if ($_ eq $oldbranch); + $branchoptions.="$branches->{$_}->{'branchname'}\n"; +} +foreach (keys %$printers) { + (next) unless ($_); + $printercount++; + my $selected=''; + ($selected='selected') if ($_ eq $oldprinter); + $printeroptions.="$printers->{$_}->{'printername'}\n"; +} + +# if there is only one.... + +if ($printercount==1) { + ($printer)=keys %$printers; +} +if ($branchcount==1) { + ($branch)=keys %$branches; +} + +# set up printer and branch selection forms.... +my ($printerform, $branchform); +if ($printercount>1) { + $printerform=<<"EOF"; + $printeroptions +EOF +} else { + my ($printer) = keys %$printers; +} + +if ($branchcount>1) { + $branchform=<<"EOF"; + $branchoptions +EOF +} else { + my ($branch) = keys %$branches; +} + + + +############################################################################################# +# Start writing page.... +# set header with cookie.... + +print $query->header(); + +print startpage(); +print startmenu('circulation'); + +print << "EOF"; +Circulation: Select Printer and Branch Settings + + + + + +Please Set Branch and Printer + +$branchform + + +$printerform + + + + + + +EOF + + +print endmenu('circulation'); +print endpage(); +