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

(-)a/C4/Circulation.pm (-1 / +11 lines)
Lines 2623-2634 sub MarkIssueReturned { Link Here
2623
            $item->last_returned_by( $patron->borrowernumber )->store;
2623
            $item->last_returned_by( $patron->borrowernumber )->store;
2624
        }
2624
        }
2625
2625
2626
        # The reason this is here, and not in Koha::Patron->has_overdues() is
2627
        # to make sure it will not cause any side effects elsewhere, since this
2628
        # is only relevant for removal of debarments.
2629
        my $has_overdue_ignore_unrestricted = 0;
2630
        if(C4::Context->preference('ODueDebarmentRemovalAllowUnrestricted')) {
2631
            $has_overdue_ignore_unrestricted = 1;
2632
        }
2633
2626
        # Remove any OVERDUES related debarment if the borrower has no overdues
2634
        # Remove any OVERDUES related debarment if the borrower has no overdues
2627
        my $overdue_restrictions = $patron->restrictions->search({ type => 'OVERDUES' });
2635
        my $overdue_restrictions = $patron->restrictions->search({ type => 'OVERDUES' });
2628
        if ( C4::Context->preference('AutoRemoveOverduesRestrictions')
2636
        if ( C4::Context->preference('AutoRemoveOverduesRestrictions')
2629
          && $patron->debarred
2637
          && $patron->debarred
2630
          && !$patron->has_overdues
2631
          && $overdue_restrictions->count
2638
          && $overdue_restrictions->count
2639
          && !$patron->has_overdues({
2640
              ignore_unrestricted => $has_overdue_ignore_unrestricted,
2641
              issue_branch => $issue->{'branchcode'} })
2632
        ) {
2642
        ) {
2633
            DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
2643
            DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
2634
        }
2644
        }
(-)a/Koha/Patron.pm (-2 / +40 lines)
Lines 1008-1016 Returns the number of patron's overdues Link Here
1008
=cut
1008
=cut
1009
1009
1010
sub has_overdues {
1010
sub has_overdues {
1011
    my ($self) = @_;
1011
    my ($self, $params) = @_;
1012
    my $date = dt_from_string();
1013
1014
    # If ignoring unrestricted overdues, calculate which delay value for
1015
    # overdue messages is set with restrictions. Then only include overdue
1016
    # issues older than that date when counting.
1017
    if($params->{ignore_unrestricted}) {
1018
        my $branchcode = $params->{issue_branchcode};
1019
        my $date_offset = _get_overdue_restrict_delay($params->{issue_branchcode}, $self->categorycode());
1020
        $date->subtract(days => $date_offset);
1021
    }
1022
1012
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
1023
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
1013
    return $self->_result->issues->search({ date_due => { '<' => $dtf->format_datetime( dt_from_string() ) } })->count;
1024
    return $self->_result->issues->search({ date_due => { '<' => $dtf->format_datetime( $date )} })->count;
1025
}
1026
1027
# Fetch first delayX value from overduerules where debarredX is set, or 0 for no delay
1028
sub _get_overdue_restrict_delay {
1029
    my ($branchcode, $categorycode) = @_;
1030
    my $dbh = C4::Context->dbh();
1031
1032
    my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? AND categorycode = ?";
1033
1034
    my $rqoverduerules =  $dbh->prepare($query);
1035
    $rqoverduerules->execute($branchcode, $categorycode);
1036
1037
    # We get default rules if there is no rule for this branch
1038
    if($rqoverduerules->rows == 0){
1039
        $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' AND categorycode = ?";
1040
1041
        $rqoverduerules = $dbh->prepare($query);
1042
        $rqoverduerules->execute($categorycode);
1043
    }
1044
1045
    while ( my $overdue_rules = $rqoverduerules->fetchrow_hashref ) {
1046
        return $overdue_rules->{"delay1"} if($overdue_rules->{"debarred1"});
1047
        return $overdue_rules->{"delay2"} if($overdue_rules->{"debarred2"});
1048
        return $overdue_rules->{"delay3"} if($overdue_rules->{"debarred3"});
1049
    }
1050
1051
    return 0;
1014
}
1052
}
1015
1053
1016
=head3 track_login
1054
=head3 track_login
(-)a/installer/data/mysql/atomicupdate/odue-debarment-removal-allow-unrestricted.pl (+14 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "",
5
    description => "Add system preference",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        # Do you stuffs here
10
        $dbh->do(q{INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('ODueDebarmentRemovalAllowUnrestricted', '0', null, 'Allow removal of OVERDUES debarment when overdues still exist, but has not reached restricting delay', 'YesNo')});
11
        # Print useful stuff here
12
        say $out "System preference added";
13
    },
14
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 658-663 Circulation: Link Here
658
                  1: Store
658
                  1: Store
659
                  0: "Don't store"
659
                  0: "Don't store"
660
            - 'the last patron to return an item. This setting is independent of the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=opacreadinghistory">opacreadinghistory</a> and <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=AnonymousPatron">AnonymousPatron</a> system preferences.'
660
            - 'the last patron to return an item. This setting is independent of the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=opacreadinghistory">opacreadinghistory</a> and <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=AnonymousPatron">AnonymousPatron</a> system preferences.'
661
        -
662
            - pref: ODueDebarmentRemovalAllowUnrestricted
663
              choices:
664
                  yes: Allow
665
                  no: Do not allow
666
            - removal of Overdue debarments when patron has overdue items but none are old enough to have reached restricting delay. Used in combination with AutoRemoveOverduesRestrictions.
661
    Holds policy:
667
    Holds policy:
662
        -
668
        -
663
            - In the staff interface, split the holds queue into separate tables by
669
            - In the staff interface, split the holds queue into separate tables by
(-)a/misc/cronjobs/overdue_notices.pl (-3 / +2 lines)
Lines 489-496 END_SQL Link Here
489
    
489
    
490
    my $rqoverduerules =  $dbh->prepare($query);
490
    my $rqoverduerules =  $dbh->prepare($query);
491
    $rqoverduerules->execute($branchcode, @myborcat, @myborcatout);
491
    $rqoverduerules->execute($branchcode, @myborcat, @myborcatout);
492
    
492
493
    # We get default rules is there is no rule for this branch
493
    # We get default rules if there is no rule for this branch
494
    if($rqoverduerules->rows == 0){
494
    if($rqoverduerules->rows == 0){
495
        $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' ";
495
        $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' ";
496
        $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
496
        $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
497
- 

Return to bug 29145