Bug 19108: Fix Stored XSS in fieldmapping.pl
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / transport-cost-matrix.tt
1 [% USE Branches %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Administration &rsaquo; Transport cost matrix</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5
6 <script type="text/javascript">
7 //<![CDATA[
8 function check_transport_cost(e) {
9     var val = e.value;
10     if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
11         return;
12     }
13     alert(_("Cost must be expressed as a decimal number >= 0"));
14 }
15 function disable_transport_cost_chg(e) {
16     var input_name = e.name;
17     var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name
18     disable_transport_cost(cost_id, e.checked);
19 }
20 function disable_transport_cost(cost_id, disable) {
21     if (disable) {
22         $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
23     } else {
24         $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
25     }
26 }
27 function enable_cost_input(cost_id) {
28     var cell = $('#celldiv_'+cost_id);
29     var cost = $(cell).text();
30     var disabled = $(cell).hasClass('disabled-transfer');
31     $(cell).removeClass('disabled-transfer');
32
33     $('#celldiv_'+cost_id).html(
34         '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+
35         '<br/>Disable <input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />'
36     );
37     disable_transport_cost(cost_id, disabled);
38 }
39
40 function form_submit (f) {
41     $(f).find('input:disabled').prop('disabled', false);
42     return true;
43 }
44 $(document).ready(function(){
45     $(".enable_cost_input").on("click",function(){
46         var cost_id = $(this).data("cost-id");
47         enable_cost_input( cost_id );
48     });
49     $("body").on("blur",".cost_input",function(){
50         check_transport_cost(this);
51     });
52     $("body").on("change",".disable_transport_cost",function(){
53         disable_transport_cost_chg(this);
54     });
55     $("#cost_matrix_form").on("submit",function(){
56         return form_submit(this);
57     });
58 })
59 //]]>
60 </script>
61 <style type="text/css">
62 .disabled-transfer {
63     background-color: #FF8888;
64 }
65 </style>
66
67 </head>
68 <body id="admin_transport_cost_matrix" class="admin">
69 [% INCLUDE 'header.inc' %]
70 [% INCLUDE 'prefs-admin-search.inc' %]
71
72 <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>
73
74 <div id="doc3" class="yui-t1">
75
76 <div id="bd">
77     <div id="yui-main">
78     <div class="yui-b">
79     <h1 class="parameters">
80             Defining transport costs between libraries
81     </h1>
82 [% IF ( WARNING_transport_cost_matrix_off ) %]
83 <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>
84 [% END %]
85
86     [% IF ( errors ) %]<div class="dialog alert">
87         <h4>There were problems with your submission</h4>
88         <ul>
89             [% FOR e IN errors %]
90                 <li>Invalid value for [% e %]</li>
91             [% END %]
92         </ul>
93     </div>[% END %]
94
95         <form method="post" action="/cgi-bin/koha/admin/transport-cost-matrix.pl" id="cost_matrix_form">
96             <input type="hidden" name="op" value="set-cost-matrix" />
97             <fieldset id="transport-cost-matrix">
98                 <div class="help">
99                     <p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
100                     <p>Red cells signify no transfer allowed.</p>
101                     <p>Click on individual cells to edit.</p>
102                 </div>
103
104                 <table>
105                     <tr>
106                         <th>From \ To</th>
107                         [% FOR b IN Branches.all() %]
108                         <th>[% b.branchname %]</th>
109                         [% END %]
110                     </tr>
111                 [% FOR bf IN branchfromloop %]
112                     <tr>
113                         <th>[% bf.name %]</th>
114                     [% FOR bt IN bf.branchtoloop %]
115                         <td>
116                         [% IF bt.skip %]
117                             &nbsp;
118                         [% ELSE %]
119                             [% IF bt.disabled %]
120                             <div id="celldiv_[% bt.id %]" class="disabled-transfer">
121                             [% ELSE %]
122                             <div id="celldiv_[% bt.id %]">
123                             [% END %]
124                             <div class="enable_cost_input" data-cost-id="[% bt.id %]">[% bt.disabled ? '&nbsp;' : bt.value %]</div>
125                             <input type="hidden" name="cost_[% bt.id %]" value="[% bt.value %]" />
126                             [% IF bt.disabled %]
127                             <input type="hidden" name="disable_[% bt.id %]" value="1" />
128                             [% END %]
129                             </div>
130                         [% END %]
131                         </td>
132                     [% END %]
133                     </tr>
134                 [% END %]
135                 </table>
136             </fieldset>
137             <fieldset class="action">
138                 <input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
139             </fieldset>
140         </form>
141     </div>
142     </div>
143 <div class="yui-b">
144 [% INCLUDE 'admin-menu.inc' %]
145 </div>
146 </div>
147 [% INCLUDE 'intranet-bottom.inc' %]