6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Invoices › Acquisitions › Koha</title>
8 [% INCLUDE 'doc-head-close.inc' %]
12 <body id="acq_invoices" class="acq">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'acquisitions-search.inc' %]
17 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
20 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
23 <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
26 <a href="#" aria-current="page">Invoices</a>
31 <div class="main container-fluid">
33 <div class="col-sm-10 col-sm-push-2">
36 [% INCLUDE 'blocking_errors.inc' %]
39 [% IF ( do_search ) %]
41 [% BLOCK invoices_table %]
43 [% SET tab = 'closed' %]
45 [% SET tab = 'opened' %]
47 <input type="checkbox" style="vertical-align: middle;" id="show_only_subscription_[% tab | html %]" class="show_only_subscription" data-tableid="[% tab | html %]resultst"/>
48 <label for="show_only_subscription_[% tab | html %]">
49 Show only subscriptions
51 <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-remove"></i> Clear all</a></p>
52 <table id="[% tab | html %]resultst" class="result">
55 [% IF CAN_user_acquisition_merge_invoices %]
59 <th>Invoice number</th>
61 <th>Shipment date</th>
63 <th>Received bibliographic records</th>
64 <th>Received items</th>
70 [% FOREACH invoice IN invoices %]
71 <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 %]">
72 [% IF CAN_user_acquisition_merge_invoices %]
73 <td>[% invoice.is_linked_to_subscriptions | html %]</td>
75 <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid | html %]" /></td>
76 <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]">[% invoice.invoicenumber | html %]</a></td>
77 <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid | uri %]">[% invoice.suppliername | html %]</a></td>
78 <td data-order="[% invoice.shipmentdate | html %]">
79 [% invoice.shipmentdate | $KohaDates %]
81 <td data-order="[% invoice.billingdate | html %]">
82 [% invoice.billingdate | $KohaDates %]
84 <td>[% invoice.receivedbiblios | html %]</td>
85 <td>[% invoice.receiveditems | html %]</td>
87 [% IF invoice.closedate %]
88 <span>Closed on [% invoice.closedate | $KohaDates %]</span>
95 <div class="btn-group dropup">
96 <a class="btn btn-default btn-xs dropdown-toggle" id="invoiceactions[% invoice.invoiceid | html %]" role="button" data-toggle="dropdown" href="#">
97 Actions <b class="caret"></b>
99 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="invoiceactions[% invoice.invoiceid | html %]">
100 <li><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]"><i class="fa fa-search"></i> Details</a></li>
101 [% IF invoice.closedate %]
102 [% IF CAN_user_acquisition_reopen_closed_invoices %]
103 <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 fa-refresh"></i> Reopen</a></li>
106 [% IF CAN_user_acquisition_edit_invoices %]
107 <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>
109 [% END # /IF invoice.closedate %]
110 [% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
111 [% IF CAN_user_acquisition_delete_invoices %]
112 <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"></i> Delete</a></li>
116 </div> <!-- /.btn-group dropup -->
119 [% END # /FOREACH invoice %]
121 </table> <!-- /#[% tab | html %]resultst -->
123 [% IF CAN_user_acquisition_merge_invoices %]
124 [% IF tab == 'closed' %]
125 <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>
126 <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 fa-refresh"></i> Reopen selected invoices</a>
128 <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>
129 <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>
130 [% END # /IF tab == 'closed' %]
131 [% END # /IF CAN_user_acquisition_merge_invoices %]
132 [% END # /BLOCK invoices_table %]
134 <div id="invoicestabs" class="toptabs">
135 <ul class="nav nav-tabs" role="tablist">
136 <li role="presentation" class="active"><a href="#opened" aria-controls="opened" role="tab" data-toggle="tab">Open invoices ([% openedinvoices.size || 0 | html %])</a></li>
137 <li role="presentation"><a href="#closed" aria-controls="closed" role="tab" data-toggle="tab">Closed invoices ([% closedinvoices.size || 0 | html %]) </a></li>
139 <div class="tab-content">
140 <div id="opened" role="tabpanel" class="tab-pane active">
141 [% IF openedinvoices %]
142 [% INCLUDE invoices_table invoices = openedinvoices %]
144 <div class="dialog message">
145 <p>Your search returned no open invoices.</p>
148 </div> <!-- /#opened -->
149 <div id="closed" role="tabpanel" class="tab-pane">
150 [% IF closedinvoices %]
151 [% INCLUDE invoices_table invoices = closedinvoices closed = 1 %]
153 <div class="dialog message">
154 <p>Your search returned no closed invoices.</p>
157 </div> <!-- /#closed -->
158 </div> <!-- /.tab-content -->
159 </div> <!-- /#invoicestabs -->
162 <div id="merge_invoices">
163 <form id="merge_invoice_form" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
164 <fieldset class="rows">
166 <li><h2>Merge invoices</h2></li>
168 <table id="merge_table">
171 <th>Invoice number</th>
172 <th>Shipment date</th>
173 <th>Billing date</th>
174 <th>Shipment cost</th>
183 <label for="merge_invoicenumber" class="required">Invoice number:</label>
184 <input type="text" size="10" id="merge_invoicenumber" name="invoicenumber" value="" class="required" required="required" />
185 <span class="required">Required</span>
189 <label for="merge_shipmentdate">Shipment date:</label>
190 <input type="text" size="10" id="merge_shipmentdate" name="shipmentdate" value="" class="flatpickr" />
191 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
195 <label for="merge_billingdate">Billing date:</label>
196 <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" class="flatpickr" />
197 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
201 <label for="merge_shipmentcost">Shipment cost:</label>
202 <input type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" />
205 <label for="merge_shipment_budgetid">Fund:</label>
206 <select id="merge_shipment_budgetid" name="shipment_budget_id">
207 <option value="">No fund</option>
208 [% FOREACH budget IN budgets_loop %]
209 <option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]</option>
215 <span class="label">Status:</span> <span id="merge_status"></span>
218 <input type="submit" value="Merge" />
221 <input type="hidden" name="op" value="mod" />
222 <input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
223 </fieldset> <!-- /.rows -->
224 </form> <!-- /#merge_invoice_form -->
225 </div> <!-- /#merge_invoices -->
226 [% ELSE # IF invoices %]
227 <p>Sorry, but there are no results for your search.</p>
230 [% IF ( invoicenumber ) %]
231 <li>Invoice number: [% invoicenumber | html %]</li>
233 [% IF booksellerid %]
234 <li>Vendor: [% suppliername | html %]</li>
236 [% IF shipmentdatefrom %]
238 <span>Shipment date:</span>
239 [% IF shipmentdateto %]
240 <span>From [% shipmentdatefrom | $KohaDates %]</span>
241 <span>To [% shipmentdateto | $KohaDates %]</span>
243 <span>All since [% shipmentdatefrom | $KohaDates %]</span>
247 [% IF shipmentdateto %]
250 All until [% shipmentdateto | $KohaDates %]
254 [% IF billingdatefrom %]
256 <span>Billing date:</span>
257 [% IF billingdateto %]
258 <span>From [% billingdatefrom | $KohaDates %]</span>
259 <span>To [% billingdateto | $KohaDates %]</span>
261 <span>All since [% billingdatefrom | $KohaDates %]</span>
265 [% IF billingdateto %]
268 All until [% billingdateto | $KohaDates %]
272 [% IF ( isbneanissn ) %]
273 <li>ISBN/EAN/ISSN: [% isbneanissn | html %]</li>
276 <li>Title: [% title | html %]</li>
279 <li>Author: [% author | html %]</li>
281 [% IF ( publisher ) %]
282 <li>Publisher: [% publisher | html %]</li>
284 [% IF ( publicationyear ) %]
285 <li>Publication year: [% publicationyear | html %]</li>
288 <li>Library: [% Branches.GetName( branch ) | html %]</li>
292 [% END # /IF invoices %]
294 <p>Use the search form on the left to find invoices.</p>
295 [% END %]<!-- do_search -->
297 </div> <!-- /.col-sm-10.col-sm-push-2 -->
299 <div class="col-sm-2 col-sm-pull-10">
301 <form action="" method="get">
302 <fieldset class="sidebar brief">
303 <h3>Search filters</h3>
306 <label for="invoicenumber">Invoice number</label>
307 <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]"
311 <label for="supplier">Vendor:</label>
312 <select id="supplier" name="supplierid">
313 <option value="">All</option>
314 [% FOREACH supplier IN suppliers_loop %]
315 [% IF ( supplier.selected ) %]
316 <option selected="selected" value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
318 <option value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
324 <fieldset class="brief">
325 <legend>Shipment date</legend>
328 <label for="shipmentdatefrom">From:</label>
329 <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | html %]" class="flatpickr" data-date_to="shipmentdateto" />
330 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
333 <label for="shipmentdateto">To:</label>
334 <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | html %]" class="flatpickr" />
335 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
341 <fieldset class="brief">
342 <legend>Billing date</legend>
345 <label for="billingdatefrom">From:</label>
346 <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | html %]" class="flatpickr" data-date_to="billingdateto" />
347 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
350 <label for="billingdateto">To:</label>
351 <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | html %]" class="flatpickr" />
352 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
358 <label for="isbneanissn">ISBN / EAN / ISSN:</label>
359 <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn | html %]" />
362 <label for="title">Title:</label>
363 <input type="text" id="title" name="title" value="[% title | html %]" />
366 <label for="author">Author:</label>
367 <input type="text" id="author" name="author" value="[% author | html %]" />
370 <label for="publisher">Publisher:</label>
371 <input type="text" id="publisher" name="publisher" value="[% publisher | html %]" />
374 <label for="publicationyear">Publication year:</label>
375 <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear | html %]" />
378 <label for="branch">Library:</label>
379 <select id="branch" name="branch">
380 <option value="">All</option>
381 [%# FIXME Should not we filter the libraries %]
382 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
386 <fieldset class="action">
387 <input type="submit" value="Search" />
389 </fieldset> <!-- /.sidebar.brief -->
390 <input type="hidden" name="op" id="op" value="do_search" />
392 [% INCLUDE 'acquisitions-menu.inc' %]
394 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
395 </div> <!-- /.row -->
397 [% MACRO jsinclude BLOCK %]
398 [% Asset.js("js/acquisitions-menu.js") | $raw %]
399 [% INCLUDE 'datatables.inc' %]
400 [% INCLUDE 'calendar.inc' %]
402 $(document).ready(function() {
403 $('[id^="CheckAll"]').click( function() {
404 var table_id = "#" + $(this).attr('data-cb') + "resultst";
405 $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
406 $(this).prop("checked" , true );
409 $('[id^="UncheckAll"]').click( function() {
410 var table_id = "#" + $(this).attr('data-cb') + "resultst";
411 $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
412 $(this).prop("checked" , false );
416 $(".delete_invoice").click(function(){
417 return confirmDelete(_("Are you sure you want to delete this invoice?"));
419 var resultst = $("table.result").dataTable($.extend(true, {}, dataTablesDefaults, {
422 { "bSortable": false, "aTargets": [1, -1] },
423 { "bVisible": false, "aTargets": [0] }
428 $(".show_only_subscription").prop("checked", false);
430 $(".show_only_subscription").click(function(){
431 var table_id = $(this).attr("data-tableid");
432 if ( $(this).prop("checked") ) {
433 $('#'+table_id).dataTable().fnFilter( "1", 0, true );
435 $('#'+table_id).dataTable().fnFilter( '', 0 );
439 $('#open_sel,#close_sel').click(function () {
440 var referer = $(this).attr("data-referer");
441 var op = $(this).attr("data-op");
442 var table = $(this).data('table');
443 var invoice_link = "invoice.pl?op="+op;
444 if ($('#' + table + ' .select-invoice:checked').length) {
445 $('#' + table + ' .select-invoice:checked').each(function () {
446 var row = $(this).parents('tr');
447 invoice_link = invoice_link + "&invoiceid="+$(row).attr('data-invoiceid');
449 window.location.href =invoice_link +"&"+referer;
451 alert ("Please select at least one invoice." );
455 $('.merge').click(function (ev) {
459 var table = $(this).data('table');
460 if ($('#' + table + ' .select-invoice:checked').size() < 2) {
461 alert(_("You must select at least two invoices to merge."));
464 $('#' + table + ' .select-invoice:checked').each(function () {
465 var row = $(this).parents('tr');
466 booksellerid = booksellerid || $(row).attr('data-booksellerid');
467 if (booksellerid !== $(row).attr('data-booksellerid')) {
470 invoices.push({ 'invoiceid': $(row).attr('data-invoiceid'),
471 'invoicenumber': $(row).find('td:nth-child(2) a').text(),
472 'shipmentdate': $(row).attr('data-shipmentdate'),
473 'billingdate': $(row).attr('data-billingdate'),
474 'shipmentcost': $(row).attr('data-shipmentcost'),
475 'shipment_budgetid': $(row).attr('data-shipment_budgetid'),
476 'closedate': $(row).attr('data-closedate'), });
477 $('#merge_invoice_form').append('<input type="hidden" name="merge" value="' + $(row).attr('data-invoiceid') + '" />');
480 alert(_("All invoices for merging must be from the same vendor"));
482 $('#merge_table tbody').empty();
483 $.each(invoices, function (idx, invoice) {
484 var row = $('<tr data-invoiceid="' + invoice.invoiceid + '"><td>' + invoice.invoicenumber + '</td><td>' + invoice.shipmentdate + '</td><td>' + invoice.billingdate + '</td><td>' + invoice.shipmentcost + '</td></tr>');
485 $(row).appendTo('#merge_table tbody');
486 $(row).click(function () {
487 $('#merge_table tbody tr').removeClass('active');
488 $(this).addClass('active');
489 $.each(['invoiceid', 'shipmentdate', 'billingdate', 'shipmentcost', 'shipment_budgetid', 'invoicenumber'], function (idx, prop) {
490 $('#merge_' + prop).val(invoice[prop]);
492 if (invoice.closedate) {
493 $('#merge_status').text(_("Closed on %s").format(invoice.closedate));
495 $('#merge_status').text(_("Open"));
499 $('#merge_table tbody tr:first').click();
500 $('#merge_invoices').show();
507 [% INCLUDE 'intranet-bottom.inc' %]