Bug 20911: Use 'POST' to submit search history forms
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / currency.tt
1 [% USE Asset %]
2 [% USE KohaDates %]
3 [% USE ColumnsSettings %]
4 [% USE HtmlTags %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Administration &rsaquo; Currencies &amp; Exchange rates &rsaquo;
8 [% IF op == 'add_form' %][% IF currency %]Modify currency '[% currency.currency %]'[% ELSE %]New currency[% END %][% END %]
9 [% IF op == 'delete_confirm' %]Confirm deletion of currency '[% currency.currency %]'[% END %]
10 [% IF op == 'list' %]Currencies[% END %]</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("css/datatables.css") %]
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 %]'[% 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 id="doc3" class="yui-t2">
26
27 <div id="bd">
28     <div id="yui-main">
29     <div class="yui-b">
30 [% IF op == 'list' %]
31 <div id="toolbar" class="btn-toolbar">
32     <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>
33 </div>
34 [% END %]
35
36 [% FOR m IN messages %]
37     <div class="dialog [% m.type %]">
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 %]
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 %]" />[% currency.currency %]
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 %]" 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 %]" 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 %]" />
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 %] orders.
132             [% ELSIF nb_of_vendors %]
133                 This currency is used by [% nb_of_vendors %] 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 %]</td>
147             </tr>
148             <tr><th>Rate</th>
149                 <td>[% currency.rate %]</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 %]" />
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 %]</td>
193             <td>[% currency.rate %]</td>
194             <td>[% currency.symbol |html %]</td>
195             <td>[% currency.isocode |html %]</td>
196             <td><span title="[% currency.timestamp %]">[% 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 %]"><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 %]"><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 </div>
222 </div>
223 <div class="yui-b">
224 [% INCLUDE 'admin-menu.inc' %]
225 </div>
226 </div>
227
228 [% MACRO jsinclude BLOCK %]
229     [% Asset.js("js/admin-menu.js") %]
230     [% INCLUDE 'datatables.inc' %]
231     [% INCLUDE 'columns_settings.inc' %]
232     <script type="text/javascript">
233
234         function check_currency(val) {
235             if ( val == 1.0 ) {
236                 $("#active").prop('disabled', false);
237                 $("#hint").html("");
238             } else {
239                 $("#active").prop('checked', false);
240                 $("#active").prop('disabled', true);
241                 $("#hint").html(_("The active currency must have a rate of 1.0"));
242             }
243         }
244
245         $(document).ready(function() {
246             columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'currency', 'currencies-table', 'json' ) %]
247             var issuest = KohaTable("currencies-table", {
248                 dom: 'B<"clearfix">t',
249                 "columnDefs": [
250                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
251                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
252                     ],
253             }, columns_settings );
254
255             // prevents users to check active with a currency != 1
256             $("#rate").keyup(function() {
257                 check_currency( $(this).val() );
258             });
259             check_currency( $("#rate").val() );
260             $("#currency_code").on("blur",function(){
261                 toUC(this);
262             });
263         });
264
265     </script>
266 [% END %]
267 [% INCLUDE 'intranet-bottom.inc' %]