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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 2778-2784 sub CanBookBeRenewed { Link Here
2778
2778
2779
        return ( 0, "too_unseen" )
2779
        return ( 0, "too_unseen" )
2780
          if C4::Context->preference('UnseenRenewals') &&
2780
          if C4::Context->preference('UnseenRenewals') &&
2781
            $issuing_rule->{unseen_renewals_allowed} &&
2781
            looks_like_number($issuing_rule->{unseen_renewals_allowed}) &&
2782
            $issuing_rule->{unseen_renewals_allowed} <= $issue->unseen_renewals;
2782
            $issuing_rule->{unseen_renewals_allowed} <= $issue->unseen_renewals;
2783
2783
2784
        my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2784
        my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
Lines 2985-2991 sub AddRenewal { Link Here
2985
                    rule_name    => 'unseen_renewals_allowed'
2985
                    rule_name    => 'unseen_renewals_allowed'
2986
                }
2986
                }
2987
            );
2987
            );
2988
            if (!$seen && $rule && $rule->rule_value) {
2988
            if (!$seen && $rule && looks_like_number($rule->rule_value)) {
2989
                $unseen_renewals++;
2989
                $unseen_renewals++;
2990
            } else {
2990
            } else {
2991
                # If the renewal is seen, unseen should revert to 0
2991
                # If the renewal is seen, unseen should revert to 0
(-)a/admin/smart-rules.pl (-6 / +5 lines)
Lines 258-264 elsif ($op eq 'add') { Link Here
258
    my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') );
258
    my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') );
259
    my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
259
    my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
260
    my $renewalsallowed  = $input->param('renewalsallowed');
260
    my $renewalsallowed  = $input->param('renewalsallowed');
261
    my $unseen_renewals_allowed  = $input->param('unseen_renewals_allowed');
261
    my $unseen_renewals_allowed  = strip_non_numeric( scalar $input->param('unseen_renewals_allowed') ) // '';
262
    my $renewalperiod    = $input->param('renewalperiod');
262
    my $renewalperiod    = $input->param('renewalperiod');
263
    my $norenewalbefore  = $input->param('norenewalbefore');
263
    my $norenewalbefore  = $input->param('norenewalbefore');
264
    $norenewalbefore = '' if $norenewalbefore =~ /^\s*$/;
264
    $norenewalbefore = '' if $norenewalbefore =~ /^\s*$/;
Lines 272-292 elsif ($op eq 'add') { Link Here
272
    my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') );
272
    my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') );
273
    my $holds_per_day    = strip_non_numeric( scalar $input->param('holds_per_day') );
273
    my $holds_per_day    = strip_non_numeric( scalar $input->param('holds_per_day') );
274
    my $onshelfholds     = $input->param('onshelfholds') || 0;
274
    my $onshelfholds     = $input->param('onshelfholds') || 0;
275
    my $issuelength  = $input->param('issuelength');
275
    my $issuelength  = $input->param('issuelength') || 0;
276
    $issuelength = $issuelength eq q{} ? undef : $issuelength;
277
    my $daysmode = $input->param('daysmode');
276
    my $daysmode = $input->param('daysmode');
278
    my $lengthunit  = $input->param('lengthunit');
277
    my $lengthunit  = $input->param('lengthunit');
279
    my $hardduedate = $input->param('hardduedate') || undef;
278
    my $hardduedate = $input->param('hardduedate') || '';
280
    $hardduedate = eval { dt_from_string( scalar $hardduedate ) } if ( $hardduedate );
279
    $hardduedate = eval { dt_from_string( scalar $hardduedate ) } if ( $hardduedate );
281
    $hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate );
280
    $hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate );
282
    my $hardduedatecompare = $input->param('hardduedatecompare');
281
    my $hardduedatecompare = $input->param('hardduedatecompare');
283
    my $rentaldiscount = $input->param('rentaldiscount');
282
    my $rentaldiscount = $input->param('rentaldiscount') || 0;
284
    my $opacitemholds = $input->param('opacitemholds') || 0;
283
    my $opacitemholds = $input->param('opacitemholds') || 0;
285
    my $article_requests = $input->param('article_requests') || 'no';
284
    my $article_requests = $input->param('article_requests') || 'no';
286
    my $overduefinescap = $input->param('overduefinescap') || '';
285
    my $overduefinescap = $input->param('overduefinescap') || '';
287
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
286
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
288
    my $note = $input->param('note');
287
    my $note = $input->param('note');
289
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
288
    my $decreaseloanholds = $input->param('decreaseloanholds') || '';
290
289
291
    my $rules = {
290
    my $rules = {
292
        maxissueqty                   => $maxissueqty,
291
        maxissueqty                   => $maxissueqty,
(-)a/installer/data/mysql/atomicupdate/bug_29012.pl (+33 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "29012",
5
    description => "Some rules are not saved when left blank while editing a 'rule' line in smart-rules.pl",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        my %default_rule_values = (
10
            issuelength             => 0,
11
            hardduedate             => '',
12
            unseenrenewalsallowed   => '',
13
            rentaldiscount          => 0,
14
            decreaseloanholds       => '',
15
        );
16
        while (my ($rule_name, $rule_value) = each (%default_rule_values)) {
17
            $dbh->do(q{
18
                INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value)
19
                    SELECT branchcode, categorycode, itemtype, ?, ? FROM circulation_rules cr
20
                        WHERE NOT EXISTS (
21
                            SELECT * FROM circulation_rules cr2
22
                                WHERE
23
                                    cr2.rule_name=?
24
                                    AND ( (cr2.branchcode=cr.branchcode) OR ( ISNULL(cr2.branchcode) AND ISNULL(cr.branchcode) ) )
25
                                    AND ( (cr2.categorycode=cr.categorycode) OR ( ISNULL(cr2.categorycode) AND ISNULL(cr.categorycode) ) )
26
                                    AND ( (cr2.itemtype=cr.itemtype) OR ( ISNULL(cr2.itemtype) AND ISNULL(cr.itemtype) ) )
27
                        )
28
                        GROUP BY branchcode, categorycode, itemtype
29
            }, undef, $rule_name, $rule_value, $rule_name);
30
        }
31
        say $out "Add default values for blank circulation rules that weren't saved to the database";
32
    },
33
}
(-)a/installer/onboarding.pl (-4 / +4 lines)
Lines 242-248 if ( $step == 5 ) { Link Here
242
        my $categorycode    = $input->param('categorycode');
242
        my $categorycode    = $input->param('categorycode');
243
        my $itemtype        = $input->param('itemtype');
243
        my $itemtype        = $input->param('itemtype');
244
        my $maxissueqty     = $input->param('maxissueqty');
244
        my $maxissueqty     = $input->param('maxissueqty');
245
        my $issuelength     = $input->param('issuelength');
245
        my $issuelength     = $input->param('issuelength') || 0;
246
        my $lengthunit      = $input->param('lengthunit');
246
        my $lengthunit      = $input->param('lengthunit');
247
        my $renewalsallowed = $input->param('renewalsallowed');
247
        my $renewalsallowed = $input->param('renewalsallowed');
248
        my $renewalperiod   = $input->param('renewalperiod');
248
        my $renewalperiod   = $input->param('renewalperiod');
Lines 252-258 if ( $step == 5 ) { Link Here
252
        my $onshelfholds    = $input->param('onshelfholds') || 0;
252
        my $onshelfholds    = $input->param('onshelfholds') || 0;
253
        $maxissueqty =~ s/\s//g;
253
        $maxissueqty =~ s/\s//g;
254
        $maxissueqty = undef if $maxissueqty !~ /^\d+/;
254
        $maxissueqty = undef if $maxissueqty !~ /^\d+/;
255
        $issuelength = $issuelength eq q{} ? undef : $issuelength;
256
255
257
        my $params = {
256
        my $params = {
258
            branchcode      => $branchcode,
257
            branchcode      => $branchcode,
Lines 286-293 if ( $step == 5 ) { Link Here
286
                overduefinescap                  => "",
285
                overduefinescap                  => "",
287
                rentaldiscount                   => 0,
286
                rentaldiscount                   => 0,
288
                reservesallowed                  => $reservesallowed,
287
                reservesallowed                  => $reservesallowed,
289
                suspension_chargeperiod          => undef,
288
                suspension_chargeperiod          => 1,
290
                decreaseloanholds                => undef,
289
                decreaseloanholds                => "",
290
                unseen_renewals_allowed          => "",
291
              }
291
              }
292
        };
292
        };
293
293
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-2 / +7 lines)
Lines 280-286 Link Here
280
                                    <td>[% suspension_chargeperiod | html %]</td>
280
                                    <td>[% suspension_chargeperiod | html %]</td>
281
                                    <td>[% renewalsallowed | html %]</td>
281
                                    <td>[% renewalsallowed | html %]</td>
282
                                    [% IF Koha.Preference('UnseenRenewals') %]
282
                                    [% IF Koha.Preference('UnseenRenewals') %]
283
                                        <td>[% unseenrenewalsallowed | html %]</td>
283
                                        <td>
284
                                            [% IF unseenrenewalsallowed.defined && unseenrenewalsallowed != '' %]
285
                                                [% unseenrenewalsallowed | html %]
286
                                            [% ELSE %]
287
                                                <span>Unlimited</span>
288
                                            [% END %]
289
                                        </td>
284
                                    [% END %]
290
                                    [% END %]
285
                                    <td>[% renewalperiod | html %]</td>
291
                                    <td>[% renewalperiod | html %]</td>
286
                                    <td>[% norenewalbefore | html %]</td>
292
                                    <td>[% norenewalbefore | html %]</td>
287
- 

Return to bug 29012