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

(-)a/Koha/CirculationRules.pm (+4 lines)
Lines 112-117 our $RULE_KINDS = { Link Here
112
    hardduedatecompare => {
112
    hardduedatecompare => {
113
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
113
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
114
    },
114
    },
115
    waiting_hold_cancellation => {
116
        scope        => [ 'branchcode', 'categorycode', 'itemtype' ],
117
        can_be_blank => 0,
118
    },
115
    holds_per_day => {
119
    holds_per_day => {
116
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
120
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
117
    },
121
    },
(-)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 17-21 return { Link Here
17
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
17
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
18
            });
18
            });
19
        }
19
        }
20
21
        my ($count) = $dbh->selectrow_array(q{
22
                SELECT COUNT(*)
23
                FROM circulation_rules
24
                WHERE rule_name = 'waiting_hold_cancellation'
25
        });
26
27
        unless ( $count ) {
28
            $dbh->do(q{
29
                INSERT INTO circulation_rules (rule_name, rule_value)
30
                VALUES ('waiting_hold_cancellation', 0)
31
            });
32
        }
33
        else {
34
            say $out "Found already existing 'waiting_hold_cancellation' circulation rules on the DB. Please review.";
35
        }
20
    },
36
    },
21
};
37
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +83 lines)
Lines 845-850 Link Here
845
    </div>
845
    </div>
846
    [% END %]
846
    [% END %]
847
847
848
    <div id="waiting-hold-cancel-category" class="container">
849
    [% IF humanbranch %]
850
        <h3>Waiting hold cancellation policy for [% Branches.GetName( humanbranch ) | html %]</h3>
851
    [% ELSE %]
852
        <h3>Default waiting hold cancellation policy</h3>
853
    [% END %]
854
        <p>Specify if waiting holds can be cancelled for a given patron category.</p>
855
        <form id="set-waiting-hold-cancellation" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
856
            <input type="hidden" name="op" value="set-waiting-hold-cancellation" />
857
            <input type="hidden" name="branch" value="[% current_branch | html %]"/>
858
            <table>
859
                <tr>
860
                    <th>Patron category</th>
861
                    <th>Item type</th>
862
                    <th>Cancellation allowed</th>
863
                    <th>&nbsp;</th>
864
                </tr>
865
    [% FOREACH c IN categorycodes %]
866
        [% SET c = '*' UNLESS c.defined AND c != '' %]
867
        [% FOREACH i IN itemtypes %]
868
            [% SET i = '*' UNLESS i.defined AND i != '' %]
869
870
            [% SET waiting_hold_cancellation = CirculationRules.Search( current_branch, c, i, 'waiting_hold_cancellation' ) %]
871
872
            [% IF ( waiting_hold_cancellation.defined && waiting_hold_cancellation != '' ) %]
873
                <tr>
874
                    <td>
875
                        [% IF c == '*' %]
876
                            <em>All</em>
877
                        [% ELSE %]
878
                            [% Categories.GetName(c) | html %]
879
                        [% END %]
880
                    </td>
881
                    <td>
882
                        [% IF i == '*' %]
883
                            <em>All</em>
884
                        [% ELSE %]
885
                            [% ItemTypes.GetDescription(i,1) | html %]
886
                        [% END %]
887
                    </td>
888
                    <td>
889
                        [% IF waiting_hold_cancellation %]
890
                            <span>Yes</span>
891
                        [% ELSE %]
892
                            <span>No</span>
893
                        [% END %]
894
                    </td>
895
                    <td class="actions">
896
                        <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>
897
                    </td>
898
                </tr>
899
            [% END %]
900
        [% END %]
901
    [% END %]
902
                <tr>
903
                    <td>
904
                        <select name="waiting_hold_cancellation_category" id="waiting_hold_cancellation_category">
905
                            <option value="*">All</option>
906
                        [% FOREACH patron_category IN patron_categories %]
907
                            <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
908
                        [% END %]
909
                        </select>
910
                    </td>
911
                    <td>
912
                        <select name="waiting_hold_cancellation_itemtype" id="waiting_hold_cancellation_itemtype">
913
                            <option value="*">All</option>
914
                        [% FOREACH itemtype IN itemtypeloop %]
915
                            <option value="[% itemtype.itemtype | html %]">[% ItemTypes.GetDescription(itemtype.itemtype) | html %]</option>
916
                        [% END %]
917
                        </select>
918
                    </td>
919
                    <td>
920
                        <select name="waiting_hold_cancellation_policy" id="waiting_hold_cancellation_policy">
921
                            <option value="0" selected>No</option>
922
                            <option value="1">Yes</option>
923
                        </select>
924
                    </td>
925
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
926
                </tr>
927
            </table>
928
        </form>
929
    </div>
930
848
[% IF Koha.Preference('ArticleRequests') %]
931
[% IF Koha.Preference('ArticleRequests') %]
849
    <div id="open-article-requests-limit-patron-category" class="container">
932
    <div id="open-article-requests-limit-patron-category" class="container">
850
    [% IF humanbranch %]
933
    [% IF humanbranch %]
851
- 

Return to bug 22456