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