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

(-)a/C4/Reserves.pm (-2 / +4 lines)
Lines 396-403 sub CanItemBeReserved { Link Here
396
    return { status => 'ageRestricted' } if $daysToAgeRestriction && $daysToAgeRestriction > 0;
396
    return { status => 'ageRestricted' } if $daysToAgeRestriction && $daysToAgeRestriction > 0;
397
397
398
    # Check that the patron doesn't have an item level hold on this item already
398
    # Check that the patron doesn't have an item level hold on this item already
399
    return { status =>'itemAlreadyOnHold' }
399
    unless (C4::Context->preference('AllowMultipleHoldsOnSameItem')) {
400
      if ( !$params->{ignore_hold_counts} && Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count() );
400
        return { status =>'itemAlreadyOnHold' }
401
          if ( !$params->{ignore_hold_counts} && Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count() );
402
    }
401
403
402
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
404
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
403
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
405
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
(-)a/installer/data/mysql/atomicupdate/bug-29505.pl (+15 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "29505",
5
    description => "Add system preference AllowMultipleHoldsOnSameItem",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{
11
            INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type)
12
            VALUES ('AllowMultipleHoldsOnSameItem', 0, NULL, 'Allow/Don\'t allow patrons to place multiple holds on the same item', 'YesNo')
13
        });
14
    },
15
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 33-38 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
33
('AllowItemsOnHoldCheckoutSCO','0','','Do not generate RESERVE_WAITING and RESERVED warning in the SCO module when checking out items reserved to someone else. This allows self checkouts for those items.','YesNo'),
33
('AllowItemsOnHoldCheckoutSCO','0','','Do not generate RESERVE_WAITING and RESERVED warning in the SCO module when checking out items reserved to someone else. This allows self checkouts for those items.','YesNo'),
34
('AllowMultipleCovers','0','1','Allow multiple cover images to be attached to each bibliographic record.','YesNo'),
34
('AllowMultipleCovers','0','1','Allow multiple cover images to be attached to each bibliographic record.','YesNo'),
35
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
35
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
36
('AllowMultipleHoldsOnSameItem', 0, NULL, 'Allow/Don\'t allow patrons to place multiple holds on the same item', 'YesNo'),
36
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
37
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
37
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
38
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
38
('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account to choose whether their checkouts are auto renewed or not','YesNo'),
39
('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account to choose whether their checkouts are auto renewed or not','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 915-920 Circulation: Link Here
915
                  months: months
915
                  months: months
916
                  years: years
916
                  years: years
917
            - from reserve date.
917
            - from reserve date.
918
        -
919
            - pref: AllowMultipleHoldsOnSameItem
920
              choices:
921
                  no: "Do not allow"
922
                  yes: "Allow"
923
            - patrons to place multiple holds on the same item.
924
            - This can be useful if AllowHoldDateInFuture is enabled too
918
    Interlibrary loans:
925
    Interlibrary loans:
919
        -
926
        -
920
            - pref: ILLModule
927
            - pref: ILLModule
(-)a/t/db_dependent/Holds/AllowMultipleHoldsOnSameItem.t (-1 / +78 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use t::lib::Mocks;
6
use t::lib::TestBuilder;
7
8
use C4::Context;
9
use C4::Reserves qw( CanItemBeReserved );
10
use Koha::CirculationRules;
11
12
use Test::More tests => 1;
13
14
my $schema  = Koha::Database->new->schema;
15
my $builder = t::lib::TestBuilder->new();
16
17
t::lib::Mocks::mock_preference('item-level_itypes', '0');
18
19
subtest 'CanItemBeReserved AllowMultipleHoldsOnSameItem tests' => sub {
20
    plan tests => 3;
21
22
    $schema->storage->txn_begin;
23
24
    my $library  = $builder->build_object( { class => 'Koha::Libraries', value => {
25
        pickup_location => 1,
26
    }});
27
    my $item = $builder->build_sample_item({
28
        homebranch    => $library->branchcode,
29
        holdingbranch => $library->branchcode
30
    });
31
    my $patron   = $builder->build_object({ class => 'Koha::Patrons', value => {
32
        branchcode => $library->branchcode
33
    }});
34
    Koha::CirculationRules->set_rules(
35
        {
36
            branchcode   => undef,
37
            categorycode => undef,
38
            itemtype     => undef,
39
            rules        => {
40
                reservesallowed  => 10,
41
                holds_per_record => 10,
42
            }
43
        }
44
    );
45
46
    is_deeply(
47
        CanItemBeReserved( $patron->borrowernumber, $item->itemnumber, $library->branchcode ),
48
        { status => 'OK' },
49
        'Patron can place a hold on specified item'
50
    );
51
52
    my $hold = $builder->build_object({ class => 'Koha::Holds', value => {
53
        biblionumber   => $item->biblionumber,
54
        itemnumber     => $item->itemnumber,
55
        found          => undef,
56
        priority       => 1,
57
        branchcode     => $library->branchcode,
58
        borrowernumber => $patron->borrowernumber,
59
    }});
60
61
    t::lib::Mocks::mock_preference('AllowMultipleHoldsOnSameItem', '0');
62
63
    is_deeply(
64
        CanItemBeReserved( $patron->borrowernumber, $item->itemnumber, $library->branchcode ),
65
        { status => 'itemAlreadyOnHold' },
66
        'When AllowMultipleHoldsOnSameItem is disabled, patron cannot place another hold on specified item'
67
    );
68
69
    t::lib::Mocks::mock_preference('AllowMultipleHoldsOnSameItem', '1');
70
71
    is_deeply(
72
        CanItemBeReserved( $patron->borrowernumber, $item->itemnumber, $library->branchcode ),
73
        { status => 'OK' },
74
        'When AllowMultipleHoldsOnSameItem is enabled, patron can place another hold on specified item'
75
    );
76
77
    $schema->storage->txn_rollback;
78
};

Return to bug 29505