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

(-)a/installer/data/mysql/atomicupdate/bug_10190-mynewcircrule.pl (+37 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "10190",
6
    description => "Add overdue_X_has_rules to pre-existing overdue rule sets in the circulation_rules table",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        if ( !column_exists( 'borrower_modifications', 'relationship' ) ) {
12
            $dbh->do(
13
                q{
14
                    INSERT INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value)
15
                    SELECT DISTINCT 
16
                        branchcode, 
17
                        categorycode, 
18
                        itemtype, 
19
                        CONCAT('overdue_', CAST(REGEXP_REPLACE(rule_name, '[^0-9]', '') AS UNSIGNED), '_has_rules' AS rule_name, 
20
                        1 AS rule_value
21
                    FROM circulation_rules c
22
                    WHERE rule_name LIKE 'overdue\_%' 
23
                        AND rule_name NOT LIKE '%has\_rules'
24
                        AND NOT EXISTS (
25
                            SELECT 1 
26
                            FROM circulation_rules r 
27
                            WHERE r.branchcode <=> circulation_rules.branchcode 
28
                                AND r.categorycode <=> circulation_rules.categorycode 
29
                                AND r.itemtype <=> circulation_rules.itemtype 
30
                                AND r.rule_name = CONCAT('overdue_', CAST(REGEXP_REPLACE(circulation_rules.rule_name, '[^0-9]', '') AS UNSIGNED), '_has_rules')
31
                        );
32
                }
33
            );
34
        }
35
    },
36
};
37
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue (-12 / +14 lines)
Lines 638-644 export default { Link Here
638
            if (this.ruleSetToSubmit === null) {
638
            if (this.ruleSetToSubmit === null) {
639
                this.ruleSetToSubmit = {
639
                this.ruleSetToSubmit = {
640
                    context: this.context,
640
                    context: this.context,
641
                    [`overdue_${this.triggerNumber}_delay`]: this.minDelay,
641
                    [`overdue_${this.triggerNumber}_delay`]: `${this.minDelay}`,
642
                    [`overdue_${this.triggerNumber}_notice`]: null,
642
                    [`overdue_${this.triggerNumber}_notice`]: null,
643
                    [`overdue_${this.triggerNumber}_mtt`]: null,
643
                    [`overdue_${this.triggerNumber}_mtt`]: null,
644
                    [`overdue_${this.triggerNumber}_restrict`]: null,
644
                    [`overdue_${this.triggerNumber}_restrict`]: null,
Lines 742-749 export default { Link Here
742
                      this.currentRuleSet[`overdue_${priorTriggerNumber}_delay`]
742
                      this.currentRuleSet[`overdue_${priorTriggerNumber}_delay`]
743
                  ) + 1
743
                  ) + 1
744
                : 0;
744
                : 0;
745
            this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] =
746
                this.minDelay;
747
        },
745
        },
748
        setMaxDelay() {
746
        setMaxDelay() {
749
            const nextTriggerNumber = parseInt(this.triggerNumber) + 1;
747
            const nextTriggerNumber = parseInt(this.triggerNumber) + 1;
Lines 791-806 export default { Link Here
791
                    null
789
                    null
792
            ) {
790
            ) {
793
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] =
791
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] =
794
                    min;
792
                    `${min}`;
795
            }
793
            }
796
794
797
            // Increment within the valid range
795
            // Increment within the valid range
798
            else {
796
            else {
799
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] =
797
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] =
800
                    Math.min(
798
                    Math.min(
801
                        this.ruleSetToSubmit[
799
                        parseInt(
802
                            `overdue_${this.triggerNumber}_delay`
800
                            this.ruleSetToSubmit[
803
                        ] + 1,
801
                                `overdue_${this.triggerNumber}_delay`
802
                            ]
803
                        ) + 1,
804
                        max
804
                        max
805
                    );
805
                    );
806
            }
806
            }
Lines 809-820 export default { Link Here
809
        decrementDelay() {
809
        decrementDelay() {
810
            // Check for minDelay
810
            // Check for minDelay
811
            const min = this.minDelay !== undefined ? this.minDelay : 1;
811
            const min = this.minDelay !== undefined ? this.minDelay : 1;
812
            let delay = parseInt(
813
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`]
814
            );
812
            // Decrement only if greater than minDelay
815
            // Decrement only if greater than minDelay
813
            if (
816
            if (delay > min) {
814
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] >
817
                delay--;
815
                min
818
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] =
816
            ) {
819
                    `${delay}`;
817
                this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`]--;
818
            }
820
            }
819
            this.setAllowSubmission();
821
            this.setAllowSubmission();
820
        },
822
        },
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js (-2 / +4 lines)
Lines 87-93 export const useCircRulesStore = defineStore("circRules", { Link Here
87
            return value.includes(type) ? $__("Yes") : $__("No");
87
            return value.includes(type) ? $__("Yes") : $__("No");
88
        },
88
        },
89
        hasConflict(oldRuleSet, newRuleSet, triggerNumber) {
89
        hasConflict(oldRuleSet, newRuleSet, triggerNumber) {
90
            if (!oldRuleSet) {
90
            if (
91
                !oldRuleSet ||
92
                oldRuleSet[`overdue_${triggerNumber}_has_rules`] === null
93
            ) {
91
                return false;
94
                return false;
92
            }
95
            }
93
            return (
96
            return (
94
- 

Return to bug 10190