3 [% USE AuthorisedValues %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Invoices › Acquisitions › Koha</title>
9 [% INCLUDE 'doc-head-close.inc' %]
13 <body id="acq_invoices" class="acq">
14 [% WRAPPER 'header.inc' %]
15 [% INCLUDE 'acquisitions-search.inc' %]
18 [% WRAPPER 'sub-header.inc' %]
19 [% WRAPPER breadcrumbs %]
20 [% WRAPPER breadcrumb_item %]
21 <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
23 [% WRAPPER breadcrumb_item bc_active= 1 %]
26 [% END #/ WRAPPER breadcrumbs %]
27 [% END #/ WRAPPER sub-header.inc %]
29 <div class="main container-fluid">
31 <div class="col-sm-10 col-sm-push-2">
34 [% INCLUDE 'blocking_errors.inc' %]
37 [% IF ( do_search ) %]
39 [% BLOCK invoices_table %]
41 [% SET tab = 'closed' %]
43 [% SET tab = 'opened' %]
45 <input type="checkbox" style="vertical-align: middle;" id="show_only_subscription_[% tab | html %]" class="show_only_subscription" data-tableid="[% tab | html %]resultst"/>
46 <label for="show_only_subscription_[% tab | html %]">
47 Show only subscriptions
49 <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>
50 <table id="[% tab | html %]resultst" class="result">
53 [% IF CAN_user_acquisition_merge_invoices %]
57 <th>Invoice number</th>
59 <th>Shipment date</th>
61 <th>Received bibliographic records</th>
62 <th>Received items</th>
68 [% FOREACH invoice IN invoices %]
69 <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 %]">
70 [% IF CAN_user_acquisition_merge_invoices %]
71 <td>[% invoice.is_linked_to_subscriptions | html %]</td>
73 <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid | html %]" /></td>
74 <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]">[% invoice.invoicenumber | html %]</a></td>
75 <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid | uri %]">[% invoice.suppliername | html %]</a></td>
76 <td data-order="[% invoice.shipmentdate | html %]">
77 [% invoice.shipmentdate | $KohaDates %]
79 <td data-order="[% invoice.billingdate | html %]">
80 [% invoice.billingdate | $KohaDates %]
82 <td>[% invoice.receivedbiblios | html %]</td>
83 <td>[% invoice.receiveditems | html %]</td>
85 [% IF invoice.closedate %]
86 <span>Closed on [% invoice.closedate | $KohaDates %]</span>
93 <div class="btn-group dropup">
94 <a class="btn btn-default btn-xs dropdown-toggle" id="invoiceactions[% invoice.invoiceid | html %]" role="button" data-toggle="dropdown" href="#">
95 Actions <b class="caret"></b>
97 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="invoiceactions[% invoice.invoiceid | html %]">
98 <li><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]"><i class="fa fa-search"></i> Details</a></li>
99 [% IF invoice.closedate %]
100 [% IF CAN_user_acquisition_reopen_closed_invoices %]
101 <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>
104 [% IF CAN_user_acquisition_edit_invoices %]
105 <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>
107 [% END # /IF invoice.closedate %]
108 [% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
109 [% IF CAN_user_acquisition_delete_invoices %]
110 <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>
114 </div> <!-- /.btn-group dropup -->
117 [% END # /FOREACH invoice %]
119 </table> <!-- /#[% tab | html %]resultst -->
121 [% IF CAN_user_acquisition_merge_invoices %]
122 [% IF tab == 'closed' %]
123 <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>
124 <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>
126 <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>
127 <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>
128 [% END # /IF tab == 'closed' %]
129 [% END # /IF CAN_user_acquisition_merge_invoices %]
130 [% END # /BLOCK invoices_table %]
132 [% WRAPPER tabs id= "invoicestabs" %]
133 [% WRAPPER tabs_nav %]
134 [% WRAPPER tab_item tabname= "opened" bt_active= 1 %]
135 <span>Open invoices</span> ([% openedinvoices.size || 0 | html %])
137 [% WRAPPER tab_item tabname= "closed" %]
138 <span>Closed invoices</span> ([% closedinvoices.size || 0 | html %])
141 [% WRAPPER tab_panels %]
142 [% WRAPPER tab_panel tabname="opened" bt_active= 1 %]
143 [% IF openedinvoices %]
144 [% INCLUDE invoices_table invoices = openedinvoices %]
146 <div class="dialog message">
147 <p>Your search returned no open invoices.</p>
152 [% WRAPPER tab_panel tabname="closed" %]
153 [% IF closedinvoices %]
154 [% INCLUDE invoices_table invoices = closedinvoices closed = 1 %]
156 <div class="dialog message">
157 <p>Your search returned no closed invoices.</p>
161 [% END # /tab_panels %]
162 [% END # /#invoicestabs %]
164 <div id="merge_invoices">
165 <form id="merge_invoice_form" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
166 <fieldset class="rows">
168 <li><h2>Merge invoices</h2></li>
170 <table id="merge_table">
173 <th>Invoice number</th>
174 <th>Shipment date</th>
175 <th>Billing date</th>
176 <th>Shipment cost</th>
185 <label for="merge_invoicenumber" class="required">Invoice number:</label>
186 <input type="text" size="10" id="merge_invoicenumber" name="invoicenumber" value="" class="required" required="required" />
187 <span class="required">Required</span>
191 <label for="merge_shipmentdate">Shipment date:</label>
192 <input type="text" size="10" id="merge_shipmentdate" name="shipmentdate" value="" class="flatpickr" />
193 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
197 <label for="merge_billingdate">Billing date:</label>
198 <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" class="flatpickr" />
199 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
203 <label for="merge_shipmentcost">Shipment cost:</label>
204 <input type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" />
207 <label for="merge_shipment_budgetid">Fund:</label>
208 <select id="merge_shipment_budgetid" name="shipment_budget_id">
209 <option value="">No fund</option>
210 [% FOREACH budget IN budgets_loop %]
211 <option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]</option>
217 <span class="label">Status:</span> <span id="merge_status"></span>
220 <input type="submit" class="btn btn-primary" value="Merge" />
223 <input type="hidden" name="op" value="mod" />
224 <input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
225 </fieldset> <!-- /.rows -->
226 </form> <!-- /#merge_invoice_form -->
227 </div> <!-- /#merge_invoices -->
228 [% ELSE # IF invoices %]
229 <p>Sorry, but there are no results for your search.</p>
232 [% IF ( invoicenumber ) %]
233 <li>Invoice number: [% invoicenumber | html %]</li>
235 [% IF booksellerid %]
236 <li>Vendor: [% suppliername | html %]</li>
238 [% IF shipmentdatefrom %]
240 <span>Shipment date:</span>
241 [% IF shipmentdateto %]
242 <span>From [% shipmentdatefrom | $KohaDates %]</span>
243 <span>To [% shipmentdateto | $KohaDates %]</span>
245 <span>All since [% shipmentdatefrom | $KohaDates %]</span>
249 [% IF shipmentdateto %]
252 All until [% shipmentdateto | $KohaDates %]
256 [% IF billingdatefrom %]
258 <span>Billing date:</span>
259 [% IF billingdateto %]
260 <span>From [% billingdatefrom | $KohaDates %]</span>
261 <span>To [% billingdateto | $KohaDates %]</span>
263 <span>All since [% billingdatefrom | $KohaDates %]</span>
267 [% IF billingdateto %]
270 All until [% billingdateto | $KohaDates %]
274 [% IF ( isbneanissn ) %]
275 <li>ISBN/EAN/ISSN: [% isbneanissn | html %]</li>
278 <li>Title: [% title | html %]</li>
281 <li>Author: [% author | html %]</li>
283 [% IF ( publisher ) %]
284 <li>Publisher: [% publisher | html %]</li>
286 [% IF ( publicationyear ) %]
287 <li>Publication year: [% publicationyear | html %]</li>
290 <li>Library: [% Branches.GetName( branch ) | html %]</li>
294 [% END # /IF invoices %]
296 <p>Use the search form on the left to find invoices.</p>
297 [% END %]<!-- do_search -->
299 </div> <!-- /.col-sm-10.col-sm-push-2 -->
301 <div class="col-sm-2 col-sm-pull-10">
303 <form action="" method="get">
304 <fieldset class="sidebar brief">
305 <h3>Search filters</h3>
308 <label for="invoicenumber">Invoice number</label>
309 <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]"
313 <label for="supplier">Vendor:</label>
314 <select id="supplier" name="supplierid">
315 <option value="">All</option>
316 [% FOREACH supplier IN suppliers_loop %]
317 [% IF ( supplier.selected ) %]
318 <option selected="selected" value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
320 <option value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
326 <fieldset class="brief">
327 <legend>Shipment date</legend>
330 <label for="shipmentdatefrom">From:</label>
331 <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | html %]" class="flatpickr" data-date_to="shipmentdateto" />
332 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
335 <label for="shipmentdateto">To:</label>
336 <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | html %]" class="flatpickr" />
337 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
343 <fieldset class="brief">
344 <legend>Billing date</legend>
347 <label for="billingdatefrom">From:</label>
348 <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | html %]" class="flatpickr" data-date_to="billingdateto" />
349 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
352 <label for="billingdateto">To:</label>
353 <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | html %]" class="flatpickr" />
354 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
360 <label for="isbneanissn">ISBN / EAN / ISSN:</label>
361 <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn | html %]" />
364 <label for="title">Title:</label>
365 <input type="text" id="title" name="title" value="[% title | html %]" />
368 <label for="author">Author:</label>
369 <input type="text" id="author" name="author" value="[% author | html %]" />
372 <label for="publisher">Publisher:</label>
373 <input type="text" id="publisher" name="publisher" value="[% publisher | html %]" />
376 <label for="publicationyear">Publication year:</label>
377 <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear | html %]" />
380 <label for="branch">Library:</label>
381 <select id="branch" name="branch">
382 <option value="">All</option>
383 [%# FIXME Should not we filter the libraries %]
384 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
387 [% FOR field IN additional_fields_for_invoice %]
389 <label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>
390 [% IF field.authorised_value_category %]
391 <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]">
392 <option value="">All</option>
393 [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox(field.authorised_value_category) %]
394 [% IF av.authorised_value == additional_field_filters.${field.id} %]
395 <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
397 <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
402 <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_field_filters.${field.id} | html %]" name="additional_field_[% field.id | html %]" />
407 </fieldset> <!-- /.sidebar.brief -->
408 <fieldset class="action">
409 <input type="submit" class="btn btn-primary" value="Search" />
411 <input type="hidden" name="op" id="op" value="do_search" />
413 [% INCLUDE 'acquisitions-menu.inc' %]
415 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
416 </div> <!-- /.row -->
418 [% MACRO jsinclude BLOCK %]
419 [% Asset.js("js/acquisitions-menu.js") | $raw %]
420 [% INCLUDE 'datatables.inc' %]
421 [% INCLUDE 'calendar.inc' %]
423 $(document).ready(function() {
424 $('[id^="CheckAll"]').click( function() {
425 var table_id = "#" + $(this).attr('data-cb') + "resultst";
426 $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
427 $(this).prop("checked" , true );
430 $('[id^="UncheckAll"]').click( function() {
431 var table_id = "#" + $(this).attr('data-cb') + "resultst";
432 $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
433 $(this).prop("checked" , false );
437 $(".delete_invoice").click(function(){
438 return confirmDelete(_("Are you sure you want to delete this invoice?"));
440 var resultst = $("table.result").dataTable($.extend(true, {}, dataTablesDefaults, {
443 { "bSortable": false, "aTargets": [1, -1] },
444 { "bVisible": false, "aTargets": [0] }
449 $(".show_only_subscription").prop("checked", false);
451 $(".show_only_subscription").click(function(){
452 var table_id = $(this).attr("data-tableid");
453 if ( $(this).prop("checked") ) {
454 $('#'+table_id).dataTable().fnFilter( "1", 0, true );
456 $('#'+table_id).dataTable().fnFilter( '', 0 );
460 $('#open_sel,#close_sel').click(function () {
461 var referer = $(this).attr("data-referer");
462 var op = $(this).attr("data-op");
463 var table = $(this).data('table');
464 var invoice_link = "invoice.pl?op="+op;
465 if ($('#' + table + ' .select-invoice:checked').length) {
466 $('#' + table + ' .select-invoice:checked').each(function () {
467 var row = $(this).parents('tr');
468 invoice_link = invoice_link + "&invoiceid="+$(row).attr('data-invoiceid');
470 window.location.href =invoice_link +"&"+referer;
472 alert ("Please select at least one invoice." );
476 $('.merge').click(function (ev) {
480 var table = $(this).data('table');
481 if ($('#' + table + ' .select-invoice:checked').size() < 2) {
482 alert(_("You must select at least two invoices to merge."));
485 $('#' + table + ' .select-invoice:checked').each(function () {
486 var row = $(this).parents('tr');
487 booksellerid = booksellerid || $(row).attr('data-booksellerid');
488 if (booksellerid !== $(row).attr('data-booksellerid')) {
491 invoices.push({ 'invoiceid': $(row).attr('data-invoiceid'),
492 'invoicenumber': $(row).find('td:nth-child(2) a').text(),
493 'shipmentdate': $(row).attr('data-shipmentdate'),
494 'billingdate': $(row).attr('data-billingdate'),
495 'shipmentcost': $(row).attr('data-shipmentcost'),
496 'shipment_budgetid': $(row).attr('data-shipment_budgetid'),
497 'closedate': $(row).attr('data-closedate'), });
498 $('#merge_invoice_form').append('<input type="hidden" name="merge" value="' + $(row).attr('data-invoiceid') + '" />');
501 alert(_("All invoices for merging must be from the same vendor"));
503 $('#merge_table tbody').empty();
504 $.each(invoices, function (idx, invoice) {
505 var row = $('<tr data-invoiceid="' + invoice.invoiceid + '"><td>' + invoice.invoicenumber + '</td><td>' + invoice.shipmentdate + '</td><td>' + invoice.billingdate + '</td><td>' + invoice.shipmentcost + '</td></tr>');
506 $(row).appendTo('#merge_table tbody');
507 $(row).click(function () {
508 $('#merge_table tbody tr').removeClass('active');
509 $(this).addClass('active');
510 $.each(['invoiceid', 'shipmentdate', 'billingdate', 'shipmentcost', 'shipment_budgetid', 'invoicenumber'], function (idx, prop) {
511 $('#merge_' + prop).val(invoice[prop]);
513 if (invoice.closedate) {
514 $('#merge_status').text(_("Closed on %s").format(invoice.closedate));
516 $('#merge_status').text(_("Open"));
520 $('#merge_table tbody tr:first').click();
521 $('#merge_invoices').show();
528 [% INCLUDE 'intranet-bottom.inc' %]