4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha › Administration › Transport cost matrix</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 <style type="text/css">
9 background-color: #FF8888;
14 <body id="admin_transport_cost_matrix" class="admin">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'prefs-admin-search.inc' %]
18 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › Transport cost matrix</div>
20 <div id="doc3" class="yui-t1">
25 <h1 class="parameters">
26 Defining transport costs between libraries
28 [% IF ( WARNING_transport_cost_matrix_off ) %]
29 <div class="dialog message">Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used. Go <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=UseTransportCostMatrix">here</a> if you wish to enable this feature.</div>
32 [% IF ( errors ) %]<div class="dialog alert">
33 <h4>There were problems with your submission</h4>
36 <li>Invalid value for [% e %]</li>
41 <form method="post" action="/cgi-bin/koha/admin/transport-cost-matrix.pl" id="cost_matrix_form">
42 <input type="hidden" name="op" value="set-cost-matrix" />
43 <fieldset id="transport-cost-matrix">
45 <p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
46 <p>Red cells signify no transfer allowed.</p>
47 <p>Click on individual cells to edit.</p>
53 [% FOR b IN Branches.all() %]
54 <th>[% b.branchname %]</th>
57 [% FOR bf IN branchfromloop %]
59 <th>[% bf.name %]</th>
60 [% FOR bt IN bf.branchtoloop %]
66 <div id="celldiv_[% bt.id %]" class="disabled-transfer">
68 <div id="celldiv_[% bt.id %]">
70 <div class="enable_cost_input" data-cost-id="[% bt.id %]">[% bt.disabled ? ' ' : bt.value %]</div>
71 <input type="hidden" name="cost_[% bt.id %]" value="[% bt.value %]" />
73 <input type="hidden" name="disable_[% bt.id %]" value="1" />
83 <fieldset class="action">
84 <input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
90 [% INCLUDE 'admin-menu.inc' %]
94 [% MACRO jsinclude BLOCK %]
95 [% Asset.js("js/admin-menu.js") %]
96 <script type="text/javascript">
97 function check_transport_cost(e) {
99 if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
102 alert(_("Cost must be expressed as a decimal number >= 0"));
104 function disable_transport_cost_chg(e) {
105 var input_name = e.name;
106 var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name
107 disable_transport_cost(cost_id, e.checked);
109 function disable_transport_cost(cost_id, disable) {
111 $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
113 $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
116 function enable_cost_input(cost_id) {
117 var cell = $('#celldiv_'+cost_id);
118 var cost = $(cell).text();
119 var disabled = $(cell).hasClass('disabled-transfer');
120 $(cell).removeClass('disabled-transfer');
122 $('#celldiv_'+cost_id).html(
123 '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+
124 '<br/>' + _("Disable ") + '<input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />'
126 disable_transport_cost(cost_id, disabled);
129 function form_submit (f) {
130 $(f).find('input:disabled').prop('disabled', false);
133 $(document).ready(function(){
134 $(".enable_cost_input").on("click",function(){
135 var cost_id = $(this).data("cost-id");
136 enable_cost_input( cost_id );
138 $("body").on("blur",".cost_input",function(){
139 check_transport_cost(this);
141 $("body").on("change",".disable_transport_cost",function(){
142 disable_transport_cost_chg(this);
144 $("#cost_matrix_form").on("submit",function(){
145 return form_submit(this);
150 [% INCLUDE 'intranet-bottom.inc' %]