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

(-)a/Koha/CirculationRules.pm (+4 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
    max_daily_article_requests => {
80
        scope => [ 'branchcode', 'categorycode' ],
81
    },
82
79
    auto_renew => {
83
    auto_renew => {
80
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
84
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
81
    },
85
    },
(-)a/admin/smart-rules.pl (+69 lines)
Lines 457-462 elsif ($op eq "add-branch-cat") { Link Here
457
        );
457
        );
458
    }
458
    }
459
}
459
}
460
elsif ( $op eq "add-max-daily-article-requests" ) {
461
    my $categorycode               = $input->param('categorycode');
462
    my $max_daily_article_requests = strip_non_numeric( scalar $input->param('max_daily_article_requests') );
463
464
    if ( $branch eq "*" ) {
465
        if ( $categorycode eq "*" ) {
466
            Koha::CirculationRules->set_rules(
467
                {   categorycode => undef,
468
                    branchcode   => undef,
469
                    rules        => { max_daily_article_requests => $max_daily_article_requests, }
470
                }
471
            );
472
        } else {
473
            Koha::CirculationRules->set_rules(
474
                {   categorycode => $categorycode,
475
                    branchcode   => undef,
476
                    rules        => { max_daily_article_requests => $max_daily_article_requests, }
477
                }
478
            );
479
        }
480
    } elsif ( $categorycode eq "*" ) {
481
        Koha::CirculationRules->set_rules(
482
            {   categorycode => undef,
483
                branchcode   => $branch,
484
                rules        => { max_daily_article_requests => $max_daily_article_requests, }
485
            }
486
        );
487
    } else {
488
        Koha::CirculationRules->set_rules(
489
            {   categorycode => $categorycode,
490
                branchcode   => $branch,
491
                rules        => { max_daily_article_requests => $max_daily_article_requests, }
492
            }
493
        );
494
    }
495
} elsif ( $op eq 'del-max-daily-article-requests' ) {
496
    my $categorycode = $input->param('categorycode');
497
    if ( $branch eq "*" ) {
498
        if ( $categorycode eq "*" ) {
499
            Koha::CirculationRules->set_rules(
500
                {   branchcode   => undef,
501
                    categorycode => undef,
502
                    rules        => { max_daily_article_requests => undef, }
503
                }
504
            );
505
        } else {
506
            Koha::CirculationRules->set_rules(
507
                {   categorycode => $categorycode,
508
                    branchcode   => undef,
509
                    rules        => { max_daily_article_requests => undef, }
510
                }
511
            );
512
        }
513
    } elsif ( $categorycode eq "*" ) {
514
        Koha::CirculationRules->set_rules(
515
            {   branchcode   => $branch,
516
                categorycode => undef,
517
                rules        => { max_daily_article_requests => undef, }
518
            }
519
        );
520
    } else {
521
        Koha::CirculationRules->set_rules(
522
            {   categorycode => $categorycode,
523
                branchcode   => $branch,
524
                rules        => { max_daily_article_requests => undef, }
525
            }
526
        );
527
    }
528
}
460
elsif ($op eq "add-branch-item") {
529
elsif ($op eq "add-branch-item") {
461
    my $itemtype                = $input->param('itemtype');
530
    my $itemtype                = $input->param('itemtype');
462
    my $holdallowed             = $input->param('holdallowed');
531
    my $holdallowed             = $input->param('holdallowed');
(-)a/installer/data/mysql/atomicupdate/bug_27945.pl (+16 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "27945",
5
    description => "Add max_daily_article_requests circulation rule",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ($dbh)  = @$args{qw(dbh)};
9
10
        # Do you stuffs here
11
        $dbh->do(q{
12
            INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value)
13
            VALUES (NULL, NULL, NULL, 'max_daily_article_requests', NULL);
14
        });
15
    },
16
  }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +56 lines)
Lines 787-792 Link Here
787
    </div>
787
    </div>
788
    [% END %]
788
    [% END %]
789
789
790
    [% IF Koha.Preference('ArticleRequests') %]
791
    <div id="max-daily-article-requests-patron-category" class="container">
792
    [% IF humanbranch %]
793
        <h3>Article requests limits for [% Branches.GetName( humanbranch ) | html %]</h3>
794
    [% ELSE %]
795
        <h3>Default article requests limits</h3>
796
    [% END %]
797
        <p>Specify the maximum number simultaneous current article requests a patron of a given category can have.</p>
798
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
799
            <input type="hidden" name="op" value="add-max-daily-article-requests" />
800
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
801
            <table>
802
                <tr>
803
                    <th>Patron category</th>
804
                    <th>Total article requests</th>
805
                    <th>&nbsp;</th>
806
                </tr>
807
                [% FOREACH c IN categorycodes %]
808
                    [% NEXT UNLESS c %]
809
                    [% SET max_daily_article_requests = CirculationRules.Search( branchcode, c, undef, 'max_daily_article_requests' ) %]
810
811
                    [% IF ( max_daily_article_requests.defined && max_daily_article_requests != '' ) %]
812
                    <tr>
813
                        <td>
814
                            [% Categories.GetName(c) | html %]
815
                        </td>
816
                        <td>
817
                            [% IF max_daily_article_requests.defined && max_daily_article_requests != '' %]
818
                                [% max_daily_article_requests | html %]
819
                            [% ELSE %]
820
                                <span>Unlimited</span>
821
                            [% END %]
822
                        </td>
823
824
                        <td class="actions">
825
                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-max-daily-article-requests&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
826
                        </td>
827
                    </tr>
828
                    [% END %]
829
                [% END %]
830
                <tr>
831
                    <td>
832
                        <select name="categorycode">
833
                        [% FOREACH patron_category IN patron_categories %]
834
                            <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
835
                        [% END %]
836
                        </select>
837
                    </td>
838
                    <td><input name="max_daily_article_requests" size="3" type="text" /></td>
839
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
840
                </tr>
841
            </table>
842
        </form>
843
    </div>
844
    [% END %]
845
790
    <div id="refund-lost-item-fee-on-return" class="container">
846
    <div id="refund-lost-item-fee-on-return" class="container">
791
        [% IF current_branch == '*' %]
847
        [% IF current_branch == '*' %]
792
            <h3>Default lost item fee refund on return policy</h3>
848
            <h3>Default lost item fee refund on return policy</h3>
793
- 

Return to bug 27945