Bug 11605: fallback to default DataTables settings where possible
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / parcel.tt
1 [% USE currency = format('%.2f') -%]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( date ) %]
4             Receipt summary for [% name %] [% IF ( invoice ) %]invoice [% invoice %][% END %] on [% formatteddatereceived %][% ELSE %]Receive orders from [% name %][% END %]</title>
5 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% INCLUDE 'datatables.inc' %]
8 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
9 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
10 [% INCLUDE 'greybox.inc' %]
11 <script type="text/javascript">
12 //<![CDATA[
13
14     dt_overwrite_html_sorting_localeCompare();
15
16     var sticky_filters = [% sticky_filters %];
17
18     $(document).ready(function(){
19       if ( $("#pendingt").length ) {
20         var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, {
21             "bStateSave": true,
22             "iCookieDuration": 60*60*24*1000, // 1000 days
23             "aoColumnDefs": [
24                 { "aTargets": [ 4, 9, 10 ], "bSortable": false, "bSearchable": false },
25             ],
26             "aoColumns": [
27                 { "sType": "html" },
28                 { "sType": "html" },
29                 { "sType": "num-html" },
30                 { "sType": "html" },
31                 null,
32                 null,
33                 null,
34                 null,
35                 null,
36                 null,
37                 null,
38             ],
39             'bAutoWidth': false,
40             "sPaginationType": "four_button"
41         } )
42         ).columnFilter({
43             sPlaceHolder: "head:after",
44             aoColumns: [
45                 { type: "text" },
46                 { type: "text" },
47                 { type: "text" },
48                 { type: "text" },
49                 null,
50                 { type: "text" },
51                 { type: "text" },
52                 { type: "text" },
53                 { type: "text" },
54                 null,
55                 null
56             ]
57         });
58       }
59
60       if ( $("#receivedt").length ) {
61         var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
62             "bStateSave": true,
63             "iCookieDuration": 60*60*24*1000, // 1000 days
64             "aoColumnDefs": [
65                 { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
66             ],
67             "aoColumns": [
68                 { "sType": "html" },
69                 { "sType": "html" },
70                 { "sType": "html" },
71                 { "sType": "num-html" },
72                 null,
73                 null,
74                 null,
75                 null,
76                 null,
77                 null,
78                 null,
79                 null
80             ],
81             "sPaginationType": "four_button"
82         } ) );
83       }
84
85       // Keep filters from finishreceive.pl to parcel.pl
86       $.cookie("filter_parcel_summary", $("#summaryfilter").val());
87       $.cookie("filter_parcel_basketname", $("#basketfilter").val());
88       $.cookie("filter_parcel_orderno", $("#orderfilter").val());
89       $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
90       $.cookie("filter_parcel_ean", $("#eanfilter").val());
91
92       $("#filterform").on('submit', function(){
93         $.cookie("filter_parcel_summary", $("#summaryfilter").val());
94         $.cookie("filter_parcel_basketname", $("#basketfilter").val());
95         $.cookie("filter_parcel_orderno", $("#orderfilter").val());
96         $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
97         $.cookie("filter_parcel_ean", $("#eanfilter").val());
98       });
99
100     });
101
102      // Case-insensitive version of jquery's contains function
103      jQuery.extend(jQuery.expr[':'], {
104             icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
105      });
106
107      // Contains exactly function
108      jQuery.extend(jQuery.expr[':'], {
109           containsExactly: "$(a).text() == m[3]"
110      });
111
112 //]]>
113 </script>
114 <script type="text/javascript">
115 //<![CDATA[
116             function confirm_delete_item(ordernumber, basketno, biblionumber) {
117                 var is_confirmed = confirm(_("Are you sure you want to delete this order ?"));
118                 if (is_confirmed) {
119                     window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&invoiceid=[% invoiceid %]";
120                 }
121             }
122             
123             function confirm_delete_biblio(ordernumber, basketno, biblionumber) {
124                 var is_confirmed = confirm(_("Are you sure you want to delete this catalog record and order ?"));
125                 if (is_confirmed) {
126                     window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1&invoiceid=[% invoiceid %]";
127                     }
128             }
129
130             function transfer_order_popup(ordernumber) {
131                 var url = "/cgi-bin/koha/acqui/transferorder.pl?"
132                     + "ordernumber=" + ordernumber
133                 window.open(url, 'TransferOrder');
134             }
135
136 //]]>
137 </script>
138 </head>
139 <body id="acq_parcel" class="acq">
140 [% INCLUDE 'header.inc' %]
141 [% INCLUDE 'acquisitions-search.inc' %]
142
143 <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;
144     [% IF ( datereceived ) %]
145         Receipt summary for <i>[% name %]</i>
146         [% IF ( invoice ) %]
147             <i>[ [% invoice %] ]</i>
148         [% END %]
149         on <i>[% formatteddatereceived %]</i>
150     [% ELSE %]
151         Receive orders from [% name %]
152     [% END %]
153 </div>
154
155 <div id="doc3" class="yui-t2">
156
157    <div id="bd">
158         <div id="yui-main">
159         <div class="yui-b">
160         [% IF ( receive_error ) %]
161         <div class="dialog alert">
162         <h3>Error adding items:</h3>
163         <ul>
164         [% FOREACH error_loo IN error_loop %]
165                 <li>[% error_loo.error_param %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li>
166         [% END %]
167         </ul>
168         </div>
169         [% END %]
170     <h1>
171         [% IF ( datereceived ) %]
172             Receipt summary for <i>[% name %]</i> [% IF ( invoice ) %] <i> [ [% invoice %] ] </i>[% END %] on <i>[% formatteddatereceived %]</i>
173         [% ELSE %]
174             Receive orders from [% name %]
175         [% END %]
176     </h1>
177
178     [% IF ( success_delorder ) %]
179     <div class="dialog message">The order has been successfully canceled.</div>
180     [% ELSE %]
181         [% IF ( error_delitem ) %]
182             <div class="dialog alert">The order has been canceled, although one or more items could not have been deleted.</div>
183         [% END %]
184         [% IF ( error_delbiblio ) %]
185             <div class="dialog alert">The order has been canceled, although the record has not been deleted.</div>
186         [% END %]
187     [% END %]
188
189     [% IF (error_cancelling_receipt) %]
190       <div class="dialog error">
191       Cannot cancel receipt. Possible reasons :
192       <ul>
193         <li>
194           The order line you trying to cancel was created from a partial receipt
195           of another order line which is already received. Try to cancel this
196           one first and retry.
197         </li>
198         <li>
199           The order line you trying to cancel was created from a partial receipt
200           of another order line which has been deleted. Cancellation is not
201           possible.
202         </li>
203       </ul>
204       </div>
205     [% END %]
206
207     [% IF error_invoice_not_known %]
208         <div class="dialog error">
209             The invoice referenced by this invoiceid does not exist.
210         </div>
211     [% END %]
212
213 [% UNLESS no_orders_to_display %]
214 <div id="acqui_receive_summary">
215 <p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
216 </div>
217 [% UNLESS (invoiceclosedate) %]
218   <div id="acqui_receive_search">
219     <h3>Pending orders</h3>
220
221     [% IF ( loop_orders ) %]
222       <table id="pendingt">
223         <thead>
224           <tr>
225             <th>Basket search</th>
226             <th>Basket group search</th>
227             <th>Order line search</th>
228             <th>Summary search</th>
229             <th>&nbsp;</th>
230             <th>Quantity search</th>
231             <th>Unit cost search</th>
232             <th>Order cost search</th>
233             <th>Fund search</th>
234             <th>&nbsp;</th>
235             <th>&nbsp;</th>
236           </tr>
237           <tr>
238             <th>Basket</th>
239             <th>Basket group</th>
240             <th>Order line</th>
241             <th>Summary</th>
242             <th>View record</th>
243             <th>Quantity</th>
244             <th>Unit cost</th>
245             <th>Order cost</th>
246             <th>Fund</th>
247             <th>&nbsp;</th>
248             <th>&nbsp;</th>
249           </tr>
250         </thead>
251         <tbody class="filterclass">
252         [% FOREACH loop_order IN loop_orders %]
253             <tr>
254                 <td class="basketfilterclass">[% loop_order.basketname %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a>)</td>
255                 <td>
256                   [% IF loop_order.basketgroupid %]
257                     [% loop_order.basketgroupname %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% loop_order.booksellerid %]">[% loop_order.basketgroupid %]</a>)
258                   [% ELSE %]
259                     No basket group
260                   [% END %]
261                 </td>
262                 <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.booksellerid %]">[% loop_order.ordernumber %]</a></td>
263                 <td class="summaryfilterclass">
264                   <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
265                 [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
266                 [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
267                 [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
268                 [% IF ( loop_order.suggestionid ) %]
269                     <br/>
270                     Suggested by: [% loop_order.surnamesuggestedby %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
271                     (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]&amp;op=show">suggestion #[% loop_order.suggestionid %]</a>)
272                 [% END %]
273                 <br />
274                 [% IF ( loop_order.notes ) %]
275                     <p class="ordernote"><strong>Note: </strong>[% loop_order.notes|html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Change note</a>]</p>
276                 [% ELSE %]
277                     [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Add note</a>]
278                 [% END %]
279                 </td>
280                 <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
281                 <td>[% loop_order.quantity %]</td>
282                 <td>[% loop_order.ecost %]</td>
283                 <td>[% loop_order.ordertotal %]</td>
284                 <td>[% loop_order.budget_name %]</td>
285                                 <td>
286                               <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
287                     <br />
288                     <a href="#" onclick="transfer_order_popup([% loop_order.ordernumber %]); return false;">Transfer</a>
289                                 </td>
290                                 <td>
291                         [% IF ( loop_order.left_holds_on_order ) %]
292                         <span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
293                         [% ELSE %]
294                         <a href="javascript:confirm_delete_item([% loop_order.ordernumber %], [% loop_order.basketno %], [% loop_order.biblionumber %])" class="button">Delete order</a><br>
295                         [% END %]
296                         [% IF ( loop_order.can_del_bib ) %]
297                         <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %], [% loop_order.basketno %], [% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
298                         [% ELSE %]
299                         <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
300                         [% END %]
301                         [% IF ( loop_order.left_item ) %]
302                         <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
303                         [% END %]
304                         [% IF ( loop_order.left_biblio ) %]
305                         <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
306                         [% END %]
307                         [% IF ( loop_order.left_subscription ) %]
308                         <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
309                         [% END %]
310                         [% IF ( loop_order.left_holds ) %]
311                         <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
312                         [% END %]
313                     </td>
314                 </tr>
315         [% END %]
316         </tbody>
317       </table>
318     [% ELSE %]There are no pending orders.[% END %]
319   </div>
320 [% ELSE %]
321     <p>
322         Invoice is closed, so you can't receive orders anymore.
323         <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Reopen it</a>.
324     </p>
325 [% END %]
326
327 <div id="acqui_receive_receivelist">
328     <h3>Already received</h3>
329
330
331    [% IF ( loop_received ) %]
332        [% SET funds = {} %]
333        [% SET estimated_total = 0 %]
334
335        [% FOREACH loop_receive IN loop_received %]
336            [% IF (funds.${ loop_receive.budget.budget_name }.estimated == '') %]
337               [% SET funds.${ loop_receive.budget.budget_name }.estimated = 0 %]
338            [% END %]
339            [% IF (funds.${ loop_receive.budget.budget_name }.actual == '') %]
340               [% SET funds.${ loop_receive.budget.budget_name }.actual = 0 %]
341            [% END %]
342            [% SET estimated_total = estimated_total + ( loop_receive.ecost * loop_receive.quantityreceived ) %]
343            [% SET funds.${ loop_receive.budget.budget_name }.estimated = funds.${ loop_receive.budget.budget_name }.estimated + ( loop_receive.ecost * loop_receive.quantityreceived )%]
344            [% SET funds.${ loop_receive.budget.budget_name }.actual = funds.${ loop_receive.budget.budget_name }.actual + loop_receive.total %]
345        [% END %]
346
347    <form action="/cgi-bin/koha/acqui/parcel.pl" method="get" name="orderform">
348     <table id="receivedt">
349         <thead>
350             <tr>
351                 <th>Basket</th>
352                 <th>Basket group</th>
353                 <th>Order Line</th>
354                 <th>Holds</th>
355                 <th>Summary</th>
356                 <th>View record</th>
357                 <th>Quantity</th>
358                 <th>Fund</th>
359                 <th>Est cost</th>
360                 <th>Actual cost</th>
361                 <th>TOTAL</th>
362         <th></th>
363             </tr>
364     </thead>
365     <tfoot>
366         [% FOREACH key IN funds.keys.sort %]
367             <tr>
368                 <td colspan="6" class="total">(Tax exc.)</td>
369                 <td><i>Subtotal for</i> [% key %]</td>
370                 <td>[% currency( funds.$key.estimated ) %]</td>
371                 <td>[% currency( funds.$key.actual ) %]</td>
372                 <td>&nbsp;</td>
373                 <td>&nbsp;</td>
374             </tr>
375         [% END %]
376         <tr>
377             <th colspan="10" class="total">Total tax exc.</th>
378             <th>[% total_gste %]</th>
379             <th></th>
380         </tr>
381         [% FOREACH book_foot IN book_foot_loop %]
382             <tr>
383                 <th colspan="10">Total (GST [% book_foot.gstrate * 100 | format ("%.1f") %]%)</th>
384                 <th>[% book_foot.value %]</th>
385                 <th></th>
386             </tr>
387         [% END %]
388         <tr>
389             <th colspan="10" class="total">Total tax inc.</th>
390             <th>[% total_gsti %]</th>
391             <th></th>
392         </tr>
393     </tfoot>
394     <tbody class="filterclass">
395         [% FOREACH loop_receive IN loop_received %]
396             <tr>
397                 <td>[% loop_receive.basketname %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_receive.basketno %]">[% loop_receive.basketno %]</a>)</td>
398                 <td>
399                   [% IF loop_order.basketgroupid %]
400                     [% loop_receive.basketgroupname %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% loop_receive.booksellerid %]">[% loop_receive.basketgroupid %]</a>)
401                   [% ELSE %]
402                     No basket group
403                   [% END %]
404                 </td>
405                 <td><a href="neworderempty.pl?ordernumber=[% loop_receive.ordernumber %]&amp;booksellerid=[% booksellerid %]">[% loop_receive.ordernumber %]</a></td>
406                 <td>
407                   [% IF loop_receive.holds > 0 %]
408                     <span class="error"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% loop_receive.biblionumber %]">[% loop_receive.holds %]</a></span>
409                   [% ELSE %]
410                     0
411                   [% END %]
412                 </td>
413                 <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_receive.biblionumber %]">[% loop_receive.title |html %]</a>
414                 [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %]
415                 [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %]
416                 [% IF ( loop_receive.publishercode ) %]<br />Publisher :[% loop_receive.publishercode %][% END %]
417                 [% IF ( loop_receive.suggestionid ) %]
418                     <br/>
419                     Suggested by: [% loop_receive.surnamesuggestedby %][% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %]
420                     (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]&amp;op=show">suggestion #[% loop_receive.suggestionid %]</a>)
421                 [% END %]
422                 </td>
423                 <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
424                 <td>[% loop_receive.quantityreceived %]</td>
425                 <td>[% loop_receive.budget.budget_name %]</td>
426                 <td>[% loop_receive.ecost %]</td>
427                 <td>[% loop_receive.unitprice %]</td>
428                 <td>[% loop_receive.total %]</td>
429                 <td>
430                     [% IF (loop_receive.cannot_cancel) %]
431                         [% span_title = BLOCK %]
432                             Cannot cancel receipt of this order line because it
433                             was created from a partial receipt of order line no.
434                             [% loop_receive.parent_ordernumber %], which is
435                             already received. Try cancelling this one first and
436                             retry.
437                         [% END %]
438                         <span title="[% span_title | collapse %]">
439                             Can't cancel receipt
440                         </span>
441                     [% ELSE %]
442                         <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]&op=cancelreceipt&ordernumber=[% loop_receive.ordernumber %]">Cancel receipt</a>
443                     [% END %]
444                 </td>
445             </tr>
446             [% END %]
447         </tbody>
448     </table>
449     </form>
450         [% ELSE %]There are no received orders.[% END %]
451 </div>
452
453 [% IF (invoiceclosedate) %]
454     <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">View invoice</a>
455 [% ELSE %]
456     <form action="/cgi-bin/koha/acqui/invoice.pl" method="get">
457         <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
458         <fieldset class="action">
459             <input type="submit" value="Finish receiving" />
460         </fieldset>
461     </form>
462 [% END %]
463
464 [% END %]
465
466 </div>
467 </div>
468
469
470 <div class="yui-b">
471 <form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post">
472   <fieldset class="brief">
473     <h4>Filter</h4>
474     <ol>
475       <li>
476         <label for="summaryfilter">ISBN, author or title :</label>
477         <input type="text" name="summaryfilter" id="summaryfilter" value="[% summaryfilter %]"/>
478       </li>
479       <li>
480         <label for="basketfilter">Basket :</label>
481         <input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter %]"/>
482       </li>
483       <li>
484           <label for="basketgroupnamefilter">Basket group name :</label>
485           <input type="text" name="basketgroupnamefilter" id="basketgroupnamefilter" value="[% basketgroupnamefilter %]" />
486       </li>
487       <li>
488         <label for="orderfilter">Order line :</label>
489         <input type="text" name="orderfilter" id="orderfilter" value="[% orderfilter %]"/>
490       </li>
491       [% IF (UNIMARC) %]
492         <li>
493           <label for="eanfilter">EAN :</label>
494           <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter %]"/>
495         </li>
496       [% END %]
497     </ol>
498     <fieldset class="action">
499       <input type="hidden" value="search" name="op" />
500       <input type="hidden" value="[% invoiceid %]" name="invoiceid" />
501       <input type="submit" value="Filter" />
502       <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Clear</a>
503     </fieldset>
504   </fieldset>
505 </form>
506 [% INCLUDE 'acquisitions-menu.inc' %]
507 </div>
508 </div>
509 [% INCLUDE 'intranet-bottom.inc' %]