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