View | Details | Raw Unified | Return to bug 10663
Collapse All | Expand All

(-)a/C4/Reserves.pm (-6 / +32 lines)
Lines 773-795 sub GetReserveStatus { Link Here
773
    my $dbh = C4::Context->dbh;
773
    my $dbh = C4::Context->dbh;
774
774
775
    my ($sth, $found, $priority);
775
    my ($sth, $found, $priority);
776
    if ( $itemnumber ) {
776
777
        $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE itemnumber = ? order by priority LIMIT 1");
777
    if ( defined $itemnumber ) {
778
        # Search for item-level reserves
779
780
        $sth = $dbh->prepare("
781
            SELECT found, priority
782
            FROM reserves
783
            WHERE itemnumber = ?
784
            ORDER BY priority
785
            LIMIT 1"
786
        );
778
        $sth->execute($itemnumber);
787
        $sth->execute($itemnumber);
779
        ($found, $priority) = $sth->fetchrow_array;
788
        ($found, $priority) = $sth->fetchrow_array;
789
790
        if ( not defined $found and
791
             not defined $priority ) {
792
            # No item-level reserves, give biblio-level a try
793
            $biblionumber = GetBiblionumberFromItemnumber( $itemnumber );
794
        }
780
    }
795
    }
781
796
782
    if ( $biblionumber and not defined $found and not defined $priority ) {
797
    if ( defined $biblionumber ) {
783
        $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE biblionumber = ? order by priority LIMIT 1");
798
        # Search for biblio-level reserves
799
800
        $sth = $dbh->prepare("
801
            SELECT found, priority
802
            FROM reserves
803
            WHERE biblionumber = ?
804
            ORDER BY priority
805
            LIMIT 1"
806
        );
784
        $sth->execute($biblionumber);
807
        $sth->execute($biblionumber);
785
        ($found, $priority) = $sth->fetchrow_array;
808
        ($found, $priority) = $sth->fetchrow_array;
786
    }
809
    }
787
810
788
    if(defined $found) {
811
    if ( defined $found ) {
789
        return 'Waiting'  if $found eq 'W' and $priority == 0;
812
        return 'Waiting'  if $found eq 'W' and $priority == 0;
790
        return 'Finished' if $found eq 'F';
813
        return 'Finished' if $found eq 'F';
814
    }
815
816
    if ( defined $priority ) {
791
        return 'Reserved' if $priority > 0;
817
        return 'Reserved' if $priority > 0;
792
    }
818
    }
819
793
    return '';
820
    return '';
794
    #empty string here will remove need for checking undef, or less log lines
821
    #empty string here will remove need for checking undef, or less log lines
795
}
822
}
796
- 

Return to bug 10663