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

(-)a/Koha/OverdueRule.pm (+40 lines)
Line 0 Link Here
1
package Koha::OverdueRule;
2
3
# Copyright ByWater Solutions 2023
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use base qw(Koha::Object);
23
24
=head1 NAME
25
26
Koha::OverdueRule - Koha Overdue rule object class
27
28
=head1 API
29
30
=head2 Class Methods
31
32
=head3 _type
33
34
=cut
35
36
sub _type {
37
    return 'Overduerule';
38
}
39
40
1;
(-)a/Koha/OverdueRules.pm (+50 lines)
Line 0 Link Here
1
package Koha::OverdueRules;
2
3
# Copyright ByWater Solutions 2023
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Koha::OverdueRule;
23
24
use base qw(Koha::Objects);
25
26
=head1 NAME
27
28
Koha::OverdueRules - Koha::OverdueRule Object set class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=head3 _type
35
36
=cut
37
38
sub _type {
39
    return 'Overduerule';
40
}
41
42
=head3 object_class
43
44
=cut
45
46
sub object_class {
47
    return 'Koha::OverdueRule';
48
}
49
50
1;
(-)a/Koha/Patron.pm (-18 / +20 lines)
Lines 25-47 use JSON qw( to_json ); Link Here
25
use Unicode::Normalize qw( NFKD );
25
use Unicode::Normalize qw( NFKD );
26
use Try::Tiny;
26
use Try::Tiny;
27
27
28
use C4::Context;
29
use C4::Auth qw( checkpw_hash );
28
use C4::Auth qw( checkpw_hash );
29
use C4::Context;
30
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages );
30
use C4::Log qw( logaction );
31
use C4::Log qw( logaction );
31
use Koha::Account;
32
use Koha::Account;
32
use Koha::ArticleRequests;
33
use Koha::ArticleRequests;
33
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages );
34
use Koha::AuthUtils;
34
use Koha::AuthUtils;
35
use Koha::Checkouts;
35
use Koha::Checkouts;
36
use Koha::CirculationRules;
36
use Koha::CirculationRules;
37
use Koha::Club::Enrollments;
37
use Koha::Club::Enrollments;
38
use Koha::CurbsidePickups;
38
use Koha::Database;
39
use Koha::Database;
39
use Koha::DateUtils qw( dt_from_string );
40
use Koha::DateUtils qw( dt_from_string );
40
use Koha::Encryption;
41
use Koha::Encryption;
41
use Koha::Exceptions::Password;
42
use Koha::Exceptions::Password;
42
use Koha::Holds;
43
use Koha::Holds;
43
use Koha::CurbsidePickups;
44
use Koha::Old::Checkouts;
44
use Koha::Old::Checkouts;
45
use Koha::OverdueRules;
45
use Koha::Patron::Attributes;
46
use Koha::Patron::Attributes;
46
use Koha::Patron::Categories;
47
use Koha::Patron::Categories;
47
use Koha::Patron::Debarments;
48
use Koha::Patron::Debarments;
Lines 1073-1095 sub _get_overdue_debarred_delay { Link Here
1073
    my ($branchcode, $categorycode) = @_;
1074
    my ($branchcode, $categorycode) = @_;
1074
    my $dbh = C4::Context->dbh();
1075
    my $dbh = C4::Context->dbh();
1075
1076
1076
    my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? AND categorycode = ?";
1077
1078
    my $rqoverduerules = $dbh->prepare($query);
1079
    $rqoverduerules->execute($branchcode, $categorycode);
1080
1081
    # We get default rules if there is no rule for this branch
1077
    # We get default rules if there is no rule for this branch
1082
    if($rqoverduerules->rows == 0) {
1078
    my $rule = Koha::OverdueRules->find(
1083
        $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' AND categorycode = ?";
1079
        {
1084
1080
            branchcode   => $branchcode,
1085
        $rqoverduerules = $dbh->prepare($query);
1081
            categorycode => $categorycode
1086
        $rqoverduerules->execute($categorycode);
1082
        }
1087
    }
1083
      )
1084
      || Koha::OverdueRules->find(
1085
        {
1086
            branchcode   => q{},
1087
            categorycode => $categorycode
1088
        }
1089
      );
1088
1090
1089
    while ( my $overdue_rules = $rqoverduerules->fetchrow_hashref ) {
1091
    if ( $rule ) {
1090
        return $overdue_rules->{"delay1"} if($overdue_rules->{"debarred1"});
1092
        return $rule->delay1 if $rule->debarred1;
1091
        return $overdue_rules->{"delay2"} if($overdue_rules->{"debarred2"});
1093
        return $rule->delay2 if $rule->debarred2;
1092
        return $overdue_rules->{"delay3"} if($overdue_rules->{"debarred3"});
1094
        return $rule->delay3 if $rule->debarred3;
1093
    }
1095
    }
1094
}
1096
}
1095
1097
(-)a/Koha/Schema/Result/Overduerule.pm (-2 / +6 lines)
Lines 198-203 __PACKAGE__->has_many( Link Here
198
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29
198
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29
199
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pORigxtC5qztZWHI29mZ/g
199
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pORigxtC5qztZWHI29mZ/g
200
200
201
sub koha_object_class {
202
    'Koha::OverdueRule';
203
}
204
sub koha_objects_class {
205
    'Koha::OverdueRules';
206
}
201
207
202
# You can replace this text with custom content, and it will be preserved on regeneration
203
1;
208
1;
204
- 

Return to bug 29145