Bug 26234: Teach our KohaTable constructor the specific th classes
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / transport-cost-matrix.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Administration &rsaquo; Transport cost matrix</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 <style>
9 .disabled-transfer {
10     background-color: #FF8888;
11 }
12 </style>
13 </head>
14
15 <body id="admin_transport_cost_matrix" class="admin">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'prefs-admin-search.inc' %]
18
19 <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>
20
21 <div class="main container-fluid">
22     <div class="row">
23         <div class="col-sm-10 col-sm-push-2">
24             <main>
25
26     <h1 class="parameters">
27             Defining transport costs between libraries
28     </h1>
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.  Go <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=UseTransportCostMatrix">here</a> if you wish to enable this feature.</div>
31 [% END %]
32
33     [% IF ( errors ) %]<div class="dialog alert">
34         <h4>There were problems with your submission</h4>
35         <ul>
36             [% FOR e IN errors %]
37                 <li>Invalid value for [% e | html %]</li>
38             [% END %]
39         </ul>
40     </div>[% END %]
41
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">
45                 <div class="help">
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>
49                 </div>
50
51                 <table>
52                     <tr>
53                         <th>From \ To</th>
54                         [% FOR b IN Branches.all() %]
55                         <th>[% b.branchname | html %]</th>
56                         [% END %]
57                     </tr>
58                 [% FOR bf IN branchfromloop %]
59                     <tr>
60                         <th>[% bf.name | html %]</th>
61                     [% FOR bt IN bf.branchtoloop %]
62                         <td>
63                         [% IF bt.skip %]
64                             &nbsp;
65                         [% ELSE %]
66                             [% IF bt.disabled %]
67                             <div id="celldiv_[% bt.id | html %]" class="disabled-transfer">
68                             [% ELSE %]
69                             <div id="celldiv_[% bt.id | html %]">
70                             [% END %]
71                             <div class="enable_cost_input" data-cost-id="[% bt.id | html %]">[% IF bt.disabled %]&nbsp;[% ELSE %][% bt.value | html %][% END %]</div>
72                             <input type="hidden" name="cost_[% bt.id | html %]" value="[% bt.value | html %]" />
73                             [% IF bt.disabled %]
74                             <input type="hidden" name="disable_[% bt.id | html %]" value="1" />
75                             [% END %]
76                             </div>
77                         [% END %]
78                         </td>
79                     [% END %]
80                     </tr>
81                 [% END %]
82                 </table>
83             </fieldset>
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>
86             </fieldset>
87         </form>
88
89             </main>
90         </div> <!-- /.col-sm-10.col-sm-push-2 -->
91
92         <div class="col-sm-2 col-sm-pull-10">
93             <aside>
94                 [% INCLUDE 'admin-menu.inc' %]
95             </aside>
96         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
97      </div> <!-- /.row -->
98
99 [% MACRO jsinclude BLOCK %]
100     [% Asset.js("js/admin-menu.js") | $raw %]
101     <script>
102         function check_transport_cost(e) {
103             var val = e.value;
104             if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
105                 return;
106             }
107             alert(_("Cost must be expressed as a decimal number >= 0"));
108         }
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);
113         }
114         function disable_transport_cost(cost_id, disable) {
115             if (disable) {
116                 $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
117             } else {
118                 $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
119             }
120         }
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');
126
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' : '')+' />'
130             );
131             disable_transport_cost(cost_id, disabled);
132         }
133
134         function form_submit (f) {
135             $(f).find('input:disabled').prop('disabled', false);
136             return true;
137         }
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 );
142             });
143             $("body").on("blur",".cost_input",function(){
144                 check_transport_cost(this);
145             });
146             $("body").on("change",".disable_transport_cost",function(){
147                 disable_transport_cost_chg(this);
148             });
149             $("#cost_matrix_form").on("submit",function(){
150                 return form_submit(this);
151             });
152         });
153     </script>
154 [% END %]
155 [% INCLUDE 'intranet-bottom.inc' %]