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 486-491 sub CanBookBeReserved{ Link Here
486
         damaged,         if the Item is damaged.
486
         damaged,         if the Item is damaged.
487
         cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK.
487
         cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK.
488
         tooManyReserves, if the borrower has exceeded his maximum reserve amount.
488
         tooManyReserves, if the borrower has exceeded his maximum reserve amount.
489
         notReservable,   if holds on this item are not allowed
489
490
490
=cut
491
=cut
491
492
Lines 577-582 sub CanItemBeReserved{ Link Here
577
        return 'tooManyReserves';
578
        return 'tooManyReserves';
578
    }
579
    }
579
580
581
    my $circ_control_branch = C4::Circulation::_GetCircControlBranch($item,
582
        $borrower);
583
    my $branchitemrule = C4::Circulation::GetBranchItemRule($circ_control_branch,
584
        $item->{itype});
585
586
    if ( $branchitemrule->{holdallowed} == 0 ) {
587
        return 'notReservable';
588
    }
589
590
    if (   $branchitemrule->{holdallowed} == 1
591
        && $borrower->{branchcode} ne $item->{homebranch} )
592
    {
593
          return 'cannotReserveFromOtherBranches';
594
    }
595
580
    # If reservecount is ok, we check item branch if IndependentBranches is ON
596
    # If reservecount is ok, we check item branch if IndependentBranches is ON
581
    # and canreservefromotherbranches is OFF
597
    # and canreservefromotherbranches is OFF
582
    if ( C4::Context->preference('IndependentBranches')
598
    if ( C4::Context->preference('IndependentBranches')
(-)a/opac/opac-reserve.pl (-11 / +1 lines)
Lines 515-531 foreach my $biblioNum (@biblionumbers) { Link Here
515
        # If there is no loan, return and transfer, we show a checkbox.
515
        # If there is no loan, return and transfer, we show a checkbox.
516
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
516
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
517
517
518
        my $branch = GetReservesControlBranch( $itemInfo, $borr );
518
        if (IsAvailableForItemLevelRequest($itemNum) and CanItemBeReserved($borrowernumber,$itemNum) eq 'OK' and ($itemLoopIter->{already_reserved} ne 1)) {
519
520
        my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} );
521
        my $policy_holdallowed = 1;
522
523
        if ( $branchitemrule->{'holdallowed'} == 0 ||
524
                ( $branchitemrule->{'holdallowed'} == 1 && $borr->{'branchcode'} ne $itemInfo->{'homebranch'} ) ) {
525
            $policy_holdallowed = 0;
526
        }
527
528
        if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) eq 'OK' and ($itemLoopIter->{already_reserved} ne 1)) {
529
            $itemLoopIter->{available} = 1;
519
            $itemLoopIter->{available} = 1;
530
            $numCopiesAvailable++;
520
            $numCopiesAvailable++;
531
        }
521
        }
(-)a/reserve/request.pl (-9 / +1 lines)
Lines 411-429 foreach my $biblionumber (@biblionumbers) { Link Here
411
            my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
411
            my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
412
412
413
            my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
413
            my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
414
            my $policy_holdallowed = 1;
415
414
416
            $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
415
            $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
417
416
418
            if ( $branchitemrule->{'holdallowed'} == 0 ||
419
                 ( $branchitemrule->{'holdallowed'} == 1 &&
420
                     $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
421
                $policy_holdallowed = 0;
422
            }
423
            
424
            if (
417
            if (
425
                   $policy_holdallowed
418
                   !$item->{cantreserve}
426
                && !$item->{cantreserve}
427
                && IsAvailableForItemLevelRequest($itemnumber)
419
                && IsAvailableForItemLevelRequest($itemnumber)
428
                && CanItemBeReserved(
420
                && CanItemBeReserved(
429
                    $borrowerinfo->{borrowernumber}, $itemnumber
421
                    $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