Bug 19429: Rename .delete to .delete_invoice
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / invoices.tt
1 [% USE KohaDates %]
2 [% USE Branches %]
3
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.css" />
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% INCLUDE 'datatables.inc' %]
9 [% INCLUDE 'calendar.inc' %]
10 <script type="text/javascript">
11 //<![CDATA[
12 $(document).ready(function() {
13     $(".delete_invoice").click(function(){
14         return confirmDelete(_("Are you sure you want to delete this invoice?"));
15     });
16
17     var resultst = $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
18         bPaginate: false,
19         aoColumnDefs: [
20             { "bSortable": false, "aTargets": [1, -1] },
21             { "bVisible": false, "aTargets": [0] },
22             { "sType": "title-string", "aTargets" : [ "title-string" ] }
23         ]
24     }));
25
26     $("#show_only_subscription").prop("checked", false);
27
28     $("#show_only_subscription").click(function(){
29         if ( $(this).prop("checked") ) {
30             resultst.fnFilter( "1", 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 %s").format(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 id="acq_invoices" class="acq">
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 class="title-string">Shipment date</th>
115                 <th class="title-string">Billing date</th>
116                 <th>Received biblios</th>
117                 <th>Received items</th>
118                 <th>Status</th>
119                 <th>&nbsp;</th>
120               </tr>
121             </thead>
122             <tbody>
123               [% FOREACH invoice IN invoices %]
124                 <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 %]">
125                   <td>[% invoice.is_linked_to_subscriptions %]</td>
126                   <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid %]" /></td>
127                   <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid %]">[% invoice.invoicenumber %]</a></td>
128                   <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid %]">[% invoice.suppliername %]</a></td>
129                   <td>
130                     [% IF invoice.shipmentdate %]
131                       <span title="[% invoice.shipmentdate %]">[% invoice.shipmentdate | $KohaDates %]</span>
132                     [% ELSE %]
133                       <span title="0000-00-00"></span>
134                     [% END %]
135                   </td>
136                   <td>
137                     [% IF invoice.billingdate %]
138                       <span title="[% invoice.billingdate %]">[% invoice.billingdate | $KohaDates %]</span>
139                     [% ELSE %]
140                       <span title="0000-00-00"></span>
141                     [% END %]
142                   </td>
143                   <td>[% invoice.receivedbiblios %]</td>
144                   <td>[% invoice.receiveditems %]</td>
145                   <td>
146                     [% IF invoice.closedate %]
147                       Closed on [% invoice.closedate | $KohaDates %]
148                     [% ELSE %]
149                       Open
150                     [% END %]
151                   </td>
152                   <td>
153
154                       <div class="dropdown dropup">
155                           <a class="btn btn-default btn-xs dropdown-toggle" id="invoiceactions[% invoice.invoiceid %]" role="button" data-toggle="dropdown" href="#">
156                              Actions <b class="caret"></b>
157                           </a>
158                           <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="invoiceactions[% invoice.invoiceid %]">
159                               <li><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid %]"><i class="fa fa-search"></i> Details</a></li>
160                             [% IF invoice.closedate %]
161                                 <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>
162                             [% ELSE %]
163                                 <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>
164                             [% END %]
165                             [% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
166                                 <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>
167                             [% END %]
168                           </ul>
169                       </div>
170                   </td>
171                 </tr>
172               [% END %]
173             </tbody>
174           </table>
175           <a class="submit" id="merge" href="#merge_invoices">Merge selected invoices</a>
176             <div id="merge_invoices">
177                 <form id="merge_invoice_form" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
178                 <fieldset class="rows">
179                     <ol>
180                     <li><h2>Merge invoices</h2></li>
181                     <li><table id="merge_table">
182                         <thead><tr><th>Invoice no.</th><th>Shipment date</th><th>Billing date</th><th>Shipment cost</th></tr></thead>
183                         <tbody>
184                         </tbody>
185                     </table></li>
186                     <li><label for="merge_invoicenumber">Invoice number:</label><span id="merge_invoicenumber"></span></li>
187                     <li><label for="merge_shipmentdate">Shipment date:</label>
188                             <input type="text" size="10" id="merge_shipmentdate" name="shipmentdate" value="" class="datepicker" /></li>
189
190                     <li><label for="merge_billingdate">Billing date:</label>
191                             <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" class="datepicker" /></li>
192
193                     <li><label for="merge_shipmentcost">Shipment cost:</label>
194                             <input type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" /></li>
195                     <li><label for="merge_shipment_budgetid">Fund:</label>
196                             <select id="merge_shipment_budgetid" name="shipment_budget_id">
197                                 <option value="">No fund</option>
198                               [% FOREACH budget IN budgets_loop %]
199                                   <option value="[% budget.budget_id %]">[% budget.budget_name %]
200                                   </option>
201                               [% END %]
202                             </select></li>
203
204                     <li><span class="label">Status:</span> <span id="merge_status"></span></li>
205                     <li><input type="submit" value="Merge" /></li>
206                     </ol>
207                     <input type="hidden" name="op" value="mod" />
208                     <input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
209                 </fieldset>
210                 </form>
211             </div>
212         [% ELSE %]
213           <p>Sorry, but there are no results for your search.</p>
214           <p>Search was:
215             <ul>
216               [% IF ( invoicenumber ) %]
217                 <li>Invoice no.: [% invoicenumber |html %]</li>
218               [% END %]
219               [% IF booksellerid %]
220                 <li>Vendor: [% suppliername %]</li>
221               [% END %]
222               [% IF shipmentdatefrom %]
223                 <li>Shipment date:
224                 [% IF shipmentdateto %]
225                   From [% shipmentdatefrom | $KohaDates %]
226                   To [% shipmentdateto | $KohaDates %]
227                 [% ELSE %]
228                   All since [% shipmentdatefrom | $KohaDates %]
229                 [% END %]
230                 </li>
231               [% ELSE %]
232                 [% IF shipmentdateto %]
233                   <li>Shipment date:
234                     All until [% shipmentdateto | $KohaDates %]
235                   </li>
236                 [% END %]
237               [% END %]
238               [% IF billingdatefrom %]
239                 <li>Billing date:
240                 [% IF billingdateto %]
241                   From [% billingdatefrom | $KohaDates %]
242                   To [% billingdateto | $KohaDates %]
243                 [% ELSE %]
244                   All since [% billingdatefrom | $KohaDates %]
245                 [% END %]
246                 </li>
247               [% ELSE %]
248                 [% IF billingdateto %]
249                   <li>Billing date:
250                     All until [% billingdateto | $KohaDates %]
251                   </li>
252                 [% END %]
253               [% END %]
254               [% IF ( isbneanissn ) %]
255                 <li>ISBN/EAN/ISSN: [% isbneanissn |html %]</li>
256               [% END %]
257               [% IF ( title ) %]
258                 <li>Title: [% title |html %]</li>
259               [% END %]
260               [% IF ( author ) %]
261                 <li>Author: [% author |html %]</li>
262               [% END %]
263               [% IF ( publisher ) %]
264                 <li>Publisher: [% publisher |html %]</li>
265               [% END %]
266               [% IF ( publicationyear ) %]
267                 <li>Publication year: [% publicationyear |html %]</li>
268               [% END %]
269               [% IF ( branch ) %]
270                 <li>Library: [% Branches.GetName( branch ) %]</li>
271               [% END %]
272             </ul>
273           </p>
274         [% END %]<!-- invoices -->
275       [% ELSE %]
276         <p>Use the search form on the left to find invoices.</p>
277       [% END %]<!-- do_search -->
278     </div>
279   </div>
280   <div class="yui-b">
281     <form action="" method="get">
282       <fieldset class="brief">
283         <h3>Search filters</h3>
284         <ol>
285           <li>
286             <label for="invoicenumber">Invoice no:</label>
287             <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber |html %]" class="focus" />
288           </li>
289           <li>
290             <label for="supplier">Vendor:</label>
291             <select id="supplier" name="supplierid">
292               <option value="">All</option>
293               [% FOREACH supplier IN suppliers_loop %]
294                 [% IF ( supplier.selected ) %]
295                   <option selected="selected" value="[% supplier.booksellerid %]">[% supplier.suppliername %]</option>
296                 [% ELSE %]
297                   <option value="[% supplier.booksellerid %]">[% supplier.suppliername %]</option>
298                 [% END %]
299               [% END %]
300             </select>
301           </li>
302           <li>
303             <fieldset class="brief">
304               <legend>Shipment date</legend>
305               <ol>
306                 <li>
307                   <label for="shipmentdatefrom">From:</label>
308                   <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | $KohaDates %]" class="datepicker" />
309                 </li>
310                 <li>
311                   <label for="shipmentdateto">To:</label>
312                   <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | $KohaDates %]" class="datepicker" />
313                 </li>
314               </ol>
315             </fieldset>
316           </li>
317           <li>
318             <fieldset class="brief">
319               <legend>Billing date</legend>
320               <ol>
321                 <li>
322                   <label for="billingdatefrom">From:</label>
323                   <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | $KohaDates %]" class="datepicker" />
324                 </li>
325                 <li>
326                   <label for="billingdateto">To:</label>
327                   <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | $KohaDates %]" class="datepicker" />
328                 </li>
329               </ol>
330             </fieldset>
331           </li>
332           <li>
333             <label for="isbneanissn">ISBN / EAN / ISSN:</label>
334             <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn |html %]" />
335           </li>
336           <li>
337             <label for="title">Title:</label>
338             <input type="text" id="title" name="title" value="[% title |html %]" />
339           </li>
340           <li>
341             <label for="author">Author:</label>
342             <input type="text" id="author" name="author" value="[% author |html %]" />
343           </li>
344           <li>
345             <label for="publisher">Publisher:</label>
346             <input type="text" id="publisher" name="publisher" value="[% publisher |html %]" />
347           </li>
348           <li>
349             <label for="publicationyear">Publication year:</label>
350             <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear |html %]" />
351           </li>
352           <li>
353             <label for="branch">Library:</label>
354             <select id="branch" name="branch">
355               <option value="">All</option>
356               [%# FIXME Should not we filter the libraries %]
357               [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
358             </select>
359           </li>
360         </ol>
361         <fieldset class="action">
362           <input type="submit" value="Search" />
363         </fieldset>
364       </fieldset>
365       <input type="hidden" name="op" id="op" value="do_search" />
366     </form>
367     [% INCLUDE 'acquisitions-menu.inc' %]
368   </div>
369 </div>
370 [% INCLUDE 'intranet-bottom.inc' %]