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