Bug 5529 Absence or Presence of lists not being reliably returned
[koha.git] / C4 / Overdues.pm
index a9af9d6..28b135c 100644 (file)
@@ -957,9 +957,13 @@ returns a list of branch codes for branches with overdue rules defined.
 
 sub GetBranchcodesWithOverdueRules {
     my $dbh               = C4::Context->dbh;
-    my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> ''");
+    my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> '' ORDER BY branchcode");
     $rqoverduebranches->execute;
     my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref };
+    if (!$branches[0]) {
+       my $availbranches = C4::Branch::GetBranches();
+       @branches = keys %$availbranches;
+    }
     return @branches;
 }