Bug 30952: Staff interface redesign (header)
[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>Transport cost matrix &rsaquo; Administration &rsaquo; Koha</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 [% WRAPPER 'header.inc' %]
17     [% INCLUDE 'prefs-admin-search.inc' %]
18 [% END %]
19
20 [% WRAPPER 'sub-header.inc' %]
21 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
22     <ol>
23         <li>
24             <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
25         </li>
26         <li>
27             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
28         </li>
29         <li>
30             <a href="#" aria-current="page">
31                 Transport cost matrix
32             </a>
33         </li>
34     </ol>
35 </nav>
36 [% END %]
37
38 <div class="main container-fluid">
39     <div class="row">
40         <div class="col-sm-10 col-sm-push-2">
41             <main>
42
43     <h1 class="parameters">
44             Defining transport costs between libraries
45     </h1>
46 [% IF ( WARNING_transport_cost_matrix_off ) %]
47 <div class="dialog message">Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used.  <br/>Go to the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=UseTransportCostMatrix">UseTransportCostMatrix</a> system preference if you wish to enable this feature.</div>
48 [% END %]
49
50     [% IF ( errors ) %]<div class="dialog alert">
51         <h4>There were problems with your submission</h4>
52         <ul>
53             [% FOR e IN errors %]
54                 <li>Invalid value for [% e | html %]</li>
55             [% END %]
56         </ul>
57     </div>[% END %]
58
59         <form method="post" action="/cgi-bin/koha/admin/transport-cost-matrix.pl" id="cost_matrix_form">
60             <input type="hidden" name="op" value="set-cost-matrix" />
61             <fieldset id="transport-cost-matrix">
62                 <div class="help">
63                     <p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
64                     <p>Red cells signify no transfer allowed.</p>
65                     <p>Click on individual cells to edit.</p>
66                 </div>
67
68                 <table>
69                     <tr>
70                         <th>From \ To</th>
71                         [% FOR b IN Branches.all() %]
72                         <th>[% b.branchname | html %]</th>
73                         [% END %]
74                     </tr>
75                 [% FOR bf IN branchfromloop %]
76                     <tr>
77                         <th>[% bf.name | html %]</th>
78                     [% FOR bt IN bf.branchtoloop %]
79                         <td>
80                         [% IF bt.skip %]
81                             &nbsp;
82                         [% ELSE %]
83                             [% IF bt.disabled %]
84                             <div id="celldiv_[% bt.id | html %]" class="disabled-transfer">
85                             [% ELSE %]
86                             <div id="celldiv_[% bt.id | html %]">
87                             [% END %]
88                             <div class="enable_cost_input" data-cost-id="[% bt.id | html %]">[% IF bt.disabled %]&nbsp;[% ELSE %][% bt.value | html %][% END %]</div>
89                             <input type="hidden" name="cost_[% bt.id | html %]" value="[% bt.value | html %]" />
90                             [% IF bt.disabled %]
91                             <input type="hidden" name="disable_[% bt.id | html %]" value="1" />
92                             [% END %]
93                             </div>
94                         [% END %]
95                         </td>
96                     [% END %]
97                     </tr>
98                 [% END %]
99                 </table>
100             </fieldset>
101             <fieldset class="action">
102                 <input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
103             </fieldset>
104         </form>
105
106             </main>
107         </div> <!-- /.col-sm-10.col-sm-push-2 -->
108
109         <div class="col-sm-2 col-sm-pull-10">
110             <aside>
111                 [% INCLUDE 'admin-menu.inc' %]
112             </aside>
113         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
114      </div> <!-- /.row -->
115
116 [% MACRO jsinclude BLOCK %]
117     [% Asset.js("js/admin-menu.js") | $raw %]
118     <script>
119         function check_transport_cost(e) {
120             var val = e.value;
121             if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
122                 return;
123             }
124             alert(_("Cost must be expressed as a decimal number >= 0"));
125         }
126         function disable_transport_cost_chg(e) {
127             var input_name = e.name;
128             var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name
129             disable_transport_cost(cost_id, e.checked);
130         }
131         function disable_transport_cost(cost_id, disable) {
132             if (disable) {
133                 $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
134             } else {
135                 $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
136             }
137         }
138         function enable_cost_input(cost_id) {
139             var cell = $('#celldiv_'+cost_id);
140             var cost = $(cell).text();
141             var disabled = $(cell).hasClass('disabled-transfer');
142             $(cell).removeClass('disabled-transfer');
143
144             $('#celldiv_'+cost_id).html(
145                 '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+
146                 '<br/>' + _("Disable ") + '<input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />'
147             );
148             disable_transport_cost(cost_id, disabled);
149         }
150
151         function form_submit (f) {
152             $(f).find('input:disabled').prop('disabled', false);
153             return true;
154         }
155         $(document).ready(function(){
156             $(".enable_cost_input").on("click",function(){
157                 var cost_id = $(this).data("cost-id");
158                 enable_cost_input( cost_id );
159             });
160             $("body").on("blur",".cost_input",function(){
161                 check_transport_cost(this);
162             });
163             $("body").on("change",".disable_transport_cost",function(){
164                 disable_transport_cost_chg(this);
165             });
166             $("#cost_matrix_form").on("submit",function(){
167                 return form_submit(this);
168             });
169         });
170     </script>
171 [% END %]
172 [% INCLUDE 'intranet-bottom.inc' %]