This doesn't make sense.

+    my $defaultbranches = $dbh->prepare("SELECT DISTINCT branchcode FROM
> overduerules WHERE delay1 IS NOT NULL AND branchcode = ''");
> +    $defaultbranches->execute();
> +    if($defaultbranches->rows > 0){
> +        foreach my $branch (keys %$availbranches){
> +            if(not grep{/^$branch$/} @branches){
> +                push @branches, $branch;
> +            }
> +        }
> +    }


You never fetch any data from $defaultbranches, so what you really are after
is SELECT COUNT (which you access via ->rows).

It doesn't make senes to me though, that basically you append all the
branches that didn't exist already in $rqoverduebranches.  In the end, that
is going to be the same as all the branchcodes in $availbranches, so you
don't need to build it piece by piece.

Then later in the loop, you have:

+    # We get default rules is there is no rule for this branch
> +    if($rqoverduerules->rows == 0){
> +        $rqoverduerules = $dbh->prepare("SELECT * FROM overduerules WHERE
> delay1 IS NOT NULL AND branchcode = '' ");
> +        $rqoverduerules->execute();
> +    }
>

The result of that is going to be the same each time.  There's no point
refetching it.  In fact, it is essentially the same query as
$defaultbranches, so it should be done only once, at the beginning of the
script.

-- 
Joe Atzberger
LibLime - Open Source Library Solutions
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to