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

(-)a/C4/Reserves.pm (-1 / +17 lines)
Lines 119-125 BEGIN { Link Here
119
119
120
        &CheckReserves
120
        &CheckReserves
121
        &CanBookBeReserved
121
        &CanBookBeReserved
122
	&CanItemBeReserved
122
        &CanItemBeReserved
123
        &CanReserveBeCanceledFromOpac
123
        &CanReserveBeCanceledFromOpac
124
        &CancelReserve
124
        &CancelReserve
125
        &CancelExpiredReserves
125
        &CancelExpiredReserves
Lines 488-493 sub CanBookBeReserved{ Link Here
488
         damaged,         if the Item is damaged.
488
         damaged,         if the Item is damaged.
489
         cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK.
489
         cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK.
490
         tooManyReserves, if the borrower has exceeded his maximum reserve amount.
490
         tooManyReserves, if the borrower has exceeded his maximum reserve amount.
491
         notReservable,   if holds on this item are not allowed
491
492
492
=cut
493
=cut
493
494
Lines 578-583 sub CanItemBeReserved{ Link Here
578
        return 'tooManyReserves';
579
        return 'tooManyReserves';
579
    }
580
    }
580
581
582
    my $circ_control_branch = C4::Circulation::_GetCircControlBranch($item,
583
        $borrower);
584
    my $branchitemrule = C4::Circulation::GetBranchItemRule($circ_control_branch,
585
        $item->{itype});
586
587
    if ( $branchitemrule->{holdallowed} == 0 ) {
588
        return 'notReservable';
589
    }
590
591
    if (   $branchitemrule->{holdallowed} == 1
592
        && $borrower->{branchcode} ne $item->{homebranch} )
593
    {
594
          return 'cannotReserveFromOtherBranches';
595
    }
596
581
    # If reservecount is ok, we check item branch if IndependentBranches is ON
597
    # If reservecount is ok, we check item branch if IndependentBranches is ON
582
    # and canreservefromotherbranches is OFF
598
    # and canreservefromotherbranches is OFF
583
    if ( C4::Context->preference('IndependentBranches')
599
    if ( C4::Context->preference('IndependentBranches')
(-)a/opac/opac-reserve.pl (-10 lines)
Lines 519-534 foreach my $biblioNum (@biblionumbers) { Link Here
519
        my $branch = GetReservesControlBranch( $itemInfo, $borr );
519
        my $branch = GetReservesControlBranch( $itemInfo, $borr );
520
520
521
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
521
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
522
        if ($policy_holdallowed) {
523
            if (my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} )) {
524
                $policy_holdallowed =
525
                  ($branchitemrule->{'holdallowed'} == 2) ||
526
                  ($branchitemrule->{'holdallowed'} == 1
527
                      && $borr->{'branchcode'} eq $itemInfo->{'homebranch'});
528
            } else {
529
                $policy_holdallowed = 0; # No rule - not allowed
530
            }
531
        }
532
        $policy_holdallowed &&=
522
        $policy_holdallowed &&=
533
            IsAvailableForItemLevelRequest($itemInfo,$borr) &&
523
            IsAvailableForItemLevelRequest($itemInfo,$borr) &&
534
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
524
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
(-)a/reserve/request.pl (-9 / +1 lines)
Lines 408-426 foreach my $biblionumber (@biblionumbers) { Link Here
408
            my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
408
            my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
409
409
410
            my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
410
            my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
411
            my $policy_holdallowed = 1;
412
411
413
            $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
412
            $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
414
413
415
            if ( $branchitemrule->{'holdallowed'} == 0 ||
416
                 ( $branchitemrule->{'holdallowed'} == 1 &&
417
                     $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
418
                $policy_holdallowed = 0;
419
            }
420
            
421
            if (
414
            if (
422
                   $policy_holdallowed
415
                   !$item->{cantreserve}
423
                && !$item->{cantreserve}
424
                && IsAvailableForItemLevelRequest($item, $borrowerinfo)
416
                && IsAvailableForItemLevelRequest($item, $borrowerinfo)
425
                && CanItemBeReserved(
417
                && CanItemBeReserved(
426
                    $borrowerinfo->{borrowernumber}, $itemnumber
418
                    $borrowerinfo->{borrowernumber}, $itemnumber
(-)a/t/db_dependent/Holds.t (-2 / +41 lines)
Lines 6-12 use t::lib::Mocks; Link Here
6
use C4::Context;
6
use C4::Context;
7
use C4::Branch;
7
use C4::Branch;
8
8
9
use Test::More tests => 38;
9
use Test::More tests => 41;
10
use MARC::Record;
10
use MARC::Record;
11
use C4::Biblio;
11
use C4::Biblio;
12
use C4::Items;
12
use C4::Items;
Lines 329-334 ok( Link Here
329
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
329
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
330
);
330
);
331
331
332
333
# Test branch item rules
334
335
$dbh->do('DELETE FROM issuingrules');
336
$dbh->do(
337
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
338
      VALUES (?, ?, ?, ?)},
339
    {},
340
    '*', '*', '*', 25
341
);
342
$dbh->do('DELETE FROM branch_item_rules');
343
$dbh->do('DELETE FROM default_branch_circ_rules');
344
$dbh->do('DELETE FROM default_branch_item_rules');
345
$dbh->do('DELETE FROM default_circ_rules');
346
$dbh->do(q{
347
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
348
    VALUES (?, ?, ?, ?)
349
}, {}, 'CPL', 'CANNOT', 0, 'homebranch');
350
$dbh->do(q{
351
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
352
    VALUES (?, ?, ?, ?)
353
}, {}, 'CPL', 'CAN', 1, 'homebranch');
354
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
355
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
356
    { homebranch => 'CPL', holdingbranch => 'CPL', itype => 'CANNOT' } , $bibnum);
357
is(CanItemBeReserved($borrowernumbers[0], $itemnumber), 'notReservable',
358
    "CanItemBeReserved should returns 'notReservable'");
359
360
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
361
    { homebranch => 'MPL', holdingbranch => 'CPL', itype => 'CAN' } , $bibnum);
362
is(CanItemBeReserved($borrowernumbers[0], $itemnumber),
363
    'cannotReserveFromOtherBranches',
364
    "CanItemBeReserved should returns 'cannotReserveFromOtherBranches'");
365
366
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
367
    { homebranch => 'CPL', holdingbranch => 'CPL', itype => 'CAN' } , $bibnum);
368
is(CanItemBeReserved($borrowernumbers[0], $itemnumber), 'OK',
369
    "CanItemBeReserved should returns 'OK'");
370
371
332
# Test CancelExpiredReserves
372
# Test CancelExpiredReserves
333
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1);
373
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1);
334
C4::Context->set_preference('ReservesMaxPickUpDelay', 1);
374
C4::Context->set_preference('ReservesMaxPickUpDelay', 1);
335
- 

Return to bug 13687