From 21b18bf6752b2d8145bad72ef7d640d17d8a37e6 Mon Sep 17 00:00:00 2001 From: tonnesen Date: Fri, 5 Jan 2001 17:39:25 +0000 Subject: [PATCH] Modified getbranch() and getprinter() subroutines to not pop up a menu if there is only one branch or one printer, but just select the single option automatically. --- C4/Circulation/Main.pm | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/C4/Circulation/Main.pm b/C4/Circulation/Main.pm index e3d276b7a6..2e3193319e 100755 --- a/C4/Circulation/Main.pm +++ b/C4/Circulation/Main.pm @@ -65,17 +65,23 @@ sub getbranch { my $query = "select * from branches order by branchcode"; my $sth = $dbh->prepare($query); $sth->execute; - my @branches; - while (my $data = $sth->fetchrow_hashref) { - push @branches,$data; + if ($sth->rows>1) { + my @branches; + while (my $data = $sth->fetchrow_hashref) { + push @branches,$data; + } + brmenu ($env,\@branches); + } else { + my $data = $sth->fetchrow_hashref; + $env->{'branchcode'}=$data->{'branchcode'}; } - brmenu ($env,\@branches); my $query = "select * from branches where branchcode = '$env->{'branchcode'}'"; $sth = $dbh->prepare($query); $sth->execute; my $data = $sth->fetchrow_hashref; $env->{'brdata'} = $data; + $env->{'branchname'} = $data->{'branchname'}; $sth->finish; $dbh->disconnect; } @@ -86,11 +92,17 @@ sub getprinter { my $query = "select * from printers order by printername"; my $sth = $dbh->prepare($query); $sth->execute; - my @printers; - while (my $data = $sth->fetchrow_hashref) { - push @printers,$data; + if ($sth->rows>1) { + my @printers; + while (my $data = $sth->fetchrow_hashref) { + push @printers,$data; + } + prmenu ($env,\@printers); + } else { + my $data=$sth->fetchrow_hashref; + $env->{'queue'}=$data->{'printqueue'}; + $env->{'printtype'}=$data->{'printtype'}; } - prmenu ($env,\@printers); $sth->finish; $dbh->disconnect; } -- 2.39.2