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

(-)a/C4/Reserves.pm (-2 / +9 lines)
Lines 289-294 sub CanBookBeReserved{ Link Here
289
        return { status => 'tooManyReserves' };
289
        return { status => 'tooManyReserves' };
290
    }
290
    }
291
291
292
    # Check for the age restriction
293
    my $biblioData = C4::Biblio::GetBiblioData( $biblionumber );
294
    my $borrower = $patron->unblessed;
295
    my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower );
296
    return { status => 'ageRestricted' } if $daysToAgeRestriction && $daysToAgeRestriction > 0;
297
292
    my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber");
298
    my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber");
293
299
294
    #get items linked via host records
300
    #get items linked via host records
Lines 320-325 sub CanBookBeReserved{ Link Here
320
         { status => libraryNotFound },   if given branchcode is not an existing library
326
         { status => libraryNotFound },   if given branchcode is not an existing library
321
         { status => libraryNotPickupLocation },   if given branchcode is not configured to be a pickup location
327
         { status => libraryNotPickupLocation },   if given branchcode is not configured to be a pickup location
322
         { status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode
328
         { status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode
329
	 { status => alreadyReserved }, if the borrower has already reserved this item.
323
330
324
=cut
331
=cut
325
332
Lines 359-372 sub CanItemBeReserved { Link Here
359
        if (   $hold->itemnumber == $itemnumber
366
        if (   $hold->itemnumber == $itemnumber
360
            or $hold->biblionumber == $item->{biblionumber} )
367
            or $hold->biblionumber == $item->{biblionumber} )
361
        {
368
        {
362
            return 'alreadyReserved';
369
            return { status => 'alreadyReserved' };
363
        }
370
        }
364
    }
371
    }
365
372
366
    # Check if borrower has reached the maximum number of holds allowed
373
    # Check if borrower has reached the maximum number of holds allowed
367
    my $maxreserves = C4::Context->preference('maxreserves');
374
    my $maxreserves = C4::Context->preference('maxreserves');
368
    if ($maxreserves && $holds->count >= $maxreserves) {
375
    if ($maxreserves && $holds->count >= $maxreserves) {
369
        return 'tooManyReserves';
376
        return { status => 'tooManyReserves' };
370
    }
377
    }
371
378
372
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
379
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
(-)a/t/db_dependent/Reserves.t (-2 / +5 lines)
Lines 59-65 my $frameworkcode = q//; Link Here
59
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1);
59
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1);
60
60
61
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached
61
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached
62
$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode);
62
$dbh->do(q|
63
    INSERT INTO marc_subfield_structure (frameworkcode, tagfield, tagsubfield, kohafield)
64
    VALUES ('', '521', 'a', 'biblioitems.agerestriction')
65
    ON DUPLICATE KEY UPDATE kohafield = VALUES(kohafield)
66
|);
63
my $cache = Koha::Caches->get_instance;
67
my $cache = Koha::Caches->get_instance;
64
$cache->clear_from_cache("MarcStructure-0-$frameworkcode");
68
$cache->clear_from_cache("MarcStructure-0-$frameworkcode");
65
$cache->clear_from_cache("MarcStructure-1-$frameworkcode");
69
$cache->clear_from_cache("MarcStructure-1-$frameworkcode");
66
- 

Return to bug 11999