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

(-)a/C4/Circulation.pm (-10 / +11 lines)
Lines 1830-1838 branch and item type, regardless of patron category. Link Here
1830
The return value is a hashref containing the following keys:
1830
The return value is a hashref containing the following keys:
1831
1831
1832
holdallowed => Hold policy for this branch and itemtype. Possible values:
1832
holdallowed => Hold policy for this branch and itemtype. Possible values:
1833
  0: No holds allowed.
1833
  not_allowed:           No holds allowed.
1834
  1: Holds allowed only by patrons that have the same homebranch as the item.
1834
  from_home_library:     Holds allowed only by patrons that have the same homebranch as the item.
1835
  2: Holds allowed from any patron.
1835
  from_any_library:      Holds allowed from any patron.
1836
  from_local_hold_group: Holds allowed from libraries in hold group
1836
1837
1837
returnbranch => branch to which to return item.  Possible values:
1838
returnbranch => branch to which to return item.  Possible values:
1838
  noreturn: do not return, let item remain where checked in (floating collections)
1839
  noreturn: do not return, let item remain where checked in (floating collections)
Lines 1857-1878 sub GetBranchItemRule { Link Here
1857
    my $holdallowed_rule = Koha::CirculationRules->get_effective_rule(
1858
    my $holdallowed_rule = Koha::CirculationRules->get_effective_rule(
1858
        {
1859
        {
1859
            branchcode => $branchcode,
1860
            branchcode => $branchcode,
1860
            itemtype => $itemtype,
1861
            itemtype   => $itemtype,
1861
            rule_name => 'holdallowed',
1862
            rule_name  => 'holdallowed',
1862
        }
1863
        }
1863
    );
1864
    );
1864
    my $hold_fulfillment_policy_rule = Koha::CirculationRules->get_effective_rule(
1865
    my $hold_fulfillment_policy_rule = Koha::CirculationRules->get_effective_rule(
1865
        {
1866
        {
1866
            branchcode => $branchcode,
1867
            branchcode => $branchcode,
1867
            itemtype => $itemtype,
1868
            itemtype   => $itemtype,
1868
            rule_name => 'hold_fulfillment_policy',
1869
            rule_name  => 'hold_fulfillment_policy',
1869
        }
1870
        }
1870
    );
1871
    );
1871
    my $returnbranch_rule = Koha::CirculationRules->get_effective_rule(
1872
    my $returnbranch_rule = Koha::CirculationRules->get_effective_rule(
1872
        {
1873
        {
1873
            branchcode => $branchcode,
1874
            branchcode => $branchcode,
1874
            itemtype => $itemtype,
1875
            itemtype   => $itemtype,
1875
            rule_name => 'returnbranch',
1876
            rule_name  => 'returnbranch',
1876
        }
1877
        }
1877
    );
1878
    );
1878
1879
Lines 1880-1886 sub GetBranchItemRule { Link Here
1880
    my $rules;
1881
    my $rules;
1881
    $rules->{holdallowed} = defined $holdallowed_rule
1882
    $rules->{holdallowed} = defined $holdallowed_rule
1882
        ? $holdallowed_rule->rule_value
1883
        ? $holdallowed_rule->rule_value
1883
        : 2;
1884
        : 'from_any_library';
1884
    $rules->{hold_fulfillment_policy} = defined $hold_fulfillment_policy_rule
1885
    $rules->{hold_fulfillment_policy} = defined $hold_fulfillment_policy_rule
1885
        ? $hold_fulfillment_policy_rule->rule_value
1886
        ? $hold_fulfillment_policy_rule->rule_value
1886
        : 'any';
1887
        : 'any';
(-)a/C4/HoldsQueue.pm (-4 / +4 lines)
Lines 373-386 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
373
sub _checkHoldPolicy {
373
sub _checkHoldPolicy {
374
    my ( $item, $request ) = @_;
374
    my ( $item, $request ) = @_;
375
375
376
    return 0 unless $item->{holdallowed};
376
    return 0 unless $item->{holdallowed} ne 'not_allowed';
377
377
378
    return 0
378
    return 0
379
      if $item->{holdallowed} == 1
379
      if $item->{holdallowed} eq 'from_home_library'
380
      && $item->{homebranch} ne $request->{borrowerbranch};
380
      && $item->{homebranch} ne $request->{borrowerbranch};
381
381
382
    return 0
382
    return 0
383
      if $item->{'holdallowed'} == 3
383
      if $item->{'holdallowed'} eq 'from_local_hold_group'
384
      && !Koha::Libraries->find( $item->{homebranch} )
384
      && !Koha::Libraries->find( $item->{homebranch} )
385
              ->validate_hold_sibling( { branchcode => $request->{borrowerbranch} } );
385
              ->validate_hold_sibling( { branchcode => $request->{borrowerbranch} } );
386
386
Lines 544-550 sub MapItemsToHoldRequests { Link Here
544
    # group available items by branch
544
    # group available items by branch
545
    my %items_by_branch = ();
545
    my %items_by_branch = ();
546
    foreach my $item (@$available_items) {
546
    foreach my $item (@$available_items) {
547
        next unless $item->{holdallowed};
547
        next unless $item->{holdallowed} ne 'not_allowed';
548
548
549
        push @{ $items_by_branch{ $item->{holdingbranch} } }, $item
549
        push @{ $items_by_branch{ $item->{holdingbranch} } }, $item
550
          unless exists $allocated_items{ $item->{itemnumber} };
550
          unless exists $allocated_items{ $item->{itemnumber} };
(-)a/C4/Reserves.pm (-8 / +8 lines)
Lines 525-542 sub CanItemBeReserved { Link Here
525
    my $branchitemrule =
525
    my $branchitemrule =
526
      C4::Circulation::GetBranchItemRule( $reserves_control_branch, $item->itype ); # FIXME Should not be item->effective_itemtype?
526
      C4::Circulation::GetBranchItemRule( $reserves_control_branch, $item->itype ); # FIXME Should not be item->effective_itemtype?
527
527
528
    if ( $branchitemrule->{holdallowed} == 0 ) {
528
    if ( $branchitemrule->{holdallowed} eq 'not_allowed' ) {
529
        return { status => 'notReservable' };
529
        return { status => 'notReservable' };
530
    }
530
    }
531
531
532
    if (   $branchitemrule->{holdallowed} == 1
532
    if (   $branchitemrule->{holdallowed} eq 'from_home_library'
533
        && $borrower->{branchcode} ne $item->homebranch )
533
        && $borrower->{branchcode} ne $item->homebranch )
534
    {
534
    {
535
        return { status => 'cannotReserveFromOtherBranches' };
535
        return { status => 'cannotReserveFromOtherBranches' };
536
    }
536
    }
537
537
538
    my $item_library = Koha::Libraries->find( {branchcode => $item->homebranch} );
538
    my $item_library = Koha::Libraries->find( {branchcode => $item->homebranch} );
539
    if ( $branchitemrule->{holdallowed} == 3) {
539
    if ( $branchitemrule->{holdallowed} eq 'from_local_hold_group') {
540
        if($borrower->{branchcode} ne $item->homebranch && !$item_library->validate_hold_sibling( {branchcode => $borrower->{branchcode}} )) {
540
        if($borrower->{branchcode} ne $item->homebranch && !$item_library->validate_hold_sibling( {branchcode => $borrower->{branchcode}} )) {
541
            return { status => 'branchNotInHoldGroup' };
541
            return { status => 'branchNotInHoldGroup' };
542
        }
542
        }
Lines 890-899 sub CheckReserves { Link Here
890
                    $patron ||= Koha::Patrons->find( $res->{borrowernumber} );
890
                    $patron ||= Koha::Patrons->find( $res->{borrowernumber} );
891
                    my $branch = GetReservesControlBranch( $item->unblessed, $patron->unblessed );
891
                    my $branch = GetReservesControlBranch( $item->unblessed, $patron->unblessed );
892
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$item->effective_itemtype);
892
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$item->effective_itemtype);
893
                    next if ($branchitemrule->{'holdallowed'} == 0);
893
                    next if ($branchitemrule->{'holdallowed'} eq 'not_allowed');
894
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode));
894
                    next if (($branchitemrule->{'holdallowed'} eq 'from_home_library') && ($branch ne $patron->branchcode));
895
                    my $library = Koha::Libraries->find({branchcode=>$item->homebranch});
895
                    my $library = Koha::Libraries->find({branchcode=>$item->homebranch});
896
                    next if (($branchitemrule->{'holdallowed'} == 3) && (!$library->validate_hold_sibling({branchcode => $patron->branchcode}) ));
896
                    next if (($branchitemrule->{'holdallowed'} eq 'from_local_hold_group') && (!$library->validate_hold_sibling({branchcode => $patron->branchcode}) ));
897
                    my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy};
897
                    my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy};
898
                    next if ( ($hold_fulfillment_policy eq 'holdgroup') && (!$library->validate_hold_sibling({branchcode => $res->{branchcode}})) );
898
                    next if ( ($hold_fulfillment_policy eq 'holdgroup') && (!$library->validate_hold_sibling({branchcode => $res->{branchcode}})) );
899
                    next if ( ($hold_fulfillment_policy eq 'homebranch') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) );
899
                    next if ( ($hold_fulfillment_policy eq 'homebranch') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) );
Lines 1395-1402 sub ItemsAnyAvailableAndNotRestricted { Link Here
1395
            || ( $i->damaged
1395
            || ( $i->damaged
1396
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1396
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1397
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1397
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1398
            || $branchitemrule->{holdallowed} == 1 && $param->{patron}->branchcode ne $i->homebranch
1398
            || $branchitemrule->{holdallowed} eq 'from_home_library' && $param->{patron}->branchcode ne $i->homebranch
1399
            || $branchitemrule->{holdallowed} == 3 && ! $item_library->validate_hold_sibling( { branchcode => $param->{patron}->branchcode } )
1399
            || $branchitemrule->{holdallowed} eq 'from_local_hold_group' && ! $item_library->validate_hold_sibling( { branchcode => $param->{patron}->branchcode } )
1400
            || CanItemBeReserved( $param->{patron}->borrowernumber, $i->id )->{status} ne 'OK';
1400
            || CanItemBeReserved( $param->{patron}->borrowernumber, $i->id )->{status} ne 'OK';
1401
    }
1401
    }
1402
1402
(-)a/Koha/Holds.pm (-1 / +1 lines)
Lines 136-142 sub get_items_that_can_fill { Link Here
136
            rule_name    => 'holdallowed',
136
            rule_name    => 'holdallowed',
137
            branchcode   => undef,
137
            branchcode   => undef,
138
            categorycode => undef,
138
            categorycode => undef,
139
            rule_value   => 0,
139
            rule_value   => 'not_allowed',
140
        }
140
        }
141
    )->get_column('itemtype');
141
    )->get_column('itemtype');
142
142
(-)a/Koha/Item.pm (-2 / +2 lines)
Lines 663-670 sub pickup_locations { Link Here
663
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype );
663
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype );
664
664
665
    if(defined $patron) {
665
    if(defined $patron) {
666
        return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} == 3 && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} );
