removing branches sub, that should be in Koha.pm package (generic sub)
authortipaul <tipaul>
Fri, 2 Sep 2005 14:30:28 +0000 (14:30 +0000)
committertipaul <tipaul>
Fri, 2 Sep 2005 14:30:28 +0000 (14:30 +0000)
C4/Acquisition.pm
C4/Koha.pm

index bc72015..7ce298c 100644 (file)
@@ -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);
index e8fc481..f87e2ae 100644 (file)
@@ -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;