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