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 122-127 elsif ($op eq 'add') { Link Here
122
    my $br = $branch; # branch
122
    my $br = $branch; # branch
123
    my $bor  = $input->param('categorycode'); # borrower category
123
    my $bor  = $input->param('categorycode'); # borrower category
124
    my $itemtype  = $input->param('itemtype');     # item type
124
    my $itemtype  = $input->param('itemtype');     # item type
125
    my $has_priority = $input->param('has_priority') ? 1 : 0;
125
    my $fine = $input->param('fine');
126
    my $fine = $input->param('fine');
126
    my $finedays     = $input->param('finedays');
127
    my $finedays     = $input->param('finedays');
127
    my $maxsuspensiondays = $input->param('maxsuspensiondays');
128
    my $maxsuspensiondays = $input->param('maxsuspensiondays');
Lines 166-171 elsif ($op eq 'add') { Link Here
166
        branchcode                    => $br,
167
        branchcode                    => $br,
167
        categorycode                  => $bor,
168
        categorycode                  => $bor,
168
        itemtype                      => $itemtype,
169
        itemtype                      => $itemtype,
170
        has_priority                  => $has_priority,
169
        fine                          => $fine,
171
        fine                          => $fine,
170
        finedays                      => $finedays,
172
        finedays                      => $finedays,
171
        maxsuspensiondays             => $maxsuspensiondays,
173
        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 51-57 $(document).ready(function() { Link Here
51
                itm = $(this).text();
51
                itm = $(this).text();
52
                itm = itm.replace(/^\s*|\s*$/g,'');
52
                itm = itm.replace(/^\s*|\s*$/g,'');
53
                var current_column = $("#edit_row td:eq("+i+")");
53
                var current_column = $("#edit_row td:eq("+i+")");
54
                if ( i == 6 ) {
54
                if ( i == 7 ) {
55
                    // specific processing for the Hard due date column
55
                    // specific processing for the Hard due date column
56
                    var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
56
                    var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
57
                    var input_value = '';
57
                    var input_value = '';
Lines 62-72 $(document).ready(function() { Link Here
62
                    }
62
                    }
63
                    $(current_column).find("input[type='text']").val(input_value);
63
                    $(current_column).find("input[type='text']").val(input_value);
64
                    $(current_column).find("select").val(select_value);
64
                    $(current_column).find("select").val(select_value);
65
                } else if ( i == 12 ) {
65
                } else if ( i == 13 ) {
66
                    // specific processing for cap_fine_to_replacement_price
66
                    // specific processing for cap_fine_to_replacement_price
67
                    var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
67
                    var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
68
                    $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
68
                    $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
69
                    $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
69
                    $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
70
                } else if ( i == 2 ) {
71
                    var has_priority = $(this).find("input[type='checkbox']");
72
                    $('#has_priority').prop('checked', has_priority.is(':checked') );
73
                    //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
70
                } else {
74
                } else {
71
                    $(current_column).find("input[type='text']").val(itm);
75
                    $(current_column).find("input[type='text']").val(itm);
72
                    // select the corresponding option
76
                    // select the corresponding option
Lines 87-93 $(document).ready(function() { Link Here
87
                        // Remove potential previous input added
91
                        // Remove potential previous input added
88
                        $(current_column).find("input").remove();
92
                        $(current_column).find("input").remove();
89
                        $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
93
                        $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
90
                    } else if ( i == 2 || i == 3 ) {
94
                    } else if ( i == 3 || i == 4 ) {
91
                        // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
95
                        // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
92
                        // The value is "Unlimited" (or an equivalent translated string)
96
                        // The value is "Unlimited" (or an equivalent translated string)
93
                        // an it should be set to an empty string
97
                        // an it should be set to an empty string
Lines 168-173 $(document).ready(function() { Link Here
168
            <tr>
172
            <tr>
169
                <th>Patron category</th>
173
                <th>Patron category</th>
170
                <th>Item type</th>
174
                <th>Item type</th>
175
                [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
171
                <th>Current checkouts allowed</th>
176
                <th>Current checkouts allowed</th>
172
                <th>Current on-site checkouts allowed</th>
177
                <th>Current on-site checkouts allowed</th>
173
                <th>Loan period</th>
178
                <th>Loan period</th>
Lines 211-216 $(document).ready(function() { Link Here
211
									[% rule.translated_description %]
216
									[% rule.translated_description %]
212
								[% END %]
217
								[% END %]
213
							</td>
218
							</td>
219
                            [% UNLESS humanbranch %]
220
                                <td>
221
                                    [% IF rule.has_priority %]
222
                                        <input type="checkbox" checked="checked" disabled="disabled"/>
223
                                    [% ELSE %]
224
                                        <input type="checkbox" disabled="disabled"/>
225
                                    [% END %]
226
                                </td>
227
                            [% END %]
214
							<td>[% IF ( rule.unlimited_maxissueqty ) %]
228
							<td>[% IF ( rule.unlimited_maxissueqty ) %]
215
									Unlimited
229
									Unlimited
216
								[% ELSE %]
230
								[% ELSE %]
Lines 315-320 $(document).ready(function() { Link Here
315
                        [% END %]
329
                        [% END %]
316
                        </select>
330
                        </select>
317
                    </td>
331
                    </td>
332
                    [% UNLESS humanbranch %]
333
                        <td>
334
                            <input type="checkbox" name="has_priority" id="has_priority"/>
335
                        </td>
336
                    [% END %]
318
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
337
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
319
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
338
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
320
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
339
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
Lines 395-400 $(document).ready(function() { Link Here
395
                    <tr>
414
                    <tr>
396
                      <th>Patron category</th>
415
                      <th>Patron category</th>
397
                      <th>Item type</th>
416
                      <th>Item type</th>
417
                      [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
398
                      <th>Current checkouts allowed</th>
418
                      <th>Current checkouts allowed</th>
399
                      <th>Current on-site checkouts allowed</th>
419
                      <th>Current on-site checkouts allowed</th>
400
                      <th>Loan period</th>
420
                      <th>Loan period</th>
Lines 588-594 $(document).ready(function() { Link Here
588
                        </td>
608
                        </td>
589
                        [% UNLESS humanbranch %]
609
                        [% UNLESS humanbranch %]
590
                            <td>
610
                            <td>
591
                                <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
611
                                [% IF branch_cat_rule_loo.has_priority %]
612
                                    <input type="checkbox" checked="checked" disabled/>
613
                                [% ELSE %]
614
                                    <input type="checkbox" disabled/>
615
                                [% END %]
592
                            </td>
616
                            </td>
593
                        [% END %]
617
                        [% END %]
594
618
(-)a/t/db_dependent/Koha/IssuingRules.t (-2 / +28 lines)
Lines 33-39 $schema->storage->txn_begin; Link Here
33
my $builder      = t::lib::TestBuilder->new;
33
my $builder      = t::lib::TestBuilder->new;
34
34
35
subtest 'get_effective_issuing_rule' => sub {
35
subtest 'get_effective_issuing_rule' => sub {
36
    plan tests => 3;
36
    plan tests => 4;
37
37
38
    my $patron       = $builder->build({ source => 'Borrower' });
38
    my $patron       = $builder->build({ source => 'Borrower' });
39
    my $item     = $builder->build({ source => 'Item' });
39
    my $item     = $builder->build({ source => 'Item' });
Lines 42-47 subtest 'get_effective_issuing_rule' => sub { Link Here
42
    my $itemtype     = $item->{'itype'};
42
    my $itemtype     = $item->{'itype'};
43
    my $branchcode   = $item->{'homebranch'};
43
    my $branchcode   = $item->{'homebranch'};
44
44
45
    subtest 'Priority rule' => sub {
46
        plan tests => 3;
47
48
        Koha::IssuingRules->delete;
49
50
        ok(Koha::IssuingRule->new({
51
            branchcode => $branchcode,
52
            categorycode => $categorycode,
53
            itemtype => $itemtype,
54
        })->store, "Given I added an issuing rule branchcode => $branchcode,'
55
           .' categorycode => $categorycode, itemtype => $itemtype,");
56
57
        ok(Koha::IssuingRule->new({
58
            branchcode => '*',
59
            categorycode => $categorycode,
60
            itemtype => $itemtype,
61
            has_priority => 1,
62
        })->store, "Add a priority rule.");
63
64
        my $rule = Koha::IssuingRules->get_effective_issuing_rule({
65
            branchcode   => $branchcode,
66
            categorycode => $categorycode,
67
            itemtype     => $itemtype,
68
        });
69
        is($rule->has_priority, 1, 'Priority rule should be returned');
70
    };
71
45
    subtest 'Call with undefined values' => sub {
72
    subtest 'Call with undefined values' => sub {
46
        plan tests => 4;
73
        plan tests => 4;
47
74
48
- 

Return to bug 8137