Bug 20538: Remove the need of writing [% KOHA_VERSION %] everywhere
[koha_ffzg] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / transport-cost-matrix.tt
1 [% USE Asset %]
2 [% USE Branches %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Administration &rsaquo; Transport cost matrix</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 <style type="text/css">
8 .disabled-transfer {
9     background-color: #FF8888;
10 }
11 </style>
12 </head>
13
14 <body id="admin_transport_cost_matrix" class="admin">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'prefs-admin-search.inc' %]
17
18 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Transport cost matrix</div>
19
20 <div id="doc3" class="yui-t1">
21
22 <div id="bd">
23     <div id="yui-main">
24     <div class="yui-b">
25     <h1 class="parameters">
26             Defining transport costs between libraries
27     </h1>
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&amp;searchfield=UseTransportCostMatrix">here</a> if you wish to enable this feature.</div>
30 [% END %]
31
32     [% IF ( errors ) %]<div class="dialog alert">
33         <h4>There were problems with your submission</h4>
34         <ul>
35             [% FOR e IN errors %]
36                 <li>Invalid value for [% e %]</li>
37             [% END %]
38         </ul>
39     </div>[% END %]
40
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">
44                 <div class="help">
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>
48                 </div>
49
50                 <table>
51                     <tr>
52                         <th>From \ To</th>
53                         [% FOR b IN Branches.all() %]
54                         <th>[% b.branchname %]</th>
55                         [% END %]
56                     </tr>
57                 [% FOR bf IN branchfromloop %]
58                     <tr>
59                         <th>[% bf.name %]</th>
60                     [% FOR bt IN bf.branchtoloop %]
61                         <td>
62                         [% IF bt.skip %]
63                             &nbsp;
64                         [% ELSE %]
65                             [% IF bt.disabled %]
66                             <div id="celldiv_[% bt.id %]" class="disabled-transfer">
67                             [% ELSE %]
68                             <div id="celldiv_[% bt.id %]">
69                             [% END %]
70                             <div class="enable_cost_input" data-cost-id="[% bt.id %]">[% bt.disabled ? '&nbsp;' : bt.value %]</div>
71                             <input type="hidden" name="cost_[% bt.id %]" value="[% bt.value %]" />
72                             [% IF bt.disabled %]
73                             <input type="hidden" name="disable_[% bt.id %]" value="1" />
74                             [% END %]
75                             </div>
76                         [% END %]
77                         </td>
78                     [% END %]
79                     </tr>
80                 [% END %]
81                 </table>
82             </fieldset>
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>
85             </fieldset>
86         </form>
87     </div>
88     </div>
89 <div class="yui-b">
90 [% INCLUDE 'admin-menu.inc' %]
91 </div>
92 </div>
93
94 [% MACRO jsinclude BLOCK %]
95     [% Asset.js("js/admin-menu.js") %]
96     <script type="text/javascript">
97         function check_transport_cost(e) {
98             var val = e.value;
99             if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
100                 return;
101             }
102             alert(_("Cost must be expressed as a decimal number >= 0"));
103         }
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);
108         }
109         function disable_transport_cost(cost_id, disable) {
110             if (disable) {
111                 $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
112             } else {
113                 $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
114             }
115         }
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');
121
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' : '')+' />'
125             );
126             disable_transport_cost(cost_id, disabled);
127         }
128
129         function form_submit (f) {
130             $(f).find('input:disabled').prop('disabled', false);
131             return true;
132         }
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 );
137             });
138             $("body").on("blur",".cost_input",function(){
139                 check_transport_cost(this);
140             });
141             $("body").on("change",".disable_transport_cost",function(){
142                 disable_transport_cost_chg(this);
143             });
144             $("#cost_matrix_form").on("submit",function(){
145                 return form_submit(this);
146             });
147         });
148     </script>
149 [% END %]
150 [% INCLUDE 'intranet-bottom.inc' %]