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 544-549 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
544
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
544
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
545
('OverdueNoticeFrom', 'cron', 'cron|item-issuebranch|item-homebranch', 'Organize and send overdue notices by item home library or checkout library', 'Choice'),
545
('OverdueNoticeFrom', 'cron', 'cron|item-issuebranch|item-homebranch', 'Organize and send overdue notices by item home library or checkout library', 'Choice'),
546
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
546
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
547
('OverduesBlockHolds','noblock','noblock|block','Allow or block placing an hold at OPAC when the patron has overdues outstanding.','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'),
548
('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'),
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'),
549
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'),
549
('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'),
550
('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 / +48 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 1735-1737 subtest 'CanItemBeReserved() tests' => sub { Link Here
1735
1735
1736
    $schema->storage->txn_rollback;
1736
    $schema->storage->txn_rollback;
1737
};
1737
};
1738
- 
1738
1739
subtest 'OverduesBlockHolds tests' => sub {
1740
    plan tests => 2;
1741
1742
    $schema->storage->txn_begin;
1743
1744
    my $library = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
1745
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1746
    my $biblio = $builder->build_sample_biblio();
1747
    my $overdueitem = $builder->build_sample_item(
1748
        {
1749
            biblionumber => $biblio->biblionumber,
1750
            library      => $library->branchcode
1751
        }
1752
    );
1753
1754
    my $context = Test::MockModule->new('C4::Context');
1755
    $context->mock( userenv => { branch => $library->id } );
1756
1757
    Koha::CirculationRules->delete;
1758
1759
    Koha::CirculationRules->set_rules(
1760
        {   branchcode   => undef,
1761
            categorycode => undef,
1762
            itemtype     => undef,
1763
            rules        => {
1764
                reservesallowed => 2,
1765
            }
1766
        }
1767
    );
1768
1769
    my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 );
1770
    my $issue = AddIssue( $patron->unblessed, $overdueitem->barcode, $yesterday );
1771
1772
    t::lib::Mocks::mock_preference('OverduesBlockHolds','block');
1773
    my $res = CanBookBeReserved($patron->id, $biblio->id, $library->id);
1774
    is_deeply( $res, { status => 'patronHasOverdues' },
1775
        'Hold is blocked for overdue patron when OverduesBlockHolds is set to block' );
1776
1777
    t::lib::Mocks::mock_preference('OverduesBlockHolds','noblock');
1778
    $res = CanBookBeReserved($patron->id, $biblio->id, $library->id);
1779
    is_deeply( $res, { status => 'OK' },
1780
        'Hold is allowed for overdue patron when OverduesBlockHolds is set to allow' );
1781
1782
    $schema->storage->txn_rollback;
1783
1784
};

Return to bug 33086