7 [% USE AuthorisedValues %]
9 [% BLOCK fund_dropdown %]
10 <label for="[% form_name | html %]">Shipping fund: </label>
11 <select id="[% form_id | html %]" name="[% form_name | html %]" class="fund_dropdown" data-selected="[% selected | html %]">
13 <label for="showallfunds" style="float:none;width:auto;"> Show inactive:</label>
14 <input type="checkbox" class="showallfunds" />
17 [% INCLUDE 'doc-head-open.inc' %]
18 <title>Invoice › Acquisitions › Koha</title>
19 [% INCLUDE 'doc-head-close.inc' %]
20 [% Asset.css("css/humanmsg.css") | $raw %]
23 <body id="acq_invoice" class="acq">
24 [% WRAPPER 'header.inc' %]
25 [% INCLUDE 'acquisitions-search.inc' %]
28 [% SET readonly = NOT CAN_user_acquisition_edit_invoices %]
30 [% WRAPPER 'sub-header.inc' %]
31 [% WRAPPER breadcrumbs %]
32 [% WRAPPER breadcrumb_item %]
33 <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
35 [% WRAPPER breadcrumb_item %]
36 <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a>
38 [% WRAPPER breadcrumb_item bc_active=1 %]
39 [% invoicenumber | html %]
41 [% END #/ WRAPPER breadcrumbs %]
42 [% END #/ WRAPPER sub-header.inc %]
44 <div class="main container-fluid">
46 <div class="col-sm-10 col-sm-push-2">
49 <h1>Invoice: [% invoicenumber | html %]</h1>
50 [% INCLUDE 'blocking_errors.inc' %]
53 <div class="dialog message">
54 <p>Invoice has been modified</p>
58 <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% suppliername | html %]</a></p>
60 <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
61 <fieldset class="rows">
65 <label for="shipmentdate">Invoice number:</label>
66 [% invoicenumber | html %]
68 <label for="shipmentdate" class="required">Invoice number:</label>
69 <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]" class="required" required="required"/>
70 <span class="required">Required</span>
74 <label for="shipmentdate">Shipment date:</label>
76 [% shipmentdate | $KohaDates %]
78 <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | html %]" class="flatpickr" />
79 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
83 <label for="billingdate">Billing date:</label>
85 [% billingdate | $KohaDates %]
87 <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | html %]" class="flatpickr" />
88 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
92 <label for="shipmentcost">Shipping cost:</label>
94 [% shipmentcost | $Price %]
96 <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" />
100 [% PROCESS fund_dropdown form_id => 'shipment_budget_id' form_name => 'shipment_budget_id' selected => shipment_budget_id %]
103 [% IF ( invoiceclosedate ) %]
105 <span class="label">Status:</span>
106 Closed on [% invoiceclosedate | $KohaDates %]
108 [% IF CAN_user_acquisition_reopen_closed_invoices AND NOT readonly %]
110 <label for="reopen">Reopen: </label>
111 <input type="checkbox" name="reopen" id="reopen" />
116 <span class="label">Status:</span>
119 [% UNLESS ( readonly ) %]
121 <label for="close">Close: </label>
122 <input type="checkbox" name="close" id="close" />
125 [% END # /IF ( invoiceclosedate ) %]
128 [% IF available_additional_fields.count %]
129 [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
133 [% UNLESS readonly %]
134 <fieldset class="action">
135 <input type="hidden" name="op" value="mod" />
136 <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
137 <input type="submit" class="btn btn-primary" value="Save" />
138 [% IF CAN_user_acquisition_delete_invoices AND NOT orders_loop.size %]
139 <a href="invoice.pl?op=delete&invoiceid=[% invoiceid | uri %]" id="delete">Delete</a>
145 <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
146 <fieldset class="rows">
147 <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
149 [% IF (adjustments && adjustments.count > 0) %]
150 <table id="invoice_adj_table">
157 <th>Encumber while invoice open</th>
158 [% UNLESS readonly %]<th> </th>[% END %]
161 [% FOREACH adjustment IN adjustments %]
162 [% total_adj = total_adj + adjustment.adjustment %]
165 <input type="hidden" name="adjustment_id" value="[% adjustment.adjustment_id | html %]" />[% adjustment.adjustment_id | html %]
169 [% adjustment.adjustment | $Price %]
171 <input type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price on_editing => 1 %]" />
176 [% AuthorisedValues.GetByCode('ADJ_REASON', adjustment.reason) | html %]
178 [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
180 <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
181 <option value="">No reason</option>
182 [% FOREACH reason IN reasons %]
183 [% IF ( adjustment.reason == reason.authorised_value ) %]
184 <option selected="selected" value="[% reason.authorised_value | html %]">
186 <option value="[% reason.authorised_value | html %]">
188 [% reason.lib | html %]
193 <p title="Define values in authorised value category ADJ_REASON to enable">None</p>
194 <input type="hidden" name="reason" id="reason_[% adjustment.adjustment_id | html %]" value="" />
195 [% END # /IF reasons.0 %]
196 [% END # /IF readonly %]
200 [% adjustment.note | html %]
202 <input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/>
206 [% PROCESS fund_dropdown form_id => "budget_id_" _ adjustment.adjustment_id form_name => 'budget_id' selected => adjustment.budget_id %]
208 [% IF adjustment.encumber_open %]
211 <input type="checkbox" checked="checked" readonly="readonly" />
213 <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment_id | html %]" checked/>
219 <input type="checkbox" disabled="disabled" />
221 <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment_id | html %]" />
224 [% END # /IF adjustment.encumber_open %]
225 [% UNLESS readonly %]
227 <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>
231 [% END # /FOREACH adjustment %]
232 </table> <!-- /#invoice_adj_table -->
233 [% END # /IF adjustments %]
235 [% UNLESS readonly %]
236 <div id="show_invoice_adjustment">
238 <a href="#" class="toggle_invoice_adjustment"><i class="fa fa-plus"></i> Add an adjustment</a>
242 <fieldset id="add_invoice_adjustment" style="display:none">
243 <h4>Add an adjustment</h4>
244 <input type="hidden" name="adjustment_id" value="new" />
247 <label for="adjustment_new">Amount: </label>
248 <input type="text" name="adjustment" id="adjustment_new" />
250 [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
253 <label for="reason_[% adjustment.adjustment_id | html %]">Reason: </label>
254 <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
255 <option value="">No reason</option>
256 [% FOREACH reason IN reasons %]
257 <option value="[% reason.authorised_value | html %]">
258 [% reason.lib | html %]
265 <span class="label">Reason: </span>
267 <div class="hint">Define values in authorised value category ADJ_REASON to enable</div>
269 [% END # /IF reasons.0 %]
271 <label for="note_new">Note: </label>
272 <input type="text" name="note" id="note_new" value=""/>
275 [% PROCESS fund_dropdown form_id => "budget_id_new" form_name => 'budget_id' selected => "" %]
278 <label for="encumber_new">Encumber while invoice open? </label>
279 <input type="checkbox" name="encumber_open" id="encumber_new" value="new" />
280 <input type="hidden" name="delete" value="">
283 </fieldset> <!-- /#add_invoice_adjustment -->
284 [% END #/UNLESS readonly %]
286 [% UNLESS readonly %]
287 <fieldset class="action" id="submit_invoice_adjustment" style="display:none">
288 <input type="hidden" name="op" value="mod_adj" />
289 <input type="submit" class="btn btn-primary" value="Update adjustments" />
290 <a href="#" id="cancel_invoice_adjustment" class="toggle_invoice_adjustment cancel" style="display:none"><i class="fa fa-times"></i> Cancel</a>
292 [% END #/UNLESS readonly %]
296 <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">Go to receipt page</a>
297 [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]">Manage invoice files</a>[% END %]
301 <legend>Invoice details</legend>
302 [% IF orders_loop.size %]
303 <label for="show_all_details">
304 <input type="checkbox" style="vertical-align: middle;" id="show_all_details" />
310 <th class="anti-the">Summary</th>
312 [% IF has_invoice_unitprice %]
313 <th>Invoice price</th>
315 <th class="tax_excluded">Actual cost tax exc.</th>
316 <th class="tax_included">Actual cost tax inc.</th>
317 <th class="replacementprice">Replacement price</th>
319 <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
320 <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
327 [% FOREACH order IN orders_loop %]
330 [% IF order.biblionumber %]
331 [% INCLUDE 'biblio-title.inc' biblio=order link = 1 %]
332 [% IF ( order.author ) %]
333 <br /><em>by</em> [% order.author | html %]
336 <em>Deleted bibliographic record, can't find title</em>
338 [% IF ( order.isbn ) %] – [% order.isbn | html %][% END %]
339 [% IF ( order.publishercode ) %]
340 <br/>[% order.publishercode | html %]
341 [% IF order.publicationyear %], [% order.publicationyear | html %]
342 [% ELSIF ( order.copyrightdate ) %][% order.copyrightdate | html %][% END %]
346 <p>[% order.branchcode | html %]</p>
347 [% IF has_invoice_unitprice %]
349 [% IF order.invoice_unitprice %]
350 [% order.invoice_unitprice | $Price %] [% order.invoice_currency | html %]
355 <td class="number tax_excluded">
356 [% order.unitprice_tax_excluded | $Price %]
358 <td class="number tax_included">
359 [% order.unitprice_tax_included | $Price %]
361 <td class="number replacementprice">
362 [% order.replacementprice | $Price %]
363 [% IF ( order.uncertainprice ) %]
364 <span>(Uncertain)</span>
368 [% order.quantity | html %]
370 <td class="number tax_excluded">
371 [% order.total_tax_excluded | $Price %]
373 <td class="number tax_included">
374 [% order.total_tax_included | $Price %]
377 [% order.tax_rate * 100 | html %]
380 [% order.tax_value | $Price %]
383 <span class="order_name" data-order_id="[% order.ordernumber | html %]">[% order.budget_name | html %]</span></br>
384 <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>
387 [% END # /FOREACH order %]
390 [% FOR tf IN foot_loop %]
392 <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
393 [% IF has_invoice_unitprice %]
396 <th class="tax_excluded"></th>
397 <th class="tax_included"></th>
398 <th class="replacementprice"/>
399 <th>[% tf.quantity | html %]</th>
400 <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
401 <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
403 <th>[% tf.tax_value | $Price %]</th>
408 <th colspan="2">Total ([% currency.symbol | html %])</th>
409 [% IF has_invoice_unitprice %]
412 <th class="tax_excluded"></th>
413 <th class="tax_included"></th>
414 <th class="replacementprice"/>
415 <th>[% total_quantity | html %]</th>
416 <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
417 <th class="tax_included">[% total_tax_included | $Price %]</th>
419 <th>[% total_tax_value | $Price %]</th>
423 <th colspan="2">Total + adjustments + shipment cost ([% currency.symbol | html %])</th>
424 [% IF has_invoice_unitprice %]
427 <th class="tax_excluded"></th>
428 <th class="tax_included"></th>
429 <th class="replacementprice"/>
430 <th>[% total_quantity | html %]</th>
431 <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
432 <th class="tax_included">[% total_tax_included_shipment + total_adj | $Price %]</th>
434 <th>[% total_tax_value | $Price %]</th>
438 </table> <!-- /#orderst -->
440 <div class="dialog message">
442 [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
443 <p>Adjustments plus shipping: [% total_adj + shipmentcost | $Price %]</p>
446 [% END # /IF orders_loop.size %]
449 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
450 <div class="page-section">
451 <h2>Files attached to invoice</h2>
452 <table id="invoice_files_table">
462 [% FOREACH f IN files %]
465 <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]&op=download&view=1&file_id=[% f.file_id | uri %]">[% f.file_name | html %]</a>
467 <td>[% f.file_type | html %]</td>
468 <td>[% f.file_description | html %]</td>
469 <td data-order="[% f.date_uploaded | html %]">
470 [% f.date_uploaded | $KohaDates %]
475 </table> <!-- /#invoice_files_table -->
477 [% END # /IF AcqEnableFiles %]
479 </div> <!-- /.col-sm-10.col-sm-push-2 -->
482 <div class="col-sm-2 col-sm-pull-10">
483 [% INCLUDE 'acquisitions-menu.inc' %]
486 </div> <!-- /.row -->
488 <div id="updateFund" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="updateReceivedFund" aria-hidden="true">
489 <div class="modal-dialog">
490 <div class="modal-content">
491 <div class="modal-header">
492 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
493 <h3 id="updateReceivedFund">Update received fund</h3>
495 <div class="modal-body">
496 <p>Updating the fund may change available statistics for the order, please check values before submitting.</p>
497 <fieldset class="rows">
500 [% PROCESS fund_dropdown form_id => 'modify_budget_id' form_name => 'modify_budget_id' selected => "" %]
503 <label for="sort1">Statistic 1: </label>
504 <input type="text" name="sort1" />
507 <label for="sort2">Statistic 2: </label>
508 <input type="text" name="sort2" />
512 <a id="update_fund" class="btn btn-default">Update fund</a>
514 <div class="modal-footer">
515 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
516 </div> <!-- /.modal-footer -->
517 </div> <!-- /.modal-content -->
518 </div> <!-- /.modal-dialog -->
519 </div> <!-- /#updateFund.modal -->
521 <span style="display:none;" id="all_fund_dropdown">
522 [% FOREACH budget IN budgets %]
523 [% IF ( budget.b_active ) %]
524 <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>
526 <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>
528 [% END # /FOREACH budget %]
529 </span> <!-- /#all_fund_dropdown -->
531 [% MACRO jsinclude BLOCK %]
532 [% Asset.js("js/acquisitions-menu.js") | $raw %]
533 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
534 [% Asset.js("js/acq.js") | $raw %]
535 [% INCLUDE 'calendar.inc' %]
536 [% INCLUDE 'datatables.inc' %]
538 function updateColumnsVisibility(visible) {
540 $("table .tax_excluded, .tax_included").show();
542 [% IF ( invoiceincgst ) %]
543 $("table .tax_excluded").hide();
545 $("table .tax_included").hide();
550 $(document).ready(function() {
551 $("#delete").click(function(){
552 return confirmDelete(_("Are you sure you want to delete this invoice?"));
554 $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
560 { "sType": "anti-the", "aTargets": [ "anti-the" ] }
563 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
564 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
571 $("#show_all_details").click(function(){
572 updateColumnsVisibility( $(this).is(":checked") );
575 $("#show_all_details").prop('checked', false);
576 updateColumnsVisibility(false);
577 $(".toggle_invoice_adjustment").on("click", function(e){
579 $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment, #submit_invoice_adjustment").toggle();
581 $("a.delete_adjustment").click(function(){
582 return ( confirm( _("Are you sure you want to delete this file ?") ) );
585 //keep a copy of all budgets before removing the inactives
586 var disabledBudgetsCopy = $("#all_fund_dropdown").html();
587 $(".fund_dropdown").each(function(){
588 $(this).html( disabledBudgetsCopy);
589 var selected = $(this).data('selected');
590 $(this).find('option[value="'+selected+'"]').removeClass('b_inactive');
591 $(this).val( selected );
594 $('.b_inactive').remove();
596 $('.showallfunds').click(function() {
597 var the_dropdown = $(this).siblings('.fund_dropdown');
598 var selected = the_dropdown.val();
599 if ($(this).is(":checked")) {
600 the_dropdown.html(disabledBudgetsCopy).val(selected);
603 the_dropdown.find('option[value="'+selected+'"]').removeClass('b_inactive');
604 $(this).siblings().find('.b_inactive').remove();
608 $(".modify_fund").on('click',function(e){
610 var selected = $(this).data('budget_id');
611 var sort1 = $(this).data('sort1');
612 var sort2 = $(this).data('sort2');
613 $("#update_fund").data('order_id',$(this).data('order_id'));
614 $("#modify_budget_id").html(disabledBudgetsCopy);
615 $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive');
616 $("#sort1").val(sort1);
617 $("#sort2").val(sort2);
618 $("#modify_budget_id").find('.b_inactive').remove();
619 $("#modify_budget_id").change();
620 $("#updateFund").modal('show');
622 $("#update_fund").on('click',function(){
623 var new_fund = $("#modify_budget_id").val();
624 var sort1 = $("#sort1").val();
625 var sort2 = $("#sort2").val();
626 var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text();
627 var order_id = $(this).data('order_id');
629 url: "/api/v1/acquisitions/orders/" + order_id,
631 contentType: 'application/json',
632 data: JSON.stringify({
639 .then(function(thing,result){
640 $("#updateFund").modal('hide');
641 $('#updateFund .showallfunds').prop('checked',false);
642 $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund);
643 $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name);
644 humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } );
647 humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } );
650 $("#modify_budget_id").change(function(){
651 var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]');
652 var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
653 var sort1 = $(destination_sort1).val() || "";
654 if ( destination_sort1.length < 1 ) {
655 destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]');
657 var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]');
658 var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
659 var sort2 = $(destination_sort2).val() || "";
660 if ( destination_sort2.length < 1 ) {
661 destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]');
663 getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
664 getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
666 // same effort for the adjustments
667 var adjBudgetId = $("#budget_id_new");
668 var disabledAdjBudgetsCopy = adjBudgetId.html();
669 $('.ab_inactive').remove();
670 $('#showallfunds_adj').click(function() {
671 if ($(this).is(":checked")) {
672 adjBudgetId.html(disabledAdjBudgetsCopy); //Puts back all the funds
675 $('.ab_inactive').remove();
682 [% INCLUDE 'intranet-bottom.inc' %]