3 [% USE AuthorisedValues %]
7 [% PROCESS 'i18n.inc' %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>[% FILTER collapse %]
10 [% t("Invoices") | html %] ›
11 [% t("Acquisitions") | html %] ›
12 [% t("Koha") | html %]
14 [% INCLUDE 'doc-head-close.inc' %]
18 <body id="acq_invoices" class="acq">
19 [% WRAPPER 'header.inc' %]
20 [% INCLUDE 'acquisitions-search.inc' %]
23 [% WRAPPER 'sub-header.inc' %]
24 [% WRAPPER breadcrumbs %]
25 [% WRAPPER breadcrumb_item %]
26 <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
28 [% WRAPPER breadcrumb_item bc_active= 1 %]
31 [% END #/ WRAPPER breadcrumbs %]
32 [% END #/ WRAPPER sub-header.inc %]
34 <div class="main container-fluid">
36 <div class="col-sm-10 col-sm-push-2">
38 [% INCLUDE 'messages.inc' %]
41 [% IF ( do_search ) %]
43 [% BLOCK invoices_table %]
45 [% SET tab = 'closed' %]
47 [% SET tab = 'opened' %]
49 <input type="checkbox" style="vertical-align: middle;" id="show_only_subscription_[% tab | html %]" class="show_only_subscription" data-tableid="[% tab | html %]resultst"/>
50 <label for="show_only_subscription_[% tab | html %]">
51 Show only subscriptions
53 <p><a id="CheckAll[% tab | html %]table" data-cb="[% tab | html %]" class="checkall" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="UncheckAll[% tab | html %]table" data-cb="[% tab | html %]" class="uncheckall" href="#"><i class="fa fa-times"></i> Clear all</a></p>
54 <table id="[% tab | html %]resultst" class="result">
57 [% IF CAN_user_acquisition_merge_invoices %]
61 <th>Invoice number</th>
63 <th>Shipment date</th>
65 <th>Received bibliographic records</th>
66 <th>Received items</th>
72 [% FOREACH invoice IN invoices %]
73 <tr data-invoiceid="[% invoice.invoiceid | html %]" data-booksellerid="[% invoice.booksellerid | html %]" data-shipmentdate="[% invoice.shipmentdate | $KohaDates %]" data-billingdate="[% invoice.billingdate | $KohaDates %]" data-shipmentcost="[% invoice.shipmentcost | html %]" data-shipment_budgetid="[% invoice.shipmentcost_budgetid | html %]" data-closedate="[% invoice.closedate | $KohaDates %]">
74 [% IF CAN_user_acquisition_merge_invoices %]
75 <td>[% invoice.is_linked_to_subscriptions | html %]</td>
77 <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid | html %]" /></td>
78 <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]">[% invoice.invoicenumber | html %]</a></td>
79 <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid | uri %]">[% invoice.suppliername | html %]</a></td>
80 <td data-order="[% invoice.shipmentdate | html %]">
81 [% invoice.shipmentdate | $KohaDates %]
83 <td data-order="[% invoice.billingdate | html %]">
84 [% invoice.billingdate | $KohaDates %]
86 <td>[% invoice.receivedbiblios | html %]</td>
87 <td>[% invoice.receiveditems | html %]</td>
89 [% IF invoice.closedate %]
90 <span>Closed on [% invoice.closedate | $KohaDates %]</span>
97 <div class="btn-group dropup">
98 <a class="btn btn-default btn-xs dropdown-toggle" id="invoiceactions[% invoice.invoiceid | html %]" role="button" data-toggle="dropdown" href="#">
99 Actions <b class="caret"></b>
101 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="invoiceactions[% invoice.invoiceid | html %]">
102 <li><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]"><i class="fa fa-search"></i> Details</a></li>
103 [% IF invoice.closedate %]
104 [% IF CAN_user_acquisition_reopen_closed_invoices %]
105 <li><a href="invoice.pl?op=reopen&invoiceid=[% invoice.invoiceid | uri %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa-solid fa-rotate"></i> Reopen</a></li>
108 [% IF CAN_user_acquisition_edit_invoices %]
109 <li><a href="invoice.pl?op=close&invoiceid=[% invoice.invoiceid | uri %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa fa-times-circle"></i> Close</a></li>
111 [% END # /IF invoice.closedate %]
112 [% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
113 [% IF CAN_user_acquisition_delete_invoices %]
114 <li><a href="invoice.pl?op=delete&invoiceid=[% invoice.invoiceid | uri %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]" class="delete_invoice"><i class="fa fa-trash-can"></i> Delete</a></li>
118 </div> <!-- /.btn-group dropup -->
121 [% END # /FOREACH invoice %]
123 </table> <!-- /#[% tab | html %]resultst -->
125 [% IF CAN_user_acquisition_merge_invoices %]
126 [% IF tab == 'closed' %]
127 <a class="btn btn-default merge" id="merge_closed" href="#merge_invoices" data-table="closedresultst"><i class="fa fa-compress"></i> Merge selected invoices</a>
128 <a class="btn btn-default" id="open_sel" href="#reopen_selected" data-table="closedresultst" data-op="reopen" data-referer="referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa-solid fa-rotate"></i> Reopen selected invoices</a>
130 <a class="btn btn-default merge" id="merge_open" href="#merge_invoices" data-table="openedresultst"><i class="fa fa-compress"></i> Merge selected invoices</a>
131 <a class="btn btn-default" id="close_sel" href="#close_selected" data-table="openedresultst" data-op="close" data-referer="referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa fa-times-circle"></i> Close selected invoices</a>
132 [% END # /IF tab == 'closed' %]
133 [% END # /IF CAN_user_acquisition_merge_invoices %]
134 [% END # /BLOCK invoices_table %]
136 [% WRAPPER tabs id= "invoicestabs" %]
137 [% WRAPPER tabs_nav %]
138 [% WRAPPER tab_item tabname= "opened" bt_active= 1 %]
139 <span>Open invoices</span> ([% openedinvoices.size || 0 | html %])
141 [% WRAPPER tab_item tabname= "closed" %]
142 <span>Closed invoices</span> ([% closedinvoices.size || 0 | html %])
145 [% WRAPPER tab_panels %]
146 [% WRAPPER tab_panel tabname="opened" bt_active= 1 %]
147 [% IF openedinvoices %]
148 [% INCLUDE invoices_table invoices = openedinvoices %]
150 <div class="dialog message">
151 <p>Your search returned no open invoices.</p>
156 [% WRAPPER tab_panel tabname="closed" %]
157 [% IF closedinvoices %]
158 [% INCLUDE invoices_table invoices = closedinvoices closed = 1 %]
160 <div class="dialog message">
161 <p>Your search returned no closed invoices.</p>
165 [% END # /tab_panels %]
166 [% END # /#invoicestabs %]
168 <div id="merge_invoices">
169 <form id="merge_invoice_form" class="validated" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
170 [% INCLUDE 'csrf-token.inc' %]
171 <fieldset class="rows">
173 <li><h2>Merge invoices</h2></li>
175 <table id="merge_table">
178 <th>Invoice number</th>
179 <th>Shipment date</th>
180 <th>Billing date</th>
181 <th>Shipment cost</th>
191 <label for="merge_invoicenumber" class="required">Invoice number:</label>
192 <input type="text" size="10" id="merge_invoicenumber" name="invoicenumber" value="" class="required" required="required" />
193 <span class="required">Required</span>
197 <label for="merge_shipmentdate">Shipment date:</label>
198 <input type="text" size="10" id="merge_shipmentdate" name="shipmentdate" value="" class="flatpickr" />
199 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
203 <label for="merge_billingdate">Billing date:</label>
204 <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" class="flatpickr" />
205 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
209 <label for="merge_shipmentcost">Shipment cost:</label>
210 <input class="decimal" type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" />
213 <label for="merge_shipment_budgetid">Fund:</label>
214 <select id="merge_shipment_budgetid" name="shipment_budget_id">
215 <option value="">No fund</option>
216 [% FOREACH budget IN budgets_loop %]
217 <option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]</option>
223 <span class="label">Status:</span> <span id="merge_status"></span>
226 <input type="submit" class="btn btn-primary" value="Merge" />
229 <input type="hidden" name="op" value="cud-mod" />
230 <input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
231 </fieldset> <!-- /.rows -->
232 </form> <!-- /#merge_invoice_form -->
233 </div> <!-- /#merge_invoices -->
234 [% ELSE # IF invoices %]
235 <p>Sorry, but there are no results for your search.</p>
238 [% IF ( invoicenumber ) %]
239 <li>Invoice number: [% invoicenumber | html %]</li>
241 [% IF booksellerid %]
242 <li>Vendor: [% suppliername | html %]</li>
244 [% IF shipmentdatefrom %]
246 <span>Shipment date:</span>
247 [% IF shipmentdateto %]
248 <span>From [% shipmentdatefrom | $KohaDates %]</span>
249 <span>To [% shipmentdateto | $KohaDates %]</span>
251 <span>All since [% shipmentdatefrom | $KohaDates %]</span>
255 [% IF shipmentdateto %]
258 All until [% shipmentdateto | $KohaDates %]
262 [% IF billingdatefrom %]
264 <span>Billing date:</span>
265 [% IF billingdateto %]
266 <span>From [% billingdatefrom | $KohaDates %]</span>
267 <span>To [% billingdateto | $KohaDates %]</span>
269 <span>All since [% billingdatefrom | $KohaDates %]</span>
273 [% IF billingdateto %]
276 All until [% billingdateto | $KohaDates %]
280 [% IF ( isbneanissn ) %]
281 <li>ISBN/EAN/ISSN: [% isbneanissn | html %]</li>
284 <li>Title: [% title | html %]</li>
287 <li>Author: [% author | html %]</li>
289 [% IF ( publisher ) %]
290 <li>Publisher: [% publisher | html %]</li>
292 [% IF ( publicationyear ) %]
293 <li>Publication year: [% publicationyear | html %]</li>
296 <li>Library: [% Branches.GetName( branch ) | html %]</li>
300 [% END # /IF invoices %]
302 <p>Use the search form on the left to find invoices.</p>
303 [% END %]<!-- do_search -->
305 </div> <!-- /.col-sm-10.col-sm-push-2 -->
307 <div class="col-sm-2 col-sm-pull-10">
309 <form action="" method="get">
310 <fieldset class="sidebar brief">
311 <h3>Search filters</h3>
314 <label for="invoicenumber">Invoice number</label>
315 <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]"
319 <label for="supplier">Vendor:</label>
320 <select id="supplierid" name="supplierid">
321 [% IF ( supplier ) %]
322 <option selected="selected" value="[% supplier.id | html %]">[% supplier.name | html %]</option>
327 <fieldset class="brief">
328 <legend>Shipment date</legend>
331 <label for="shipmentdatefrom">From:</label>
332 <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | html %]" class="flatpickr" data-date_to="shipmentdateto" />
333 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
336 <label for="shipmentdateto">To:</label>
337 <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | html %]" class="flatpickr" />
338 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
344 <fieldset class="brief">
345 <legend>Billing date</legend>
348 <label for="billingdatefrom">From:</label>
349 <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | html %]" class="flatpickr" data-date_to="billingdateto" />
350 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
353 <label for="billingdateto">To:</label>
354 <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | html %]" class="flatpickr" />
355 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
361 <label for="isbneanissn">ISBN / EAN / ISSN:</label>
362 <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn | html %]" />
365 <label for="title">Title:</label>
366 <input type="text" id="title" name="title" value="[% title | html %]" />
369 <label for="author">Author:</label>
370 <input type="text" id="author" name="author" value="[% author | html %]" />
373 <label for="publisher">Publisher:</label>
374 <input type="text" id="publisher" name="publisher" value="[% publisher | html %]" />
377 <label for="publicationyear">Publication year:</label>
378 <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear | html %]" />
381 <label for="branch">Library:</label>
382 <select id="branch" name="branch">
383 <option value="">All</option>
384 [%# FIXME Should not we filter the libraries %]
385 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
388 [% FOR field IN additional_fields_for_invoice %]
390 <label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>
391 [% IF field.authorised_value_category %]
392 <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]">
393 <option value="">All</option>
394 [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox(field.authorised_value_category) %]
395 [% IF av.authorised_value == additional_field_filters.${field.id} %]
396 <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
398 <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
403 <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_field_filters.${field.id} | html %]" name="additional_field_[% field.id | html %]" />
408 </fieldset> <!-- /.sidebar.brief -->
409 <fieldset class="action">
410 <input type="submit" class="btn btn-primary" value="Search" />
412 <input type="hidden" name="op" id="op" value="do_search" />
414 [% INCLUDE 'acquisitions-menu.inc' %]
416 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
417 </div> <!-- /.row -->
419 [% MACRO jsinclude BLOCK %]
420 [% Asset.js("js/acquisitions-menu.js") | $raw %]
421 [% INCLUDE 'datatables.inc' %]
422 [% INCLUDE 'calendar.inc' %]
423 [% INCLUDE 'select2.inc' %]
425 $(document).ready(function() {
426 $('[id^="CheckAll"]').click( function() {
427 var table_id = "#" + $(this).attr('data-cb') + "resultst";
428 $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
429 $(this).prop("checked" , true );
432 $('[id^="UncheckAll"]').click( function() {
433 var table_id = "#" + $(this).attr('data-cb') + "resultst";
434 $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
435 $(this).prop("checked" , false );
439 $(".delete_invoice").click(function(){
440 return confirmDelete(_("Are you sure you want to delete this invoice?"));
442 var resultst = $("table.result").dataTable($.extend(true, {}, dataTablesDefaults, {
445 { "orderable": false, "targets": [1, -1] },
446 { "visible": false, "targets": [0] }
451 $(".show_only_subscription").prop("checked", false);
453 $(".show_only_subscription").click(function(){
454 var table_id = $(this).attr("data-tableid");
455 if ( $(this).prop("checked") ) {
456 $('#'+table_id).dataTable().fnFilter( "1", 0, true );
458 $('#'+table_id).dataTable().fnFilter( '', 0 );
462 $('#open_sel,#close_sel').click(function () {
463 var referer = $(this).attr("data-referer");
464 var op = $(this).attr("data-op");
465 var table = $(this).data('table');
466 var invoice_link = "invoice.pl?op="+op;
467 if ($('#' + table + ' .select-invoice:checked').length) {
468 $('#' + table + ' .select-invoice:checked').each(function () {
469 var row = $(this).parents('tr');
470 invoice_link = invoice_link + "&invoiceid="+$(row).attr('data-invoiceid');
472 window.location.href =invoice_link +"&"+referer;
474 alert ("Please select at least one invoice." );
478 $('.merge').click(function (ev) {
482 var table = $(this).data('table');
483 if ($('#' + table + ' .select-invoice:checked').size() < 2) {
484 alert(_("You must select at least two invoices to merge."));
487 $('#' + table + ' .select-invoice:checked').each(function () {
488 var row = $(this).parents('tr');
489 booksellerid = booksellerid || $(row).attr('data-booksellerid');
490 if (booksellerid !== $(row).attr('data-booksellerid')) {
493 invoices.push({ 'invoiceid': $(row).attr('data-invoiceid'),
494 'invoicenumber': $(row).find('td:nth-child(2) a').text(),
495 'shipmentdate': $(row).attr('data-shipmentdate'),
496 'billingdate': $(row).attr('data-billingdate'),
497 'shipmentcost': $(row).attr('data-shipmentcost'),
498 'shipment_budgetid': $(row).attr('data-shipment_budgetid'),
499 'closedate': $(row).attr('data-closedate'), });
500 $('#merge_invoice_form').append('<input type="hidden" name="merge" value="' + $(row).attr('data-invoiceid') + '" />');
503 alert(_("All invoices for merging must be from the same vendor"));
505 $('#merge_table tbody').empty();
506 $.each(invoices, function (idx, invoice) {
507 var row = $('<tr data-invoiceid="' + invoice.invoiceid + '"><td>' + invoice.invoicenumber + '</td><td>' + invoice.shipmentdate + '</td><td>' + invoice.billingdate + '</td><td>' + invoice.shipmentcost + '</td></tr>');
508 $(row).appendTo('#merge_table tbody');
509 $(row).click(function () {
510 $('#merge_table tbody tr').removeClass('active');
511 $(this).addClass('active');
512 $.each(['invoiceid', 'shipmentdate', 'billingdate', 'shipmentcost', 'shipment_budgetid', 'invoicenumber'], function (idx, prop) {
513 $('#merge_' + prop).val(invoice[prop]);
515 if (invoice.closedate) {
516 $('#merge_status').text(_("Closed on %s").format(invoice.closedate));
518 $('#merge_status').text(_("Open"));
522 $('#merge_table tbody tr:first').click();
523 $('#merge_invoices').show();
527 function display_vendor(vendor) {
529 $text = $('<span>'+vendor.text+'</span>');
533 $("#supplierid").kohaSelect({
537 url: '/api/v1/acquisitions/vendors',
538 delay: 300, // wait 300 milliseconds before triggering the request
541 data: function (params) {
542 var search_term = (params.term === undefined) ? '' : params.term;
544 "q": JSON.stringify({"name":{"-like":'%'+search_term+'%'}}),
551 processResults: function (data) {
553 data.results.forEach( function ( vendor ) {
557 "text": vendor.name.escapeHtml()
561 return { "results": results, "pagination": { "more": data.pagination.more } };
564 templateResult: display_vendor,
565 templateSelection: display_vendor
574 [% INCLUDE 'intranet-bottom.inc' %]