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

(-)a/Koha/CirculationRules.pm (-1 / +6 lines)
Lines 59-65 our $RULE_KINDS = { Link Here
59
    max_holds => {
59
    max_holds => {
60
        scope => [ 'branchcode', 'categorycode' ],
60
        scope => [ 'branchcode', 'categorycode' ],
61
    },
61
    },
62
62
    has_priority => {
63
	scope => [ 'branchcode', 'categorycode' ],
64
    },
63
    holdallowed => {
65
    holdallowed => {
64
        scope => [ 'branchcode', 'itemtype' ],
66
        scope => [ 'branchcode', 'itemtype' ],
65
        can_be_blank => 0,
67
        can_be_blank => 0,
Lines 189-199 sub get_effective_rule { Link Here
189
    $params->{categorycode} //= undef;
191
    $params->{categorycode} //= undef;
190
    $params->{branchcode}   //= undef;
192
    $params->{branchcode}   //= undef;
191
    $params->{itemtype}     //= undef;
193
    $params->{itemtype}     //= undef;
194
    $params->{has_priority} //= undef;
192
195
193
    my $rule_name    = $params->{rule_name};
196
    my $rule_name    = $params->{rule_name};
194
    my $categorycode = $params->{categorycode};
197
    my $categorycode = $params->{categorycode};
195
    my $itemtype     = $params->{itemtype};
198
    my $itemtype     = $params->{itemtype};
196
    my $branchcode   = $params->{branchcode};
199
    my $branchcode   = $params->{branchcode};
200
    my $has_priority = $params->{has_priority};
197
201
198
    Koha::Exceptions::MissingParameter->throw(
202
    Koha::Exceptions::MissingParameter->throw(
199
        "Required parameter 'rule_name' missing")
203
        "Required parameter 'rule_name' missing")
Lines 212-217 sub get_effective_rule { Link Here
212
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
216
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
213
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
217
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
214
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
218
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
219
    $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef;
215
220
216
    my $rule = $self->search(
221
    my $rule = $self->search(
217
        $search_params,
222
        $search_params,
(-)a/admin/smart-rules.pl (+4 lines)
Lines 251-256 elsif ($op eq 'add') { Link Here
251
    my $br = $branch; # branch
251
    my $br = $branch; # branch
252
    my $bor  = $input->param('categorycode'); # borrower category
252
    my $bor  = $input->param('categorycode'); # borrower category
253
    my $itemtype  = $input->param('itemtype');     # item type
253
    my $itemtype  = $input->param('itemtype');     # item type
254
    my $has_priority = $input->param('has_priority') ? 1 : 0;
254
    my $fine = $input->param('fine');
255
    my $fine = $input->param('fine');
255
    my $finedays     = $input->param('finedays');
256
    my $finedays     = $input->param('finedays');
256
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
257
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
Lines 292-301 elsif ($op eq 'add') { Link Here
292
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
293
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
293
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
294
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
294
295
296
295
    my $rules = {
297
    my $rules = {
296
        maxissueqty                   => $maxissueqty,
298
        maxissueqty                   => $maxissueqty,
297
        maxonsiteissueqty             => $maxonsiteissueqty,
299
        maxonsiteissueqty             => $maxonsiteissueqty,
298
        rentaldiscount                => $rentaldiscount,
300
        rentaldiscount                => $rentaldiscount,
301
        has_priority                  => $has_priority,
299
        fine                          => $fine,
302
        fine                          => $fine,
300
        finedays                      => $finedays,
303
        finedays                      => $finedays,
301
        maxsuspensiondays             => $maxsuspensiondays,
304
        maxsuspensiondays             => $maxsuspensiondays,
Lines 332-337 elsif ($op eq 'add') { Link Here
332
            categorycode => $bor eq '*' ? undef : $bor,
335
            categorycode => $bor eq '*' ? undef : $bor,
333
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
336
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
334
            branchcode   => $br eq '*' ? undef : $br,
337
            branchcode   => $br eq '*' ? undef : $br,
338
	    has_priority => $has_priority,
335
            rules        => $rules,
339
            rules        => $rules,
336
        }
340
        }
337
    );
341
    );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +26 lines)
Lines 96-101 Link Here
96
                <th class="fixed_sort">Item type</th>
96
                <th class="fixed_sort">Item type</th>
97
                <th class="noExport">Actions</th>
97
                <th class="noExport">Actions</th>
98
                <th>Note</th>
98
                <th>Note</th>
99
                [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
99
                <th>Current checkouts allowed</th>
100
                <th>Current checkouts allowed</th>
100
                <th>Current on-site checkouts allowed</th>
101
                <th>Current on-site checkouts allowed</th>
101
                <th>Loan period</th>
102
                <th>Loan period</th>
Lines 199-204 Link Here
199
                                            <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
200
                                            <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
200
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
201
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
201
                                    </td>
202
                                    </td>
203
                                    [% UNLESS humanbranch %]
204
                                    <td>
205
                                        [% IF rule.has_priority %]
206
                                            <input type="checkbox" checked="checked" disabled="disabled"/>
207
                                        [% ELSE %]
208
                                            <input type="checkbox" disabled="disabled"/>
209
                                        [% END %]
210
                                    </td>
211
                                    [% END %]
202
                                    <td>
212
                                    <td>
203
                                        [% IF maxissueqty.defined && maxissueqty != '' %]
213
                                        [% IF maxissueqty.defined && maxissueqty != '' %]
204
                                            [% maxissueqty | html %]
214
                                            [% maxissueqty | html %]
Lines 374-379 Link Here
374
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
384
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
375
                    </td>
385
                    </td>
376
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
386
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
387
                    [% UNLESS humanbranch %]
388
                        <td>
389
                            <input type="checkbox" name="has_priority" id="has_priority"/>
390
                        </td>
391
                    [% END %]
377
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
392
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
378
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
393
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
379
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
394
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
Lines 473-478 Link Here
473
                      <th>Item type</th>
488
                      <th>Item type</th>
474
                      <th>&nbsp;</th>
489
                      <th>&nbsp;</th>
475
                      <th>Note</th>
490
                      <th>Note</th>
491
                      [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
476
                      <th>Current checkouts allowed</th>
492
                      <th>Current checkouts allowed</th>
477
                      <th>Current on-site checkouts allowed</th>
493
                      <th>Current on-site checkouts allowed</th>
478
                      <th>Loan period</th>
494
                      <th>Loan period</th>
Lines 744-750 Link Here
744
                        </td>
760
                        </td>
745
                        [% UNLESS humanbranch %]
761
                        [% UNLESS humanbranch %]
746
                            <td>
762
                            <td>
747
                                <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
763
                                [% IF branch_cat_rule_loo.has_priority %]
764
                                    <input type="checkbox" checked="checked" disabled/>
765
                                [% ELSE %]
766
                                    <input type="checkbox" disabled/>
767
                                [% END %]
748
                            </td>
768
                            </td>
749
                        [% END %]
769
                        [% END %]
750
770
Lines 1118-1123 Link Here
1118
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1138
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1119
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1139
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1120
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1140
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1141
                    } else if ( i == 3 ) {
1142
                        var has_priority = $(this).find("input[type='checkbox']");
1143
                        $('#has_priority').prop('checked', has_priority.is(':checked') );
1144
                        //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1121
                    } else {
1145
                    } else {
1122
                        $(current_column).find("input[type='text']").val(itm);
1146
                        $(current_column).find("input[type='text']").val(itm);
1123
                        // select the corresponding option
1147
                        // select the corresponding option
Lines 1146-1151 Link Here
1146
                            //     - "Holds allowed (total)"
1170
                            //     - "Holds allowed (total)"
1147
                            //     - "Holds allowed (daily)"
1171
                            //     - "Holds allowed (daily)"
1148
                            //     - "Holds per record (count)"
1172
                            //     - "Holds per record (count)"
1173
                            // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
1149
                            // The value is "Unlimited" (or an equivalent translated string)
1174
                            // The value is "Unlimited" (or an equivalent translated string)
1150
                            // an it should be set to an empty string
1175
                            // an it should be set to an empty string
1151
                            if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
1176
                            if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
(-)a/t/db_dependent/Koha/IssuingRules.t (-2 / +28 lines)
Lines 36-47 $schema->storage->txn_begin; Link Here
36
my $builder      = t::lib::TestBuilder->new;
36
my $builder      = t::lib::TestBuilder->new;
37
37
38
subtest 'get_effective_issuing_rule' => sub {
38
subtest 'get_effective_issuing_rule' => sub {
39
    plan tests => 2;
39
    plan tests => 3;
40
40
41
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
41
    my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
42
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
42
    my $itemtype     = $builder->build({ source => 'Itemtype' })->{'itemtype'};
43
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
43
    my $branchcode   = $builder->build({ source => 'Branch' })->{'branchcode'};
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 => 5;
73
        plan tests => 5;
47
74
48
- 

Return to bug 8137