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

(-)a/Koha/CirculationRules.pm (+4 lines)
Lines 110-115 our $RULE_KINDS = { Link Here
110
    hardduedatecompare => {
110
    hardduedatecompare => {
111
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
111
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
112
    },
112
    },
113
    waiting_hold_cancellation => {
114
        scope        => [ 'branchcode', 'categorycode', 'itemtype' ],
115
        can_be_blank => 0,
116
    },
113
    holds_per_day => {
117
    holds_per_day => {
114
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
118
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
115
    },
119
    },
(-)a/admin/smart-rules.pl (+33 lines)
Lines 660-667 elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) { Link Here
660
            }
660
            }
661
        );
661
        );
662
    }
662
    }
663
} elsif ( $op eq "set-waiting-hold-cancellation" ) {
664
665
    my $category = $input->param('waiting_hold_cancellation_category');
666
    my $itemtype = $input->param('waiting_hold_cancellation_itemtype');
667
    my $policy   = strip_non_numeric( scalar $input->param('waiting_hold_cancellation_policy') )
668
                    ? 1
669
                    : 0;
670
671
    Koha::Exception->throw("No value passed for waiting holds cancellation policy")
672
      if not defined $policy # There is a JS check for that
673
      || $policy eq '';
674
675
    Koha::CirculationRules->set_rules(
676
        {   categorycode => ( $category eq '*' ) ? undef : $category,
677
            itemtype     => ( $itemtype eq '*' ) ? undef : $itemtype,
678
            branchcode   => ( $branch   eq '*' ) ? undef : $branch,
679
            rules        => { waiting_hold_cancellation => $policy },
680
        }
681
    );
682
683
} elsif ( $op eq 'del-waiting-hold-cancellation' ) {
684
685
    my $category = $input->param('waiting_hold_cancellation_category');
686
    my $itemtype = $input->param('waiting_hold_cancellation_itemtype');
687
688
    Koha::CirculationRules->set_rules(
689
        {   categorycode => ( $category eq '*' ) ? undef : $category,
690
            itemtype     => ( $itemtype eq '*' ) ? undef : $itemtype,
691
            branchcode   => ( $branch   eq '*' ) ? undef : $branch,
692
            rules        => { waiting_hold_cancellation => undef },
693
        }
694
    );
663
}
695
}
664
696
697
665
my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'lostreturn' });
698
my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'lostreturn' });
666
my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'lostreturn' });
699
my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'lostreturn' });
667
$template->param(
700
$template->param(
(-)a/installer/data/mysql/atomicupdate/bug_22456.pl (+16 lines)
Lines 25-29 return { Link Here
25
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
25
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
26
            });
26
            });
27
        }
27
        }
28
29
        my ($count) = $dbh->selectrow_array(q{
30
                SELECT COUNT(*)
31
                FROM circulation_rules
32
                WHERE rule_name = 'waiting_hold_cancellation'
33
        });
34
35
        unless ( $count ) {
36
            $dbh->do(q{
37
                INSERT INTO circulation_rules (rule_name, rule_value)
38
                VALUES ('waiting_hold_cancellation', 0)
39
            });
40
        }
41
        else {
42
            say $out "Found already existing 'waiting_hold_cancellation' circulation rules on the DB. Please review.";
43
        }
28
    },
44
    },
29
};
45
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +83 lines)
Lines 836-841 Link Here
836
    </div>
836
    </div>
837
    [% END %]
837
    [% END %]
838
838
839
    <div id="waiting-hold-cancel-category" class="container">
840
    [% IF humanbranch %]
841
        <h3>Waiting hold cancellation policy for [% Branches.GetName( humanbranch ) | html %]</h3>
842
    [% ELSE %]
843
        <h3>Default waiting hold cancellation policy</h3>
844
    [% END %]
845
        <p>Specify if waiting holds can be cancelled for a given patron category.</p>
846
        <form id="set-waiting-hold-cancellation" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
847
            <input type="hidden" name="op" value="set-waiting-hold-cancellation" />
848
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
849
            <table>
850
                <tr>
851
                    <th>Patron category</th>
852
                    <th>Item type</th>
853
                    <th>Cancellation allowed</th>
854
                    <th>&nbsp;</th>
855
                </tr>
856
    [% FOREACH c IN categorycodes %]
857
        [% SET c = '*' UNLESS c.defined AND c != '' %]
858
        [% FOREACH i IN itemtypes %]
859
            [% SET i = '*' UNLESS i.defined AND i != '' %]
860
861
            [% SET waiting_hold_cancellation = CirculationRules.Search( current_branch, c, i, 'waiting_hold_cancellation' ) %]
862
863
            [% IF ( waiting_hold_cancellation.defined && waiting_hold_cancellation != '' ) %]
864
                <tr>
865
                    <td>
866
                        [% IF c == '*' %]
867
                            <em>All</em>
868
                        [% ELSE %]
869
                            [% Categories.GetName(c) | html %]
870
                        [% END %]
871
                    </td>
872
                    <td>
873
                        [% IF i == '*' %]
874
                            <em>All</em>
875
                        [% ELSE %]
876
                            [% ItemTypes.GetDescription(i,1) | html %]
877
                        [% END %]
878
                    </td>
879
                    <td>
880
                        [% IF waiting_hold_cancellation %]
881
                            <span>Yes</span>
882
                        [% ELSE %]
883
                            <span>No</span>
884
                        [% END %]
885
                    </td>
886
                    <td class="actions">
887
                        <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-waiting-hold-cancellation&amp;waiting_hold_cancellation_category=[% c | uri %]&amp;waiting_hold_cancellation_itemtype=[% i | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
888
                    </td>
889
                </tr>
890
            [% END %]
891
        [% END %]
892
    [% END %]
893
                <tr>
894
                    <td>
895
                        <select name="waiting_hold_cancellation_category" id="waiting_hold_cancellation_category">
896
                            <option value="*">All</option>
897
                        [% FOREACH patron_category IN patron_categories %]
898
                            <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
899
                        [% END %]
900
                        </select>
901
                    </td>
902
                    <td>
903
                        <select name="waiting_hold_cancellation_itemtype" id="waiting_hold_cancellation_itemtype">
904
                            <option value="*">All</option>
905
                        [% FOREACH itemtype IN itemtypeloop %]
906
                            <option value="[% itemtype.itemtype | html %]">[% ItemTypes.GetDescription(itemtype.itemtype) | html %]</option>
907
                        [% END %]
908
                        </select>
909
                    </td>
910
                    <td>
911
                        <select name="waiting_hold_cancellation_policy" id="waiting_hold_cancellation_policy">
912
                            <option value="0" selected>No</option>
913
                            <option value="1">Yes</option>
914
                        </select>
915
                    </td>
916
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
917
                </tr>
918
            </table>
919
        </form>
920
    </div>
921
839
[% IF Koha.Preference('ArticleRequests') %]
922
[% IF Koha.Preference('ArticleRequests') %]
840
    <div id="open-article-requests-limit-patron-category" class="container">
923
    <div id="open-article-requests-limit-patron-category" class="container">
841
    [% IF humanbranch %]
924
    [% IF humanbranch %]
842
- 

Return to bug 22456