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