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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 2885-2891 sub CanBookBeRenewed { Link Here
2885
2885
2886
        return ( 0, "too_unseen" )
2886
        return ( 0, "too_unseen" )
2887
          if C4::Context->preference('UnseenRenewals') &&
2887
          if C4::Context->preference('UnseenRenewals') &&
2888
            looks_like_number($issuing_rule->{unseen_renewals_allowed}) &&
2888
            $issuing_rule->{unseen_renewals_allowed} &&
2889
            $issuing_rule->{unseen_renewals_allowed} <= $issue->unseen_renewals;
2889
            $issuing_rule->{unseen_renewals_allowed} <= $issue->unseen_renewals;
2890
2890
2891
        my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2891
        my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
Lines 3099-3105 sub AddRenewal { Link Here
3099
                    rule_name    => 'unseen_renewals_allowed'
3099
                    rule_name    => 'unseen_renewals_allowed'
3100
                }
3100
                }
3101
            );
3101
            );
3102
            if (!$seen && $rule && looks_like_number($rule->rule_value)) {
3102
            if (!$seen && $rule && $rule->rule_value) {
3103
                $unseen_renewals++;
3103
                $unseen_renewals++;
3104
            } else {
3104
            } else {
3105
                # If the renewal is seen, unseen should revert to 0
3105
                # If the renewal is seen, unseen should revert to 0
(-)a/admin/smart-rules.pl (-5 / +6 lines)
Lines 263-269 elsif ($op eq 'add') { Link Here
263
    my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') );
263
    my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') );
264
    my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
264
    my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
265
    my $renewalsallowed  = $input->param('renewalsallowed');
265
    my $renewalsallowed  = $input->param('renewalsallowed');
266
    my $unseen_renewals_allowed  = strip_non_numeric( scalar $input->param('unseen_renewals_allowed') ) // '';
266
    my $unseen_renewals_allowed  = $input->param('unseen_renewals_allowed');
267
    my $renewalperiod    = $input->param('renewalperiod');
267
    my $renewalperiod    = $input->param('renewalperiod');
268
    my $norenewalbefore  = $input->param('norenewalbefore');
268
    my $norenewalbefore  = $input->param('norenewalbefore');
269
    $norenewalbefore = '' if $norenewalbefore =~ /^\s*$/;
269
    $norenewalbefore = '' if $norenewalbefore =~ /^\s*$/;
Lines 277-296 elsif ($op eq 'add') { Link Here
277
    my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') );
277
    my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') );
278
    my $holds_per_day    = strip_non_numeric( scalar $input->param('holds_per_day') );
278
    my $holds_per_day    = strip_non_numeric( scalar $input->param('holds_per_day') );
279
    my $onshelfholds     = $input->param('onshelfholds') || 0;
279
    my $onshelfholds     = $input->param('onshelfholds') || 0;
280
    my $issuelength  = $input->param('issuelength') || 0;
280
    my $issuelength  = $input->param('issuelength');
281
    $issuelength = $issuelength eq q{} ? undef : $issuelength;
281
    my $daysmode = $input->param('daysmode');
282
    my $daysmode = $input->param('daysmode');
282
    my $lengthunit  = $input->param('lengthunit');
283
    my $lengthunit  = $input->param('lengthunit');
283
    my $hardduedate = $input->param('hardduedate') || '';
284
    my $hardduedate = $input->param('hardduedate') || undef;
284
    $hardduedate = eval { dt_from_string( scalar $hardduedate ) } if ( $hardduedate );
285
    $hardduedate = eval { dt_from_string( scalar $hardduedate ) } if ( $hardduedate );
285
    $hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate );
286
    $hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate );
286
    my $hardduedatecompare = $input->param('hardduedatecompare');
287
    my $hardduedatecompare = $input->param('hardduedatecompare');
287
    my $rentaldiscount = $input->param('rentaldiscount') || 0;
288
    my $rentaldiscount = $input->param('rentaldiscount');
288
    my $opacitemholds = $input->param('opacitemholds') || 0;
289
    my $opacitemholds = $input->param('opacitemholds') || 0;
289
    my $article_requests = $input->param('article_requests') || 'no';
290
    my $article_requests = $input->param('article_requests') || 'no';
290
    my $overduefinescap = $input->param('overduefinescap') || '';
291
    my $overduefinescap = $input->param('overduefinescap') || '';
291
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
292
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
292
    my $note = $input->param('note');
293
    my $note = $input->param('note');
293
    my $decreaseloanholds = $input->param('decreaseloanholds') || '';
294
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
294
    my $recalls_allowed = $input->param('recalls_allowed');
295
    my $recalls_allowed = $input->param('recalls_allowed');
295
    my $recalls_per_record = $input->param('recalls_per_record');
296
    my $recalls_per_record = $input->param('recalls_per_record');
296
    my $on_shelf_recalls = $input->param('on_shelf_recalls');
297
    my $on_shelf_recalls = $input->param('on_shelf_recalls');
(-)a/installer/data/mysql/atomicupdate/bug_29012.pl (-33 lines)
Lines 1-33 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 230-236 if ( $step == 5 ) { Link Here
230
        my $categorycode    = $input->param('categorycode');
230
        my $categorycode    = $input->param('categorycode');
231
        my $itemtype        = $input->param('itemtype');
231
        my $itemtype        = $input->param('itemtype');
232
        my $maxissueqty     = $input->param('maxissueqty');
232
        my $maxissueqty     = $input->param('maxissueqty');
233
        my $issuelength     = $input->param('issuelength') || 0;
233
        my $issuelength     = $input->param('issuelength');
234
        my $lengthunit      = $input->param('lengthunit');
234
        my $lengthunit      = $input->param('lengthunit');
235
        my $renewalsallowed = $input->param('renewalsallowed');
235
        my $renewalsallowed = $input->param('renewalsallowed');
236
        my $renewalperiod   = $input->param('renewalperiod');
236
        my $renewalperiod   = $input->param('renewalperiod');
Lines 240-245 if ( $step == 5 ) { Link Here
240
        my $onshelfholds    = $input->param('onshelfholds') || 0;
240
        my $onshelfholds    = $input->param('onshelfholds') || 0;
241
        $maxissueqty =~ s/\s//g;
241
        $maxissueqty =~ s/\s//g;
242
        $maxissueqty = undef if $maxissueqty !~ /^\d+/;
242
        $maxissueqty = undef if $maxissueqty !~ /^\d+/;
243
        $issuelength = $issuelength eq q{} ? undef : $issuelength;
243
244
244
        my $params = {
245
        my $params = {
245
            branchcode      => $branchcode,
246
            branchcode      => $branchcode,
Lines 273-281 if ( $step == 5 ) { Link Here
273
                overduefinescap                  => "",
274
                overduefinescap                  => "",
274
                rentaldiscount                   => 0,
275
                rentaldiscount                   => 0,
275
                reservesallowed                  => $reservesallowed,
276
                reservesallowed                  => $reservesallowed,
276
                suspension_chargeperiod          => 1,
277
                suspension_chargeperiod          => undef,
277
                decreaseloanholds                => "",
278
                decreaseloanholds                => undef,
278
                unseen_renewals_allowed          => "",
279
                recalls_allowed                  => undef,
279
                recalls_allowed                  => undef,
280
                recalls_per_record               => undef,
280
                recalls_per_record               => undef,
281
                on_shelf_recalls                 => undef,
281
                on_shelf_recalls                 => undef,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-8 / +1 lines)
Lines 308-320 Link Here
308
                                    <td>[% suspension_chargeperiod | html %]</td>
308
                                    <td>[% suspension_chargeperiod | html %]</td>
309
                                    <td>[% renewalsallowed | html %]</td>
309
                                    <td>[% renewalsallowed | html %]</td>
310
                                    [% IF Koha.Preference('UnseenRenewals') %]
310
                                    [% IF Koha.Preference('UnseenRenewals') %]
311
                                        <td>
311
                                        <td>[% unseenrenewalsallowed | html %]</td>
312
                                            [% IF unseenrenewalsallowed.defined && unseenrenewalsallowed != '' %]
313
                                                [% unseenrenewalsallowed | html %]
314
                                            [% ELSE %]
315
                                                <span>Unlimited</span>
316
                                            [% END %]
317
                                        </td>
318
                                    [% END %]
312
                                    [% END %]
319
                                    <td>[% renewalperiod | html %]</td>
313
                                    <td>[% renewalperiod | html %]</td>
320
                                    <td>[% norenewalbefore | html %]</td>
314
                                    <td>[% norenewalbefore | html %]</td>
321
- 

Return to bug 29012