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

(-)a/C4/Reserves.pm (-12 / +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 311-317 sub CanBookBeReserved{ Link Here
311
  $canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode)
317
  $canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode)
312
  if ($canReserve->{status} eq 'OK') { #We can reserve this Item! }
318
  if ($canReserve->{status} eq 'OK') { #We can reserve this Item! }
313
319
314
<<<<<<< HEAD
315
@RETURNS { status => OK },              if the Item can be reserved.
320
@RETURNS { status => OK },              if the Item can be reserved.
316
         { status => ageRestricted },   if the Item is age restricted for this borrower.
321
         { status => ageRestricted },   if the Item is age restricted for this borrower.
317
         { status => damaged },         if the Item is damaged.
322
         { status => damaged },         if the Item is damaged.
Lines 321-335 sub CanBookBeReserved{ Link Here
321
         { status => libraryNotFound },   if given branchcode is not an existing library
326
         { status => libraryNotFound },   if given branchcode is not an existing library
322
         { 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
323
         { 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
324
=======
329
	 { status => alreadyReserved }, if the borrower has already reserved this item.
325
@RETURNS OK,              if the Item can be reserved.
326
         ageRestricted,   if the Item is age restricted for this borrower.
327
         damaged,         if the Item is damaged.
328
         cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK.
329
         tooManyReserves, if the borrower has exceeded his maximum reserve amount.
330
         notReservable,   if holds on this item are not allowed
331
         alreadyReserved, if the borrower has already reserved this item.
332
>>>>>>> Bug 11999: Add two checks in CanBookBeReserved and CanItemBeReserved
333
330
334
=cut
331
=cut
335
332
Lines 369-382 sub CanItemBeReserved { Link Here
369
        if (   $hold->itemnumber == $itemnumber
366
        if (   $hold->itemnumber == $itemnumber
370
            or $hold->biblionumber == $item->{biblionumber} )
367
            or $hold->biblionumber == $item->{biblionumber} )
371
        {
368
        {
372
            return 'alreadyReserved';
369
            return { status => 'alreadyReserved' };
373
        }
370
        }
374
    }
371
    }
375
372
376
    # Check if borrower has reached the maximum number of holds allowed
373
    # Check if borrower has reached the maximum number of holds allowed
377
    my $maxreserves = C4::Context->preference('maxreserves');
374
    my $maxreserves = C4::Context->preference('maxreserves');
378
    if ($maxreserves && $holds->count >= $maxreserves) {
375
    if ($maxreserves && $holds->count >= $maxreserves) {
379
        return 'tooManyReserves';
376
        return { status => 'tooManyReserves' };
380
    }
377
    }
381
378
382
    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