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 252-257 elsif ($op eq 'add') { Link Here
252
    my $br = $branch; # branch
252
    my $br = $branch; # branch
253
    my $bor  = $input->param('categorycode'); # borrower category
253
    my $bor  = $input->param('categorycode'); # borrower category
254
    my $itemtype  = $input->param('itemtype');     # item type
254
    my $itemtype  = $input->param('itemtype');     # item type
255
    my $has_priority = $input->param('has_priority') ? 1 : 0;
255
    my $fine = $input->param('fine');
256
    my $fine = $input->param('fine');
256
    my $finedays     = $input->param('finedays');
257
    my $finedays     = $input->param('finedays');
257
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
258
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
Lines 291-300 elsif ($op eq 'add') { Link Here
291
    my $note = $input->param('note');
292
    my $note = $input->param('note');
292
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
293
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
293
294
295
294
    my $rules = {
296
    my $rules = {
295
        maxissueqty                   => $maxissueqty,
297
        maxissueqty                   => $maxissueqty,
296
        maxonsiteissueqty             => $maxonsiteissueqty,
298
        maxonsiteissueqty             => $maxonsiteissueqty,
297
        rentaldiscount                => $rentaldiscount,
299
        rentaldiscount                => $rentaldiscount,
300
        has_priority                  => $has_priority,
298
        fine                          => $fine,
301
        fine                          => $fine,
299
        finedays                      => $finedays,
302
        finedays                      => $finedays,
300
        maxsuspensiondays             => $maxsuspensiondays,
303
        maxsuspensiondays             => $maxsuspensiondays,
Lines 329-334 elsif ($op eq 'add') { Link Here
329
            categorycode => $bor eq '*' ? undef : $bor,
332
            categorycode => $bor eq '*' ? undef : $bor,
330
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
333
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
331
            branchcode   => $br eq '*' ? undef : $br,
334
            branchcode   => $br eq '*' ? undef : $br,
335
	    has_priority => $has_priority,
332
            rules        => $rules,
336
            rules        => $rules,
333
        }
337
        }
334
    );
338
    );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +26 lines)
Lines 90-95 Link Here
90
                <th>Item type</th>
90
                <th>Item type</th>
91
                <th>Actions</th>
91
                <th>Actions</th>
92
                <th>Note</th>
92
                <th>Note</th>
93
                [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
93
                <th>Current checkouts allowed</th>
94
                <th>Current checkouts allowed</th>
94
                <th>Current on-site checkouts allowed</th>
95
                <th>Current on-site checkouts allowed</th>
95
                <th>Loan period</th>
96
                <th>Loan period</th>
Lines 185-190 Link Here
185
                                            <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
186
                                            <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
186
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
187
                                        [% ELSE %]<span>&nbsp;</span>[% END %]
187
                                    </td>
188
                                    </td>
189
                                    [% UNLESS humanbranch %]
190
                                    <td>
191
                                        [% IF rule.has_priority %]
192
                                            <input type="checkbox" checked="checked" disabled="disabled"/>
193
                                        [% ELSE %]
194
                                            <input type="checkbox" disabled="disabled"/>
195
                                        [% END %]
196
                                    </td>
197
                                    [% END %]
188
                                    <td>
198
                                    <td>
189
                                        [% IF maxissueqty.defined && maxissueqty != '' %]
199
                                        [% IF maxissueqty.defined && maxissueqty != '' %]
190
                                            [% maxissueqty | html %]
200
                                            [% maxissueqty | html %]
Lines 342-347 Link Here
342
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
352
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
343
                    </td>
353
                    </td>
344
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
354
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
355
                    [% UNLESS humanbranch %]
356
                        <td>
357
                            <input type="checkbox" name="has_priority" id="has_priority"/>
358
                        </td>
359
                    [% END %]
345
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
360
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
346
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
361
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
347
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
362
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
Lines 435-440 Link Here
435
                      <th>Item type</th>
450
                      <th>Item type</th>
436
                      <th>&nbsp;</th>
451
                      <th>&nbsp;</th>
437
                      <th>Note</th>
452
                      <th>Note</th>
453
                      [% UNLESS humanbranch %]<th>Has priority</th>[% END %]
438
                      <th>Current checkouts allowed</th>
454
                      <th>Current checkouts allowed</th>
439
                      <th>Current on-site checkouts allowed</th>
455
                      <th>Current on-site checkouts allowed</th>
440
                      <th>Loan period</th>
456
                      <th>Loan period</th>
Lines 702-708 Link Here
702
                        </td>
718
                        </td>
703
                        [% UNLESS humanbranch %]
719
                        [% UNLESS humanbranch %]
704
                            <td>
720
                            <td>
705
                                <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/>
721
                                [% IF branch_cat_rule_loo.has_priority %]
722
                                    <input type="checkbox" checked="checked" disabled/>
723
                                [% ELSE %]
724
                                    <input type="checkbox" disabled/>
725
                                [% END %]
706
                            </td>
726
                            </td>
707
                        [% END %]
727
                        [% END %]
708
728
Lines 1039-1044 Link Here
1039
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1059
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1040
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1060
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1041
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1061
                        $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1062
                    } else if ( i == 3 ) {
1063
                        var has_priority = $(this).find("input[type='checkbox']");
1064
                        $('#has_priority').prop('checked', has_priority.is(':checked') );
1065
                        //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1042
                    } else {
1066
                    } else {
1043
                        $(current_column).find("input[type='text']").val(itm);
1067
                        $(current_column).find("input[type='text']").val(itm);
1044
                        // select the corresponding option
1068
                        // select the corresponding option
Lines 1066-1071 Link Here
1066
                            //     - "Holds allowed (total)"
1090
                            //     - "Holds allowed (total)"
1067
                            //     - "Holds allowed (daily)"
1091
                            //     - "Holds allowed (daily)"
1068
                            //     - "Holds per record (count)"
1092
                            //     - "Holds per record (count)"
1093
                            // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
1069
                            // The value is "Unlimited" (or an equivalent translated string)
1094
                            // The value is "Unlimited" (or an equivalent translated string)
1070
                            // an it should be set to an empty string
1095
                            // an it should be set to an empty string
1071
                            if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
1096
                            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 => 3;
39
    plan tests => 4;
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