666
        return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_local_hold_group' && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} );
667
        return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} == 1 && $self->home_branch->branchcode ne $patron->branchcode;
667
        return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_home_library' && $self->home_branch->branchcode ne $patron->branchcode;
668
    }
668
    }
669
669
670
    my $pickup_libraries = Koha::Libraries->search();
670
    my $pickup_libraries = Koha::Libraries->search();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-20 / +20 lines)
Lines 564-597 Link Here
564
                                Not set
564
                                Not set
565
                            </option>
565
                            </option>
566
566
567
                            [% IF holdallowed == 2 %]
567
                            [% IF holdallowed == 'from_any_library' %]
568
                                <option value="2" selected="selected">
568
                                <option value="from_any_library" selected="selected">
569
                            [% ELSE %]
569
                            [% ELSE %]
570
                                <option value="2">
570
                                <option value="from_any_library">
571
                            [% END %]
571
                            [% END %]
572
                                From any library
572
                                From any library
573
                            </option>
573
                            </option>
574
574
575
                            [% IF holdallowed == 3 %]
575
                            [% IF holdallowed == 'from_local_hold_group' %]
576
                            <option value="3" selected="selected">
576
                            <option value="from_local_hold_group" selected="selected">
577
                            [% ELSE %]
577
                            [% ELSE %]
