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

(-)a/Koha/IssuingRules.pm (+16 lines)
Lines 58-63 sub get_effective_issuing_rule { Link Here
58
        $search_branchcode = { 'in' => [ $branchcode, $default ] };
58
        $search_branchcode = { 'in' => [ $branchcode, $default ] };
59
    }
59
    }
60
60
61
    # First check for priority rules
62
    if (my $rule = $self->search({
63
        categorycode => $search_categorycode,
64
        itemtype     => $search_itemtype,
65
        branchcode   => '*',
66
        has_priority => 1,
67
    }, {
68
        order_by => {
69
            -desc => ['branchcode', 'categorycode', 'itemtype']
70
        },
71
        rows => 1,
72
    })->single) {
73
        return $rule;
74
    }
75
76
61
    my $rule = $self->search({
77
    my $rule = $self->search({
62
        categorycode => $search_categorycode,
78
        categorycode => $search_categorycode,
63
        itemtype     => $search_itemtype,
79
        itemtype     => $search_itemtype,
(-)a/admin/smart-rules.pl (+2 lines)
Lines 121-126 elsif ($op eq 'add') { Link Here
121
    my $br = $branch; # branch
121
    my $br = $branch; # branch
122
    my $bor  = $input->param('categorycode'); # borrower category
122
    my $bor  = $input->param('categorycode'); # borrower category
123
    my $itemtype  = $input->param('itemtype');     # item type
123
    my $itemtype  = $input->param('itemtype');     # item type
124
    my $has_priority = $input->param('has_priority') ? 1 : 0;
124
    my $fine = $input->param('fine');
125
    my $fine = $input->param('fine');
125
    my $finedays     = $input->param('finedays');
126
    my $finedays     = $input->param('finedays');
126
    my $maxsuspensiondays = $input->param('maxsuspensiondays');
127
    my $maxsuspensiondays = $input->param('maxsuspensiondays');
Lines 165-170 elsif ($op eq 'add') { Link Here
165
        branchcode                    => $br,
166
        branchcode                    => $br,
166
        categorycode                  => $bor,
167
        categorycode                  => $bor,
167
        itemtype                      => $itemtype,
168
        itemtype                      => $itemtype,
169
        has_priority                  => $has_priority,
168
        fine                          => $fine,
170
        fine                          => $fine,
169
        finedays                      => $finedays,
171
        finedays                      => $finedays,
170
        maxsuspensiondays             => $maxsuspensiondays,
172
        maxsuspensiondays             => $maxsuspensiondays,
(-)a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql (+3 lines)
Line 0 Link Here
1
ALTER TABLE issuingrules ADD has_priority INT(1) DEFAULT 0 AFTER itemtype;
2
ALTER TABLE issuingrules DROP primary key;
3
ALTER TABLE issuingrules ADD primary key(branchcode , categorycode, itemtype, has_priority);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-4 / +28 lines)
Lines 65-70 Link Here
65
                <th>Patron category</th>
65
                <th>Patron category</th>
66
                <th>Item type</th>
66
                <th>Item type</th>
67
                <th>Actions</th>
67
                <th>Actions</th>
68
                [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
68
                <th>Current checkouts allowed</th>
69
                <th>Current checkouts allowed</th>
69
                <th>Current on-site checkouts allowed</th>
70
                <th>Current on-site checkouts allowed</th>
70
                <th>Loan period</th>
71
                <th>Loan period</th>
Lines 113-118 Link Here
113
                                                          <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a>
114
                                                          <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a>
114
                                                        </td>
115
                                                        </td>
115
116
117
                            [% UNLESS humanbranch %]
118
                                <td>
119
                                    [% IF rule.has_priority %]
120
                                        <input type="checkbox" checked="checked" disabled="disabled"/>
121
                                    [% ELSE %]
122
                                        <input type="checkbox" disabled="disabled"/>
123
                                    [% END %]
124
                                </td>
125
                            [% END %]
116
							<td>[% IF ( rule.unlimited_maxissueqty ) %]
126
							<td>[% IF ( rule.unlimited_maxissueqty ) %]
117
									Unlimited
127
									Unlimited
118
								[% ELSE %]
128
								[% ELSE %]
Lines 223-228 Link Here
223
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
233
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
224
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
234
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
225
                    </td>
235
                    </td>
236
                    [% UNLESS humanbranch %]
237
                        <td>
238
                            <input type="checkbox" name="has_priority" id="has_priority"/>
239
                        </td>
240
                    [% END %]
226
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
241
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
227
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
242
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
228
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
243
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
Lines 304-309 Link Here
304
                      <th>Patron category</th>
319
                      <th>Patron category</th>
305
                      <th>Item type</th>
320
                      <th>Item type</th>
306
                      <th>&nbsp;</th>
321
                      <th>&nbsp;</th>
322
                      [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
307
                      <th>Current checkouts allowed</th>
323
                      <th>Current checkouts allowed</th>
308
                      <th>Current on-site checkouts allowed</th>
324
                      <th>Current on-site checkouts allowed</th>
309
                      <th>Loan period</th>
325
                      <th>Loan period</th>
Lines 497-503 Link Here
497
                        </td>
513
                        </td>
498
                        [% UNLESS humanbranch %]
514
                        [% UNLESS humanbranch %]
499
                            <td>
515
                            <td>
500
                                <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
516
                                [% IF branch_cat_rule_loo.has_priority %]
517
                                    <input type="checkbox" checked="checked" disabled/>
518
                                [% ELSE %]
519
                                    <input type="checkbox" disabled/>
520
                                [% END %]
501
                            </td>
521
                            </td>
502
                        [% END %]
522
                        [% END %]
503
523
Lines 795-801 Link Here
795
                    itm = $(this).text();
815
                    itm = $(this).text();
796
                    itm = itm.replace(/^\s*|\s*$/g,'');
816
                    itm = itm.replace(/^\s*|\s*$/g,'');
797
                    var current_column = $("#edit_row td:eq("+i+")");
817
                    var current_column = $("#edit_row td:eq("+i+")");
798
                    if ( i == 7 ) {
818
                    if ( i == 8 ) {
799
                        // specific processing for the Hard due date column
819
                        // specific processing for the Hard due date column
800
                        var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
820
                        var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
801
                        var input_value = '';
821
                        var input_value = '';
Lines 806-816 Link Here
806
                        }
826
                        }
807
                        $(current_column).find("input[type='text']").val(input_value);
827
                        $(current_column).find("input[type='text']").val(input_value);
808
                        $(current_column).find("select").val(select_value);
828
                        $(current_column).find("select").val(select_value);
809
                    } else if ( i == 13 ) {
829
                    } else if ( i == 14 ) {
810
                        // specific processing for cap_fine_to_replacement_price
830
                        // specific processing for cap_fine_to_replacement_price
811
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
831
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
812
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
832
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
813
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
833
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
834
                    } else if ( i == 3 ) {
835
                        var has_priority = $(this).find("input[type='checkbox']");
836
                        $('#has_priority').prop('checked', has_priority.is(':checked') );
837
                        //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
814
                    } else {
838
                    } else {
815
                        $(current_column).find("input[type='text']").val(itm);
839
                        $(current_column).find("input[type='text']").val(itm);
816
                        // select the corresponding option
840
                        // select the corresponding option
Lines 831-837 Link Here
831
                            // Remove potential previous input added
855
                            // Remove potential previous input added
832
                            $(current_column).find("input").remove();
856
                            $(current_column).find("input").remove();
833
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
857
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
834
                        } else if ( i == 3 || i == 4 ) {
858
                        } else if ( i == 4 || i == 5 ) {
835
                            // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
859
                            // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
836
                            // The value is "Unlimited" (or an equivalent translated string)
860
                            // The value is "Unlimited" (or an equivalent translated string)
837
                            // an it should be set to an empty string
861
                            // an it should be set to an empty string
(-)a/t/db_dependent/Koha/IssuingRules.t (-2 / +28 lines)
Lines 34-40 $schema->storage->txn_begin; Link Here
34
my $builder      = t::lib::TestBuilder->new;
34
my $builder      = t::lib::TestBuilder->new;
35
35
36
subtest 'get_effective_issuing_rule' => sub {
36
subtest 'get_effective_issuing_rule' => sub {
37
    plan tests => 3;
37
    plan tests => 4;
38
38
39
    my $patron       = $builder->build({ source => 'Borrower' });
39
    my $patron       = $builder->build({ source => 'Borrower' });
40
    my $item     = $builder->build({ source => 'Item' });
40
    my $item     = $builder->build({ source => 'Item' });
Lines 43-48 subtest 'get_effective_issuing_rule' => sub { Link Here
43
    my $itemtype     = $item->{'itype'};
43
    my $itemtype     = $item->{'itype'};
44
    my $branchcode   = $item->{'homebranch'};
44
    my $branchcode   = $item->{'homebranch'};
45
45
46
    subtest 'Priority rule' => sub {
47
        plan tests => 3;
48
49
        Koha::IssuingRules->delete;
50
51
        ok(Koha::IssuingRule->new({
52
            branchcode => $branchcode,
53
            categorycode => $categorycode,
54
            itemtype => $itemtype,
55
        })->store, "Given I added an issuing rule branchcode => $branchcode,'
56
           .' categorycode => $categorycode, itemtype => $itemtype,");
57
58
        ok(Koha::IssuingRule->new({
59
            branchcode => '*',
60
            categorycode => $categorycode,
61
            itemtype => $itemtype,
62
            has_priority => 1,
63
        })->store, "Add a priority rule.");
64
65
        my $rule = Koha::IssuingRules->get_effective_issuing_rule({
66
            branchcode   => $branchcode,
67
            categorycode => $categorycode,
68
            itemtype     => $itemtype,
69
        });
70
        is($rule->has_priority, 1, 'Priority rule should be returned');
71
    };
72
46
    subtest 'Call with undefined values' => sub {
73
    subtest 'Call with undefined values' => sub {
47
        plan tests => 4;
74
        plan tests => 4;
48
75
49
- 

Return to bug 8137