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

(-)a/Koha/IssuingRule.pm (+42 lines)
Line 0 Link Here
1
package Koha::IssuingRule;
2
3
# Copyright Vaara-kirjastot 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use Koha::Database;
22
use base qw(Koha::Object);
23
24
=head1 NAME
25
26
Koha::Hold - Koha Hold object class
27
28
=head1 API
29
30
=head2 Class Methods
31
32
=cut
33
34
=head3 type
35
36
=cut
37
38
sub type {
39
    return 'Issuingrule';
40
}
41
42
1;
(-)a/Koha/IssuingRules.pm (+50 lines)
Line 0 Link Here
1
package Koha::IssuingRules;
2
3
# Copyright Vaara-kirjastot 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use Koha::Database;
22
use base qw(Koha::Objects);
23
24
=head1 NAME
25
26
Koha::IssuingRules - Koha IssuingRules object set class
27
28
=head1 API
29
30
=head2 Class Methods
31
32
=cut
33
34
=head3 type
35
36
=cut
37
38
sub type {
39
    return 'Issuingrule';
40
}
41
42
=head3 object_class
43
44
=cut
45
46
sub object_class {
47
    return 'Koha::IssuingRule';
48
}
49
50
1;
(-)a/admin/smart-rules.pl (-5 / +8 lines)
Lines 28-33 use C4::Debug; Link Here
28
use C4::Branch; # GetBranches
28
use C4::Branch; # GetBranches
29
use Koha::DateUtils;
29
use Koha::DateUtils;
30
use Koha::Database;
30
use Koha::Database;
31
use Koha::IssuingRule;
32
use Koha::IssuingRules;
31
33
32
my $input = CGI->new;
34
my $input = CGI->new;
33
my $dbh = C4::Context->dbh;
35
my $dbh = C4::Context->dbh;
Lines 136-144 elsif ($op eq 'add') { Link Here
136
    my $overduefinescap = $input->param('overduefinescap') || undef;
138
    my $overduefinescap = $input->param('overduefinescap') || undef;
137
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty";
139
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty";
138
140
139
    my $schema = Koha::Database->new()->schema();
140
    my $rs = $schema->resultset('Issuingrule');
141
142
    my $params = {
141
    my $params = {
143
        branchcode             => $br,
142
        branchcode             => $br,
144
        categorycode           => $bor,
143
        categorycode           => $bor,
Lines 166-172 elsif ($op eq 'add') { Link Here
166
        overduefinescap        => $overduefinescap,
165
        overduefinescap        => $overduefinescap,
167
    };
166
    };
168
167
169
    $rs->update_or_create($params);
168
    my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br});
169
    if ($issuingrule) {
170
        $issuingrule->set($params)->store();
171
    } else {
172
        Koha::IssuingRule->new()->set($params)->store();
173
    }
170
174
171
}
175
}
172
elsif ($op eq "set-branch-defaults") {
176
elsif ($op eq "set-branch-defaults") {
173
- 

Return to bug 15129