578
                            <option value="3">
578
                            <option value="from_local_hold_group">
579
                            [% END %]
579
                            [% END %]
580
                                From local hold group
580
                                From local hold group
581
                            </option>
581
                            </option>
582
582
583
                            [% IF holdallowed == 1 %]
583
                            [% IF holdallowed == 'from_home_library' %]
584
                                <option value="1" selected="selected">
584
                                <option value="from_home_library" selected="selected">
585
                            [% ELSE %]
585
                            [% ELSE %]
586
                                <option value="1">
586
                                <option value="from_home_library">
587
                            [% END %]
587
                            [% END %]
588
                                From home library
588
                                From home library
589
                            </option>
589
                            </option>
590
590
591
                            [% IF holdallowed == 0 %]
591
                            [% IF holdallowed == 'not_allowed' %]
592
                                <option value="0" selected="selected">
592
                                <option value="not_allowed" selected="selected">
593
                            [% ELSE %]
593
                            [% ELSE %]
594
                                <option value="0">
594
                                <option value="not_allowed">
595
                            [% END %]
595
                            [% END %]
596
                                No holds allowed
596
                                No holds allowed
597
                            </option>
597
                            </option>
Lines 916-932 Link Here
916
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
916
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
917
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
917
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
918
918
919
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
919
                    [% IF holdallowed != 'not_allowed' || hold_fulfillment_policy || returnbranch %]
