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 <table id="[% tab | html %]resultst" class="result">
54 [% IF CAN_user_acquisition_merge_invoices %]
60 <th>Shipment date</th>
62 <th>Received bibliographic records</th>
63 <th>Received items</th>
69 [% FOREACH invoice IN invoices %]
70 <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 %]">
71 [% IF CAN_user_acquisition_merge_invoices %]
72 <td>[% invoice.is_linked_to_subscriptions | html %]</td>
74 <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid | html %]" /></td>
75 <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]">[% invoice.invoicenumber | html %]</a></td>
76 <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid | uri %]">[% invoice.suppliername | html %]</a></td>
77 <td data-order="[% invoice.shipmentdate | html %]">
78 [% invoice.shipmentdate | $KohaDates %]
80 <td data-order="[% invoice.billingdate | html %]">
81 [% invoice.billingdate | $KohaDates %]
83 <td>[% invoice.receivedbiblios | html %]</td>
84 <td>[% invoice.receiveditems | html %]</td>
86 [% IF invoice.closedate %]
87 Closed on [% invoice.closedate | $KohaDates %]
94 <div class="btn-group dropup">
95 <a class="btn btn-default btn-xs dropdown-toggle" id="invoiceactions[% invoice.invoiceid | html %]" role="button" data-toggle="dropdown" href="#">
96 Actions <b class="caret"></b>
98 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="invoiceactions[% invoice.invoiceid | html %]">
99 <li><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]"><i class="fa fa-search"></i> Details</a></li>
100 [% IF invoice.closedate %]
101 [% IF CAN_user_acquisition_reopen_closed_invoices %]
102 <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>
105 [% IF CAN_user_acquisition_edit_invoices %]
106 <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 [% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
110 [% IF CAN_user_acquisition_delete_invoices %]
111 <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>
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 fa-refresh"></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>
129 [% END %] <!-- invoices_table -->
131 <div id="invoicestabs" class="toptabs" style="clear:both;">
132 <ul class="ui-tabs-nav">
133 <li><a href="#opened">Open invoices ([% openedinvoices.size || 0 | html %])</a></li>
134 <li><a href="#closed">Closed invoices ([% closedinvoices.size || 0 | html %]) </a></li>
137 [% IF openedinvoices %]
138 [% INCLUDE invoices_table invoices = openedinvoices %]
140 <div class="dialog message">
141 <p>Your search returned no open invoices.</p>
144 </div> <!-- opened -->
146 [% IF closedinvoices %]
147 [% INCLUDE invoices_table invoices = closedinvoices closed = 1 %]
149 <div class="dialog message">
150 <p>Your search returned no closed invoices.</p>
153 </div> <!-- closed -->
154 </div> <!-- invoicestabs -->
157 <div id="merge_invoices">
158 <form id="merge_invoice_form" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
159 <fieldset class="rows">
161 <li><h2>Merge invoices</h2></li>
162 <li><table id="merge_table">
163 <thead><tr><th>Invoice no.</th><th>Shipment date</th><th>Billing date</th><th>Shipment cost</th></tr></thead>
167 <li><label for="merge_invoicenumber" class="required">Invoice number:</label>
168 <input type="text" size="10" id="merge_invoicenumber" name="invoicenumber" value="" class="required" required="required" />
169 <span class="required">Required</span>
171 <li><label for="merge_shipmentdate">Shipment date:</label>
172 <input type="text" size="10" id="merge_shipmentdate" name="shipmentdate" value="" class="datepicker" /></li>
174 <li><label for="merge_billingdate">Billing date:</label>
175 <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" class="datepicker" /></li>
177 <li><label for="merge_shipmentcost">Shipment cost:</label>
178 <input type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" /></li>
179 <li><label for="merge_shipment_budgetid">Fund:</label>
180 <select id="merge_shipment_budgetid" name="shipment_budget_id">
181 <option value="">No fund</option>
182 [% FOREACH budget IN budgets_loop %]
183 <option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]
188 <li><span class="label">Status:</span> <span id="merge_status"></span></li>
189 <li><input type="submit" value="Merge" /></li>
191 <input type="hidden" name="op" value="mod" />
192 <input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
197 <p>Sorry, but there are no results for your search.</p>
200 [% IF ( invoicenumber ) %]
201 <li>Invoice no.: [% invoicenumber | html %]</li>
203 [% IF booksellerid %]
204 <li>Vendor: [% suppliername | html %]</li>
206 [% IF shipmentdatefrom %]
208 [% IF shipmentdateto %]
209 From [% shipmentdatefrom | $KohaDates %]
210 To [% shipmentdateto | $KohaDates %]
212 All since [% shipmentdatefrom | $KohaDates %]
216 [% IF shipmentdateto %]
218 All until [% shipmentdateto | $KohaDates %]
222 [% IF billingdatefrom %]
224 [% IF billingdateto %]
225 From [% billingdatefrom | $KohaDates %]
226 To [% billingdateto | $KohaDates %]
228 All since [% billingdatefrom | $KohaDates %]
232 [% IF billingdateto %]
234 All until [% billingdateto | $KohaDates %]
238 [% IF ( isbneanissn ) %]
239 <li>ISBN/EAN/ISSN: [% isbneanissn | html %]</li>
242 <li>Title: [% title | html %]</li>
245 <li>Author: [% author | html %]</li>
247 [% IF ( publisher ) %]
248 <li>Publisher: [% publisher | html %]</li>
250 [% IF ( publicationyear ) %]
251 <li>Publication year: [% publicationyear | html %]</li>
254 <li>Library: [% Branches.GetName( branch ) | html %]</li>
258 [% END %]<!-- invoices -->
260 <p>Use the search form on the left to find invoices.</p>
261 [% END %]<!-- do_search -->
263 </div> <!-- /.col-sm-10.col-sm-push-2 -->
265 <div class="col-sm-2 col-sm-pull-10">
267 <form action="" method="get">
268 <fieldset class="sidebar brief">
269 <h3>Search filters</h3>
272 <label for="invoicenumber">Invoice no:</label>
273 <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]" class="focus" />
276 <label for="supplier">Vendor:</label>
277 <select id="supplier" name="supplierid">
278 <option value="">All</option>
279 [% FOREACH supplier IN suppliers_loop %]
280 [% IF ( supplier.selected ) %]
281 <option selected="selected" value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
283 <option value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
289 <fieldset class="brief">
290 <legend>Shipment date</legend>
293 <label for="shipmentdatefrom">From:</label>
294 <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | $KohaDates %]" class="datepicker" />
297 <label for="shipmentdateto">To:</label>
298 <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | $KohaDates %]" class="datepicker" />
304 <fieldset class="brief">
305 <legend>Billing date</legend>
308 <label for="billingdatefrom">From:</label>
309 <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | $KohaDates %]" class="datepicker" />
312 <label for="billingdateto">To:</label>
313 <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | $KohaDates %]" class="datepicker" />
319 <label for="isbneanissn">ISBN / EAN / ISSN:</label>
320 <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn | html %]" />
323 <label for="title">Title:</label>
324 <input type="text" id="title" name="title" value="[% title | html %]" />
327 <label for="author">Author:</label>
328 <input type="text" id="author" name="author" value="[% author | html %]" />
331 <label for="publisher">Publisher:</label>
332 <input type="text" id="publisher" name="publisher" value="[% publisher | html %]" />
335 <label for="publicationyear">Publication year:</label>
336 <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear | html %]" />
339 <label for="branch">Library:</label>
340 <select id="branch" name="branch">
341 <option value="">All</option>
342 [%# FIXME Should not we filter the libraries %]
343 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
347 <fieldset class="action">
348 <input type="submit" value="Search" />
351 <input type="hidden" name="op" id="op" value="do_search" />
353 [% INCLUDE 'acquisitions-menu.inc' %]
355 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
356 </div> <!-- /.row -->
358 [% MACRO jsinclude BLOCK %]
359 [% Asset.js("js/acquisitions-menu.js") | $raw %]
360 [% INCLUDE 'datatables.inc' %]
361 [% INCLUDE 'calendar.inc' %]
363 $(document).ready(function() {
364 $('#invoicestabs').tabs();
365 $(".delete_invoice").click(function(){
366 return confirmDelete(_("Are you sure you want to delete this invoice?"));
368 var resultst = $("table.result").dataTable($.extend(true, {}, dataTablesDefaults, {
371 { "bSortable": false, "aTargets": [1, -1] },
372 { "bVisible": false, "aTargets": [0] }
377 $(".show_only_subscription").prop("checked", false);
379 $(".show_only_subscription").click(function(){
380 var table_id = $(this).attr("data-tableid");
381 if ( $(this).prop("checked") ) {
382 $('#'+table_id).dataTable().fnFilter( "1", 0, true );
384 $('#'+table_id).dataTable().fnFilter( '', 0 );
388 $('#open_sel,#close_sel').click(function () {
389 var referer = $(this).attr("data-referer");
390 var op = $(this).attr("data-op");
391 var table = $(this).data('table');
392 var invoice_link = "invoice.pl?op="+op;
393 if ($('#' + table + ' .select-invoice:checked').length) {
394 $('#' + table + ' .select-invoice:checked').each(function () {
395 var row = $(this).parents('tr');
396 invoice_link = invoice_link + "&invoiceid="+$(row).attr('data-invoiceid');
398 window.location.href =invoice_link +"&"+referer;
400 alert ("Please select at least one invoice." );
404 $('.merge').click(function (ev) {
408 var table = $(this).data('table');
409 if ($('#' + table + ' .select-invoice:checked').size() < 2) {
410 alert(_("You must select at least two invoices to merge."));
413 $('#' + table + ' .select-invoice:checked').each(function () {
414 var row = $(this).parents('tr');
415 booksellerid = booksellerid || $(row).attr('data-booksellerid');
416 if (booksellerid !== $(row).attr('data-booksellerid')) {
419 invoices.push({ 'invoiceid': $(row).attr('data-invoiceid'),
420 'invoicenumber': $(row).find('td:nth-child(2) a').text(),
421 'shipmentdate': $(row).attr('data-shipmentdate'),
422 'billingdate': $(row).attr('data-billingdate'),
423 'shipmentcost': $(row).attr('data-shipmentcost'),
424 'shipment_budgetid': $(row).attr('data-shipment_budgetid'),
425 'closedate': $(row).attr('data-closedate'), });
426 $('#merge_invoice_form').append('<input type="hidden" name="merge" value="' + $(row).attr('data-invoiceid') + '" />');
429 alert(_("All invoices for merging must be from the same vendor"));
431 $('#merge_table tbody').empty();
432 $.each(invoices, function (idx, invoice) {
433 var row = $('<tr data-invoiceid="' + invoice.invoiceid + '"><td>' + invoice.invoicenumber + '</td><td>' + invoice.shipmentdate + '</td><td>' + invoice.billingdate + '</td><td>' + invoice.shipmentcost + '</td></tr>');
434 $(row).appendTo('#merge_table tbody');
435 $(row).click(function () {
436 $('#merge_table tbody tr').removeClass('active');
437 $(this).addClass('active');
438 $.each(['invoiceid', 'shipmentdate', 'billingdate', 'shipmentcost', 'shipment_budgetid', 'invoicenumber'], function (idx, prop) {
439 $('#merge_' + prop).val(invoice[prop]);
441 if (invoice.closedate) {
442 $('#merge_status').text(_("Closed on %s").format(invoice.closedate));
444 $('#merge_status').text(_("Open"));
448 $('#merge_table tbody tr:first').click();
449 $('#merge_invoices').show();
456 [% INCLUDE 'intranet-bottom.inc' %]