From 2ba136efd29c8c0fb92b843797cad02044be7e54 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 2 Sep 2005 14:30:28 +0000 Subject: [PATCH] removing branches sub, that should be in Koha.pm package (generic sub) --- C4/Acquisition.pm | 37 +------------------------------------ C4/Koha.pm | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index bc72015de9..7ce298c090 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -62,7 +62,7 @@ orders, converting money to different currencies, and so forth. &bookfunds &curconvert &getcurrencies &bookfundbreakdown &updatecurrencies &getcurrency - &branches &updatesup &insertsup + &updatesup &insertsup &bookseller &breakdown ); @@ -987,41 +987,6 @@ sub breakdown { return(scalar(@results),\@results); } -=item branches - - ($count, @results) = &branches(); - -Returns a list of all library branches. - -C<$count> is the number of elements in C<@results>. C<@results> is an -array of references-to-hash, whose keys are the fields of the branches -table of the Koha database. - -=cut -#' -sub branches { - my $dbh = C4::Context->dbh; - my $sth; - if (C4::Context->preference("IndependantBranches") && (C4::Context->userenv->{flags}!=1)){ - my $strsth ="Select * from branches "; - $strsth.= " WHERE branchcode = ".$dbh->quote(C4::Context->userenv->{branch}); - $strsth.= " order by branchname"; - warn "C4::Acquisition->branches : ".$strsth; - $sth=$dbh->prepare($strsth); - } else { - $sth = $dbh->prepare("Select * from branches order by branchname"); - } - my @results = (); - - $sth->execute(); - while (my $data = $sth->fetchrow_hashref) { - push(@results,$data); - } # while - - $sth->finish; - return(scalar(@results), @results); -} # sub branches - =item updatesup &updatesup($bookseller); diff --git a/C4/Koha.pm b/C4/Koha.pm index e8fc481a1d..f87e2aeb9f 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -178,7 +178,7 @@ sub subfield_is_koha_internal_p ($) { my $branches = getbranches; my @branchloop; -foreach my $thisbranch (keys %$branches) { +foreach my $thisbranch (sort keys %$branches) { my $selected = 1 if $thisbranch eq $branch; my %row =(value => $thisbranch, selected => $selected, @@ -202,7 +202,15 @@ sub getbranches { # returns a reference to a hash of references to branches... my %branches; my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select * from branches order by branchname"); + my $sth; + if (C4::Context->preference("IndependantBranches") && (C4::Context->userenv->{flags}!=1)){ + my $strsth ="Select * from branches "; + $strsth.= " WHERE branchcode = ".$dbh->quote(C4::Context->userenv->{branch}); + $strsth.= " order by branchname"; + $sth=$dbh->prepare($strsth); + } else { + $sth = $dbh->prepare("Select * from branches order by branchname"); + } $sth->execute; while (my $branch=$sth->fetchrow_hashref) { my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?"); @@ -236,7 +244,7 @@ build a HTML select with the following code : my $itemtypes = getitemtypes; my @itemtypesloop; -foreach my $thisitemtype (keys %$itemtypes) { +foreach my $thisitemtype (sort keys %$itemtypes) { my $selected = 1 if $thisitemtype eq $itemtype; my %row =(value => $thisitemtype, selected => $selected, @@ -266,7 +274,7 @@ sub getitemtypes { # returns a reference to a hash of references to branches... my %itemtypes; my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select * from itemtypes order by description"); + my $sth=$dbh->prepare("select * from itemtypes"); $sth->execute; while (my $IT=$sth->fetchrow_hashref) { $itemtypes{$IT->{'itemtype'}}=$IT; -- 2.39.5