Bug 15758: Koha::Libraries - Remove GetBranchesLoop
[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 })
56 //]]>
57 </script>
58 <style type="text/css">
59 .disabled-transfer {
60     background-color: #FF8888;
61 }
62 </style>
63
64 </head>
65 <body id="admin_transport_cost_matrix" class="admin">
66 [% INCLUDE 'header.inc' %]
67 [% INCLUDE 'cat-search.inc' %]
68
69 <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>
70
71 <div id="doc3" class="yui-t1">
72
73 <div id="bd">
74     <div id="yui-main">
75     <div class="yui-b">
76     <h1 class="parameters">
77             Defining transport costs between libraries
78     </h1>
79 [% IF ( WARNING_transport_cost_matrix_off ) %]
80 <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>
81 [% END %]
82
83     [% IF ( errors ) %]<div class="dialog alert">
84         <h4>There were problems with your submission</h4>
85         <ul>
86             [% FOR e IN errors %]
87                 <li>Invalid value for [% e %]</li>
88             [% END %]
89         </ul>
90     </div>[% END %]
91
92         <form method="post" action="?" onsubmit="return form_submit(this);">
93             <input type="hidden" name="op" value="set-cost-matrix" />
94             <fieldset id="transport-cost-matrix">
95                 <div class="help">
96                     <p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
97                     <p>Red cells signify no transfer allowed.</p>
98                     <p>Click on individual cells to edit.</p>
99                 </div>
100
101                 <table>
102                     <tr>
103                         <th>From \ To</th>
104                         [% FOR b IN Branches.all() %]
105                         <th>[% b.branchname %]</th>
106                         [% END %]
107                     </tr>
108                 [% FOR bf IN branchfromloop %]
109                     <tr>
110                         <th>[% bf.name %]</th>
111                     [% FOR bt IN bf.branchtoloop %]
112                         <td>
113                         [% IF bt.skip %]
114                             &nbsp;
115                         [% ELSE %]
116                             [% IF bt.disabled %]
117                             <div id="celldiv_[% bt.id %]" class="disabled-transfer">
118                             [% ELSE %]
119                             <div id="celldiv_[% bt.id %]">
120                             [% END %]
121                             <div class="enable_cost_input" data-cost-id="[% bt.id %]">[% bt.disabled ? '&nbsp;' : bt.value %]</div>
122                             <input type="hidden" name="cost_[% bt.id %]" value="[% bt.value %]" />
123                             [% IF bt.disabled %]
124                             <input type="hidden" name="disable_[% bt.id %]" value="1" />
125                             [% END %]
126                             </div>
127                         [% END %]
128                         </td>
129                     [% END %]
130                     </tr>
131                 [% END %]
132                 </table>
133             </fieldset>
134             <fieldset class="action">
135                 <input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
136             </fieldset>
137         </form>
138     </div>
139     </div>
140 <div class="yui-b">
141 [% INCLUDE 'admin-menu.inc' %]
142 </div>
143 </div>
144 [% INCLUDE 'intranet-bottom.inc' %]