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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 476-482 sub TooMany { Link Here
476
        my $max_checkouts_allowed = $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef;
476
        my $max_checkouts_allowed = $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef;
477
        my $max_onsite_checkouts_allowed = $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef;
477
        my $max_onsite_checkouts_allowed = $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef;
478
478
479
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
479
        if ( $onsite_checkout and $max_onsite_checkouts_allowed ne '' ) {
480
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
480
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
481
                return {
481
                return {
482
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
482
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
Lines 2276-2282 sub _debar_user_on_return { Link Here
2276
            # If the max suspension days is < than the suspension days
2276
            # If the max suspension days is < than the suspension days
2277
            # the suspension days is limited to this maximum period.
2277
            # the suspension days is limited to this maximum period.
2278
            my $max_sd = $issuing_rule->{maxsuspensiondays};
2278
            my $max_sd = $issuing_rule->{maxsuspensiondays};
2279
            if ( defined $max_sd ) {
2279
            if ( defined $max_sd && $max_sd ne '' ) {
2280
                $max_sd = DateTime::Duration->new( days => $max_sd );
2280
                $max_sd = DateTime::Duration->new( days => $max_sd );
2281
                $suspension_days = $max_sd
2281
                $suspension_days = $max_sd
2282
                  if DateTime::Duration->compare( $max_sd, $suspension_days ) < 0;
2282
                  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 893-899 subtest "CanBookBeRenewed tests" => sub { Link Here
893
            }
893
            }
894
        });
894
        });
895
895
896
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
896
        Koha::CirculationRules->set_rules(
897
            {
898
                categorycode => undef,
899
                branchcode   => undef,
900
                itemtype     => undef,
901
                rules        => {
902
                    norenewalbefore       => 10,
903
                    no_auto_renewal_after => 11,
904
                }
905
            }
906
        );
897
907
898
        my $ten_days_before = dt_from_string->add( days => -10 );
908
        my $ten_days_before = dt_from_string->add( days => -10 );
899
        my $ten_days_ahead = dt_from_string->add( days => 10 );
909
        my $ten_days_ahead = dt_from_string->add( days => 10 );
Lines 2969-2994 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
2969
    plan tests => 3;
2979
    plan tests => 3;
2970
2980
2971
    # Set a simple circ policy
2981
    # Set a simple circ policy
2972
    $dbh->do('DELETE FROM issuingrules');
2982
    Koha::CirculationRules->set_rules(
2973
    $dbh->do(
2983
        {
2974
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
2984
            categorycode => undef,
2975
                                    issuelength, lengthunit,
2985
            branchcode   => undef,
2976
                                    renewalsallowed, renewalperiod,
2986
            itemtype     => undef,
2977
                                    norenewalbefore, auto_renew,
2987
            rules        => {
2978
                                    fine, chargeperiod)
2988
                reservesallowed => 25,
2979
          VALUES (?, ?, ?, ?,
2989
                issuelength     => 14,
2980
                  ?, ?,
2990
                lengthunit      => 'days',
2981
                  ?, ?,
2991
                renewalsallowed => 1,
2982
                  ?, ?,
2992
                renewalperiod   => 7,
2983
                  ?, ?
2993
                norenewalbefore => undef,
2984
                 )
2994
                auto_renew      => 0,
2985
        },
2995
                fine            => .10,
2986
        {},
2996
                chargeperiod    => 1,
2987
        '*',   '*', '*', 25,
2997
            }
2988
        14,  'days',
2998
        }
2989
        1,     7,
2990
        undef, 0,
2991
        .10,   1
2992
    );
2999
    );
2993
3000
2994
    my $five_days_go = output_pref({ dt => dt_from_string->add( days => 5 ), dateonly => 1});
3001
    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 163-169 subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { Link Here
163
        {
163
        {
164
            branchcode   => $branch->{branchcode},
164
            branchcode   => $branch->{branchcode},
165
            categorycode => $category->{categorycode},
165
            categorycode => $category->{categorycode},
166
            itemtype     => '*',
166
            itemtype     => undef,
167
            rules        => {
167
            rules        => {
168
                maxissueqty       => 1,
168
                maxissueqty       => 1,
169
                maxonsiteissueqty => undef,
169
                maxonsiteissueqty => undef,
170
- 

Return to bug 18936