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