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

(-)a/Koha/CirculationRules.pm (+3 lines)
Lines 76-81 our $RULE_KINDS = { Link Here
76
    article_requests => {
76
    article_requests => {
77
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
77
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
78
    },
78
    },
79
    article_request_fee => {
80
        scope => [ 'branchcode', 'categorycode' ],
81
    },
79
    open_article_requests_limit => {
82
    open_article_requests_limit => {
80
        scope => [ 'branchcode', 'categorycode' ],
83
        scope => [ 'branchcode', 'categorycode' ],
81
    },
84
    },
(-)a/admin/smart-rules.pl (+27 lines)
Lines 531-536 elsif ( $op eq "add-open-article-requests-limit" ) { Link Here
531
        );
531
        );
532
    }
532
    }
533
}
533
}
534
elsif ( $op eq "set-article-request-fee" ) {
535
536
    my $category = $input->param('article_request_fee_category');
537
    my $fee      = strip_non_numeric( scalar $input->param('article_request_fee') );
538
539
    Koha::Exceptions::Exception->throw("No value passed for article request fee")
540
      if not defined $fee # There is a JS check for that
541
      || $fee eq '';
542
543
    Koha::CirculationRules->set_rules(
544
        {   categorycode => ( $category  eq '*' ) ? undef : $category,
545
            branchcode   => ( $branch    eq '*' ) ? undef : $branch,
546
            rules        => { article_request_fee => $fee },
547
        }
548
    );
549
550
} elsif ( $op eq 'del-article-request-fee' ) {
551
552
    my $category  = $input->param('article_request_fee_category');
553
554
    Koha::CirculationRules->set_rules(
555
        {   categorycode => ( $category eq  '*' ) ? undef : $category,
556
            branchcode   => ( $branch eq    '*' ) ? undef : $branch,
557
            rules        => { article_request_fee => undef },
558
        }
559
    );
560
}
534
elsif ($op eq "add-branch-item") {
561
elsif ($op eq "add-branch-item") {
535
    my $itemtype                = $input->param('itemtype');
562
    my $itemtype                = $input->param('itemtype');
536
    my $holdallowed             = $input->param('holdallowed');
563
    my $holdallowed             = $input->param('holdallowed');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-2 / +68 lines)
Lines 787-793 Link Here
787
    </div>
787
    </div>
788
    [% END %]
788
    [% END %]
789
789
790
    [% IF Koha.Preference('ArticleRequests') %]
790
[% IF Koha.Preference('ArticleRequests') %]
791
    <div id="open-article-requests-limit-patron-category" class="container">
791
    <div id="open-article-requests-limit-patron-category" class="container">
792
    [% IF humanbranch %]
792
    [% IF humanbranch %]
793
        <h3>Daily open article requests limit for [% Branches.GetName( humanbranch ) | html %]</h3>
793
        <h3>Daily open article requests limit for [% Branches.GetName( humanbranch ) | html %]</h3>
Lines 841-847 Link Here
841
            </table>
841
            </table>
842
        </form>
842
        </form>
843
    </div>
843
    </div>
844
    <div id="article-request-fee-category" class="container">
845
    [% IF humanbranch %]
846
        <h3>Article request fees for [% Branches.GetName( humanbranch ) | html %]</h3>
847
    [% ELSE %]
848
        <h3>Default article request fees</h3>
844
    [% END %]
849
    [% END %]
850
        <p>Specify the article request fee for a given patron category.</p>
851
        <form id="set-article-request-fee" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
852
            <input type="hidden" name="op" value="set-article-request-fee" />
853
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
854
            <table>
855
                <tr>
856
                    <th>Patron category</th>
857
                    <th>Fee</th>
858
                    <th>&nbsp;</th>
859
                </tr>
860
                [% FOREACH c IN categorycodes %]
861
                    [% SET c = '*' UNLESS c.defined AND c != '' %]
862
863
                    [% SET article_request_fee = CirculationRules.Search( current_branch, c, undef, 'article_request_fee' ) %]
864
865
                    [% IF ( article_request_fee.defined && article_request_fee != '' ) %]
866
                    <tr>
867
                        <td>
868
                            [% IF c == '*' %]
869
                                <em>All</em>
870
                            [% ELSE %]
871
                                [% Categories.GetName(c) | html %]
872
                            [% END %]
873
                        </td>
874
                        <td>
875
                            [% IF article_request_fee.defined && article_request_fee != '' %]
876
                                [% article_request_fee | html %]
877
                            [% ELSE %]
878
                                <span>0</span>
879
                            [% END %]
880
                        </td>
881
                        <td class="actions">
882
                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-article-request-fee&amp;article_request_fee_category=[% c | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
883
                        </td>
884
                    </tr>
885
                    [% END %]
886
                [% END %]
887
                <tr>
888
                    <td>
889
                        <select name="article_request_fee_category" id="article_request_fee_category">
890
                            <option value="*">All</option>
891
                        [% FOREACH patron_category IN patron_categories%]
892
                            <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
893
                        [% END %]
894
                        </select>
895
                    </td>
896
                    <td><input name="article_request_fee" size="3" type="text" /></td>
897
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
898
                </tr>
899
            </table>
900
        </form>
901
    </div>
902
903
[% END %]
845
904
846
    <div id="refund-lost-item-fee-on-return" class="container">
905
    <div id="refund-lost-item-fee-on-return" class="container">
847
        [% IF current_branch == '*' %]
906
        [% IF current_branch == '*' %]
Lines 1237-1242 Link Here
1237
                }
1296
                }
1238
                return true;
1297
                return true;
1239
            });
1298
            });
1299
1300
            $("#set-article-request-fee").on("submit", function(){
1301
                if (! $("input[name='article_request_fee'").val().length){
1302
                    alert("Please set a valid value for the fee");
1303
                    return false;
1304
                }
1305
                return true;
1306
            });
1240
        });
1307
        });
1241
    </script>
1308
    </script>
1242
[% END %]
1309
[% END %]
1243
- 

Return to bug 27946