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 <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>
21 <div class="main container-fluid">
23 <div class="col-sm-10 col-sm-push-2">
26 <h1 class="parameters">
27 Defining transport costs between libraries
29 [% IF ( WARNING_transport_cost_matrix_off ) %]
30 <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>
33 [% IF ( errors ) %]<div class="dialog alert">
34 <h4>There were problems with your submission</h4>
37 <li>Invalid value for [% e | html %]</li>
42 <form method="post" action="/cgi-bin/koha/admin/transport-cost-matrix.pl" id="cost_matrix_form">
43 <input type="hidden" name="op" value="set-cost-matrix" />
44 <fieldset id="transport-cost-matrix">
46 <p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
47 <p>Red cells signify no transfer allowed.</p>
48 <p>Click on individual cells to edit.</p>
54 [% FOR b IN Branches.all() %]
55 <th>[% b.branchname | html %]</th>
58 [% FOR bf IN branchfromloop %]
60 <th>[% bf.name | html %]</th>
61 [% FOR bt IN bf.branchtoloop %]
67 <div id="celldiv_[% bt.id | html %]" class="disabled-transfer">
69 <div id="celldiv_[% bt.id | html %]">
71 <div class="enable_cost_input" data-cost-id="[% bt.id | html %]">[% IF bt.disabled %] [% ELSE %][% bt.value | html %][% END %]</div>
72 <input type="hidden" name="cost_[% bt.id | html %]" value="[% bt.value | html %]" />
74 <input type="hidden" name="disable_[% bt.id | html %]" value="1" />
84 <fieldset class="action">
85 <input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
90 </div> <!-- /.col-sm-10.col-sm-push-2 -->
92 <div class="col-sm-2 col-sm-pull-10">
94 [% INCLUDE 'admin-menu.inc' %]
96 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
99 [% MACRO jsinclude BLOCK %]
100 [% Asset.js("js/admin-menu.js") | $raw %]
102 function check_transport_cost(e) {
104 if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
107 alert(_("Cost must be expressed as a decimal number >= 0"));
109 function disable_transport_cost_chg(e) {
110 var input_name = e.name;
111 var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name
112 disable_transport_cost(cost_id, e.checked);
114 function disable_transport_cost(cost_id, disable) {
116 $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
118 $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
121 function enable_cost_input(cost_id) {
122 var cell = $('#celldiv_'+cost_id);
123 var cost = $(cell).text();
124 var disabled = $(cell).hasClass('disabled-transfer');
125 $(cell).removeClass('disabled-transfer');
127 $('#celldiv_'+cost_id).html(
128 '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+
129 '<br/>' + _("Disable ") + '<input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />'
131 disable_transport_cost(cost_id, disabled);
134 function form_submit (f) {
135 $(f).find('input:disabled').prop('disabled', false);
138 $(document).ready(function(){
139 $(".enable_cost_input").on("click",function(){
140 var cost_id = $(this).data("cost-id");
141 enable_cost_input( cost_id );
143 $("body").on("blur",".cost_input",function(){
144 check_transport_cost(this);
146 $("body").on("change",".disable_transport_cost",function(){
147 disable_transport_cost_chg(this);
149 $("#cost_matrix_form").on("submit",function(){
150 return form_submit(this);
155 [% INCLUDE 'intranet-bottom.inc' %]