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 550-583 Link Here
550
                                Not set
550
                                Not set
551
                            </option>
551
                            </option>
552
552
553
                            [% IF holdallowed == 2 %]
553
                            [% IF holdallowed == 'from_any_library' %]
554
                                <option value="2" selected="selected">
554
                                <option value="from_any_library" selected="selected">
555
                            [% ELSE %]
555
                            [% ELSE %]
556
                                <option value="2">
556
                                <option value="from_any_library">
557
                            [% END %]
557
                            [% END %]
558
                                From any library
558
                                From any library
559
                            </option>
559
                            </option>
560
560
561
                            [% IF holdallowed == 3 %]
561
                            [% IF holdallowed == 'from_local_hold_group' %]
562
                            <option value="3" selected="selected">
562
                            <option value="from_local_hold_group" selected="selected">
563
                            [% ELSE %]
563
                            [% ELSE %]
564
                            <option value="3">
564
                            <option value="from_local_hold_group">
565
                            [% END %]
565
                            [% END %]
566
                                From local hold group
566
                                From local hold group
567
                            </option>
567
                            </option>
568
568
569
                            [% IF holdallowed == 1 %]
569
                            [% IF holdallowed == 'from_home_library' %]
570
                                <option value="1" selected="selected">
570
                                <option value="from_home_library" selected="selected">
571
                            [% ELSE %]
571
                            [% ELSE %]
572
                                <option value="1">
572
                                <option value="from_home_library">
573
                            [% END %]
573
                            [% END %]
574
                                From home library
574
                                From home library
575
                            </option>
575
                            </option>
576
576
577
                            [% IF holdallowed == 0 %]
577
                            [% IF holdallowed == 'not_allowed' %]
578
                                <option value="0" selected="selected">
578
                                <option value="not_allowed" selected="selected">
579
                            [% ELSE %]
579
                            [% ELSE %]
580
                                <option value="0">
580
                                <option value="not_allowed">
581
                            [% END %]
581
                            [% END %]
582
                                No holds allowed
582
                                No holds allowed
583
                            </option>
583
                            </option>
Lines 902-918 Link Here
902
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
902
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
903
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
903
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
904
904
905
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
905
                    [% IF holdallowed != 'not_allowed' || hold_fulfillment_policy || returnbranch %]
906
                        <tr>
906
                        <tr>
907
                            <td>
907
                            <td>
908
                                [% i.translated_description | html %]
908
                                [% i.translated_description | html %]
909
                            </td>
909
                            </td>
910
                            <td>
910
                            <td>
911
                                [% IF holdallowed == 2 %]
911
                                [% IF holdallowed == 'from_any_library' %]
912
                                    <span>From any library</span>
912
                                    <span>From any library</span>
913
                                [% ELSIF holdallowed == 3 %]
913
                                [% ELSIF holdallowed == 'from_local_hold_group' %]
914
                                    <span>From local hold group</span>
914
                                    <span>From local hold group</span>
915
                                [% ELSIF holdallowed == 1 %]
915
                                [% ELSIF holdallowed == 'from_home_library' %]
916
                                    <span>From home library</span>
916
                                    <span>From home library</span>
917
                                [% ELSE %]
917
                                [% ELSE %]
918
                                    <span>No holds allowed</span>
918
                                    <span>No holds allowed</span>
Lines 956-965 Link Here
956
                    </td>
956
                    </td>
957
                    <td>
957
                    <td>
958
                        <select name="holdallowed">
958
                        <select name="holdallowed">
959
                            <option value="2">From any library</option>
959
                            <option value="from_any_library">From any library</option>
960
                            <option value="3">From local hold group</option>
960
                            <option value="from_local_hold_group">From local hold group</option>
961
                            <option value="1">From home library</option>
961
                            <option value="from_home_library">From home library</option>
962
                            <option value="0">No holds allowed</option>
962
                            <option value="not_allowed">No holds allowed</option>
963
                        </select>
963
                        </select>
964
                    </td>
964
                    </td>
965
                    <td>
965
                    <td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-3 / +2 lines)
Lines 1266-1273 Link Here
1266
                var msg = '';
1266
                var msg = '';
1267
1267
1268
                switch (override_items[itemnumber].holdallowed) {
1268
                switch (override_items[itemnumber].holdallowed) {
1269
                    case 0: msg = _("This item normally cannot be put on hold."); break;
1269
                    case "not_allowed": msg = _("This item normally cannot be put on hold."); break;
1270
                    case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1270
                    case "from_home_library": msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1271
                }
1271
                }
1272
1272
1273
                msg += "\n\n" + _("Place hold on this item?");
1273
                msg += "\n\n" + _("Place hold on this item?");
1274
- 

Return to bug 27069