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

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 416-422 sub CanItemBeReserved { Link Here
416
            rule_name    => 'max_holds',
416
            rule_name    => 'max_holds',
417
        }
417
        }
418
    );
418
    );
419
    if ( $rule ) {
419
    if ( $rule && defined( $rule->rule_value ) && $rule->rule_value ne '' ) {
420
        my $total_holds_count = Koha::Holds->search(
420
        my $total_holds_count = Koha::Holds->search(
421
            {
421
            {
422
                borrowernumber => $borrower->{borrowernumber}
422
                borrowernumber => $borrower->{borrowernumber}
(-)a/Koha/CirculationRules.pm (-1 / +4 lines)
Lines 136-142 sub set_rule { Link Here
136
136
137
sub set_rules {
137
sub set_rules {
138
    my ( $self, $params ) = @_;
138
    my ( $self, $params ) = @_;
139
    warn Data::Dumper::Dumper( $params );
140
139
141
    my $branchcode   = $params->{branchcode};
140
    my $branchcode   = $params->{branchcode};
142
    my $categorycode = $params->{categorycode};
141
    my $categorycode = $params->{categorycode};
Lines 164-169 sub _type { Link Here
164
    return 'CirculationRule';
163
    return 'CirculationRule';
165
}
164
}
166
165
166
=head3 object_class
167
168
=cut
169
167
sub object_class {
170
sub object_class {
168
    return 'Koha::CirculationRule';
171
    return 'Koha::CirculationRule';
169
}
172
}
(-)a/admin/smart-rules.pl (-3 / +15 lines)
Lines 226-237 elsif ($op eq "set-branch-defaults") { Link Here
226
    my $holdallowed   = $input->param('holdallowed');
226
    my $holdallowed   = $input->param('holdallowed');
227
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
227
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
228
    my $returnbranch  = $input->param('returnbranch');
228
    my $returnbranch  = $input->param('returnbranch');
229
    my $max_holds = $input->param('max_holds');
229
    $maxissueqty =~ s/\s//g;
230
    $maxissueqty =~ s/\s//g;
230
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
231
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
231
    $maxonsiteissueqty =~ s/\s//g;
232
    $maxonsiteissueqty =~ s/\s//g;
232
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
233
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
233
    $holdallowed =~ s/\s//g;
234
    $holdallowed =~ s/\s//g;
234
    $holdallowed = undef if $holdallowed !~ /^\d+/;
235
    $holdallowed = undef if $holdallowed !~ /^\d+/;
236
    $max_holds =~ s/\s//g;
237
    $max_holds = '' if $max_holds !~ /^\d+/;
235
238
236
    if ($branch eq "*") {
239
    if ($branch eq "*") {
237
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
240
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
Lines 267-272 elsif ($op eq "set-branch-defaults") { Link Here
267
            $sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch);
270
            $sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch);
268
        }
271
        }
269
    }
272
    }
273
    Koha::CirculationRules->set_rule(
274
        {
275
            branchcode   => $branch,
276
            categorycode => '*',
277
            itemtype     => undef,
278
            rule_name    => 'max_holds',
279
            rule_value   => $max_holds,
280
        }
281
    );
270
}
282
}
271
elsif ($op eq "add-branch-cat") {
283
elsif ($op eq "add-branch-cat") {
272
    my $categorycode  = $input->param('categorycode');
284
    my $categorycode  = $input->param('categorycode');
Lines 278-284 elsif ($op eq "add-branch-cat") { Link Here
278
    $maxonsiteissueqty =~ s/\s//g;
290
    $maxonsiteissueqty =~ s/\s//g;
279
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
291
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
280
    $max_holds =~ s/\s//g;
292
    $max_holds =~ s/\s//g;
281
    $max_holds = undef if $max_holds !~ /^\d+/;
293
    $max_holds = '' if $max_holds !~ /^\d+/;
282
294
283
    if ($branch eq "*") {
295
    if ($branch eq "*") {
284
        if ($categorycode eq "*") {
296
        if ($categorycode eq "*") {
Lines 319-325 elsif ($op eq "add-branch-cat") { Link Here
319
            my $sth_insert = $dbh->prepare(q|
331
            my $sth_insert = $dbh->prepare(q|
320
                INSERT INTO default_borrower_circ_rules
332
                INSERT INTO default_borrower_circ_rules
321
                    (categorycode, maxissueqty, maxonsiteissueqty)
333
                    (categorycode, maxissueqty, maxonsiteissueqty)
322
                    VALUES (?, ?, ?, ?)
334
                    VALUES (?, ?, ?)
323
            |);
335
            |);
324
            my $sth_update = $dbh->prepare(q|
336
            my $sth_update = $dbh->prepare(q|
325
                UPDATE default_borrower_circ_rules
337
                UPDATE default_borrower_circ_rules
Lines 337-343 elsif ($op eq "add-branch-cat") { Link Here
337
349
338
            Koha::CirculationRules->set_rule(
350
            Koha::CirculationRules->set_rule(
339
                {
351
                {
340
                    branchcode   => undef,
352
                    branchcode   => '*',
341
                    categorycode => $categorycode,
353
                    categorycode => $categorycode,
342
                    itemtype     => undef,
354
                    itemtype     => undef,
343
                    rule_name    => 'max_holds',
355
                    rule_name    => 'max_holds',
(-)a/installer/data/mysql/atomicupdate/bug_18887.perl (-2 / +2 lines)
Lines 20-31 if( CheckVersion( $DBversion ) ) { Link Here
20
20
21
    $dbh->do(q{
21
    $dbh->do(q{
22
        INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
22
        INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
23
        SELECT branchcode, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules
23
        SELECT branchcode, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM branch_borrower_circ_rules
24
    });
24
    });
25
25
26
    $dbh->do(q{
26
    $dbh->do(q{
27
        INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
27
        INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
28
        SELECT NULL, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules
28
        SELECT NULL, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM default_borrower_circ_rules
29
    });
29
    });
30
30
31
    $dbh->do(q{
31
    $dbh->do(q{
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-2 / +6 lines)
Lines 350-355 Link Here
350
                    <th>&nbsp;</th>
350
                    <th>&nbsp;</th>
351
                    <th>Total current checkouts allowed</th>
351
                    <th>Total current checkouts allowed</th>
352
                    <th>Total current on-site checkouts allowed</th>
352
                    <th>Total current on-site checkouts allowed</th>
353
                    <th>Maximum total holds allowed (count)</th>
353
                    <th>Hold policy</th>
354
                    <th>Hold policy</th>
354
                    <th>Hold pickup library match</th>
355
                    <th>Hold pickup library match</th>
355
                    <th>Return policy</th>
356
                    <th>Return policy</th>
Lines 359-364 Link Here
359
                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
360
                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
360
                    <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty %]"/></td>
361
                    <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty %]"/></td>
361
                    <td><input type="text" name="maxonsiteissueqty" size="3" value="[% default_maxonsiteissueqty %]"/></td>
362
                    <td><input type="text" name="maxonsiteissueqty" size="3" value="[% default_maxonsiteissueqty %]"/></td>
363
                    <td>
364
                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
365
                        <input name="max_holds" size="3" value="[% rule_value %]" />
366
                    </td>
362
                    <td>
367
                    <td>
363
                        <select name="holdallowed">
368
                        <select name="holdallowed">
364
                            [% IF ( default_holdallowed_any ) %]
369
                            [% IF ( default_holdallowed_any ) %]
Lines 496-502 Link Here
496
                        </td>
501
                        </td>
497
                        <td>
502
                        <td>
498
                            [% SET rule_value = CirculationRules.Get( branch_cat_rule_loo.branchcode, branch_cat_rule_loo.categorycode, branch_cat_rule_loo.itemtype, 'max_holds' ) %]
503
                            [% SET rule_value = CirculationRules.Get( branch_cat_rule_loo.branchcode, branch_cat_rule_loo.categorycode, branch_cat_rule_loo.itemtype, 'max_holds' ) %]
499
                            [% IF rule_value  %]
504
                            [% IF rule_value.defined && rule_value != '' %]
500
                                [% rule_value %]
505
                                [% rule_value %]
501
                            [% ELSE %]
506
                            [% ELSE %]
502
                                Unlimited
507
                                Unlimited
503
- 

Return to bug 18887