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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt (-1 / +57 lines)
Lines 37-42 Link Here
37
37
38
[% WRAPPER 'main-container.inc' aside='admin-menu' %]
38
[% WRAPPER 'main-container.inc' aside='admin-menu' %]
39
    <h1 class="parameters"> Transport cost matrix </h1>
39
    <h1 class="parameters"> Transport cost matrix </h1>
40
    <div id="toolbar" class="btn-toolbar">
41
        <a id="enable_all_cells" class="btn btn-default" href="#"><i class="fa-solid fa-circle-check" aria-hidden="true"></i> Enable all cells</a>
42
        <a id="disable_all_empty_cells" class="btn btn-default" href="#"><i class="fa-solid fa-ban" aria-hidden="true"></i> Disable empty cells</a>
43
        <div id="addchild" class="btn-group">
44
            <button class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-plus"></i> Populate empty cells</button>
45
            <ul class="dropdown-menu">
46
                <li><a class="populate_empty_cells dropdown-item" data-value="0" href="#">0</a></li>
47
                <li><a class="populate_empty_cells dropdown-item" data-value="10" href="#">10</a></li>
48
                <li><a class="populate_empty_cells dropdown-item" data-value="20" href="#">20</a></li>
49
                <li><a class="populate_empty_cells dropdown-item" data-value="30" href="#">30</a></li>
50
                <li><a class="populate_empty_cells dropdown-item" data-value="40" href="#">40</a></li>
51
                <li><a class="populate_empty_cells dropdown-item" data-value="50" href="#">50</a></li>
52
                <li><a class="populate_empty_cells dropdown-item" data-value="60" href="#">60</a></li>
53
                <li><a class="populate_empty_cells dropdown-item" data-value="70" href="#">70</a></li>
54
                <li><a class="populate_empty_cells dropdown-item" data-value="80" href="#">80</a></li>
55
                <li><a class="populate_empty_cells dropdown-item" data-value="90" href="#">90</a></li>
56
                <li><a class="populate_empty_cells dropdown-item" data-value="100" href="#">100</a></li>
57
            </ul>
58
        </div>
59
    </div>
60
40
    [% IF ( WARNING_transport_cost_matrix_off ) %]
61
    [% IF ( WARNING_transport_cost_matrix_off ) %]
41
        <div class="alert alert-info"
62
        <div class="alert alert-info"
42
            >Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used. <br />Go to the
63
            >Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used. <br />Go to the
Lines 113-123 Link Here
113
            }
134
            }
114
            alert(_("Cost must be expressed as a decimal number >= 0"));
135
            alert(_("Cost must be expressed as a decimal number >= 0"));
115
        }
136
        }
137
116
        function disable_transport_cost_chg(e) {
138
        function disable_transport_cost_chg(e) {
117
            var input_name = e.name;
139
            var input_name = e.name;
118
            var cost_id = input_name.replace(/disable_/, ""); // Parse the code_id out of the input name
140
            var cost_id = input_name.replace(/disable_/, ""); // Parse the code_id out of the input name
119
            disable_transport_cost(cost_id, e.checked);
141
            disable_transport_cost(cost_id, e.checked);
120
        }
142
        }
143
121
        function disable_transport_cost(cost_id, disable) {
144
        function disable_transport_cost(cost_id, disable) {
122
            if (disable) {
145
            if (disable) {
123
                $("#celldiv_" + cost_id)
146
                $("#celldiv_" + cost_id)
Lines 131-136 Link Here
131
                    .removeClass("disabled-transfer");
154
                    .removeClass("disabled-transfer");
132
            }
155
            }
133
        }
156
        }
157
134
        function enable_cost_input(cost_id) {
158
        function enable_cost_input(cost_id) {
135
            var cell = $("#celldiv_" + cost_id);
159
            var cell = $("#celldiv_" + cost_id);
136
            var cost = $(cell).text();
160
            var cost = $(cell).text();
Lines 158-177 Link Here
158
            $(f).find("input:disabled").prop("disabled", false);
182
            $(f).find("input:disabled").prop("disabled", false);
159
            return true;
183
            return true;
160
        }
184
        }
185
161
        $(document).ready(function () {
186
        $(document).ready(function () {
162
            $(".enable_cost_input").on("click", function () {
187
            $(".enable_cost_input").on("click", function () {
163
                var cost_id = $(this).data("cost-id");
188
                var cost_id = $(this).data("cost-id");
164
                enable_cost_input(cost_id);
189
                enable_cost_input(cost_id);
165
            });
190
            });
191
166
            $("body").on("blur", ".cost_input", function () {
192
            $("body").on("blur", ".cost_input", function () {
167
                check_transport_cost(this);
193
                check_transport_cost(this);
168
            });
194
            });
195
169
            $("body").on("change", ".disable_transport_cost", function () {
196
            $("body").on("change", ".disable_transport_cost", function () {
170
                disable_transport_cost_chg(this);
197
                disable_transport_cost_chg(this);
171
            });
198
            });
199
172
            $("#cost_matrix_form").on("submit", function () {
200
            $("#cost_matrix_form").on("submit", function () {
173
                return form_submit(this);
201
                return form_submit(this);
174
            });
202
            });
203
204
            $("#enable_all_cells").on("click", function () {
205
                $(".enable_cost_input").each(function () {
206
                    $(this).trigger("click");
207
                });
208
209
                $(".disable_transport_cost")
210
                    .filter(":checked")
211
                    .each(function () {
212
                        $(this).trigger("click");
213
                    });
214
            });
215
216
            $("#disable_all_empty_cells").on("click", function () {
217
                $(".cost_input").each(function () {
218
                    if ($(this).val() == "") {
219
                        $(this).siblings(".disable_transport_cost").filter(":not(:checked)").trigger("click");
220
                    }
221
                });
222
            });
223
224
            $(".populate_empty_cells").on("click", function () {
225
                var value = $(this).data("value");
226
                $(".cost_input").each(function () {
227
                    if ($(this).val() == "") {
228
                        $(this).val(value);
229
                    }
230
                });
231
            });
175
        });
232
        });
176
    </script>
233
    </script>
177
[% END %]
234
[% END %]
178
- 

Return to bug 41360