Bug 27846: admin folder
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / currency.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE TablesSettings %]
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 <nav aria-label="Breadcrumb" class="breadcrumb">
20     <ol>
21         <li>
22             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
23         </li>
24         <li>
25             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
26         </li>
27         <li>
28             <a href="/cgi-bin/koha/admin/currency.pl">Currencies &amp; Exchange rates</a>
29         </li>
30
31         [% IF op == 'add_form' %]
32             <li>
33                 <a href="#" aria-current="page">
34                     [% IF currency %]
35                         Modify currency '[% currency.currency | html %]'
36                     [% ELSE %]
37                         New currency
38                     [% END %]
39                 </a>
40             </li>
41         [% END %]
42
43         [% IF op == 'delete_confirm' %]
44             <li>
45                 <a href="#" aria-current="page">
46                     Confirm deletion of currency [% currency.currency | $HtmlTags tag='span' attributes=>'class="ex"' %]
47                 </a>
48             </li>
49
50         [% ELSIF op == 'list' %]
51             <li>
52                 <a href="#" aria-current="page">
53                     Currencies
54                 </a>
55             </li>
56         [% END %]
57     </ol>
58 </nav>
59
60 <div class="main container-fluid">
61     <div class="row">
62         <div class="col-sm-10 col-sm-push-2">
63             <main>
64
65 [% IF op == 'list' %]
66 <div id="toolbar" class="btn-toolbar">
67     <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>
68 </div>
69 [% END %]
70
71 [% FOR m IN messages %]
72     <div class="dialog [% m.type | html %]">
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 | html %]
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 | html %]" />[% currency.currency | html %]
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 | html %]" 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 | html %]" 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 | html %]" />
128             </li>
129             <li>
130                 <span class="label">Last updated: </span>[% currency.timestamp | $KohaDates %]
131             </li>
132             <li>
133                 <label for="p_sep_by_space">Space separation between symbol and value: </label>
134                 [% IF currency.p_sep_by_space %]
135                     <input type="checkbox" id="p_sep_by_space" name="p_sep_by_space" value="1" checked="checked" />
136                 [% ELSE %]
137                     <input type="checkbox" id="p_sep_by_space" name="p_sep_by_space" value="1" />
138                 [% END %]
139             </li>
140             <li>
141                 <label for="active">Active: </label>
142                 [% IF currency.active %]
143                 <input type="checkbox" id="active" name="active" value="1" checked="checked" />
144                 [% ELSE %]
145                 <input type="checkbox" id="active" name="active" value="1" />
146                 [% END %]
147                 <span id="hint" class="hint"></span>
148             </li>
149         </ol>
150     </fieldset>
151
152     <fieldset class="action">
153         <input type="submit" value="Submit" />
154         <a href="/cgi-bin/koha/admin/currency.pl" class="cancel">Cancel</a>
155     </fieldset>
156     </form>
157
158 [% END %]
159
160 [% IF op =='delete_confirm' %]
161     [% IF nb_of_orders or nb_of_vendors %]
162     <div class="dialog alert">
163         <h3>Cannot delete currency [% currency.currency | $HtmlTags tag='span' attributes=>'class="ex"' %]</h3>
164         <p>
165             [% IF nb_of_orders %]
166                 This currency is used by [% nb_of_orders | html %] orders.
167             [% ELSIF nb_of_vendors %]
168                 This currency is used by [% nb_of_vendors | html %] vendors.
169             [% END %]
170             Deletion not possible
171         </p>
172         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
173             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
174         </form>
175     </div>
176     [% ELSE %]
177     <div class="dialog alert">
178         <h3>Confirm deletion of currency [% currency.currency | $HtmlTags tag='span' attributes=>'class="ex"' %]</h3>
179         <table>
180             <tr><th>Currency</th>
181                 <td>[% currency.currency | html %]</td>
182             </tr>
183             <tr><th>Rate</th>
184                 <td>[% currency.rate | html %]</td>
185             </tr>
186         </table>
187         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
188             <input type="hidden" name="op" value="delete_confirmed" />
189             <input type="hidden" name="currency_code" value="[% currency.currency | html %]" />
190             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this currency</button>
191         </form>
192         <form action="/cgi-bin/koha/admin/currency.pl" method="post">
193             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
194         </form>
195     </div>
196     [% END %]
197 [% END %]
198
199 [% IF op == 'list' %]
200
201 <h2>Currencies and exchange rates</h2>
202
203     [% IF currencies and no_active_currency %]
204         <div class="dialog alert"><h3>No active currency is defined</h3><p>Please edit one currency and mark it as active.</p></div>
205     [% END %]
206
207     [% IF searchfield %]
208         You searched for [% searchfield | html %]</span>
209     [% END %]
210
211     <table id='currencies-table'>
212       <thead>
213         <tr>
214             <th>Currency</th>
215             <th>Rate</th>
216             <th>Symbol</th>
217             <th>ISO code</th>
218             <th class="title-string">Last updated</th>
219             <th>Active</th>
220             <th>Archived</th>
221             <th class="NoSort noExport">Actions</th>
222         </tr>
223       </thead>
224       <tbody>
225         [% FOREACH currency IN currencies %]
226           <tr>
227             <td>[% currency.currency | html %]</td>
228             <td>[% currency.rate | html %]</td>
229             <td>[% currency.symbol | html %]</td>
230             <td>[% currency.isocode | html %]</td>
231             <td><span title="[% currency.timestamp | html %]">[% currency.timestamp | $KohaDates %]</span></td>
232             <td style="color:green;">[% IF currency.active %]✓[% END %]</td>
233             <td>[% IF currency.archived %]Yes[% END %]</td>
234             <td class="actions">
235               <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>
236               <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>
237             </td>
238           </tr>
239         [% END %]
240       </tbody>
241     </table>
242
243     <br />
244     <div class="hint">
245         <p>
246             When importing MARC files via the staging tools, the tool will attempt to find and use the price of the currently active currency.
247         </p>
248         <p>
249             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)".
250             These examples assume USD is the active currency.
251         </p>
252     </div>
253
254 [% END %]
255
256             </main>
257         </div> <!-- /.col-sm-10.col-sm-push-2 -->
258
259         <div class="col-sm-2 col-sm-pull-10">
260             <aside>
261                 [% INCLUDE 'admin-menu.inc' %]
262             </aside>
263         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
264      </div> <!-- /.row -->
265
266 [% MACRO jsinclude BLOCK %]
267     [% Asset.js("js/admin-menu.js") | $raw %]
268     [% INCLUDE 'datatables.inc' %]
269     [% INCLUDE 'columns_settings.inc' %]
270     <script>
271
272         function check_currency(val) {
273             if ( val == 1.0 ) {
274                 $("#active").prop('disabled', false);
275                 $("#hint").html("");
276             } else {
277                 $("#active").prop('checked', false);
278                 $("#active").prop('disabled', true);
279                 $("#hint").html(_("The active currency must have a rate of 1.0"));
280             }
281         }
282
283         $(document).ready(function() {
284             columns_settings = [% TablesSettings.GetColumns( 'admin', 'currency', 'currencies-table', 'json' ) | $raw %]
285             var issuest = KohaTable("currencies-table", {
286                 dom: 'B<"clearfix">t',
287             }, columns_settings );
288
289             // prevents users to check active with a currency != 1
290             $("#rate").keyup(function() {
291                 check_currency( $(this).val() );
292             });
293             check_currency( $("#rate").val() );
294             $("#currency_code").on("blur",function(){
295                 toUC(this);
296             });
297         });
298
299     </script>
300 [% END %]
301 [% INCLUDE 'intranet-bottom.inc' %]