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