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