Bug 33908: Improve translation of title tags: Acquisitions
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / invoice.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Price %]
6 [% SET footerjs = 1 %]
7 [% USE AuthorisedValues %]
8 [% PROCESS 'i18n.inc' %]
9 [% BLOCK fund_dropdown %]
10     <select id="[% form_id | html %]" name="[% form_name | html %]" class="fund_dropdown" data-selected="[% selected | html %]">
11     </select>
12     <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
13     <input type="checkbox" class="showallfunds" />
14 [% END %]
15
16 [% INCLUDE 'doc-head-open.inc' %]
17 <title>[% FILTER collapse %]
18     [% t("Invoice") | html %] &rsaquo;
19     [% t("Acquisitions") | html %] &rsaquo;
20     [% t("Koha") | html %]
21 [% END %]</title>
22 [% INCLUDE 'doc-head-close.inc' %]
23 [% Asset.css("css/humanmsg.css") | $raw %]
24 </head>
25
26 <body id="acq_invoice" class="acq">
27 [% WRAPPER 'header.inc' %]
28     [% INCLUDE 'acquisitions-search.inc' %]
29 [% END %]
30
31 [% SET readonly = NOT CAN_user_acquisition_edit_invoices %]
32
33 [% WRAPPER 'sub-header.inc' %]
34     [% WRAPPER breadcrumbs %]
35         [% WRAPPER breadcrumb_item %]
36             <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
37         [% END %]
38         [% WRAPPER breadcrumb_item %]
39             <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a>
40         [% END %]
41         [% WRAPPER breadcrumb_item bc_active=1 %]
42             [% invoicenumber | html %]
43         [% END %]
44     [% END #/ WRAPPER breadcrumbs %]
45 [% END #/ WRAPPER sub-header.inc %]
46
47 <div class="main container-fluid">
48     <div class="row">
49         <div class="col-sm-10 col-sm-push-2">
50             <main>
51
52                 <h1>Invoice: [% invoicenumber | html %]</h1>
53                 [% INCLUDE 'blocking_errors.inc' %]
54
55                 [% IF ( modified ) %]
56                     <div class="dialog message">
57                         <p>Invoice has been modified</p>
58                     </div>
59                 [% END %]
60
61                 <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% suppliername | html %]</a></p>
62
63                 <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
64                     <fieldset class="rows">
65                         <ol>
66                             <li>
67                                 [% IF readonly %]
68                                     <label for="shipmentdate">Invoice number:</label>
69                                     [% invoicenumber | html %]
70                                 [% ELSE %]
71                                     <label for="shipmentdate" class="required">Invoice number:</label>
72                                     <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]" class="required" required="required"/>
73                                     <span class="required">Required</span>
74                                 [% END %]
75                             </li>
76                             <li>
77                                 <label for="shipmentdate">Shipment date:</label>
78                                 [% IF readonly %]
79                                     [% shipmentdate | $KohaDates %]
80                                 [% ELSE %]
81                                     <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | html %]" class="flatpickr" />
82                                     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
83                                 [% END %]
84                             </li>
85                             <li>
86                                 <label for="billingdate">Billing date:</label>
87                                 [% IF readonly %]
88                                     [% billingdate | $KohaDates %]
89                                 [% ELSE %]
90                                     <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | html %]" class="flatpickr" />
91                                     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
92                                 [% END %]
93                             </li>
94                             <li>
95                                 <label for="shipmentcost">Shipping cost:</label>
96                                 [% IF readonly %]
97                                     [% shipmentcost | $Price %]
98                                 [% ELSE %]
99                                     <input class="decimal" type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% IF shipmentcost %][% shipmentcost | $Price on_editing => 1 %][% END %]" />
100                                 [% END %]
101                             </li>
102                             <li>
103                                 <label for="shipment_budget_id">Shipping fund: </label>
104                                 [% PROCESS fund_dropdown form_id => 'shipment_budget_id' form_name => 'shipment_budget_id' selected => shipment_budget_id %]
105                             </li>
106
107                             [% IF ( invoiceclosedate ) %]
108                                 <li>
109                                     <span class="label">Status:</span>
110                                     Closed on [% invoiceclosedate | $KohaDates %]
111                                 </li>
112                                 [% IF CAN_user_acquisition_reopen_closed_invoices AND NOT readonly %]
113                                     <li>
114                                         <label for="reopen">Reopen: </label>
115                                         <input type="checkbox" name="reopen" id="reopen" />
116                                     </li>
117                                 [% END %]
118                             [% ELSE %]
119                                 <li>
120                                     <span class="label">Status:</span>
121                                     Open
122                                 </li>
123                                 [% UNLESS ( readonly ) %]
124                                     <li>
125                                         <label for="close">Close: </label>
126                                         <input type="checkbox" name="close" id="close" />
127                                     </li>
128                                 [% END %]
129                             [% END # /IF ( invoiceclosedate ) %]
130                         </ol>
131
132                         [% IF available_additional_fields.count %]
133                             [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
134                         [% END %]
135
136                     </fieldset>
137                     [% UNLESS readonly %]
138                         <fieldset class="action">
139                             <input type="hidden" name="op" value="mod" />
140                             <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
141                             <input type="submit" class="btn btn-primary" value="Save" />
142                             [% IF CAN_user_acquisition_delete_invoices AND NOT orders_loop.size %]
143                                 <a href="invoice.pl?op=delete&invoiceid=[% invoiceid | uri %]" id="delete">Delete</a>
144                             [% END %]
145                         </fieldset>
146                     [% END %]
147                 </form>
148
149                 <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
150                     <fieldset class="rows">
151                         <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
152                         <h3>Adjustments</h3>
153                         [% IF (adjustments && adjustments.count > 0) %]
154                             <table id="invoice_adj_table">
155                                 <tr>
156                                     <th>Id</th>
157                                     <th>Amount</th>
158                                     <th>Reason</th>
159                                     <th>Note</th>
160                                     <th>Fund</th>
161                                     <th>Encumber while invoice open</th>
162                                     [% UNLESS readonly %]<th>&nbsp;</th>[% END %]
163                                 </tr>
164                                 [% total_adj = 0 %]
165                                 [% FOREACH adjustment IN adjustments %]
166                                     [% total_adj = total_adj + adjustment.adjustment %]
167                                     <tr>
168                                         <td>
169                                             <input type="hidden" name="adjustment_id" value="[% adjustment.adjustment_id | html %]" />[% adjustment.adjustment_id | html %]
170                                         </td>
171                                         <td>
172                                             [% IF readonly %]
173                                                 [% adjustment.adjustment | $Price %]
174                                             [% ELSE %]
175                                                 <input class="decimal" type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price on_editing => 1 %]" />
176                                             [% END %]
177                                         </td>
178                                         <td>
179                                             [% IF readonly %]
180                                                 [% AuthorisedValues.GetByCode('ADJ_REASON', adjustment.reason) | html %]
181                                             [% ELSE %]
182                                                 [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
183                                                 [% IF reasons.0 %]
184                                                     <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
185                                                         <option value="">No reason</option>
186                                                         [% FOREACH reason IN reasons %]
187                                                             [% IF ( adjustment.reason == reason.authorised_value ) %]
188                                                                 <option selected="selected" value="[% reason.authorised_value | html %]">
189                                                             [% ELSE %]
190                                                                 <option value="[% reason.authorised_value | html %]">
191                                                             [% END %]
192                                                                 [% reason.lib | html %]
193                                                                 </option>
194                                                         [% END %]
195                                                     </select>
196                                                 [% ELSE %]
197                                                     <p title="Define values in authorised value category ADJ_REASON to enable">None</p>
198                                                     <input type="hidden" name="reason" id="reason_[% adjustment.adjustment_id | html %]" value="" />
199                                                 [% END # /IF reasons.0 %]
200                                             [% END # /IF readonly %]
201                                         </td>
202                                         <td>
203                                             [% IF readonly %]
204                                                 [% adjustment.note | html %]
205                                             [% ELSE %]
206                                                 <input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/>
207                                             [% END %]
208                                         </td>
209                                         <td>
210                                             [% PROCESS fund_dropdown form_id => "budget_id_" _ adjustment.adjustment_id form_name => 'budget_id' selected => adjustment.budget_id %]
211                                         </td>
212                                         [% IF adjustment.encumber_open %]
213                                             <td>
214                                                 [% IF readonly %]
215                                                     <input type="checkbox" checked="checked" readonly="readonly" />
216                                                 [% ELSE %]
217                                                     <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]"  value="[% adjustment.adjustment_id | html %]" checked/>
218                                                 [% END %]
219                                             </td>
220                                         [% ELSE %]
221                                             <td>
222                                                 [% IF readonly %]
223                                                     <input type="checkbox" disabled="disabled" />
224                                                 [% ELSE %]
225                                                     <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]"  value="[% adjustment.adjustment_id | html %]" />
226                                                 [% END %]
227                                             </td>
228                                         [% END # /IF adjustment.encumber_open  %]
229                                         [% UNLESS readonly %]
230                                             <td>
231                                                 <a class="btn btn-default btn-xs delete_adjustment" href="/cgi-bin/koha/acqui/invoice.pl?op=del_adj&adjustment_id=[% adjustment.adjustment_id | html %]&invoiceid=[% invoiceid | html %]"><i class="fa fa-trash-can"></i> Delete</a>
232                                             </td>
233                                         [% END %]
234                                     </tr>
235                                 [% END # /FOREACH adjustment %]
236                             </table> <!-- /#invoice_adj_table -->
237                         [% END # /IF adjustments %]
238
239                         [% UNLESS readonly %]
240                             <div id="show_invoice_adjustment">
241                                 <p>
242                                     <a href="#" class="toggle_invoice_adjustment"><i class="fa fa-plus"></i> Add an adjustment</a>
243                                 </p>
244                             </div>
245
246                             <fieldset id="add_invoice_adjustment" style="display:none">
247                                 <h4>Add an adjustment</h4>
248                                 <input type="hidden" name="adjustment_id" value="new" />
249                                 <ol>
250                                     <li>
251                                         <label for="adjustment_new">Amount: </label>
252                                         <input class="decimal" type="text" name="adjustment" id="adjustment_new" />
253                                     </li>
254                                     [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
255                                     [% IF reasons.0 %]
256                                         <li>
257                                             <label for="reason_[% adjustment.adjustment_id | html %]">Reason: </label>
258                                             <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
259                                                 <option value="">No reason</option>
260                                                 [% FOREACH reason IN reasons %]
261                                                     <option value="[% reason.authorised_value | html %]">
262                                                         [% reason.lib | html %]
263                                                     </option>
264                                                 [% END %]
265                                             </select>
266                                         </li>
267                                     [% ELSE %]
268                                         <li>
269                                             <span class="label">Reason: </span>
270                                             <span>None</span>
271                                             <div class="hint">Define values in authorised value category ADJ_REASON to enable</div>
272                                         </li>
273                                     [% END # /IF reasons.0 %]
274                                     <li>
275                                         <label for="note_new">Note: </label>
276                                         <input type="text" name="note" id="note_new" value=""/>
277                                     </li>
278                                     <li>
279                                         <label for="budget_id_new">Fund: </label>
280                                         [% PROCESS fund_dropdown form_id => "budget_id_new" form_name => 'budget_id' selected => "" %]
281                                     </li>
282                                     <li>
283                                         <label for="encumber_new">Encumber while invoice open? </label>
284                                         <input type="checkbox" name="encumber_open" id="encumber_new" value="new" />
285                                         <input type="hidden" name="delete" value="">
286                                     </li>
287                                 </ol>
288                             </fieldset> <!-- /#add_invoice_adjustment -->
289                         [% END #/UNLESS readonly %]
290                     </fieldset>
291                     [% UNLESS readonly %]
292                         <fieldset class="action" id="submit_invoice_adjustment">
293                             <input type="hidden" name="op" value="mod_adj" />
294                             <input type="submit" class="btn btn-primary" value="Update adjustments" />
295                             <a href="#" id="cancel_invoice_adjustment" class="toggle_invoice_adjustment cancel" style="display:none"><i class="fa fa-times"></i> Cancel</a>
296                         </fieldset>
297                     [% END #/UNLESS readonly %]
298                 </form>
299
300                 <p>
301                     <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">Go to receipt page</a>
302                     [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]">Manage invoice files</a>[% END %]
303                 </p>
304
305                 <fieldset>
306                     <legend>Invoice details</legend>
307                     [% IF orders_loop.size %]
308                         <label for="show_all_details">
309                             <input type="checkbox" style="vertical-align: middle;" id="show_all_details" />
310                             Show all details
311                         </label>
312                         <table id="orderst">
313                             <thead>
314                                 <tr>
315                                     <th class="anti-the">Summary</th>
316                                     <th>Library</th>
317                                     [% IF has_invoice_unitprice %]
318                                         <th>Invoice price</th>
319                                     [% END %]
320                                     <th class="tax_excluded">Actual cost tax exc.</th>
321                                     <th class="tax_included">Actual cost tax inc.</th>
322                                     <th class="replacementprice">Replacement price</th>
323                                     <th>Qty.</th>
324                                     <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
325                                     <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
326                                     <th>GST %</th>
327                                     <th>GST</th>
328                                     <th>Fund</th>
329                                 </tr>
330                             </thead>
331                             <tbody>
332                                 [% FOREACH order IN orders_loop %]
333                                     <tr>
334                                         <td>
335                                             [% IF order.biblionumber %]
336                                                 [% INCLUDE 'biblio-title.inc' biblio=order link = 1 %]
337                                                 [% IF ( order.author ) %]
338                                                     <br /><em>by</em> [% order.author | html %]
339                                                 [% END %]
340                                             [% ELSE %]
341                                                 <em>Deleted bibliographic record, can't find title</em>
342                                             [% END %]
343                                             [% IF ( order.isbn ) %] &ndash; [% order.isbn | html %][% END %]
344                                             [% IF ( order.publishercode ) %]
345                                                 <br/>[% order.publishercode | html %]
346                                                 [% IF order.publicationyear %], [% order.publicationyear | html %]
347                                                 [% ELSIF ( order.copyrightdate ) %][% order.copyrightdate | html %][% END %]
348                                             [% END %]
349                                         </td>
350                                         <td>
351                                             <p>[% order.branchcode | html %]</p>
352                                             [% IF has_invoice_unitprice %]
353                                                 <td>
354                                                     [% IF order.invoice_unitprice %]
355                                                         [% order.invoice_unitprice | $Price %] [% order.invoice_currency | html %]
356                                                     [% END %]
357                                                 </td>
358                                             [% END %]
359                                         </td>
360                                         <td class="number tax_excluded">
361                                             [% order.unitprice_tax_excluded | $Price %]
362                                         </td>
363                                         <td class="number tax_included">
364                                             [% order.unitprice_tax_included | $Price %]
365                                         </td>
366                                         <td class="number replacementprice">
367                                             [% order.replacementprice | $Price %]
368                                             [% IF ( order.uncertainprice ) %]
369                                                 <span>(Uncertain)</span>
370                                             [% END %]
371                                         </td>
372                                         <td class="number">
373                                             [% order.quantity | html %]
374                                         </td>
375                                         <td class="number tax_excluded">
376                                             [% order.total_tax_excluded | $Price %]
377                                         </td>
378                                         <td class="number tax_included">
379                                             [% order.total_tax_included | $Price %]
380                                         </td>
381                                         <td class="number">
382                                             [% order.tax_rate * 100 | html %]
383                                         </td>
384                                         <td class="number">
385                                             [% order.tax_value | $Price %]
386                                         </td>
387                                         <td>
388                                             <span class="order_name" data-order_id="[% order.ordernumber | html %]">[% order.budget_name | html %]</span></br>
389                                             <a href="#" class="modify_fund" data-order_id="[% order.ordernumber | html %]" data-budget_id="[% order.budget_id | html %]" data-sort_1="[% order.sort1 | html %]" data-sort_2="[% order.sort2 | html %]" data-sort1="[% order.sort1 | html %]" data-sort2="[% order.sort2 | html %]">Modify fund</a>
390                                         </td>
391                                     </tr>
392                                 [% END # /FOREACH order %]
393                             </tbody>
394                             <tfoot>
395                                 [% FOR tf IN foot_loop %]
396                                     <tr>
397                                         <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
398                                         [% IF has_invoice_unitprice %]
399                                             <th></th>
400                                         [% END %]
401                                         <th class="tax_excluded"></th>
402                                         <th class="tax_included"></th>
403                                         <th class="replacementprice"/>
404                                         <th>[% tf.quantity | html %]</th>
405                                         <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
406                                         <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
407                                         <th>&nbsp;</th>
408                                         <th>[% tf.tax_value | $Price %]</th>
409                                         <th>&nbsp;</th>
410                                     </tr>
411                                 [% END # /FOR tf %]
412                                 <tr>
413                                     <th colspan="2">Total ([% currency.symbol | html %])</th>
414                                     [% IF has_invoice_unitprice %]
415                                         <th></th>
416                                     [% END %]
417                                     <th class="tax_excluded"></th>
418                                     <th class="tax_included"></th>
419                                     <th class="replacementprice"/>
420                                     <th>[% total_quantity | html %]</th>
421                                     <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
422                                     <th class="tax_included">[% total_tax_included | $Price %]</th>
423                                     <th>&nbsp;</th>
424                                     <th>[% total_tax_value | $Price %]</th>
425                                     <th>&nbsp;</th>
426                                 </tr>
427                                 <tr>
428                                     <th colspan="2">Total + adjustments + shipment cost ([% currency.symbol | html %])</th>
429                                     [% IF has_invoice_unitprice %]
430                                         <th></th>
431                                     [% END %]
432                                     <th class="tax_excluded"></th>
433                                     <th class="tax_included"></th>
434                                     <th class="replacementprice"/>
435                                     <th>[% total_quantity | html %]</th>
436                                     <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
437                                     <th class="tax_included">[% total_tax_included_shipment + total_adj | $Price %]</th>
438                                     <th>&nbsp;</th>
439                                     <th>[% total_tax_value | $Price %]</th>
440                                     <th>&nbsp;</th>
441                                 </tr>
442                             </tfoot>
443                         </table> <!-- /#orderst -->
444                     [% ELSE %]
445                         <div class="dialog message">
446                             <p>No orders yet</p>
447                             [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
448                                 <p>Adjustments plus shipping: [% total_adj + shipmentcost | $Price %]</p>
449                             [% END %]
450                         </div>
451                     [% END # /IF orders_loop.size %]
452                 </fieldset>
453
454                 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
455                     <div class="page-section">
456                         <h2>Files attached to invoice</h2>
457                         <table id="invoice_files_table">
458                             <thead>
459                                 <tr>
460                                     <th>Name</th>
461                                     <th>Type</th>
462                                     <th>Description</th>
463                                     <th>Uploaded</th>
464                                 </tr>
465                             </thead>
466                             <tbody>
467                                 [% FOREACH f IN files %]
468                                     <tr>
469                                         <td>
470                                             <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id | uri %]">[% f.file_name | html %]</a>
471                                         </td>
472                                         <td>[% f.file_type | html %]</td>
473                                         <td>[% f.file_description | html %]</td>
474                                         <td data-order="[% f.date_uploaded | html %]">
475                                             [% f.date_uploaded | $KohaDates %]
476                                         </td>
477                                     </tr>
478                                 [% END %]
479                             </tbody>
480                         </table> <!-- /#invoice_files_table -->
481                     </div>
482                 [% END # /IF AcqEnableFiles %]
483             </main>
484         </div> <!-- /.col-sm-10.col-sm-push-2 -->
485
486         <aside>
487             <div class="col-sm-2 col-sm-pull-10">
488                 [% INCLUDE 'acquisitions-menu.inc' %]
489             </div>
490         </aside>
491     </div> <!-- /.row -->
492
493 <div id="updateFund" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="updateReceivedFund" aria-hidden="true">
494     <div class="modal-dialog">
495         <div class="modal-content">
496             <div class="modal-header">
497                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
498                 <h3 id="updateReceivedFund">Update received fund</h3>
499             </div>
500             <div class="modal-body">
501                 <p>Updating the fund may change available statistics for the order, please check values before submitting.</p>
502                 <fieldset class="rows">
503                     <ol>
504                         <li>
505                             [% PROCESS fund_dropdown form_id => 'modify_budget_id' form_name => 'modify_budget_id' selected => "" %]
506                         </li>
507                         <li>
508                             <label for="sort1">Statistic 1: </label>
509                             <input type="text" name="sort1" />
510                         </li>
511                         <li>
512                             <label for="sort2">Statistic 2: </label>
513                             <input type="text" name="sort2" />
514                         </li>
515                     </ol>
516                 </fieldset>
517                 <a id="update_fund" class="btn btn-default">Update fund</a>
518             </div>
519             <div class="modal-footer">
520                 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
521             </div> <!-- /.modal-footer -->
522         </div> <!-- /.modal-content -->
523     </div> <!-- /.modal-dialog -->
524 </div> <!-- /#updateFund.modal -->
525
526 <span style="display:none;" id="all_fund_dropdown">
527     [% FOREACH budget IN budgets %]
528         [% IF ( budget.b_active ) %]
529             <option value="[% budget.b_id | html %]" data-sort1-authcat="[% budget.b_sort1_authcat | html %]" data-sort2-authcat="[% budget.b_sort2_authcat | html %]">[% budget.b_txt | html %]</option>
530         [% ELSE %]
531             <option value="[% budget.b_id | html %]" class="b_inactive" data-sort1-authcat="[% budget.b_sort1_authcat | html %]" data-sort2-authcat="[% budget.b_sort2_authcat |html %]">[% budget.b_txt | html %] (inactive)</option>
532         [% END %]
533     [% END # /FOREACH budget %]
534 </span> <!-- /#all_fund_dropdown -->
535
536 [% MACRO jsinclude BLOCK %]
537     [% Asset.js("js/acquisitions-menu.js") | $raw %]
538     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
539     [% Asset.js("js/acq.js") | $raw %]
540     [% INCLUDE 'calendar.inc' %]
541     [% INCLUDE 'datatables.inc' %]
542     <script>
543         function updateColumnsVisibility(visible) {
544             if ( visible ) {
545                 $("table .tax_excluded, .tax_included").show();
546             } else {
547                 [% IF ( invoiceincgst ) %]
548                     $("table .tax_excluded").hide();
549                 [% ELSE %]
550                     $("table .tax_included").hide();
551                 [% END %]
552             }
553         }
554
555         $(document).ready(function() {
556             $("#delete").click(function(){
557                 return confirmDelete(_("Are you sure you want to delete this invoice?"));
558             });
559             $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
560                 bInfo: false,
561                 bPaginate: false,
562                 bFilter: false,
563                 sDom: "t",
564                 "aoColumnDefs": [
565                     { "sType": "anti-the", "aTargets": [ "anti-the" ] }
566                 ]
567             }));
568             [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
569                 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
570                     bInfo: false,
571                     bPaginate: false,
572                     bFilter: false,
573                     sDom: "t"
574                 }));
575             [% END %]
576             $("#show_all_details").click(function(){
577                 updateColumnsVisibility( $(this).is(":checked") );
578             });
579
580             $("#show_all_details").prop('checked', false);
581             updateColumnsVisibility(false);
582             $(".toggle_invoice_adjustment").on("click", function(e){
583                 e.preventDefault();
584                 $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
585             });
586             $("a.delete_adjustment").click(function(){
587                 return ( confirm( _("Are you sure you want to delete this file ?") ) );
588             });
589
590             //keep a copy of all budgets before removing the inactives
591             var disabledBudgetsCopy = $("#all_fund_dropdown").html();
592             $(".fund_dropdown").each(function(){
593                 $(this).html( disabledBudgetsCopy);
594                 var selected = $(this).data('selected');
595                 $(this).find('option[value="'+selected+'"]').removeClass('b_inactive');
596                 $(this).val( selected );
597             });
598
599             $('.b_inactive').remove();
600
601             $('.showallfunds').click(function() {
602                 var the_dropdown = $(this).siblings('.fund_dropdown');
603                 var selected = the_dropdown.val();
604                 if ($(this).is(":checked")) {
605                     the_dropdown.html(disabledBudgetsCopy).val(selected);
606                 }
607                 else {
608                     the_dropdown.find('option[value="'+selected+'"]').removeClass('b_inactive');
609                     $(this).siblings().find('.b_inactive').remove();
610                 }
611             });
612
613             $(".modify_fund").on('click',function(e){
614                 e.preventDefault();
615                 var selected = $(this).data('budget_id');
616                 var sort1 = $(this).data('sort1');
617                 var sort2 = $(this).data('sort2');
618                 $("#update_fund").data('order_id',$(this).data('order_id'));
619                 $("#modify_budget_id").html(disabledBudgetsCopy);
620                 $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive');
621                 $("#sort1").val(sort1);
622                 $("#sort2").val(sort2);
623                 $("#modify_budget_id").find('.b_inactive').remove();
624                 $("#modify_budget_id").change();
625                 $("#updateFund").modal('show');
626             });
627             $("#update_fund").on('click',function(){
628                 var new_fund = $("#modify_budget_id").val();
629                 var sort1 = $("#sort1").val();
630                 var sort2 = $("#sort2").val();
631                 var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text();
632                 var order_id = $(this).data('order_id');
633                 let options = {
634                     url: "/api/v1/acquisitions/orders/" + order_id,
635                     method: 'PUT',
636                     contentType: 'application/json',
637                     data: JSON.stringify({
638                         fund_id: new_fund,
639                         statistics_1: sort1,
640                         statistics_2: sort2
641                     })
642                 };
643                 $.ajax(options)
644                     .then(function(thing,result){
645                         $("#updateFund").modal('hide');
646                         $('#updateFund .showallfunds').prop('checked',false);
647                         $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund);
648                         $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name);
649                         humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } );
650                     })
651                     .fail(function(err){
652                         humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } );
653                     });
654             });
655             $("#modify_budget_id").change(function(){
656                 var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]');
657                 var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
658                 var sort1 = $(destination_sort1).val() || "";
659                 if ( destination_sort1.length < 1 ) {
660                     destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]');
661                 }
662                 var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]');
663                 var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
664                 var sort2 = $(destination_sort2).val() || "";
665                 if ( destination_sort2.length < 1 ) {
666                     destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]');
667                 }
668                 getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
669                 getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
670             });
671             // same effort for the adjustments
672             var adjBudgetId = $("#budget_id_new");
673             var disabledAdjBudgetsCopy = adjBudgetId.html();
674             $('.ab_inactive').remove();
675             $('#showallfunds_adj').click(function() {
676                 if ($(this).is(":checked")) {
677                     adjBudgetId.html(disabledAdjBudgetsCopy); //Puts back all the funds
678                 }
679                 else {
680                     $('.ab_inactive').remove();
681                 }
682             });
683         });
684     </script>
685 [% END %]
686
687 [% INCLUDE 'intranet-bottom.inc' %]