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

(-)a/C4/ILSDI/Services.pm (-20 / +13 lines)
Lines 796-804 sub HoldTitle { Link Here
796
796
797
    my $title = $biblio ? $biblio->title : '';
797
    my $title = $biblio ? $biblio->title : '';
798
798
799
    # Check if the biblio can be reserved
799
    my $resdate = $cgi->param('start_date');
800
    my $code = CanBookBeReserved( $borrowernumber, $biblionumber )->{status};
800
    my $expdate = $cgi->param('expiry_date');
801
    return { code => $code } unless ( $code eq 'OK' );
802
801
803
    my $branch;
802
    my $branch;
804
803
Lines 814-827 sub HoldTitle { Link Here
814
    return { code => 'libraryNotPickupLocation' } unless $destination->pickup_location;
813
    return { code => 'libraryNotPickupLocation' } unless $destination->pickup_location;
815
    return { code => 'cannotBeTransferred' }      unless $biblio->can_be_transferred( { to => $destination } );
814
    return { code => 'cannotBeTransferred' }      unless $biblio->can_be_transferred( { to => $destination } );
816
815
817
    my $resdate = $cgi->param('start_date');
816
    # Check if the biblio can be reserved
818
    my $expdate = $cgi->param('expiry_date');
817
    my $code = CanBookBeReserved(
819
818
        $borrowernumber, $biblionumber, $branch,
820
    if ( C4::Context->preference('PreventReservesOnSamePeriod')
819
        { start_date => $resdate, expiry_date => $expdate }
821
        && ReservesOnSamePeriod( $biblionumber, undef, $resdate, $expdate ) )
820
    )->{status};
822
    {
821
    return { code => $code } unless ( $code eq 'OK' );
823
        return { code => 'overlap' };
824
    }
825
822
826
    # Add the reserve
823
    # Add the reserve
827
    #    $branch,    $borrowernumber, $biblionumber,
824
    #    $branch,    $borrowernumber, $biblionumber,
Lines 912-929 sub HoldItem { Link Here
912
        $branch = $patron->branchcode;
909
        $branch = $patron->branchcode;
913
    }
910
    }
914
911
915
    # Check for item disponibility
916
    my $canitembereserved = C4::Reserves::CanItemBeReserved( $patron, $item, $branch )->{status};
917
    return { code => $canitembereserved } unless $canitembereserved eq 'OK';
918
919
    my $resdate = $cgi->param('start_date');
912
    my $resdate = $cgi->param('start_date');
920
    my $expdate = $cgi->param('expiry_date');
913
    my $expdate = $cgi->param('expiry_date');
921
914
922
    if ( C4::Context->preference('PreventReservesOnSamePeriod')
915
    # Check for item disponibility
923
        && ReservesOnSamePeriod( $biblionumber, $itemnumber, $resdate, $expdate ) )
916
    my $canitembereserved =
924
    {
917
        C4::Reserves::CanItemBeReserved( $patron, $item, $branch, { start_date => $resdate, expiry_date => $expdate } )
925
        return { code => 'overlap' };
918
        ->{status};
926
    }
919
    return { code => $canitembereserved } unless $canitembereserved eq 'OK';
927
920
928
    # Add the reserve
921
    # Add the reserve
929
    my $priority = C4::Reserves::CalculatePriority($biblionumber);
922
    my $priority = C4::Reserves::CalculatePriority($biblionumber);
(-)a/C4/Reserves.pm (-1 / +8 lines)
Lines 473-478 sub CanBookBeReserved { Link Here
473
         { status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode
473
         { status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode
474
         { status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups.
474
         { status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups.
475
         { status => recall }, if the borrower has already placed a recall on this item
475
         { status => recall }, if the borrower has already placed a recall on this item
476
         { status => overlap }, if PreventReservesOnSamePeriod is true and reservation dates overlaps with a previous reservation
476
477
477
=cut
478
=cut
478
479
Lines 537-542 sub CanItemBeReserved { Link Here
537
        return _cache { status => 'alreadypossession' };
538
        return _cache { status => 'alreadypossession' };
538
    }
539
    }
539
540
541
    if ( C4::Context->preference('PreventReservesOnSamePeriod')
542
        && ReservesOnSamePeriod( $item->biblionumber, $item->itemnumber, $params->{start_date}, $params->{expiry_date} )
543
        )
544
    {
545
        return _cache { status => 'overlap' };
546
    }
547
540
    # check if a recall exists on this item from this borrower
548
    # check if a recall exists on this item from this borrower
541
    return _cache { status => 'recall' }
549
    return _cache { status => 'recall' }
542
        if $patron->recalls->filter_by_current->search( { item_id => $item->itemnumber } )->count;
550
        if $patron->recalls->filter_by_current->search( { item_id => $item->itemnumber } )->count;
543
- 

Return to bug 15261