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

(-)a/admin/smart-rules.pl (+6 lines)
Lines 409-414 elsif ($op eq "add-branch-cat") { Link Here
409
    my $max_holds = $input->param('max_holds');
409
    my $max_holds = $input->param('max_holds');
410
    $max_holds =~ s/\s//g;
410
    $max_holds =~ s/\s//g;
411
    $max_holds = undef if $max_holds !~ /^\d+/;
411
    $max_holds = undef if $max_holds !~ /^\d+/;
412
    my $has_priority = $input->param('has_priority');
413
    $has_priority = $has_priority ? 1 : 0;
412
414
413
    if ($branch eq "*") {
415
    if ($branch eq "*") {
414
        if ($categorycode eq "*") {
416
        if ($categorycode eq "*") {
Lines 424-429 elsif ($op eq "add-branch-cat") { Link Here
424
                }
426
                }
425
            );
427
            );
426
        } else {
428
        } else {
429
427
            Koha::CirculationRules->set_rules(
430
            Koha::CirculationRules->set_rules(
428
                {
431
                {
429
                    categorycode => $categorycode,
432
                    categorycode => $categorycode,
Lines 432-437 elsif ($op eq "add-branch-cat") { Link Here
432
                        max_holds         => $max_holds,
435
                        max_holds         => $max_holds,
433
                        patron_maxissueqty       => $patron_maxissueqty,
436
                        patron_maxissueqty       => $patron_maxissueqty,
434
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
437
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
438
                        has_priority      => $has_priority,
435
                    }
439
                    }
436
                }
440
                }
437
            );
441
            );
Lines 445-450 elsif ($op eq "add-branch-cat") { Link Here
445
                    max_holds         => $max_holds,
449
                    max_holds         => $max_holds,
446
                    patron_maxissueqty       => $patron_maxissueqty,
450
                    patron_maxissueqty       => $patron_maxissueqty,
447
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
451
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
452
                    has_priority      => $has_priority,
448
                }
453
                }
449
            }
454
            }
450
        );
455
        );
Lines 457-462 elsif ($op eq "add-branch-cat") { Link Here
457
                    max_holds         => $max_holds,
462
                    max_holds         => $max_holds,
458
                    patron_maxissueqty       => $patron_maxissueqty,
463
                    patron_maxissueqty       => $patron_maxissueqty,
459
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
464
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
465
                    has_priority      => $has_priority,
460
                }
466
                }
461
            }
467
            }
462
        );
468
        );
(-)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 690-695 Link Here
690
        <p>If the total amount loanable for a given patron category is left blank,
690
        <p>If the total amount loanable for a given patron category is left blank,
691
           no limit applies, except possibly for a limit you define for a specific item type.
691
           no limit applies, except possibly for a limit you define for a specific item type.
692
        </p>
692
        </p>
693
        <p>
694
            <b>Has priority: </b>If checked, the rule will override those for all branches. Else
695
            it behaves like a default one: used if no rule existe for the coresponding branch.
696
        </p>
693
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
697
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
694
            <input type="hidden" name="op" value="add-branch-cat" />
698
            <input type="hidden" name="op" value="add-branch-cat" />
695
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
699
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
Lines 699-704 Link Here
699
                    <th>Total current checkouts allowed</th>
703
                    <th>Total current checkouts allowed</th>
700
                    <th>Total current on-site checkouts allowed</th>
704
                    <th>Total current on-site checkouts allowed</th>
701
                    <th>Total holds allowed</th>
705
                    <th>Total holds allowed</th>
706
                    [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
702
                    <th>&nbsp;</th>
707
                    <th>&nbsp;</th>
703
                </tr>
708
                </tr>
704
                [% FOREACH c IN categorycodes %]
709
                [% FOREACH c IN categorycodes %]
Lines 737-742 Link Here
737
                                <span>Unlimited</span>
742
                                <span>Unlimited</span>
738
                            [% END %]
743
                            [% END %]
739
                        </td>
744
                        </td>
745
                        [% UNLESS humanbranch %]
746
                            <td>
747
                                <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
748
                            </td>
749
                        [% END %]
740
750
741
                        <td class="actions">
751
                        <td class="actions">
742
                            <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>
752
                            <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 755-760 Link Here
755
                    <td><input name="patron_maxissueqty" size="3" type="text" /></td>
765
                    <td><input name="patron_maxissueqty" size="3" type="text" /></td>
756
                    <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
766
                    <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
757
                    <td><input name="max_holds" size="3" type="text" /></td>
767
                    <td><input name="max_holds" size="3" type="text" /></td>
768
                    [% UNLESS humanbranch %]
769
                        <td>
770
                            <input type="checkbox" name="has_priority"/>
771
                        </td>
772
                    [% END %]
758
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
773
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
759
                </tr>
774
                </tr>
760
            </table>
775
            </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