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 1058-1080 sub _get_overdue_debarred_delay { Link Here
1058
    my ($branchcode, $categorycode) = @_;
1059
    my ($branchcode, $categorycode) = @_;
1059
    my $dbh = C4::Context->dbh();
1060
    my $dbh = C4::Context->dbh();
1060
1061
1061
    my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? AND categorycode = ?";
1062
1063
    my $rqoverduerules = $dbh->prepare($query);
1064
    $rqoverduerules->execute($branchcode, $categorycode);
1065
1066
    # We get default rules if there is no rule for this branch
1062
    # We get default rules if there is no rule for this branch
1067
    if($rqoverduerules->rows == 0) {
1063
    my $rule = Koha::OverdueRules->find(
1068
        $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' AND categorycode = ?";
1064
        {
1069
1065
            branchcode   => $branchcode,
1070
        $rqoverduerules = $dbh->prepare($query);
1066
            categorycode => $categorycode
1071
        $rqoverduerules->execute($categorycode);
1067
        }
1072
    }
1068
      )
1069
      || Koha::OverdueRules->find(
1070
        {
1071
            branchcode   => q{},
1072
            categorycode => $categorycode
1073
        }
1074
      );
1073
1075
1074
    while ( my $overdue_rules = $rqoverduerules->fetchrow_hashref ) {
1076
    if ( $rule ) {
1075
        return $overdue_rules->{"delay1"} if($overdue_rules->{"debarred1"});
1077
        return $rule->delay1 if $rule->debarred1;
1076
        return $overdue_rules->{"delay2"} if($overdue_rules->{"debarred2"});
1078
        return $rule->delay2 if $rule->debarred2;
1077
        return $overdue_rules->{"delay3"} if($overdue_rules->{"debarred3"});
1079
        return $rule->delay3 if $rule->debarred3;
1078
    }
1080
    }
1079
}
1081
}
1080
1082
(-)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