5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha › Administration › Transport cost matrix</title>
7 [% INCLUDE 'doc-head-close.inc' %]
10 background-color: #FF8888;
15 <body id="admin_transport_cost_matrix" class="admin">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'prefs-admin-search.inc' %]
19 <nav aria-label="Breadcrumb" class="breadcrumb">
22 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
25 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
28 <a href="#" aria-current="page">
35 <div class="main container-fluid">
37 <div class="col-sm-10 col-sm-push-2">
40 <h1 class="parameters">
41 Defining transport costs between libraries
43 [% IF ( WARNING_transport_cost_matrix_off ) %]
44 <div class="dialog message">Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used. <br/>Go to the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=UseTransportCostMatrix">UseTransportCostMatrix</a> system preference if you wish to enable this feature.</div>
47 [% IF ( errors ) %]<div class="dialog alert">
48 <h4>There were problems with your submission</h4>
51 <li>Invalid value for [% e | html %]</li>
56 <form method="post" action="/cgi-bin/koha/admin/transport-cost-matrix.pl" id="cost_matrix_form">
57 <input type="hidden" name="op" value="set-cost-matrix" />
58 <fieldset id="transport-cost-matrix">
60 <p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
61 <p>Red cells signify no transfer allowed.</p>
62 <p>Click on individual cells to edit.</p>
68 [% FOR b IN Branches.all() %]
69 <th>[% b.branchname | html %]</th>
72 [% FOR bf IN branchfromloop %]
74 <th>[% bf.name | html %]</th>
75 [% FOR bt IN bf.branchtoloop %]
81 <div id="celldiv_[% bt.id | html %]" class="disabled-transfer">
83 <div id="celldiv_[% bt.id | html %]">
85 <div class="enable_cost_input" data-cost-id="[% bt.id | html %]">[% IF bt.disabled %] [% ELSE %][% bt.value | html %][% END %]</div>
86 <input type="hidden" name="cost_[% bt.id | html %]" value="[% bt.value | html %]" />
88 <input type="hidden" name="disable_[% bt.id | html %]" value="1" />
98 <fieldset class="action">
99 <input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
104 </div> <!-- /.col-sm-10.col-sm-push-2 -->
106 <div class="col-sm-2 col-sm-pull-10">
108 [% INCLUDE 'admin-menu.inc' %]
110 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
111 </div> <!-- /.row -->
113 [% MACRO jsinclude BLOCK %]
114 [% Asset.js("js/admin-menu.js") | $raw %]
116 function check_transport_cost(e) {
118 if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
121 alert(_("Cost must be expressed as a decimal number >= 0"));
123 function disable_transport_cost_chg(e) {
124 var input_name = e.name;
125 var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name
126 disable_transport_cost(cost_id, e.checked);
128 function disable_transport_cost(cost_id, disable) {
130 $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
132 $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
135 function enable_cost_input(cost_id) {
136 var cell = $('#celldiv_'+cost_id);
137 var cost = $(cell).text();
138 var disabled = $(cell).hasClass('disabled-transfer');
139 $(cell).removeClass('disabled-transfer');
141 $('#celldiv_'+cost_id).html(
142 '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+
143 '<br/>' + _("Disable ") + '<input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />'
145 disable_transport_cost(cost_id, disabled);
148 function form_submit (f) {
149 $(f).find('input:disabled').prop('disabled', false);
152 $(document).ready(function(){
153 $(".enable_cost_input").on("click",function(){
154 var cost_id = $(this).data("cost-id");
155 enable_cost_input( cost_id );
157 $("body").on("blur",".cost_input",function(){
158 check_transport_cost(this);
160 $("body").on("change",".disable_transport_cost",function(){
161 disable_transport_cost_chg(this);
163 $("#cost_matrix_form").on("submit",function(){
164 return form_submit(this);
169 [% INCLUDE 'intranet-bottom.inc' %]