bug_5911: Transport Cost Matrix
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / transport-cost-matrix.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Transport Cost Matrix</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4
5 <script type="text/javascript">
6 //<![CDATA[
7 function check_transport_cost(e) {
8     var val = e.value;
9     if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
10         return;
11     }
12     alert("Cost must be expressed as a decimal number >= 0");
13 }
14 function disable_transport_cost_chg(e, cost_id) {
15     disable_transport_cost(cost_id, e.checked);
16 }
17 function disable_transport_cost(cost_id, disable) {
18     if (disable) {
19         $('#celldiv_'+cost_id).find('input[type=text]').attr("disabled","disabled").addClass('disabled-transfer');
20     } else {
21         $('#celldiv_'+cost_id).find('input:disabled').removeAttr("disabled").removeClass('disabled-transfer');
22     }
23 }
24 function enable_cost_input(cost_id) {
25     var cell = $('#celldiv_'+cost_id);
26     var cost = $(cell).text();
27     var disabled = $(cell).hasClass('disabled-transfer');
28     $(cell).removeClass('disabled-transfer');
29
30     $('#celldiv_'+cost_id).html(
31         '<input type="text" name="cost_'+cost_id+'" onblur="check_transport_cost(this);" size="4" value="'+$.trim(cost)+'" />'+
32         '<br/>Disable <input name="disable_'+cost_id+'" value="1" onchange="disable_transport_cost_chg(this, \''+cost_id+'\');" type="checkbox" '+(disabled ? 'checked' : '')+' />'
33     );
34     disable_transport_cost(cost_id, disabled);
35 }
36
37 function form_submit (f) {
38     $(f).find('input:disabled').removeAttr("disabled");
39     return true;
40 }
41
42 $(document).ready(function() {
43     show_transport_cost_matrix([% IF UseTransportCostMatrix %]true[% ELSE %]false[% END %]);
44 });
45 //]]>
46 </script>
47 <style type="text/css">
48 .disabled-transfer {
49     background-color: red;
50 }
51 .errors {
52     color: red;
53 }
54 </style>
55
56 </head>
57 <body>
58 [% INCLUDE 'header.inc' %]
59 [% INCLUDE 'cat-search.inc' %]
60
61 <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>
62
63 <div id="doc3" class="yui-t1">
64
65 <div id="bd">
66     <div id="yui-main">
67     <div class="yui-b">
68     <h1 class="parameters">
69             Defining transport costs between libraries
70     </h1>
71 [% IF ( WARNING_transport_cost_matrix_off ) %]
72 <div class="dialog message">Because the "UseTransportCostMatrix" system preference is currently not enabled, 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>
73 [% END %]
74
75     <div class="container">
76         <form method="post" action="?" onSubmit="return form_submit(this);">
77             <input type="hidden" name="op" value="set-cost-matrix" />
78             <div id="transport-cost-matrix">
79                 <div class="help">
80                     <p>Costs are decimal values 0 to some arbitrarymax value (1 or 100), 0 being minimum (no) cost.</p>
81                     <p>Red cells signify no transfer allowed</p>
82                     <p>Click on the cell to edit</p>
83                 </div>
84                 <ul class="errors" %]>
85                 [% FOR e IN errors %]
86                     <li>[% e %]</li>
87                 [% END %]
88                 </ul>
89                 <table>
90                     <tr>
91                         <th>From \ To</th>
92                 [% FOR b IN branchloop %]
93                         <th>[% b.name %]</th>
94                 [% END %]
95                     <tr>
96                 [% FOR bf IN branchfromloop %]
97                     <tr>
98                         <th>[% bf.name %]</th>
99                     [% FOR bt IN bf.branchtoloop %]
100                         <td>
101                         [% IF bt.skip %]
102                             &nbsp;
103                         [% ELSE %]
104                             [% IF bt.disabled %]
105                             <div id="celldiv_[% bt.id %]" class="disabled-transfer">
106                             [% ELSE %]
107                             <div id="celldiv_[% bt.id %]">
108                             [% END %]
109                             <div onclick="enable_cost_input('[% bt.id %]');">[% bt.disabled ? '&nbsp;' : bt.value %]</div>
110                             <input type="hidden" name="cost_[% bt.id %]" value="[% bt.value %]" />
111                             [% IF bt.disabled %]
112                             <input type="hidden" name="disable_[% bt.id %]" value="1" />
113                             [% END %]
114                             </div>
115                         [% END %]
116                         </td>
117                     [% END %]
118                     </tr>
119                 [% END %]
120                 </table>
121             </div>
122             <input type="submit" value="Save" class="submit" />
123         </form>
124     </div>
125     </div>
126     </div>
127 <div class="yui-b">
128 [% INCLUDE 'admin-menu.inc' %]
129 </div>
130 </div>
131 [% INCLUDE 'intranet-bottom.inc' %]