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

(-)a/C4/Circulation.pm (-5 / +4 lines)
Lines 2473-2490 sub CanBookBeRenewed { Link Here
2473
2473
2474
    $sthcount->execute( $borrowernumber, $itemnumber );
2474
    $sthcount->execute( $borrowernumber, $itemnumber );
2475
    if ( my $data1 = $sthcount->fetchrow_hashref ) {
2475
    if ( my $data1 = $sthcount->fetchrow_hashref ) {
2476
        
2477
        if ( ( $data1->{renewalsallowed} && $data1->{renewalsallowed} > $data1->{renewals} ) || $override_limit ) {
2476
        if ( ( $data1->{renewalsallowed} && $data1->{renewalsallowed} > $data1->{renewals} ) || $override_limit ) {
2478
            $renewokay = 1;
2477
            $renewokay = 1;
2479
        }
2478
        }
2480
        else {
2479
        else {
2481
			$error="too_many";
2480
            $error = "too_many";
2482
		}
2481
        }
2483
		
2482
2484
        my $resstatus = C4::Reserves::GetReserveStatus($itemnumber);
2483
        my $resstatus = C4::Reserves::GetReserveStatus($itemnumber);
2485
        if ( $resstatus eq "Waiting" or $resstatus eq "Reserved" ) {
2484
        if ( $resstatus eq "Waiting" or $resstatus eq "Reserved" ) {
2486
            $renewokay = 0;
2485
            $renewokay = 0;
2487
            $error->{message} = "on_reserve";
2486
            $error = "on_reserve";
2488
        }
2487
        }
2489
    }
2488
    }
2490
    return ($renewokay,$error);
2489
    return ($renewokay,$error);
(-)a/C4/Reserves.pm (-7 / +12 lines)
Lines 735-760 sub GetReservesForBranch { Link Here
735
    return (@transreserv);
735
    return (@transreserv);
736
}
736
}
737
737
738
=head2 GetReserveStatus
739
740
  $reservestatus = GetReserveStatus($itemnumber, $biblionumber);
741
742
Take an itemnumber or a biblionumber and return the status of the reserve places on it.
743
If several reserves exist, the reserve with the lower priority is given.
744
745
=cut
746
738
sub GetReserveStatus {
747
sub GetReserveStatus {
739
    my ($itemnumber, $biblionumber) = @_;
748
    my ($itemnumber, $biblionumber) = @_;
740
749
741
    my $dbh = C4::Context->dbh;
750
    my $dbh = C4::Context->dbh;
742
751
743
    my ($sth, $found, $priority);
752
    my ($sth, $found, $priority) = (undef, q{}, 0);
744
    if ( $itemnumber ) {
753
    if ( $itemnumber ) {
745
        $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE itemnumber = ? order by priority LIMIT 1");
754
        $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE itemnumber = ? order by priority LIMIT 1");
746
        $sth->execute($itemnumber);
755
        $sth->execute($itemnumber);
747
        ($found, $priority) = $sth->fetchrow_array;
748
    }
756
    }
749
757
750
    if ( $biblionumber and not defined $found and not defined $priority ) {
758
    if ( $biblionumber and not defined $found and not defined $priority ) {
751
        $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE biblionumber = ? order by priority LIMIT 1");
759
        $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE biblionumber = ? order by priority LIMIT 1");
752
        $sth->execute($biblionumber);
760
        $sth->execute($biblionumber);
753
    } else {
754
        return;
755
    }
761
    }
756
    ($found, $priority) = $sth->fetchrow_array;
762
    ($found, $priority) = $sth->fetchrow_array;
757
763
764
    return unless defined $found;
758
    return 'Waiting'  if $found eq 'W' and $priority == 0;
765
    return 'Waiting'  if $found eq 'W' and $priority == 0;
759
    return 'Finished' if $found eq 'F';
766
    return 'Finished' if $found eq 'F';
760
    return 'Reserved' if $priority > 0;
767
    return 'Reserved' if $priority > 0;
Lines 1455-1462 sub IsAvailableForItemLevelRequest { Link Here
1455
    if (C4::Context->preference('AllowOnShelfHolds')) {
1462
    if (C4::Context->preference('AllowOnShelfHolds')) {
1456
        return $available_per_item;
1463
        return $available_per_item;
1457
    } else {
1464
    } else {
1458
        my $status = GetReserveStatus($itemnumber);
1465
        return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "Waiting"));
1459
        return ($available_per_item and ($item->{onloan} or $status eq "Waiting" or $status = "Reserved"));
1460
    }
1466
    }
1461
}
1467
}
1462
1468
1463
- 

Return to bug 9367