920
                        <tr>
920
                        <tr>
921
                            <td>
921
                            <td>
922
                                [% i.translated_description | html %]
922
                                [% i.translated_description | html %]
923
                            </td>
923
                            </td>
924
                            <td>
924
                            <td>
925
                                [% IF holdallowed == 2 %]
925
                                [% IF holdallowed == 'from_any_library' %]
926
                                    <span>From any library</span>
926
                                    <span>From any library</span>
927
                                [% ELSIF holdallowed == 3 %]
927
                                [% ELSIF holdallowed == 'from_local_hold_group' %]
928
                                    <span>From local hold group</span>
928
                                    <span>From local hold group</span>
929
                                [% ELSIF holdallowed == 1 %]
929
                                [% ELSIF holdallowed == 'from_home_library' %]
930
                                    <span>From home library</span>
930
                                    <span>From home library</span>
931
                                [% ELSE %]
931
                                [% ELSE %]
932
                                    <span>No holds allowed</span>
932
                                    <span>No holds allowed</span>
Lines 970-979 Link Here
970
                    </td>
970
                    </td>
971
                    <td>
971
                    <td>
972
                        <select name="holdallowed">
972
                        <select name="holdallowed">
973
                            <option value="2">From any library</option>
973
                            <option value="from_any_library">From any library</option>
974
                            <option value="3">From local hold group</option>
974
                            <option value="from_local_hold_group">From local hold group</option>
975
                            <option value="1">From home library</option>
975
                            <option value="from_home_library">From home library</option>
976
                            <option value="0">No holds allowed</option>
976
                            <option value="not_allowed">No holds allowed</option>
977
                        </select>
977
                        </select>
978
                    </td>
978
                    </td>
979
                    <td>
979
                    <td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-3 / +2 lines)
Lines 1292-1299 Link Here
1292
                var msg = '';
1292
                var msg = '';
1293
1293
1294
                switch (override_items[itemnumber].holdallowed) {
1294
                switch (override_items[itemnumber].holdallowed) {
1295
                    case 0: msg = _("This item normally cannot be put on hold."); break;
1295
                    case "not_allowed": msg = _("This item normally cannot be put on hold."); break;
1296
                    case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1296
                    case "from_home_library": msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1297
                }
1297
                }
1298
1298
1299
                msg += "\n\n" + _("Place hold on this item?");
1299
                msg += "\n\n" + _("Place hold on this item?");
1300
- 

Return to bug 27069