diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt index 0b1c848393..501765d65f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt @@ -37,6 +37,27 @@ [% WRAPPER 'main-container.inc' aside='admin-menu' %]

Transport cost matrix

+
+ Enable all cells + Disable empty cells +
+ + +
+
+ [% IF ( WARNING_transport_cost_matrix_off ) %]
Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used.
Go to the @@ -113,11 +134,13 @@ } alert(_("Cost must be expressed as a decimal number >= 0")); } + function disable_transport_cost_chg(e) { var input_name = e.name; var cost_id = input_name.replace(/disable_/, ""); // Parse the code_id out of the input name disable_transport_cost(cost_id, e.checked); } + function disable_transport_cost(cost_id, disable) { if (disable) { $("#celldiv_" + cost_id) @@ -131,6 +154,7 @@ .removeClass("disabled-transfer"); } } + function enable_cost_input(cost_id) { var cell = $("#celldiv_" + cost_id); var cost = $(cell).text(); @@ -158,20 +182,53 @@ $(f).find("input:disabled").prop("disabled", false); return true; } + $(document).ready(function () { $(".enable_cost_input").on("click", function () { var cost_id = $(this).data("cost-id"); enable_cost_input(cost_id); }); + $("body").on("blur", ".cost_input", function () { check_transport_cost(this); }); + $("body").on("change", ".disable_transport_cost", function () { disable_transport_cost_chg(this); }); + $("#cost_matrix_form").on("submit", function () { return form_submit(this); }); + + $("#enable_all_cells").on("click", function () { + $(".enable_cost_input").each(function () { + $(this).trigger("click"); + }); + + $(".disable_transport_cost") + .filter(":checked") + .each(function () { + $(this).trigger("click"); + }); + }); + + $("#disable_all_empty_cells").on("click", function () { + $(".cost_input").each(function () { + if ($(this).val() == "") { + $(this).siblings(".disable_transport_cost").filter(":not(:checked)").trigger("click"); + } + }); + }); + + $(".populate_empty_cells").on("click", function () { + var value = $(this).data("value"); + $(".cost_input").each(function () { + if ($(this).val() == "") { + $(this).val(value); + } + }); + }); }); [% END %]