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