7 [% USE AuthorisedValues %]
9 [% BLOCK fund_dropdown %]
10 <select id="[% form_id | html %]" name="[% form_name | html %]" class="fund_dropdown" data-selected="[% selected | html %]">
12 <label for="showallfunds" style="float:none;width:auto;"> Show inactive:</label>
13 <input type="checkbox" class="showallfunds" />
16 [% INCLUDE 'doc-head-open.inc' %]
17 <title>Invoice › Acquisitions › Koha</title>
18 [% INCLUDE 'doc-head-close.inc' %]
19 [% Asset.css("css/humanmsg.css") | $raw %]
22 <body id="acq_invoice" class="acq">
23 [% WRAPPER 'header.inc' %]
24 [% INCLUDE 'acquisitions-search.inc' %]
27 [% SET readonly = NOT CAN_user_acquisition_edit_invoices %]
29 [% WRAPPER 'sub-header.inc' %]
30 [% WRAPPER breadcrumbs %]
31 [% WRAPPER breadcrumb_item %]
32 <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
34 [% WRAPPER breadcrumb_item %]
35 <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a>
37 [% WRAPPER breadcrumb_item bc_active=1 %]
38 [% invoicenumber | html %]
40 [% END #/ WRAPPER breadcrumbs %]
41 [% END #/ WRAPPER sub-header.inc %]
43 <div class="main container-fluid">
45 <div class="col-sm-10 col-sm-push-2">
48 <h1>Invoice: [% invoicenumber | html %]</h1>
49 [% INCLUDE 'blocking_errors.inc' %]
52 <div class="dialog message">
53 <p>Invoice has been modified</p>
57 <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% suppliername | html %]</a></p>
59 <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
60 <fieldset class="rows">
64 <label for="shipmentdate">Invoice number:</label>
65 [% invoicenumber | html %]
67 <label for="shipmentdate" class="required">Invoice number:</label>
68 <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]" class="required" required="required"/>
69 <span class="required">Required</span>
73 <label for="shipmentdate">Shipment date:</label>
75 [% shipmentdate | $KohaDates %]
77 <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | html %]" class="flatpickr" />
78 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
82 <label for="billingdate">Billing date:</label>
84 [% billingdate | $KohaDates %]
86 <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | html %]" class="flatpickr" />
87 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
91 <label for="shipmentcost">Shipping cost:</label>
93 [% shipmentcost | $Price %]
95 <input class="decimal" type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" />
99 <label for="shipment_budget_id">Shipping fund: </label>
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 class="decimal" 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 class="decimal" 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 <label for="budget_id_new">Fund: </label>
276 [% PROCESS fund_dropdown form_id => "budget_id_new" form_name => 'budget_id' selected => "" %]
279 <label for="encumber_new">Encumber while invoice open? </label>
280 <input type="checkbox" name="encumber_open" id="encumber_new" value="new" />
281 <input type="hidden" name="delete" value="">
284 </fieldset> <!-- /#add_invoice_adjustment -->
285 [% END #/UNLESS readonly %]
287 [% UNLESS readonly %]
288 <fieldset class="action" id="submit_invoice_adjustment">
289 <input type="hidden" name="op" value="mod_adj" />
290 <input type="submit" class="btn btn-primary" value="Update adjustments" />
291 <a href="#" id="cancel_invoice_adjustment" class="toggle_invoice_adjustment cancel" style="display:none"><i class="fa fa-times"></i> Cancel</a>
293 [% END #/UNLESS readonly %]
297 <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">Go to receipt page</a>
298 [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]">Manage invoice files</a>[% END %]
302 <legend>Invoice details</legend>
303 [% IF orders_loop.size %]
304 <label for="show_all_details">
305 <input type="checkbox" style="vertical-align: middle;" id="show_all_details" />
311 <th class="anti-the">Summary</th>
313 [% IF has_invoice_unitprice %]
314 <th>Invoice price</th>
316 <th class="tax_excluded">Actual cost tax exc.</th>
317 <th class="tax_included">Actual cost tax inc.</th>
318 <th class="replacementprice">Replacement price</th>
320 <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
321 <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
328 [% FOREACH order IN orders_loop %]
331 [% IF order.biblionumber %]
332 [% INCLUDE 'biblio-title.inc' biblio=order link = 1 %]
333 [% IF ( order.author ) %]
334 <br /><em>by</em> [% order.author | html %]
337 <em>Deleted bibliographic record, can't find title</em>
339 [% IF ( order.isbn ) %] – [% order.isbn | html %][% END %]
340 [% IF ( order.publishercode ) %]
341 <br/>[% order.publishercode | html %]
342 [% IF order.publicationyear %], [% order.publicationyear | html %]
343 [% ELSIF ( order.copyrightdate ) %][% order.copyrightdate | html %][% END %]
347 <p>[% order.branchcode | html %]</p>
348 [% IF has_invoice_unitprice %]
350 [% IF order.invoice_unitprice %]
351 [% order.invoice_unitprice | $Price %] [% order.invoice_currency | html %]
356 <td class="number tax_excluded">
357 [% order.unitprice_tax_excluded | $Price %]
359 <td class="number tax_included">
360 [% order.unitprice_tax_included | $Price %]
362 <td class="number replacementprice">
363 [% order.replacementprice | $Price %]
364 [% IF ( order.uncertainprice ) %]
365 <span>(Uncertain)</span>
369 [% order.quantity | html %]
371 <td class="number tax_excluded">
372 [% order.total_tax_excluded | $Price %]
374 <td class="number tax_included">
375 [% order.total_tax_included | $Price %]
378 [% order.tax_rate * 100 | html %]
381 [% order.tax_value | $Price %]
384 <span class="order_name" data-order_id="[% order.ordernumber | html %]">[% order.budget_name | html %]</span></br>
385 <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>
388 [% END # /FOREACH order %]
391 [% FOR tf IN foot_loop %]
393 <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
394 [% IF has_invoice_unitprice %]
397 <th class="tax_excluded"></th>
398 <th class="tax_included"></th>
399 <th class="replacementprice"/>
400 <th>[% tf.quantity | html %]</th>
401 <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
402 <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
404 <th>[% tf.tax_value | $Price %]</th>
409 <th colspan="2">Total ([% currency.symbol | html %])</th>
410 [% IF has_invoice_unitprice %]
413 <th class="tax_excluded"></th>
414 <th class="tax_included"></th>
415 <th class="replacementprice"/>
416 <th>[% total_quantity | html %]</th>
417 <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
418 <th class="tax_included">[% total_tax_included | $Price %]</th>
420 <th>[% total_tax_value | $Price %]</th>
424 <th colspan="2">Total + adjustments + shipment cost ([% currency.symbol | html %])</th>
425 [% IF has_invoice_unitprice %]
428 <th class="tax_excluded"></th>
429 <th class="tax_included"></th>
430 <th class="replacementprice"/>
431 <th>[% total_quantity | html %]</th>
432 <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
433 <th class="tax_included">[% total_tax_included_shipment + total_adj | $Price %]</th>
435 <th>[% total_tax_value | $Price %]</th>
439 </table> <!-- /#orderst -->
441 <div class="dialog message">
443 [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
444 <p>Adjustments plus shipping: [% total_adj + shipmentcost | $Price %]</p>
447 [% END # /IF orders_loop.size %]
450 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
451 <div class="page-section">
452 <h2>Files attached to invoice</h2>
453 <table id="invoice_files_table">
463 [% FOREACH f IN files %]
466 <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>
468 <td>[% f.file_type | html %]</td>
469 <td>[% f.file_description | html %]</td>
470 <td data-order="[% f.date_uploaded | html %]">
471 [% f.date_uploaded | $KohaDates %]
476 </table> <!-- /#invoice_files_table -->
478 [% END # /IF AcqEnableFiles %]
480 </div> <!-- /.col-sm-10.col-sm-push-2 -->
483 <div class="col-sm-2 col-sm-pull-10">
484 [% INCLUDE 'acquisitions-menu.inc' %]
487 </div> <!-- /.row -->
489 <div id="updateFund" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="updateReceivedFund" aria-hidden="true">
490 <div class="modal-dialog">
491 <div class="modal-content">
492 <div class="modal-header">
493 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
494 <h3 id="updateReceivedFund">Update received fund</h3>
496 <div class="modal-body">
497 <p>Updating the fund may change available statistics for the order, please check values before submitting.</p>
498 <fieldset class="rows">
501 [% PROCESS fund_dropdown form_id => 'modify_budget_id' form_name => 'modify_budget_id' selected => "" %]
504 <label for="sort1">Statistic 1: </label>
505 <input type="text" name="sort1" />
508 <label for="sort2">Statistic 2: </label>
509 <input type="text" name="sort2" />
513 <a id="update_fund" class="btn btn-default">Update fund</a>
515 <div class="modal-footer">
516 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
517 </div> <!-- /.modal-footer -->
518 </div> <!-- /.modal-content -->
519 </div> <!-- /.modal-dialog -->
520 </div> <!-- /#updateFund.modal -->
522 <span style="display:none;" id="all_fund_dropdown">
523 [% FOREACH budget IN budgets %]
524 [% IF ( budget.b_active ) %]
525 <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>
527 <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>
529 [% END # /FOREACH budget %]
530 </span> <!-- /#all_fund_dropdown -->
532 [% MACRO jsinclude BLOCK %]
533 [% Asset.js("js/acquisitions-menu.js") | $raw %]
534 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
535 [% Asset.js("js/acq.js") | $raw %]
536 [% INCLUDE 'calendar.inc' %]
537 [% INCLUDE 'datatables.inc' %]
539 function updateColumnsVisibility(visible) {
541 $("table .tax_excluded, .tax_included").show();
543 [% IF ( invoiceincgst ) %]
544 $("table .tax_excluded").hide();
546 $("table .tax_included").hide();
551 $(document).ready(function() {
552 $("#delete").click(function(){
553 return confirmDelete(_("Are you sure you want to delete this invoice?"));
555 $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
561 { "sType": "anti-the", "aTargets": [ "anti-the" ] }
564 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
565 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
572 $("#show_all_details").click(function(){
573 updateColumnsVisibility( $(this).is(":checked") );
576 $("#show_all_details").prop('checked', false);
577 updateColumnsVisibility(false);
578 $(".toggle_invoice_adjustment").on("click", function(e){
580 $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
582 $("a.delete_adjustment").click(function(){
583 return ( confirm( _("Are you sure you want to delete this file ?") ) );
586 //keep a copy of all budgets before removing the inactives
587 var disabledBudgetsCopy = $("#all_fund_dropdown").html();
588 $(".fund_dropdown").each(function(){
589 $(this).html( disabledBudgetsCopy);
590 var selected = $(this).data('selected');
591 $(this).find('option[value="'+selected+'"]').removeClass('b_inactive');
592 $(this).val( selected );
595 $('.b_inactive').remove();
597 $('.showallfunds').click(function() {
598 var the_dropdown = $(this).siblings('.fund_dropdown');
599 var selected = the_dropdown.val();
600 if ($(this).is(":checked")) {
601 the_dropdown.html(disabledBudgetsCopy).val(selected);
604 the_dropdown.find('option[value="'+selected+'"]').removeClass('b_inactive');
605 $(this).siblings().find('.b_inactive').remove();
609 $(".modify_fund").on('click',function(e){
611 var selected = $(this).data('budget_id');
612 var sort1 = $(this).data('sort1');
613 var sort2 = $(this).data('sort2');
614 $("#update_fund").data('order_id',$(this).data('order_id'));
615 $("#modify_budget_id").html(disabledBudgetsCopy);
616 $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive');
617 $("#sort1").val(sort1);
618 $("#sort2").val(sort2);
619 $("#modify_budget_id").find('.b_inactive').remove();
620 $("#modify_budget_id").change();
621 $("#updateFund").modal('show');
623 $("#update_fund").on('click',function(){
624 var new_fund = $("#modify_budget_id").val();
625 var sort1 = $("#sort1").val();
626 var sort2 = $("#sort2").val();
627 var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text();
628 var order_id = $(this).data('order_id');
630 url: "/api/v1/acquisitions/orders/" + order_id,
632 contentType: 'application/json',
633 data: JSON.stringify({
640 .then(function(thing,result){
641 $("#updateFund").modal('hide');
642 $('#updateFund .showallfunds').prop('checked',false);
643 $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund);
644 $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name);
645 humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } );
648 humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } );
651 $("#modify_budget_id").change(function(){
652 var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]');
653 var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
654 var sort1 = $(destination_sort1).val() || "";
655 if ( destination_sort1.length < 1 ) {
656 destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]');
658 var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]');
659 var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
660 var sort2 = $(destination_sort2).val() || "";
661 if ( destination_sort2.length < 1 ) {
662 destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]');
664 getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
665 getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
667 // same effort for the adjustments
668 var adjBudgetId = $("#budget_id_new");
669 var disabledAdjBudgetsCopy = adjBudgetId.html();
670 $('.ab_inactive').remove();
671 $('#showallfunds_adj').click(function() {
672 if ($(this).is(":checked")) {
673 adjBudgetId.html(disabledAdjBudgetsCopy); //Puts back all the funds
676 $('.ab_inactive').remove();
683 [% INCLUDE 'intranet-bottom.inc' %]