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

(-)a/Koha/Patron.pm (+7 lines)
Lines 694-699 sub do_check_for_previous_checkout { Link Here
694
        itemnumber => \@item_nos,
694
        itemnumber => \@item_nos,
695
    };
695
    };
696
696
697
    my $delay = C4::Context->preference('CheckPrevCheckoutDelay') || 0;
698
    if ($delay) {
699
        my $dtf = Koha::Database->new->schema->storage->datetime_parser;
700
        my $newer_than = dt_from_string()->subtract( days => $delay );
701
        $criteria->{'returndate'} = { '>'   =>  $dtf->format_datetime($newer_than), };
702
    }
703
697
    # Check current issues table
704
    # Check current issues table
698
    my $issues = Koha::Checkouts->search($criteria);
705
    my $issues = Koha::Checkouts->search($criteria);
699
    return 1 if $issues->count; # 0 || N
706
    return 1 if $issues->count; # 0 || N
(-)a/installer/data/mysql/atomicupdate/Bug26937.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    # you can use $dbh here like:
4
    $dbh->do( "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CheckPrevCheckoutDelay','0', 'Maximum number of days that will trigger a warning if the patron has borrowed that item in the past when CheckPrevCheckout is enabled. Disabled if 0 or empty.', NULL, 'free')" );
5
6
    # Always end with this (adjust the bug info)
7
    SetVersion( $DBversion );
8
    print "Upgrade to $DBversion done (Bug 26937 - Add CheckPrevCheckoutDelay system preference)\n";
9
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 122-127 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
122
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
122
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
123
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
123
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
124
('CheckPrevCheckout','hardno','hardyes|softyes|softno|hardno','By default, for every item checked out, should we warn if the patron has borrowed that item in the past?','Choice'),
124
('CheckPrevCheckout','hardno','hardyes|softyes|softno|hardno','By default, for every item checked out, should we warn if the patron has borrowed that item in the past?','Choice'),
125
('CheckPrevCheckoutDelay','0', NULL,'Maximum number of days that will trigger a warning if the patron has borrowed that item in the past when CheckPrevCheckout is enabled.','free'),
125
('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'),
126
('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'),
126
('CircConfirmItemParts', '0', NULL, 'Require staff to confirm that all parts of an item are present at checkin/checkout.', 'Yes/No'),
127
('CircConfirmItemParts', '0', NULL, 'Require staff to confirm that all parts of an item are present at checkin/checkout.', 'Yes/No'),
127
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
128
('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+4 lines)
Lines 10-15 Patrons: Link Here
10
               hardno: "Do not"
10
               hardno: "Do not"
11
         - " check borrower checkout history to see if the current item has been checked out before."
11
         - " check borrower checkout history to see if the current item has been checked out before."
12
     -
12
     -
13
         - pref: CheckPrevCheckoutDelay
14
           default: 0
15
         - "Maximum number of days that will trigger a warning if the patron has borrowed that item in the past when CheckPrevCheckout is enabled. Disabled if 0 or empty."
16
     -
13
         - pref: ExtendedPatronAttributes
17
         - pref: ExtendedPatronAttributes
14
           choices:
18
           choices:
15
               yes: Enable
19
               yes: Enable
(-)a/t/db_dependent/Patron/Borrower_PrevCheckout.t (-2 / +34 lines)
Lines 4-12 use Modern::Perl; Link Here
4
use C4::Members;
4
use C4::Members;
5
use C4::Circulation;
5
use C4::Circulation;
6
use Koha::Database;
6
use Koha::Database;
7
use Koha::DateUtils;
7
use Koha::Patrons;
8
use Koha::Patrons;
8
9
9
use Test::More tests => 60;
10
use Test::More tests => 61;
10
11
11
use_ok('Koha::Patron');
12
use_ok('Koha::Patron');
12
13
Lines 450-453 subtest 'Check previous checkouts for serial' => sub { Link Here
450
    is($patron->do_check_for_previous_checkout($item2->unblessed), 0, 'Check only one item if bibliographic record is serial');
451
    is($patron->do_check_for_previous_checkout($item2->unblessed), 0, 'Check only one item if bibliographic record is serial');
451
452
452
    $schema->storage->txn_rollback;
453
    $schema->storage->txn_rollback;
454
};
455
456
subtest 'Check previous checkouts with delay' => sub {
457
    plan tests => 3;
458
    $schema->storage->txn_begin;
459
    my $library = $builder->build_object({ class => 'Koha::Libraries'});
460
    my $biblio = $builder->build_sample_biblio;
461
    my $patron = $builder->build({source => 'Borrower'});
462
    my $item_object = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
463
464
    my $issue = Koha::Checkout->new({ branchcode => $library->branchcode, borrowernumber => $patron->{borrowernumber}, itemnumber => $item_object->itemnumber })->store;
465
    my $returndate = dt_from_string()->subtract( days => 3 );
466
    my $return = AddReturn($item_object->barcode, $library->branchcode, undef, $returndate);
467
468
    t::lib::Mocks::mock_preference('checkprevcheckout', 'hardyes');
469
    t::lib::Mocks::mock_preference('checkprevcheckoutdelay', 0);
470
    my $patron1 = Koha::Patrons->find($patron->{borrowernumber});
471
    is(
472
            $patron1->do_check_for_previous_checkout($item_object->unblessed),
473
            1, "Checking CheckPrevCheckoutDelay disabled"
474
    );
475
    t::lib::Mocks::mock_preference('checkprevcheckoutdelay', 5);
476
    is(
477
            $patron1->do_check_for_previous_checkout($item_object->unblessed),
478
            1, "Checking CheckPrevCheckoutDelay enabled within delay"
479
    );
480
    t::lib::Mocks::mock_preference('checkprevcheckoutdelay', 1);
481
    is(
482
            $patron1->do_check_for_previous_checkout($item_object->unblessed),
483
            0, "Checking CheckPrevCheckoutDelay enabled after delay"
484
    );
485
    $schema->storage->txn_rollback;
453
}
486
}
454
- 

Return to bug 26937