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

(-)a/admin/smart-rules.pl (+6 lines)
Lines 406-411 elsif ($op eq "add-branch-cat") { Link Here
406
    my $max_holds = $input->param('max_holds');
406
    my $max_holds = $input->param('max_holds');
407
    $max_holds =~ s/\s//g;
407
    $max_holds =~ s/\s//g;
408
    $max_holds = undef if $max_holds !~ /^\d+/;
408
    $max_holds = undef if $max_holds !~ /^\d+/;
409
    my $has_priority = $input->param('has_priority');
410
    $has_priority = $has_priority ? 1 : 0;
409
411
410
    if ($branch eq "*") {
412
    if ($branch eq "*") {
411
        if ($categorycode eq "*") {
413
        if ($categorycode eq "*") {
Lines 421-426 elsif ($op eq "add-branch-cat") { Link Here
421
                }
423
                }
422
            );
424
            );
423
        } else {
425
        } else {
426
424
            Koha::CirculationRules->set_rules(
427
            Koha::CirculationRules->set_rules(
425
                {
428
                {
426
                    categorycode => $categorycode,
429
                    categorycode => $categorycode,
Lines 429-434 elsif ($op eq "add-branch-cat") { Link Here
429
                        max_holds         => $max_holds,
432
                        max_holds         => $max_holds,
430
                        patron_maxissueqty       => $patron_maxissueqty,
433
                        patron_maxissueqty       => $patron_maxissueqty,
431
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
434
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
435
                        has_priority      => $has_priority,
432
                    }
436
                    }
433
                }
437
                }
434
            );
438
            );
Lines 442-447 elsif ($op eq "add-branch-cat") { Link Here
442
                    max_holds         => $max_holds,
446
                    max_holds         => $max_holds,
443
                    patron_maxissueqty       => $patron_maxissueqty,
447
                    patron_maxissueqty       => $patron_maxissueqty,
444
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
448
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
449
                    has_priority      => $has_priority,
445
                }
450
                }
446
            }
451
            }
447
        );
452
        );
Lines 454-459 elsif ($op eq "add-branch-cat") { Link Here
454
                    max_holds         => $max_holds,
459
                    max_holds         => $max_holds,
455
                    patron_maxissueqty       => $patron_maxissueqty,
460
                    patron_maxissueqty       => $patron_maxissueqty,
456
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
461
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
462
                    has_priority      => $has_priority,
457
                }
463
                }
458
            }
464
            }
459
        );
465
        );
(-)a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql (+5 lines)
Line 0 Link Here
1
ALTER TABLE default_borrower_circ_rules ADD has_priority INT(1) DEFAULT 0;
2
ALTER TABLE default_borrower_circ_rules DROP foreign key borrower_borrower_circ_rules_ibfk_1;
3
ALTER TABLE default_borrower_circ_rules DROP primary key;
4
ALTER TABLE default_borrower_circ_rules ADD primary key(categorycode, has_priority);
5
ALTER TABLE default_borrower_circ_rules ADD CONSTRAINT borrower_borrower_circ_rules_ibfk_1 FOREIGN KEY (categorycode) REFERENCES categories (categorycode) ON DELETE CASCADE ON UPDATE CASCADE;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (+15 lines)
Lines 672-677 Link Here
672
        <p>If the total amount loanable for a given patron category is left blank,
672
        <p>If the total amount loanable for a given patron category is left blank,
673
           no limit applies, except possibly for a limit you define for a specific item type.
673
           no limit applies, except possibly for a limit you define for a specific item type.
674
        </p>
674
        </p>
675
        <p>
676
            <b>Has priority: </b>If checked, the rule will override those for all branches. Else
677
            it behaves like a default one: used if no rule existe for the coresponding branch.
678
        </p>
675
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
679
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
676
            <input type="hidden" name="op" value="add-branch-cat" />
680
            <input type="hidden" name="op" value="add-branch-cat" />
677
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
681
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
Lines 681-686 Link Here
681
                    <th>Total current checkouts allowed</th>
685
                    <th>Total current checkouts allowed</th>
682
                    <th>Total current on-site checkouts allowed</th>
686
                    <th>Total current on-site checkouts allowed</th>
683
                    <th>Total holds allowed</th>
687
                    <th>Total holds allowed</th>
688
                    [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
684
                    <th>&nbsp;</th>
689
                    <th>&nbsp;</th>
685
                </tr>
690
                </tr>
686
                [% FOREACH c IN categorycodes %]
691
                [% FOREACH c IN categorycodes %]
Lines 719-724 Link Here
719
                                <span>Unlimited</span>
724
                                <span>Unlimited</span>
720
                            [% END %]
725
                            [% END %]
721
                        </td>
726
                        </td>
727
                        [% UNLESS humanbranch %]
728
                            <td>
729
                                <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
730
                            </td>
731
                        [% END %]
722
732
723
                        <td class="actions">
733
                        <td class="actions">
724
                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
734
                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
Lines 737-742 Link Here
737
                    <td><input name="patron_maxissueqty" size="3" type="text" /></td>
747
                    <td><input name="patron_maxissueqty" size="3" type="text" /></td>
738
                    <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
748
                    <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
739
                    <td><input name="max_holds" size="3" type="text" /></td>
749
                    <td><input name="max_holds" size="3" type="text" /></td>
750
                    [% UNLESS humanbranch %]
751
                        <td>
752
                            <input type="checkbox" name="has_priority"/>
753
                        </td>
754
                    [% END %]
740
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
755
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
741
                </tr>
756
                </tr>
742
            </table>
757
            </table>
(-)a/t/db_dependent/Circulation/Branch.t (-1 / +24 lines)
Lines 232-238 Koha::CirculationRules->set_rules( Link Here
232
    }
232
    }
233
);
233
);
234
234
235
$query = q|
236
    INSERT INTO default_borrower_circ_rules
237
    (categorycode, maxissueqty, maxonsiteissueqty, has_priority)
238
    VALUES( ?, ?, ?, ? )
239
|;
240
$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 0);
241
235
#Test GetBranchBorrowerCircRule
242
#Test GetBranchBorrowerCircRule
243
#
236
is_deeply(
244
is_deeply(
237
    GetBranchBorrowerCircRule(),
245
    GetBranchBorrowerCircRule(),
238
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
246
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
Lines 257-262 is_deeply( Link Here
257
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
265
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
258
);
266
);
259
267
268
$query = q|
269
    INSERT INTO default_borrower_circ_rules
270
    (categorycode, maxissueqty, maxonsiteissueqty, has_priority)
271
    VALUES( ?, ?, ?, ? )
272
|;
273
$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 1);
274
275
is_deeply(
276
    GetBranchBorrowerCircRule(
277
        $samplebranch1->{branchcode},
278
        $samplecat->{categorycode}
279
    ),
280
    { maxissueqty => 3, maxonsiteissueqty => 3, has_priority => 1 },
281
    "GetBranchBorrower returns the rule having priority"
282
);
283
260
#Test GetBranchItemRule
284
#Test GetBranchItemRule
261
my @lazy_any = ( 'hold_fulfillment_policy' => 'any' );
285
my @lazy_any = ( 'hold_fulfillment_policy' => 'any' );
262
is_deeply(
286
is_deeply(
263
- 

Return to bug 8137