Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / currency.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE ColumnsSettings %]
5 [% USE HtmlTags %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Administration &rsaquo; Currencies &amp; Exchange rates &rsaquo;
9 [% IF op == 'add_form' %][% IF currency %]Modify currency '[% currency.currency | html %]'[% ELSE %]New currency[% END %][% END %]
10 [% IF op == 'delete_confirm' %]Confirm deletion of currency '[% currency.currency | html %]'[% END %]
11 [% IF op == 'list' %]Currencies[% END %]</title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 [% Asset.css("css/datatables.css") | $raw %]
14 </head>
15
16 <body id="admin_currency" class="admin">
17 [% INCLUDE 'header.inc' %]
18 [% INCLUDE 'currencies-admin-search.inc' %]
19
20 <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;  <a href="/cgi-bin/koha/admin/currency.pl">Currencies &amp; Exchange rates</a> &rsaquo; [% IF op == 'add_form' %][% IF currency %]Modify currency '[% currency.currency | html %]'[% ELSE %]New currency[% END %][% END %]
21 [% IF op == 'delete_confirm' %]Confirm deletion of currency [% currency.currency | $HtmlTags tag='span' attributes=>'class="ex"' | html %]
22 [% ELSIF op == 'list' %]Currencies
23 [% END %]
24 </div>
25
26 <div id="doc3" class="yui-t2">
27
28 <div id="bd">
29     <div id="yui-main">
30     <div class="yui-b">
31 [% IF op == 'list' %]
32 <div id="toolbar" class="btn-toolbar">
33     <a class="btn btn-default btn-sm" id="newcurrency" href="/cgi-bin/koha/admin/currency.pl?op=add_form"><i class="fa fa-plus"></i> New currency</a>
34 </div>
35 [% END %]
36
37 [% FOR m IN messages %]
38     <div class="dialog [% m.type | html %]">
39         [% SWITCH m.code %]
40         [% CASE 'error_on_update' %]
41             An error occurred when updating this currency. Perhaps it already exists.
42         [% CASE 'error_on_insert' %]
43             An error occurred when adding this currency. The currency code might already exist.
44         [% CASE 'error_on_delete' %]
45             An error occurred when deleting this currency. Check the logs.
46         [% CASE 'success_on_update' %]
47             Currency updated successfully.
48         [% CASE 'success_on_insert' %]
49             Currency added successfully.
50         [% CASE 'success_on_delete' %]
51             Currency deleted successfully.
52         [% CASE %]
53             [% m.code | html %]
54         [% END %]
55     </div>
56 [% END %]
57
58
59
60 [% IF op == 'add_form' %]
61
62 <form action="/cgi-bin/koha/admin/currency.pl" name="Aform" method="post" class="validated">
63     <input type="hidden" name="op" value="add_validate" />
64     <fieldset class="rows">
65         <legend>
66             [% IF currency %]
67                 Modify currency
68             [% ELSE %]
69                 New currency
70             [% END %]
71         </legend>
72         <ol>
73             <li>
74                 [% IF currency %]
75                     <span class="label">Currency: </span>
76                     <input type="hidden" name="is_a_modif" value="1" />
77                     <input type="hidden" name="currency_code" id="currency" value="[% currency.currency | html %]" />[% currency.currency | html %]
78                 [% ELSE %]
79                     <label for="currency_code" class="required">Currency: </label>
80                     <input type="text" name="currency_code" id="currency_code" size="50" maxlength="50" required="required" class="required" /> <span class="required">Required</span>
81                 [% END %]
82             </li>
83             <li>
84                 <label for="rate" class="required">Rate: </label>
85                 <input type="text" name="rate" id="rate" size="10" maxlength="10" value="[% currency.rate | html %]" required="required" class="required" /> <span class="required">Required</span>
86             </li>
87             <li>
88                 <label for="symbol" class="required">Symbol: </label>
89                 <input type="text" name="symbol" id="symbol" size="5" maxlength="5" value="[% currency.symbol | html %]" required="required" class="required" /> <span class="required">Required</span>
90             </li>
91             <li>
92                 <label for="isocode">ISO code: </label>
93                 <input type="text" name="isocode" id="isocode" size="5" maxlength="5" value="[% currency.isocode | html %]" />
94             </li>
95             <li>
96                 <span class="label">Last updated: </span>[% currency.timestamp | $KohaDates %]
97             </li>
98             <li>
99                 <label for="p_sep_by_space">Space separation between symbol and value: </label>
100                 [% IF currency.p_sep_by_space %]
101                     <input type="checkbox" id="p_sep_by_space" name="p_sep_by_space" value="1" checked="checked" />
102                 [% ELSE %]
103                     <input type="checkbox" id="p_sep_by_space" name="p_sep_by_space" value="1" />
104                 [% END %]
105             </li>
106             <li>
107                 <label for="active">Active: </label>
108                 [% IF currency.active %]
109                 <input type="checkbox" id="active" name="active" value="1" checked="checked" />
110                 [% ELSE %]
111                 <input type="checkbox" id="active" name="active" value="1" />
112                 [% END %]
113                 <span id="hint" class="hint"></span>
114             </li>
115         </ol>
116     </fieldset>
117
118     <fieldset class="action">
119         <input type="submit" value="Submit" />
120         <a href="/cgi-bin/koha/admin/currency.pl" class="cancel">Cancel</a>
121     </fieldset>
122     </form>
123
124 [% END %]
125
126 [% IF op =='delete_confirm' %]
127     [% IF nb_of_orders or nb_of_vendors %]
128     <div class="dialog alert">
129         <h3>Cannot delete currency [% currency.currency | $HtmlTags tag='span' attributes=>'class="ex"' | html %]</h3>
130         <p>
131             [% IF nb_of_orders %]
132                 This currency is used by [% nb_of_orders | html %] orders.
133             [% ELSIF nb_of_vendors %]
134                 This currency is used by [% nb_of_vendors | html %] vendors.
135             [% END %]
136             Deletion not possible
137         </p>
138         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
139             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
140         </form>
141     </div>
142     [% ELSE %]
143     <div class="dialog alert">
144         <h3>Confirm deletion of currency [% currency.currency | $HtmlTags tag='span' attributes=>'class="ex"' | html %]</h3>
145         <table>
146             <tr><th>Currency</th>
147                 <td>[% currency.currency | html %]</td>
148             </tr>
149             <tr><th>Rate</th>
150                 <td>[% currency.rate | html %]</td>
151             </tr>
152         </table>
153         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
154             <input type="hidden" name="op" value="delete_confirmed" />
155             <input type="hidden" name="currency_code" value="[% currency.currency | html %]" />
156             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this currency</button>
157         </form>
158         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
159             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
160         </form>
161     </div>
162     [% END %]
163 [% END %]
164
165 [% IF op == 'list' %]
166
167 <h2>Currencies and exchange rates</h2>
168
169     [% IF currencies and no_active_currency %]
170         <div class="dialog alert"><h3>No active currency is defined</h3><p>Please edit one currency and mark it as active.</p></div>
171     [% END %]
172
173     [% IF searchfield %]
174         You searched for [% searchfield | html %]</span>
175     [% END %]
176
177     <table id='currencies-table'>
178       <thead>
179         <tr>
180             <th>Currency</th>
181             <th>Rate</th>
182             <th>Symbol</th>
183             <th>ISO code</th>
184             <th class="title-string">Last updated</th>
185             <th>Active</th>
186             <th>Archived</th>
187             <th>Actions</th>
188         </tr>
189       </thead>
190       <tbody>
191         [% FOREACH currency IN currencies %]
192           <tr>
193             <td>[% currency.currency | html %]</td>
194             <td>[% currency.rate | html %]</td>
195             <td>[% currency.symbol | html %]</td>
196             <td>[% currency.isocode | html %]</td>
197             <td><span title="[% currency.timestamp | html %]">[% currency.timestamp | $KohaDates %]</span></td>
198             <td style="color:green;">[% IF currency.active %]✓[% END %]</td>
199             <td>[% IF currency.archived %]Yes[% END %]</td>
200             <td class="actions">
201               <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/currency.pl?op=add_form&amp;currency_code=[% currency.currency | html %]"><i class="fa fa-pencil"></i> Edit</a>
202               <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/currency.pl?op=delete_confirm&amp;currency_code=[% currency.currency | html %]"><i class="fa fa-trash"></i> Delete</a>
203             </td>
204           </tr>
205         [% END %]
206       </tbody>
207     </table>
208
209     <br />
210     <div class="hint">
211         <p>
212             When importing MARC files via the staging tools, the tool will attempt to find and use the price of the currently active currency.
213         </p>
214         <p>
215             Some examples of compatible price fields include "$9.99", "9.99 USD", "$9.99 USD", "9.99 USD (10.00 CAN)", "$9.99 USD (paperback)".
216             These examples assume USD is the active currency.
217         </p>
218     </div>
219
220 [% END %]
221
222 </div>
223 </div>
224 <div class="yui-b">
225 [% INCLUDE 'admin-menu.inc' %]
226 </div>
227 </div>
228
229 [% MACRO jsinclude BLOCK %]
230     [% Asset.js("js/admin-menu.js") | $raw %]
231     [% INCLUDE 'datatables.inc' %]
232     [% INCLUDE 'columns_settings.inc' %]
233     <script type="text/javascript">
234
235         function check_currency(val) {
236             if ( val == 1.0 ) {
237                 $("#active").prop('disabled', false);
238                 $("#hint").html("");
239             } else {
240                 $("#active").prop('checked', false);
241                 $("#active").prop('disabled', true);
242                 $("#hint").html(_("The active currency must have a rate of 1.0"));
243             }
244         }
245
246         $(document).ready(function() {
247             columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'currency', 'currencies-table', 'json' ).raw %]
248             var issuest = KohaTable("currencies-table", {
249                 dom: 'B<"clearfix">t',
250                 "columnDefs": [
251                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
252                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
253                     ],
254             }, columns_settings );
255
256             // prevents users to check active with a currency != 1
257             $("#rate").keyup(function() {
258                 check_currency( $(this).val() );
259             });
260             check_currency( $("#rate").val() );
261             $("#currency_code").on("blur",function(){
262                 toUC(this);
263             });
264         });
265
266     </script>
267 [% END %]
268 [% INCLUDE 'intranet-bottom.inc' %]