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

(-)a/C4/Reserves.pm (+7 lines)
Lines 341-346 sub CanBookBeReserved{ Link Here
341
        return { status =>'alreadypossession' };
341
        return { status =>'alreadypossession' };
342
    }
342
    }
343
343
344
    if (C4::Context->preference("OverduesBlockHolds") && C4::Context->preference("OverduesBlockHolds") eq 'block') {
345
        my $patron = Koha::Patrons->find($borrowernumber);
346
        if ($patron->has_overdues) {
347
            return { status => 'patronHasOverdues' };
348
        }
349
    }
350
344
    if ( $params->{itemtype} ) {
351
    if ( $params->{itemtype} ) {
345
352
346
        # biblio-level, item type-contrained
353
        # biblio-level, item type-contrained
(-)a/installer/data/mysql/atomicupdate/Bug33086-Allow-blocking-holds-on-overdues.pl (+12 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "33086",
5
    description => "Allow blocking holds at OPAC on overdues",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('OverduesBlockHolds', 'noblock', 'noblock|block', 'Allow or block placing an hold at OPAC when the patron has overdues outstanding.', 'Choice')});
10
        say $out "Added new system preference 'OverduesBlockHolds'";
11
    },
12
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 543-548 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
543
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
543
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
544
('OverdueNoticeFrom', 'cron', 'cron|item-issuebranch|item-homebranch', 'Organize and send overdue notices by item home library or checkout library', 'Choice'),
544
('OverdueNoticeFrom', 'cron', 'cron|item-issuebranch|item-homebranch', 'Organize and send overdue notices by item home library or checkout library', 'Choice'),
545
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
545
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
546
('OverduesBlockHolds','noblock','noblock|block','Allow or block placing an hold at OPAC when the patron has overdues outstanding.','Choice'),
546
('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'),
547
('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'),
547
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'),
548
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'),
548
('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'),
549
('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 429-434 Circulation: Link Here
429
                  noblock: "Don't block"
429
                  noblock: "Don't block"
430
                  confirmation: Ask for confirmation
430
                  confirmation: Ask for confirmation
431
            - "when checking out to a patron that has overdues outstanding."
431
            - "when checking out to a patron that has overdues outstanding."
432
        -
433
            - pref: OverduesBlockHolds
434
              choices:
435
                  block: Block
436
                  noblock: "Don't block"
437
            - "placing an hold at OPAC when the patron has overdues outstanding."
432
        -
438
        -
433
            - "When checking out an item with rental fees, "
439
            - "When checking out an item with rental fees, "
434
            - pref: RentalFeesCheckoutConfirmation
440
            - pref: RentalFeesCheckoutConfirmation
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+8 lines)
Lines 430-435 Link Here
430
                    </div>
430
                    </div>
431
                [% END %]
431
                [% END %]
432
432
433
                [% IF ( patronHasOverdues ) %]
434
                    <div class="dialog alert">
435
                        <ul>
436
                            <li>Patron has overdues</li>
437
                        </ul>
438
                    </div>
439
                [% END %]
440
433
                [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted || recall ) %]
441
                [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted || recall ) %]
434
                    <div class="dialog alert">
442
                    <div class="dialog alert">
435
443
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (+2 lines)
Lines 214-219 Link Here
214
                                            <div class="alert alert-warning">This title cannot be requested because you reached the daily hold limit.</div>
214
                                            <div class="alert alert-warning">This title cannot be requested because you reached the daily hold limit.</div>
215
                                        [% ELSIF bibitemloo.itemAlreadyOnHold %]
215
                                        [% ELSIF bibitemloo.itemAlreadyOnHold %]
216
                                            <div class="alert alert-warning">This title cannot be requested because you already have hold for this item.</div>
216
                                            <div class="alert alert-warning">This title cannot be requested because you already have hold for this item.</div>
217
                                        [% ELSIF bibitemloo.patronHasOverdues %]
218
                                            <div class="alert alert-warning">This title cannot be requested because you have overdues.</div>
217
                                        [% ELSE %]
219
                                        [% ELSE %]
218
                                            [% UNLESS ( bibitemloo.bib_available ) %]
220
                                            [% UNLESS ( bibitemloo.bib_available ) %]
219
                                                <div class="alert">There are no items that can be placed on hold.</div>
221
                                                <div class="alert">There are no items that can be placed on hold.</div>
(-)a/reserve/request.pl (+4 lines)
Lines 338-343 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
338
                    $template->param( $canReserve->{status} => 1 );
338
                    $template->param( $canReserve->{status} => 1 );
339
                    $biblioloopiter{ $canReserve->{status} } = 1;
339
                    $biblioloopiter{ $canReserve->{status} } = 1;
340
                }
340
                }
341
                elsif ( $canReserve->{status} eq 'patronHasOverdues' ) {
342
                    $template->param( $canReserve->{status} => 1 );
343
                    $biblioloopiter{ $canReserve->{status} } = 1;
344
                }
341
                else {
345
                else {
342
                    $biblioloopiter{ $canReserve->{status} } = 1;
346
                    $biblioloopiter{ $canReserve->{status} } = 1;
343
                }
347
                }
(-)a/t/db_dependent/Reserves.t (-2 / +50 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 77;
20
use Test::More tests => 78;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1719-1721 subtest 'CanItemBeReserved() tests' => sub { Link Here
1719
1719
1720
    $schema->storage->txn_rollback;
1720
    $schema->storage->txn_rollback;
1721
};
1721
};
1722
- 
1722
1723
subtest 'OverduesBlockHolds tests' => sub {
1724
    plan tests => 2;
1725
1726
    $schema->storage->txn_begin;
1727
1728
    my $library = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
1729
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1730
    my $biblio = $builder->build_sample_biblio();
1731
    my $overdueitem = $builder->build_sample_item(
1732
        {
1733
            biblionumber => $biblio->biblionumber,
1734
            library      => $library->branchcode
1735
        }
1736
    );
1737
1738
    my $context = Test::MockModule->new('C4::Context');
1739
    $context->mock( userenv => { branch => $library->id } );
1740
1741
    Koha::CirculationRules->delete;
1742
1743
    Koha::CirculationRules->set_rules(
1744
        {   branchcode   => undef,
1745
            categorycode => undef,
1746
            itemtype     => undef,
1747
            rules        => {
1748
                reservesallowed => 2,
1749
            }
1750
        }
1751
    );
1752
1753
    my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 );
1754
    my $issue = AddIssue( $patron->unblessed, $overdueitem->barcode, $yesterday );
1755
1756
    t::lib::Mocks::mock_preference('OverduesBlockHolds','block');
1757
    my $res = CanBookBeReserved($patron->id, $biblio->id, $library->id);
1758
    is_deeply( $res, { status => 'patronHasOverdues' },
1759
        'Hold is blocked for overdue patron when OverduesBlockHolds is set to block' );
1760
1761
    t::lib::Mocks::mock_preference('OverduesBlockHolds','noblock');
1762
    $res = CanBookBeReserved($patron->id, $biblio->id, $library->id);
1763
    is_deeply( $res, { status => 'OK' },
1764
        'Hold is allowed for overdue patron when OverduesBlockHolds is set to allow' );
1765
1766
    $schema->storage->txn_rollback;
1767
1768
};
1769
1770

Return to bug 33086