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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 473-479 sub TooMany { Link Here
473
        my $max_checkouts_allowed = $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef;
473
        my $max_checkouts_allowed = $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef;
474
        my $max_onsite_checkouts_allowed = $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef;
474
        my $max_onsite_checkouts_allowed = $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef;
475
475
476
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
476
        if ( $onsite_checkout and $max_onsite_checkouts_allowed ne '' ) {
477
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
477
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
478
                return {
478
                return {
479
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
479
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
Lines 2303-2309 sub _calculate_new_debar_dt { Link Here
2303
        # If the max suspension days is < than the suspension days
2303
        # If the max suspension days is < than the suspension days
2304
        # the suspension days is limited to this maximum period.
2304
        # the suspension days is limited to this maximum period.
2305
        my $max_sd = $issuing_rule->{maxsuspensiondays};
2305
        my $max_sd = $issuing_rule->{maxsuspensiondays};
2306
        if ( defined $max_sd ) {
2306
        if ( defined $max_sd && $max_sd ne '' ) {
2307
            $max_sd = DateTime::Duration->new( days => $max_sd );
2307
            $max_sd = DateTime::Duration->new( days => $max_sd );
2308
            $suspension_days = $max_sd
2308
            $suspension_days = $max_sd
2309
              if DateTime::Duration->compare( $max_sd, $suspension_days ) < 0;
2309
              if DateTime::Duration->compare( $max_sd, $suspension_days ) < 0;
(-)a/admin/smart-rules.pl (-4 / +5 lines)
Lines 253-258 elsif ($op eq 'add') { Link Here
253
    my $finedays     = $input->param('finedays');
253
    my $finedays     = $input->param('finedays');
254
    my $maxsuspensiondays = $input->param('maxsuspensiondays');
254
    my $maxsuspensiondays = $input->param('maxsuspensiondays');
255
    $maxsuspensiondays = undef if $maxsuspensiondays eq q||;
255
    $maxsuspensiondays = undef if $maxsuspensiondays eq q||;
256
    $maxsuspensiondays = '' if $maxsuspensiondays eq q||;
256
    my $suspension_chargeperiod = $input->param('suspension_chargeperiod') || 1;
257
    my $suspension_chargeperiod = $input->param('suspension_chargeperiod') || 1;
257
    my $firstremind  = $input->param('firstremind');
258
    my $firstremind  = $input->param('firstremind');
258
    my $chargeperiod = $input->param('chargeperiod');
259
    my $chargeperiod = $input->param('chargeperiod');
Lines 262-272 elsif ($op eq 'add') { Link Here
262
    my $renewalsallowed  = $input->param('renewalsallowed');
263
    my $renewalsallowed  = $input->param('renewalsallowed');
263
    my $renewalperiod    = $input->param('renewalperiod');
264
    my $renewalperiod    = $input->param('renewalperiod');
264
    my $norenewalbefore  = $input->param('norenewalbefore');
265
    my $norenewalbefore  = $input->param('norenewalbefore');
265
    $norenewalbefore = undef if $norenewalbefore =~ /^\s*$/;
266
    $norenewalbefore = '' if $norenewalbefore =~ /^\s*$/;
266
    my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
267
    my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
267
    my $no_auto_renewal_after = $input->param('no_auto_renewal_after');
268
    my $no_auto_renewal_after = $input->param('no_auto_renewal_after');
268
    $no_auto_renewal_after = undef if $no_auto_renewal_after =~ /^\s*$/;
269
    $no_auto_renewal_after = '' if $no_auto_renewal_after =~ /^\s*$/;
269
    my $no_auto_renewal_after_hard_limit = $input->param('no_auto_renewal_after_hard_limit') || undef;
270
    my $no_auto_renewal_after_hard_limit = $input->param('no_auto_renewal_after_hard_limit') || '';
270
    $no_auto_renewal_after_hard_limit = eval { dt_from_string( $input->param('no_auto_renewal_after_hard_limit') ) } if ( $no_auto_renewal_after_hard_limit );
271
    $no_auto_renewal_after_hard_limit = eval { dt_from_string( $input->param('no_auto_renewal_after_hard_limit') ) } if ( $no_auto_renewal_after_hard_limit );
271
    $no_auto_renewal_after_hard_limit = output_pref( { dt => $no_auto_renewal_after_hard_limit, dateonly => 1, dateformat => 'iso' } ) if ( $no_auto_renewal_after_hard_limit );
272
    $no_auto_renewal_after_hard_limit = output_pref( { dt => $no_auto_renewal_after_hard_limit, dateonly => 1, dateformat => 'iso' } ) if ( $no_auto_renewal_after_hard_limit );
272
    my $reservesallowed  = $input->param('reservesallowed');
273
    my $reservesallowed  = $input->param('reservesallowed');
Lines 289-295 elsif ($op eq 'add') { Link Here
289
    my $rentaldiscount = $input->param('rentaldiscount');
290
    my $rentaldiscount = $input->param('rentaldiscount');
290
    my $opacitemholds = $input->param('opacitemholds') || 0;
291
    my $opacitemholds = $input->param('opacitemholds') || 0;
291
    my $article_requests = $input->param('article_requests') || 'no';
292
    my $article_requests = $input->param('article_requests') || 'no';
292
    my $overduefinescap = $input->param('overduefinescap') || undef;
293
    my $overduefinescap = $input->param('overduefinescap') || '';
293
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
294
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
294
    my $note = $input->param('note');
295
    my $note = $input->param('note');
295
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
296
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
(-)a/installer/data/mysql/atomicupdate/bug_18936.perl (-1 / +3 lines)
Lines 27-39 if( CheckVersion( $DBversion ) ) { Link Here
27
        onshelfholds
27
        onshelfholds
28
        opacitemholds
28
        opacitemholds
29
        article_requests
29
        article_requests
30
        maxissueqty
31
        maxonsiteissueqty
30
    );
32
    );
31
33
32
    if ( column_exists( 'issuingrules', 'categorycode' ) ) {
34
    if ( column_exists( 'issuingrules', 'categorycode' ) ) {
33
        foreach my $column ( @columns ) {
35
        foreach my $column ( @columns ) {
34
            $dbh->do("
36
            $dbh->do("
35
                INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
37
                INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
36
                SELECT categorycode, branchcode, itemtype, \'$column\', $column
38
                SELECT categorycode, branchcode, itemtype, \'$column\', COALESCE( $column, '' )
37
                FROM issuingrules
39
                FROM issuingrules
38
            ");
40
            ");
39
        }
41
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-2 / +2 lines)
Lines 185-198 Link Here
185
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
185
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
186
                                    </td>
186
                                    </td>
187
                                    <td>
187
                                    <td>
188
                                        [% IF maxissueqty  %]
188
                                        [% IF maxissueqty.defined && maxissueqty != '' %]
189
                                            [% maxissueqty %]
189
                                            [% maxissueqty %]
190
                                        [% ELSE %]
190
                                        [% ELSE %]
191
                                            <span>Unlimited</span>
191
                                            <span>Unlimited</span>
192
                                        [% END %]
192
                                        [% END %]
193
                                    </td>
193
                                    </td>
194
                                    <td>
194
                                    <td>
195
                                        [% IF maxonsiteissueqty  %]
195
                                        [% IF maxonsiteissueqty.defined && maxonsiteissueqty != ''  %]
196
                                            [% maxonsiteissueqty %]
196
                                            [% maxonsiteissueqty %]
197
                                        [% ELSE %]
197
                                        [% ELSE %]
198
                                            <span>Unlimited</span>
198
                                            <span>Unlimited</span>
(-)a/t/db_dependent/Circulation.t (-21 / +28 lines)
Lines 914-920 subtest "CanBookBeRenewed tests" => sub { Link Here
914
            }
914
            }
915
        });
915
        });
916
916
917
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
917
        Koha::CirculationRules->set_rules(
918
            {
919
                categorycode => undef,
920
                branchcode   => undef,
921
                itemtype     => undef,
922
                rules        => {
923
                    norenewalbefore       => 10,
924
                    no_auto_renewal_after => 11,
925
                }
926
            }
927
        );
918
928
919
        my $ten_days_before = dt_from_string->add( days => -10 );
929
        my $ten_days_before = dt_from_string->add( days => -10 );
920
        my $ten_days_ahead = dt_from_string->add( days => 10 );
930
        my $ten_days_ahead = dt_from_string->add( days => 10 );
Lines 2892-2917 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
2892
    plan tests => 3;
2902
    plan tests => 3;
2893
2903
2894
    # Set a simple circ policy
2904
    # Set a simple circ policy
2895
    $dbh->do('DELETE FROM issuingrules');
2905
    Koha::CirculationRules->set_rules(
2896
    $dbh->do(
2906
        {
2897
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
2907
            categorycode => undef,
2898
                                    issuelength, lengthunit,
2908
            branchcode   => undef,
2899
                                    renewalsallowed, renewalperiod,
2909
            itemtype     => undef,
2900
                                    norenewalbefore, auto_renew,
2910
            rules        => {
2901
                                    fine, chargeperiod)
2911
                reservesallowed => 25,
2902
          VALUES (?, ?, ?, ?,
2912
                issuelength     => 14,
2903
                  ?, ?,
2913
                lengthunit      => 'days',
2904
                  ?, ?,
2914
                renewalsallowed => 1,
2905
                  ?, ?,
2915
                renewalperiod   => 7,
2906
                  ?, ?
2916
                norenewalbefore => undef,
2907
                 )
2917
                auto_renew      => 0,
2908
        },
2918
                fine            => .10,
2909
        {},
2919
                chargeperiod    => 1,
2910
        '*',   '*', '*', 25,
2920
            }
2911
        14,  'days',
2921
        }
2912
        1,     7,
2913
        undef, 0,
2914
        .10,   1
2915
    );
2922
    );
2916
2923
2917
    my $five_days_go = output_pref({ dt => dt_from_string->add( days => 5 ), dateonly => 1});
2924
    my $five_days_go = output_pref({ dt => dt_from_string->add( days => 5 ), dateonly => 1});
(-)a/t/db_dependent/Circulation/TooMany.t (-2 / +1 lines)
Lines 164-170 subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { Link Here
164
        {
164
        {
165
            branchcode   => $branch->{branchcode},
165
            branchcode   => $branch->{branchcode},
166
            categorycode => $category->{categorycode},
166
            categorycode => $category->{categorycode},
167
            itemtype     => '*',
167
            itemtype     => undef,
168
            rules        => {
168
            rules        => {
169
                maxissueqty       => 1,
169
                maxissueqty       => 1,
170
                maxonsiteissueqty => undef,
170
                maxonsiteissueqty => undef,
171
- 

Return to bug 18936