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