Bug 19833: Kill the "biblios"
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / invoices.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Branches %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Acquisitions &rsaquo; Invoices</title>
8 [% Asset.css("css/datatables.css") | $raw %]
9 [% INCLUDE 'doc-head-close.inc' %]
10
11 </head>
12
13 <body id="acq_invoices" class="acq">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'acquisitions-search.inc' %]
16
17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; Invoices</div>
18
19 <div class="main container-fluid">
20     <div class="row">
21         <div class="col-sm-10 col-sm-push-2">
22             <main>
23
24       <h1>Invoices</h1>
25       [% IF ( do_search ) %]
26         [% IF invoices %]
27           <label for="show_only_subscription">
28             <input type="checkbox" style="vertical-align: middle;" id="show_only_subscription" />
29             Show only subscriptions
30           </label>
31           <table id="resultst">
32             <thead>
33               <tr>
34                 <th>&nbsp;</th>
35                 <th>&nbsp;</th>
36                 <th>Invoice no.</th>
37                 <th>Vendor</th>
38                 <th class="title-string">Shipment date</th>
39                 <th class="title-string">Billing date</th>
40                 <th>Received bibliographic records</th>
41                 <th>Received items</th>
42                 <th>Status</th>
43                 <th>&nbsp;</th>
44               </tr>
45             </thead>
46             <tbody>
47               [% FOREACH invoice IN invoices %]
48                 <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 %]">
49                   <td>[% invoice.is_linked_to_subscriptions | html %]</td>
50                   <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid | html %]" /></td>
51                   <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | html %]">[% invoice.invoicenumber | html %]</a></td>
52                   <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid | html %]">[% invoice.suppliername | html %]</a></td>
53                   <td>
54                     [% IF invoice.shipmentdate %]
55                       <span title="[% invoice.shipmentdate | html %]">[% invoice.shipmentdate | $KohaDates %]</span>
56                     [% ELSE %]
57                       <span title="0000-00-00"></span>
58                     [% END %]
59                   </td>
60                   <td>
61                     [% IF invoice.billingdate %]
62                       <span title="[% invoice.billingdate | html %]">[% invoice.billingdate | $KohaDates %]</span>
63                     [% ELSE %]
64                       <span title="0000-00-00"></span>
65                     [% END %]
66                   </td>
67                   <td>[% invoice.receivedbiblios | html %]</td>
68                   <td>[% invoice.receiveditems | html %]</td>
69                   <td>
70                     [% IF invoice.closedate %]
71                       Closed on [% invoice.closedate | $KohaDates %]
72                     [% ELSE %]
73                       Open
74                     [% END %]
75                   </td>
76                   <td>
77
78                       <div class="dropdown dropup">
79                           <a class="btn btn-default btn-xs dropdown-toggle" id="invoiceactions[% invoice.invoiceid | html %]" role="button" data-toggle="dropdown" href="#">
80                              Actions <b class="caret"></b>
81                           </a>
82                           <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="invoiceactions[% invoice.invoiceid | html %]">
83                               <li><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | html %]"><i class="fa fa-search"></i> Details</a></li>
84                             [% IF invoice.closedate %]
85                                 <li><a href="invoice.pl?op=reopen&amp;invoiceid=[% invoice.invoiceid | html %]&amp;referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | html %]%26supplier=[% booksellerid | html %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | html %]%26title=[% title | html %]%26author=[% author | html %]%26publisher=[% publisher | html %]%26publicationyear=[% publicationyear | html %]%26branch=[% branch | html %]"><i class="fa fa-refresh"></i> Reopen</a></li>
86                             [% ELSE %]
87                                 <li><a href="invoice.pl?op=close&amp;invoiceid=[% invoice.invoiceid | html %]&amp;referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | html %]%26supplier=[% booksellerid | html %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | html %]%26title=[% title | html %]%26author=[% author | html %]%26publisher=[% publisher | html %]%26publicationyear=[% publicationyear | html %]%26branch=[% branch | html %]"><i class="fa fa-times-circle"></i> Close</a></li>
88                             [% END %]
89                             [% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
90                                 <li><a href="invoice.pl?op=delete&amp;invoiceid=[% invoice.invoiceid | html %]&amp;referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | html %]%26supplier=[% booksellerid | html %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | html %]%26title=[% title | html %]%26author=[% author | html %]%26publisher=[% publisher | html %]%26publicationyear=[% publicationyear | html %]%26branch=[% branch | html %]" class="delete_invoice"><i class="fa fa-trash"></i> Delete</a></li>
91                             [% END %]
92                           </ul>
93                       </div>
94                   </td>
95                 </tr>
96               [% END %]
97             </tbody>
98           </table>
99           <a class="submit" id="merge" href="#merge_invoices">Merge selected invoices</a>
100             <div id="merge_invoices">
101                 <form id="merge_invoice_form" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
102                 <fieldset class="rows">
103                     <ol>
104                     <li><h2>Merge invoices</h2></li>
105                     <li><table id="merge_table">
106                         <thead><tr><th>Invoice no.</th><th>Shipment date</th><th>Billing date</th><th>Shipment cost</th></tr></thead>
107                         <tbody>
108                         </tbody>
109                     </table></li>
110                     <li><label for="merge_invoicenumber" class="required">Invoice number:</label>
111                             <input type="text" size="10" id="merge_invoicenumber" name="invoicenumber" value="" class="required" required="required" />
112                             <span class="required">Required</span>
113                             </li>
114                     <li><label for="merge_shipmentdate">Shipment date:</label>
115                             <input type="text" size="10" id="merge_shipmentdate" name="shipmentdate" value="" class="datepicker" /></li>
116
117                     <li><label for="merge_billingdate">Billing date:</label>
118                             <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" class="datepicker" /></li>
119
120                     <li><label for="merge_shipmentcost">Shipment cost:</label>
121                             <input type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" /></li>
122                     <li><label for="merge_shipment_budgetid">Fund:</label>
123                             <select id="merge_shipment_budgetid" name="shipment_budget_id">
124                                 <option value="">No fund</option>
125                               [% FOREACH budget IN budgets_loop %]
126                                   <option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]
127                                   </option>
128                               [% END %]
129                             </select></li>
130
131                     <li><span class="label">Status:</span> <span id="merge_status"></span></li>
132                     <li><input type="submit" value="Merge" /></li>
133                     </ol>
134                     <input type="hidden" name="op" value="mod" />
135                     <input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
136                 </fieldset>
137                 </form>
138             </div>
139         [% ELSE %]
140           <p>Sorry, but there are no results for your search.</p>
141           <p>Search was:
142             <ul>
143               [% IF ( invoicenumber ) %]
144                 <li>Invoice no.: [% invoicenumber | html %]</li>
145               [% END %]
146               [% IF booksellerid %]
147                 <li>Vendor: [% suppliername | html %]</li>
148               [% END %]
149               [% IF shipmentdatefrom %]
150                 <li>Shipment date:
151                 [% IF shipmentdateto %]
152                   From [% shipmentdatefrom | $KohaDates %]
153                   To [% shipmentdateto | $KohaDates %]
154                 [% ELSE %]
155                   All since [% shipmentdatefrom | $KohaDates %]
156                 [% END %]
157                 </li>
158               [% ELSE %]
159                 [% IF shipmentdateto %]
160                   <li>Shipment date:
161                     All until [% shipmentdateto | $KohaDates %]
162                   </li>
163                 [% END %]
164               [% END %]
165               [% IF billingdatefrom %]
166                 <li>Billing date:
167                 [% IF billingdateto %]
168                   From [% billingdatefrom | $KohaDates %]
169                   To [% billingdateto | $KohaDates %]
170                 [% ELSE %]
171                   All since [% billingdatefrom | $KohaDates %]
172                 [% END %]
173                 </li>
174               [% ELSE %]
175                 [% IF billingdateto %]
176                   <li>Billing date:
177                     All until [% billingdateto | $KohaDates %]
178                   </li>
179                 [% END %]
180               [% END %]
181               [% IF ( isbneanissn ) %]
182                 <li>ISBN/EAN/ISSN: [% isbneanissn | html %]</li>
183               [% END %]
184               [% IF ( title ) %]
185                 <li>Title: [% title | html %]</li>
186               [% END %]
187               [% IF ( author ) %]
188                 <li>Author: [% author | html %]</li>
189               [% END %]
190               [% IF ( publisher ) %]
191                 <li>Publisher: [% publisher | html %]</li>
192               [% END %]
193               [% IF ( publicationyear ) %]
194                 <li>Publication year: [% publicationyear | html %]</li>
195               [% END %]
196               [% IF ( branch ) %]
197                 <li>Library: [% Branches.GetName( branch ) | html %]</li>
198               [% END %]
199             </ul>
200           </p>
201         [% END %]<!-- invoices -->
202       [% ELSE %]
203         <p>Use the search form on the left to find invoices.</p>
204       [% END %]<!-- do_search -->
205     </main>
206 </div> <!-- /.col-sm-10.col-sm-push-2 -->
207
208 <div class="col-sm-2 col-sm-pull-10">
209 <aside>
210     <form action="" method="get">
211       <fieldset class="sidebar brief">
212         <h3>Search filters</h3>
213         <ol>
214           <li>
215             <label for="invoicenumber">Invoice no:</label>
216             <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]" class="focus" />
217           </li>
218           <li>
219             <label for="supplier">Vendor:</label>
220             <select id="supplier" name="supplierid">
221               <option value="">All</option>
222               [% FOREACH supplier IN suppliers_loop %]
223                 [% IF ( supplier.selected ) %]
224                   <option selected="selected" value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
225                 [% ELSE %]
226                   <option value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
227                 [% END %]
228               [% END %]
229             </select>
230           </li>
231           <li>
232             <fieldset class="brief">
233               <legend>Shipment date</legend>
234               <ol>
235                 <li>
236                   <label for="shipmentdatefrom">From:</label>
237                   <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | $KohaDates %]" class="datepicker" />
238                 </li>
239                 <li>
240                   <label for="shipmentdateto">To:</label>
241                   <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | $KohaDates %]" class="datepicker" />
242                 </li>
243               </ol>
244             </fieldset>
245           </li>
246           <li>
247             <fieldset class="brief">
248               <legend>Billing date</legend>
249               <ol>
250                 <li>
251                   <label for="billingdatefrom">From:</label>
252                   <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | $KohaDates %]" class="datepicker" />
253                 </li>
254                 <li>
255                   <label for="billingdateto">To:</label>
256                   <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | $KohaDates %]" class="datepicker" />
257                 </li>
258               </ol>
259             </fieldset>
260           </li>
261           <li>
262             <label for="isbneanissn">ISBN / EAN / ISSN:</label>
263             <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn | html %]" />
264           </li>
265           <li>
266             <label for="title">Title:</label>
267             <input type="text" id="title" name="title" value="[% title | html %]" />
268           </li>
269           <li>
270             <label for="author">Author:</label>
271             <input type="text" id="author" name="author" value="[% author | html %]" />
272           </li>
273           <li>
274             <label for="publisher">Publisher:</label>
275             <input type="text" id="publisher" name="publisher" value="[% publisher | html %]" />
276           </li>
277           <li>
278             <label for="publicationyear">Publication year:</label>
279             <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear | html %]" />
280           </li>
281           <li>
282             <label for="branch">Library:</label>
283             <select id="branch" name="branch">
284               <option value="">All</option>
285               [%# FIXME Should not we filter the libraries %]
286               [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
287             </select>
288           </li>
289         </ol>
290         <fieldset class="action">
291           <input type="submit" value="Search" />
292         </fieldset>
293       </fieldset>
294       <input type="hidden" name="op" id="op" value="do_search" />
295     </form>
296     [% INCLUDE 'acquisitions-menu.inc' %]
297   </aside>
298 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
299 </div> <!-- /.row -->
300
301 [% MACRO jsinclude BLOCK %]
302     [% Asset.js("js/acquisitions-menu.js") | $raw %]
303     [% INCLUDE 'datatables.inc' %]
304     [% INCLUDE 'calendar.inc' %]
305     <script>
306         $(document).ready(function() {
307             $(".delete_invoice").click(function(){
308                 return confirmDelete(_("Are you sure you want to delete this invoice?"));
309             });
310             var resultst = $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
311                 bPaginate: false,
312                 aoColumnDefs: [
313                     { "bSortable": false, "aTargets": [1, -1] },
314                     { "bVisible": false, "aTargets": [0] },
315                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
316                 ]
317             }));
318
319             $("#show_only_subscription").prop("checked", false);
320
321             $("#show_only_subscription").click(function(){
322                 if ( $(this).prop("checked") ) {
323                     resultst.fnFilter( "1", 0, true );
324                 } else {
325                     resultst.fnFilter( '', 0 );
326                 }
327             });
328
329             $('#merge').click(function (ev) {
330                 var booksellerid;
331                 var mismatch;
332                 var invoices = [ ];
333                 if ($('.select-invoice:checked').size() < 2) {
334                     alert(_("You must select at least two invoices to merge."));
335                     return false;
336                 }
337                 $('.select-invoice:checked').each(function () {
338                     var row = $(this).parents('tr');
339                     booksellerid = booksellerid || $(row).attr('data-booksellerid');
340                     if (booksellerid !== $(row).attr('data-booksellerid')) {
341                         mismatch = true;
342                     }
343                     invoices.push({ 'invoiceid': $(row).attr('data-invoiceid'),
344                                     'invoicenumber': $(row).find('td:nth-child(2) a').text(),
345                                     'shipmentdate': $(row).attr('data-shipmentdate'),
346                                     'billingdate': $(row).attr('data-billingdate'),
347                                     'shipmentcost': $(row).attr('data-shipmentcost'),
348                                     'shipment_budgetid': $(row).attr('data-shipment_budgetid'),
349                                     'closedate': $(row).attr('data-closedate'), });
350                     $('#merge_invoice_form').append('<input type="hidden" name="merge" value="' + $(row).attr('data-invoiceid') + '" />');
351                 });
352                 if (mismatch) {
353                     alert(_("All invoices for merging must be from the same vendor"));
354                 } else {
355                     $('#merge_table tbody').empty();
356                     $.each(invoices, function (idx, invoice) {
357                         var row = $('<tr data-invoiceid="' + invoice.invoiceid + '"><td>' + invoice.invoicenumber + '</td><td>' + invoice.shipmentdate + '</td><td>' + invoice.billingdate + '</td><td>' + invoice.shipmentcost + '</td></tr>');
358                         $(row).appendTo('#merge_table tbody');
359                         $(row).click(function () {
360                             $('#merge_table tbody tr').removeClass('active');
361                             $(this).addClass('active');
362                             $.each(['invoiceid', 'shipmentdate', 'billingdate', 'shipmentcost', 'shipment_budgetid', 'invoicenumber'], function (idx, prop) {
363                                 $('#merge_' + prop).val(invoice[prop]);
364                             });
365                             if (invoice.closedate) {
366                                 $('#merge_status').text(_("Closed on %s").format(invoice.closedate));
367                             } else {
368                                 $('#merge_status').text(_("Open"));
369                             }
370                         });
371                     });
372                     $('#merge_table tbody tr:first').click();
373                     $('#merge_invoices').show();
374                 }
375             });
376         });
377     </script>
378 [% END %]
379
380 [% INCLUDE 'intranet-bottom.inc' %]