Bug 9259: Use is instead of is_deeply
[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 deletion of currency '[% searchfield %]'[% 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     });
42 //]]>
43 </script>
44 </head>
45 <body id="admin_currency" class="admin">
46 [% INCLUDE 'header.inc' %]
47 [% INCLUDE 'currencies-admin-search.inc' %]
48
49
50
51 <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 %]
52 [% IF op == 'delete_confirm' %]Confirm deletion of currency '<span class="ex">[% searchfield %]</span>'
53 [% ELSIF op == 'list' %]Currencies
54 [% END %]
55 </div>
56
57 <div id="doc3" class="yui-t2">
58
59 <div id="bd">
60     <div id="yui-main">
61     <div class="yui-b">
62 [% IF op == 'list' %]
63 <div id="toolbar" class="btn-toolbar">
64     <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>
65 </div>
66 [% END %]
67
68 [% FOR m IN messages %]
69     <div class="dialog [% m.type %]">
70         [% SWITCH m.code %]
71         [% CASE 'error_on_update' %]
72             An error occurred when updating this currency. Perhaps it already exists.
73         [% CASE 'error_on_insert' %]
74             An error occurred when adding this currency. The currency code might already exist.
75         [% CASE 'error_on_delete' %]
76             An error occurred when deleting this currency. Check the logs.
77         [% CASE 'success_on_update' %]
78             Currency updated successfully.
79         [% CASE 'success_on_insert' %]
80             Currency added successfully.
81         [% CASE 'success_on_delete' %]
82             Currency deleted successfully.
83         [% CASE %]
84             [% m.code %]
85         [% END %]
86     </div>
87 [% END %]
88
89
90
91 [% IF op == 'add_form' %]
92
93 <form action="/cgi-bin/koha/admin/currency.pl" name="Aform" method="post" class="validated">
94     <input type="hidden" name="op" value="add_validate" />
95     <fieldset class="rows">
96         <legend>
97             [% IF currency %]
98                 Modify currency
99             [% ELSE %]
100                 New currency
101             [% END %]
102         </legend>
103         <ol>
104             <li>
105                 [% IF currency %]
106                     <span class="label">Currency: </span>
107                     <input type="hidden" name="is_a_modif" value="1" />
108                     <input type="hidden" name="currency_code" id="currency" value="[% currency.currency %]" />[% currency.currency %]
109                 [% ELSE %]
110                     <label for="currency_code" class="required">Currency: </label>
111                     <input type="text" name="currency_code" id="currency_code" size="50" maxlength="50" onblur="toUC(this);" required="required" class="required" /> <span class="required">Required</span>
112                 [% END %]
113             </li>
114             <li>
115                 <label for="rate" class="required">Rate: </label>
116                 <input type="text" name="rate" id="rate" size="10" maxlength="10" value="[% currency.rate %]" required="required" class="required" /> <span class="required">Required</span>
117             </li>
118             <li>
119                 <label for="symbol" class="required">Symbol: </label>
120                 <input type="text" name="symbol" id="symbol" size="5" maxlength="5" value="[% currency.symbol %]" required="required" class="required" /> <span class="required">Required</span>
121             </li>
122             <li>
123                 <label for="isocode">ISO code: </label>
124                 <input type="text" name="isocode" id="isocode" size="5" maxlength="5" value="[% currency.isocode %]" />
125             </li>
126             <li>
127                 <span class="label">Last updated: </span>[% currency.timestamp | $KohaDates %]
128             </li>
129             <li>
130                 <label for="active">Active: </label>
131                 [% IF currency.active %]
132                 <input type="checkbox" id="active" name="active" value="1" checked="checked" />
133                 [% ELSE %]
134                 <input type="checkbox" id="active" name="active" value="1" />
135                 [% END %]
136                 <span id="hint" class="hint"></span>
137             </li>
138         </ol>
139     </fieldset>
140
141     <fieldset class="action">
142         <input type="submit" value="Submit" />
143         <a href="/cgi-bin/koha/admin/currency.pl" class="cancel">Cancel</a>
144     </fieldset>
145     </form>
146
147 [% END %]
148
149 [% IF op =='delete_confirm' %]
150     [% IF nb_of_orders or nb_of_vendors %]
151     <div class="dialog alert">
152         <h3>Cannot delete currency <span class="ex">'[% currency.currency %]'</span></h3>
153         <p>
154             [% IF nb_of_orders %]
155                 This currency is used by [% nb_of_orders %] orders.
156             [% ELSIF nb_of_vendors %]
157                 This currency is used by [% nb_of_vendors %] vendors.
158             [% END %]
159             Deletion not possible
160         </p>
161         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
162             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
163         </form>
164     </div>
165     [% ELSE %]
166     <div class="dialog alert">
167         <h3>Confirm deletion of currency <span class="ex">'[% currency.currency %]'</span></h3>
168         <table>
169             <tr><th>Currency</th>
170                 <td>[% currency.currency %]</td>
171             </tr>
172             <tr><th>Rate</th>
173                 <td>[% currency.rate %]</td>
174             </tr>
175         </table>
176         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
177             <input type="hidden" name="op" value="delete_confirmed" />
178             <input type="hidden" name="currency_code" value="[% currency.currency %]" />
179             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this currency</button>
180         </form>
181         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
182             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
183         </form>
184     </div>
185     [% END %]
186 [% END %]
187
188 [% IF op == 'list' %]
189
190 <h2>Currencies and exchange rates</h2>
191
192     [% IF currencies and no_active_currency %]
193         <div class="dialog alert"><h3>No active currency is defined</h3><p>Please edit one currency and mark it as active.</p></div>
194     [% END %]
195
196     [% IF searchfield %]
197         You searched for [% searchfield %]</span>
198     [% END %]
199
200     <table id='currencies-table'>
201       <thead>
202         <tr>
203             <th>Currency</th>
204             <th>Rate</th>
205             <th>Symbol</th>
206             <th>ISO code</th>
207             <th class="title-string">Last updated</th>
208             <th>Active</th>
209             <th>Archived</th>
210             <th>Actions</th>
211         </tr>
212       </thead>
213       <tbody>
214         [% FOREACH currency IN currencies %]
215           <tr>
216             <td>[% currency.currency %]</td>
217             <td>[% currency.rate %]</td>
218             <td>[% currency.symbol |html %]</td>
219             <td>[% currency.isocode |html %]</td>
220             <td><span title="[% currency.timestamp %]">[% currency.timestamp | $KohaDates %]</span></td>
221             <td style="color:green;">[% IF currency.active %]✓[% END %]</td>
222             <td>[% IF currency.archived %]Yes[% END %]</td>
223             <td class="actions">
224               <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>
225               <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>
226             </td>
227           </tr>
228         [% END %]
229       </tbody>
230     </table>
231
232     <br />
233     <div class="hint">
234         <p>
235             When importing MARC files via the staging tools, the tool will attempt to find and use the price of the currently active currency.
236         </p>
237         <p>
238             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)".
239             These examples assume USD is the active currency.
240         </p>
241     </div>
242
243 [% END %]
244
245 </div>
246 </div>
247 <div class="yui-b">
248 [% INCLUDE 'admin-menu.inc' %]
249 </div>
250 </div>
251 [% INCLUDE 'intranet-bottom.inc' %]