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
    },
67
    },
Lines 180-190 sub get_effective_rule { Link Here
180
    $params->{categorycode} //= undef;
182
    $params->{categorycode} //= undef;
181
    $params->{branchcode}   //= undef;
183
    $params->{branchcode}   //= undef;
182
    $params->{itemtype}     //= undef;
184
    $params->{itemtype}     //= undef;
185
    $params->{has_priority} //= undef;
183
186
184
    my $rule_name    = $params->{rule_name};
187
    my $rule_name    = $params->{rule_name};
185
    my $categorycode = $params->{categorycode};
188
    my $categorycode = $params->{categorycode};
186
    my $itemtype     = $params->{itemtype};
189
    my $itemtype     = $params->{itemtype};
187
    my $branchcode   = $params->{branchcode};
190
    my $branchcode   = $params->{branchcode};
191
    my $has_priority = $params->{has_priority};
188
192
189
    Koha::Exceptions::MissingParameter->throw(
193
    Koha::Exceptions::MissingParameter->throw(
190
        "Required parameter 'rule_name' missing")
194
        "Required parameter 'rule_name' missing")
Lines 203-208 sub get_effective_rule { Link Here
203
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
207
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
204
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
208
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
205
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
209
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
210
    $search_params->{has_priority} = defined $has_priority ? [ $has_priority, undef ] : undef;
206
211
207
    my $rule = $self->search(
212
    my $rule = $self->search(
208
        $search_params,
213
        $search_params,
(-)a/admin/smart-rules.pl (+4 lines)
Lines 250-255 elsif ($op eq 'add') { Link Here
250
    my $br = $branch; # branch
250
    my $br = $branch; # branch
251
    my $bor  = $input->param('categorycode'); # borrower category
251
    my $bor  = $input->param('categorycode'); # borrower category
252
    my $itemtype  = $input->param('itemtype');     # item type
252
    my $itemtype  = $input->param('itemtype');     # item type
253
    my $has_priority = $input->param('has_priority') ? 1 : 0;
253
    my $fine = $input->param('fine');
254
    my $fine = $input->param('fine');
254
    my $finedays     = $input->param('finedays');
255
    my $finedays     = $input->param('finedays');
255
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
256
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
Lines 289-298 elsif ($op eq 'add') { Link Here
289
    my $note = $input->param('note');
290
    my $note = $input->param('note');
290
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
291
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
291
292
293
292
    my $rules = {
294
    my $rules = {
293
        maxissueqty                   => $maxissueqty,
295
        maxissueqty                   => $maxissueqty,
294
        maxonsiteissueqty             => $maxonsiteissueqty,
296
        maxonsiteissueqty             => $maxonsiteissueqty,
295
        rentaldiscount                => $rentaldiscount,
297
        rentaldiscount                => $rentaldiscount,
298
        has_priority                  => $has_priority,
296
        fine                          => $fine,
299
        fine                          => $fine,
297
        finedays                      => $finedays,
300
        finedays                      => $finedays,
298
        maxsuspensiondays             => $maxsuspensiondays,
301
        maxsuspensiondays             => $maxsuspensiondays,
Lines 327-332 elsif ($op eq 'add') { Link Here
327
            categorycode => $bor eq '*' ? undef : $bor,
330
            categorycode => $bor eq '*' ? undef : $bor,
328
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
331
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
329
            branchcode   => $br eq '*' ? undef : $br,
332
            branchcode   => $br eq '*' ? undef : $br,
333
	    has_priority => $has_priority,
330
            rules        => $rules,
334
            rules        => $rules,
331
        }
335
        }
332
    );
336
    );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +26 lines)
Lines 96-101 Link Here
96
                <th>Item type</th>
96
                <th>Item type</th>
97
                <th>Actions</th>
97
                <th>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 193-198 Link Here
193
                                            <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
194
                                            <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
194
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
195
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
195
                                    </td>
196
                                    </td>
197
                                    [% UNLESS humanbranch %]
198
                                    <td>
199
                                        [% IF rule.has_priority %]
200
                                            <input type="checkbox" checked="checked" disabled="disabled"/>
201
                                        [% ELSE %]
202
                                            <input type="checkbox" disabled="disabled"/>
203
                                        [% END %]
204
                                    </td>
205
                                    [% END %]
196
                                    <td>
206
                                    <td>
197
                                        [% IF maxissueqty.defined && maxissueqty != '' %]
207
                                        [% IF maxissueqty.defined && maxissueqty != '' %]
198
                                            [% maxissueqty | html %]
208
                                            [% maxissueqty | html %]
Lines 364-369 Link Here
364
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
374
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
365
                    </td>
375
                    </td>
366
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
376
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
377
                    [% UNLESS humanbranch %]
378
                        <td>
379
                            <input type="checkbox" name="has_priority" id="has_priority"/>
380
                        </td>
381
                    [% END %]
367
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
382
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
368
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
383
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
369
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
384
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
Lines 459-464 Link Here
459
                      <th>Item type</th>
474
                      <th>Item type</th>
460
                      <th>&nbsp;</th>
475
                      <th>&nbsp;</th>
461
                      <th>Note</th>
476
                      <th>Note</th>
477
                      [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
462
                      <th>Current checkouts allowed</th>
478
                      <th>Current checkouts allowed</th>
463
                      <th>Current on-site checkouts allowed</th>
479
                      <th>Current on-site checkouts allowed</th>
464
                      <th>Loan period</th>
480
                      <th>Loan period</th>
Lines 726-732 Link Here
726
                        </td>
742
                        </td>
727
                        [% UNLESS humanbranch %]
743
                        [% UNLESS humanbranch %]
728
                            <td>
744
                            <td>
729
                                <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
745
                                [% IF branch_cat_rule_loo.has_priority %]
746
                                    <input type="checkbox" checked="checked" disabled/>
747
                                [% ELSE %]
748
                                    <input type="checkbox" disabled/>
749
                                [% END %]
730
                            </td>
750
                            </td>
731
                        [% END %]
751
                        [% END %]
732
752
Lines 1075-1080 Link Here
1075
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1095
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1076
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1096
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1077
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1097
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1098
                    } else if ( i == 3 ) {
1099
                        var has_priority = $(this).find("input[type='checkbox']");
1100
                        $('#has_priority').prop('checked', has_priority.is(':checked') );
1101
                        //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1078
                    } else {
1102
                    } else {
1079
                        $(current_column).find("input[type='text']").val(itm);
1103
                        $(current_column).find("input[type='text']").val(itm);
1080
                        // select the corresponding option
1104
                        // select the corresponding option
Lines 1103-1108 Link Here
1103
                            //     - "Holds allowed (total)"
1127
                            //     - "Holds allowed (total)"
1104
                            //     - "Holds allowed (daily)"
1128
                            //     - "Holds allowed (daily)"
1105
                            //     - "Holds per record (count)"
1129
                            //     - "Holds per record (count)"
1130
                            // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
1106
                            // The value is "Unlimited" (or an equivalent translated string)
1131
                            // The value is "Unlimited" (or an equivalent translated string)
1107
                            // an it should be set to an empty string
1132
                            // an it should be set to an empty string
1108
                            if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
1133
                            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