5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Transport cost matrix › Administration › Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
10 background-color: #FF8888;
15 <body id="admin_transport_cost_matrix" class="admin">
16 [% WRAPPER 'header.inc' %]
17 [% INCLUDE 'prefs-admin-search.inc' %]
20 [% WRAPPER 'sub-header.inc' %]
21 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
24 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
27 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
30 <a href="#" aria-current="page">
38 <div class="main container-fluid">
40 <div class="col-sm-10 col-sm-push-2">
43 <h1 class="parameters">
44 Defining transport costs between libraries
46 [% IF ( WARNING_transport_cost_matrix_off ) %]
47 <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>
50 [% IF ( errors ) %]<div class="dialog alert">
51 <h4>There were problems with your submission</h4>
54 <li>Invalid value for [% e | html %]</li>
59 <form method="post" action="/cgi-bin/koha/admin/transport-cost-matrix.pl" id="cost_matrix_form">
60 <input type="hidden" name="op" value="set-cost-matrix" />
61 <fieldset id="transport-cost-matrix">
63 <p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
64 <p>Red cells signify no transfer allowed.</p>
65 <p>Click on individual cells to edit.</p>
71 [% FOR b IN Branches.all() %]
72 <th>[% b.branchname | html %]</th>
75 [% FOR bf IN branchfromloop %]
77 <th>[% bf.name | html %]</th>
78 [% FOR bt IN bf.branchtoloop %]
84 <div id="celldiv_[% bt.id | html %]" class="disabled-transfer">
86 <div id="celldiv_[% bt.id | html %]">
88 <div class="enable_cost_input" data-cost-id="[% bt.id | html %]">[% IF bt.disabled %] [% ELSE %][% bt.value | html %][% END %]</div>
89 <input type="hidden" name="cost_[% bt.id | html %]" value="[% bt.value | html %]" />
91 <input type="hidden" name="disable_[% bt.id | html %]" value="1" />
101 <fieldset class="action">
102 <input type="submit" class="btn btn-primary" value="Save" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
107 </div> <!-- /.col-sm-10.col-sm-push-2 -->
109 <div class="col-sm-2 col-sm-pull-10">
111 [% INCLUDE 'admin-menu.inc' %]
113 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
114 </div> <!-- /.row -->
116 [% MACRO jsinclude BLOCK %]
117 [% Asset.js("js/admin-menu.js") | $raw %]
119 function check_transport_cost(e) {
121 if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
124 alert(_("Cost must be expressed as a decimal number >= 0"));
126 function disable_transport_cost_chg(e) {
127 var input_name = e.name;
128 var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name
129 disable_transport_cost(cost_id, e.checked);
131 function disable_transport_cost(cost_id, disable) {
133 $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
135 $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
138 function enable_cost_input(cost_id) {
139 var cell = $('#celldiv_'+cost_id);
140 var cost = $(cell).text();
141 var disabled = $(cell).hasClass('disabled-transfer');
142 $(cell).removeClass('disabled-transfer');
144 $('#celldiv_'+cost_id).html(
145 '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+
146 '<br/>' + _("Disable ") + '<input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />'
148 disable_transport_cost(cost_id, disabled);
151 function form_submit (f) {
152 $(f).find('input:disabled').prop('disabled', false);
155 $(document).ready(function(){
156 $(".enable_cost_input").on("click",function(){
157 var cost_id = $(this).data("cost-id");
158 enable_cost_input( cost_id );
160 $("body").on("blur",".cost_input",function(){
161 check_transport_cost(this);
163 $("body").on("change",".disable_transport_cost",function(){
164 disable_transport_cost_chg(this);
166 $("#cost_matrix_form").on("submit",function(){
167 return form_submit(this);
172 [% INCLUDE 'intranet-bottom.inc' %]