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