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