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 %]">
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>[% FILTER collapse %]
18 [% t("Invoice") | html %] ›
19 [% t("Acquisitions") | html %] ›
20 [% t("Koha") | html %]
22 [% INCLUDE 'doc-head-close.inc' %]
23 [% Asset.css("css/humanmsg.css") | $raw %]
26 <body id="acq_invoice" class="acq">
27 [% WRAPPER 'header.inc' %]
28 [% INCLUDE 'acquisitions-search.inc' %]
31 [% SET readonly = NOT CAN_user_acquisition_edit_invoices %]
33 [% WRAPPER 'sub-header.inc' %]
34 [% WRAPPER breadcrumbs %]
35 [% WRAPPER breadcrumb_item %]
36 <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
38 [% WRAPPER breadcrumb_item %]
39 <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a>
41 [% WRAPPER breadcrumb_item bc_active=1 %]
42 [% invoicenumber | html %]
44 [% END #/ WRAPPER breadcrumbs %]
45 [% END #/ WRAPPER sub-header.inc %]
47 <div class="main container-fluid">
49 <div class="col-sm-10 col-sm-push-2">
52 <h1>Invoice: [% invoicenumber | html %]</h1>
53 [% INCLUDE 'blocking_errors.inc' %]
56 <div class="dialog message">
57 <p>Invoice has been modified</p>
61 <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% suppliername | html %]</a></p>
63 <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
64 <fieldset class="rows">
68 <label for="shipmentdate">Invoice number:</label>
69 [% invoicenumber | html %]
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>
77 <label for="shipmentdate">Shipment date:</label>
79 [% shipmentdate | $KohaDates %]
81 <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | html %]" class="flatpickr" />
82 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
86 <label for="billingdate">Billing date:</label>
88 [% billingdate | $KohaDates %]
90 <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | html %]" class="flatpickr" />
91 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
95 <label for="shipmentcost">Shipping cost:</label>
97 [% shipmentcost | $Price %]
99 <input class="decimal" type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% IF shipmentcost %][% shipmentcost | $Price on_editing => 1 %][% END %]" />
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 %]
107 [% IF ( invoiceclosedate ) %]
109 <span class="label">Status:</span>
110 Closed on [% invoiceclosedate | $KohaDates %]
112 [% IF CAN_user_acquisition_reopen_closed_invoices AND NOT readonly %]
114 <label for="reopen">Reopen: </label>
115 <input type="checkbox" name="reopen" id="reopen" />
120 <span class="label">Status:</span>
123 [% UNLESS ( readonly ) %]
125 <label for="close">Close: </label>
126 <input type="checkbox" name="close" id="close" />
129 [% END # /IF ( invoiceclosedate ) %]
132 [% IF available_additional_fields.count %]
133 [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
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>
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 %]" />
153 [% IF (adjustments && adjustments.count > 0) %]
154 <table id="invoice_adj_table">
161 <th>Encumber while invoice open</th>
162 [% UNLESS readonly %]<th> </th>[% END %]
165 [% FOREACH adjustment IN adjustments %]
166 [% total_adj = total_adj + adjustment.adjustment %]
169 <input type="hidden" name="adjustment_id" value="[% adjustment.adjustment_id | html %]" />[% adjustment.adjustment_id | html %]
173 [% adjustment.adjustment | $Price %]
175 <input class="decimal" type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price on_editing => 1 %]" />
180 [% AuthorisedValues.GetByCode('ADJ_REASON', adjustment.reason) | html %]
182 [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
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 %]">
190 <option value="[% reason.authorised_value | html %]">
192 [% reason.lib | html %]
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 %]
204 [% adjustment.note | html %]
206 <input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/>
210 [% PROCESS fund_dropdown form_id => "budget_id_" _ adjustment.adjustment_id form_name => 'budget_id' selected => adjustment.budget_id %]
212 [% IF adjustment.encumber_open %]
215 <input type="checkbox" checked="checked" readonly="readonly" />
217 <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment_id | html %]" checked/>
223 <input type="checkbox" disabled="disabled" />
225 <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment_id | html %]" />
228 [% END # /IF adjustment.encumber_open %]
229 [% UNLESS readonly %]
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>
235 [% END # /FOREACH adjustment %]
236 </table> <!-- /#invoice_adj_table -->
237 [% END # /IF adjustments %]
239 [% UNLESS readonly %]
240 <div id="show_invoice_adjustment">
242 <a href="#" class="toggle_invoice_adjustment"><i class="fa fa-plus"></i> Add an adjustment</a>
246 <fieldset id="add_invoice_adjustment" style="display:none">
247 <h4>Add an adjustment</h4>
248 <input type="hidden" name="adjustment_id" value="new" />
251 <label for="adjustment_new">Amount: </label>
252 <input class="decimal" type="text" name="adjustment" id="adjustment_new" />
254 [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
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 %]
269 <span class="label">Reason: </span>
271 <div class="hint">Define values in authorised value category ADJ_REASON to enable</div>
273 [% END # /IF reasons.0 %]
275 <label for="note_new">Note: </label>
276 <input type="text" name="note" id="note_new" value=""/>
279 <label for="budget_id_new">Fund: </label>
280 [% PROCESS fund_dropdown form_id => "budget_id_new" form_name => 'budget_id' selected => "" %]
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="">
288 </fieldset> <!-- /#add_invoice_adjustment -->
289 [% END #/UNLESS readonly %]
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>
297 [% END #/UNLESS readonly %]
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 %]
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" />
315 <th class="anti-the">Summary</th>
317 [% IF has_invoice_unitprice %]
318 <th>Invoice price</th>
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>
324 <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
325 <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
332 [% FOREACH order IN orders_loop %]
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 %]
341 <em>Deleted bibliographic record, can't find title</em>
343 [% IF ( order.isbn ) %] – [% 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 %]
351 <p>[% order.branchcode | html %]</p>
352 [% IF has_invoice_unitprice %]
354 [% IF order.invoice_unitprice %]
355 [% order.invoice_unitprice | $Price %] [% order.invoice_currency | html %]
360 <td class="number tax_excluded">
361 [% order.unitprice_tax_excluded | $Price %]
363 <td class="number tax_included">
364 [% order.unitprice_tax_included | $Price %]
366 <td class="number replacementprice">
367 [% order.replacementprice | $Price %]
368 [% IF ( order.uncertainprice ) %]
369 <span>(Uncertain)</span>
373 [% order.quantity | html %]
375 <td class="number tax_excluded">
376 [% order.total_tax_excluded | $Price %]
378 <td class="number tax_included">
379 [% order.total_tax_included | $Price %]
382 [% order.tax_rate * 100 | html %]
385 [% order.tax_value | $Price %]
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>
392 [% END # /FOREACH order %]
395 [% FOR tf IN foot_loop %]
397 <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
398 [% IF has_invoice_unitprice %]
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>
408 <th>[% tf.tax_value | $Price %]</th>
413 <th colspan="2">Total ([% currency.symbol | html %])</th>
414 [% IF has_invoice_unitprice %]
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>
424 <th>[% total_tax_value | $Price %]</th>
428 <th colspan="2">Total + adjustments + shipment cost ([% currency.symbol | html %])</th>
429 [% IF has_invoice_unitprice %]
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>
439 <th>[% total_tax_value | $Price %]</th>
443 </table> <!-- /#orderst -->
445 <div class="dialog message">
447 [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
448 <p>Adjustments plus shipping: [% total_adj + shipmentcost | $Price %]</p>
451 [% END # /IF orders_loop.size %]
454 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
455 <div class="page-section">
456 <h2>Files attached to invoice</h2>
457 <table id="invoice_files_table">
467 [% FOREACH f IN files %]
470 <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>
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 %]
480 </table> <!-- /#invoice_files_table -->
482 [% END # /IF AcqEnableFiles %]
484 </div> <!-- /.col-sm-10.col-sm-push-2 -->
487 <div class="col-sm-2 col-sm-pull-10">
488 [% INCLUDE 'acquisitions-menu.inc' %]
491 </div> <!-- /.row -->
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>
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">
505 [% PROCESS fund_dropdown form_id => 'modify_budget_id' form_name => 'modify_budget_id' selected => "" %]
508 <label for="sort1">Statistic 1: </label>
509 <input type="text" name="sort1" />
512 <label for="sort2">Statistic 2: </label>
513 <input type="text" name="sort2" />
517 <a id="update_fund" class="btn btn-default">Update fund</a>
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 -->
526 <span style="display:none;" id="all_fund_dropdown">
527 <option value="">No fund</option>
528 [% FOREACH budget IN budgets %]
529 [% IF ( budget.b_active ) %]
530 <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>
532 <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>
534 [% END # /FOREACH budget %]
535 </span> <!-- /#all_fund_dropdown -->
537 [% MACRO jsinclude BLOCK %]
538 [% Asset.js("js/acquisitions-menu.js") | $raw %]
539 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
540 [% Asset.js("js/acq.js") | $raw %]
541 [% INCLUDE 'calendar.inc' %]
542 [% INCLUDE 'datatables.inc' %]
544 function updateColumnsVisibility(visible) {
546 $("table .tax_excluded, .tax_included").show();
548 [% IF ( invoiceincgst ) %]
549 $("table .tax_excluded").hide();
551 $("table .tax_included").hide();
556 $(document).ready(function() {
557 $("#delete").click(function(){
558 return confirmDelete(_("Are you sure you want to delete this invoice?"));
560 $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
566 { "type": "anti-the", "targets": [ "anti-the" ] }
569 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
570 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
577 $("#show_all_details").click(function(){
578 updateColumnsVisibility( $(this).is(":checked") );
581 $("#show_all_details").prop('checked', false);
582 updateColumnsVisibility(false);
583 $(".toggle_invoice_adjustment").on("click", function(e){
585 $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
587 $("a.delete_adjustment").click(function(){
588 return ( confirm( _("Are you sure you want to delete this file ?") ) );
591 //keep a copy of all budgets before removing the inactives
592 var disabledBudgetsCopy = $("#all_fund_dropdown").html();
593 $(".fund_dropdown").each(function(){
594 $(this).html( disabledBudgetsCopy);
595 var selected = $(this).data('selected');
596 $(this).find('option[value="'+selected+'"]').removeClass('b_inactive');
597 $(this).val( selected );
600 $('.b_inactive').remove();
602 $('.showallfunds').click(function() {
603 var the_dropdown = $(this).siblings('.fund_dropdown');
604 var selected = the_dropdown.val();
605 if ($(this).is(":checked")) {
606 the_dropdown.html(disabledBudgetsCopy).val(selected);
609 the_dropdown.find('option[value="'+selected+'"]').removeClass('b_inactive');
610 $(this).siblings().find('.b_inactive').remove();
614 $(".modify_fund").on('click',function(e){
616 var selected = $(this).data('budget_id');
617 var sort1 = $(this).data('sort1');
618 var sort2 = $(this).data('sort2');
619 $("#update_fund").data('order_id',$(this).data('order_id'));
620 $("#modify_budget_id").html(disabledBudgetsCopy);
621 $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive');
622 $("#sort1").val(sort1);
623 $("#sort2").val(sort2);
624 $("#modify_budget_id").find('.b_inactive').remove();
625 $("#modify_budget_id").change();
626 $("#updateFund").modal('show');
628 $("#update_fund").on('click',function(){
629 var new_fund = $("#modify_budget_id").val();
630 var sort1 = $("#sort1").val();
631 var sort2 = $("#sort2").val();
632 var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text();
633 var order_id = $(this).data('order_id');
635 url: "/api/v1/acquisitions/orders/" + order_id,
637 contentType: 'application/json',
638 data: JSON.stringify({
645 .then(function(thing,result){
646 $("#updateFund").modal('hide');
647 $('#updateFund .showallfunds').prop('checked',false);
648 $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund);
649 $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name);
650 humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } );
653 humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } );
656 $("#modify_budget_id").change(function(){
657 var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]');
658 var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
659 var sort1 = $(destination_sort1).val() || "";
660 if ( destination_sort1.length < 1 ) {
661 destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]');
663 var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]');
664 var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
665 var sort2 = $(destination_sort2).val() || "";
666 if ( destination_sort2.length < 1 ) {
667 destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]');
669 getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
670 getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
672 // same effort for the adjustments
673 var adjBudgetId = $("#budget_id_new");
674 var disabledAdjBudgetsCopy = adjBudgetId.html();
675 $('.ab_inactive').remove();
676 $('#showallfunds_adj').click(function() {
677 if ($(this).is(":checked")) {
678 adjBudgetId.html(disabledAdjBudgetsCopy); //Puts back all the funds
681 $('.ab_inactive').remove();
688 [% INCLUDE 'intranet-bottom.inc' %]