Bug 31115: Add additional field filtering for invoice search
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / duplicate_orders.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>
8 [% UNLESS blocking_error %]
9 Basket [% basket.basketno | html %] &rsaquo; Duplicate existing orders &rsaquo; [% END %]
10 Acquisitions &rsaquo; Koha
11 </title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 <style>
14     .picked_to_duplicate > td { background-color: #bcdb89 !important; }
15     span.hint { margin-left: 1em; }
16 </style>
17 </head>
18
19 <body id="acq_duplicate_orders" class="acq">
20
21 [% WRAPPER 'header.inc' %]
22     [% INCLUDE 'acquisitions-search.inc' %]
23 [% END %]
24
25 [% WRAPPER 'sub-header.inc' %]
26 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27     <ol>
28         <li>
29             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
30         </li>
31         <li>
32             <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
33     [% UNLESS blocking_error %]
34         </li>
35         <li>
36             <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% vendor.id | uri %]">[% vendor.name | html %]</a>
37         </li>
38         <li>
39             <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | uri %]">Basket [% basket.basketno | html %]</a>
40         </li>
41         <li>
42             <a href="#" aria-current="page">
43                 Duplicate existing orders
44             </a>
45         </li>
46     [% END %]
47     </ol>
48 </nav>
49 [% END %]
50
51 <div class="main container-fluid">
52     <div class="row">
53         <div class="col-sm-10 col-sm-push-2">
54             <main>
55
56 <h1>Duplicate existing orders</h1>
57 [% INCLUDE 'blocking_errors.inc' %]
58
59 [% IF op == 'search' || op == 'select' %]
60 <form action="/cgi-bin/koha/acqui/duplicate_orders.pl" method="post">
61     <fieldset class="rows">
62         <legend>
63             [% IF op == 'search' %]
64                 <span>Search orders</span>
65             [% ELSE %]
66                 <span>Refine search</span>
67             [% END %]
68             <span class="toggle_orders_filters" id="show_orders_filters"><a href="#">[+]</a></span>
69             <span class="toggle_orders_filters" id="hide_orders_filters"><a href="#">[-]</a></span>
70         </legend>
71         <div id="orders_filters">
72             [% INCLUDE 'filter-orders.inc' %]
73             <input type="hidden" name="op" value="select" />
74             <input type="hidden" name="basketno" value="[% basket.basketno | html %]" />
75
76             <input type="hidden" name="ordernumbers" value="[% ordernumbers.join(',') | html %]" />
77             <fieldset class="action"><input type="submit" value="Search" /></fieldset>
78         </div>
79     </fieldset>
80 </form>
81 [% END %]
82
83 [% BLOCK display_order_line %]
84     [% IF selected %]
85     <tr class="picked_to_duplicate" data-ordernumber="[% order.ordernumber | html %]">
86     [% ELSE %]
87     <tr data-ordernumber="[% order.ordernumber | html %]">
88     [% END %]
89         <td>
90             [% IF can_check %]
91                 [% IF selected %]
92                     <input type="checkbox" name="ordernumber" value="[% order.ordernumber | html %]" checked="checked" />
93                 [% ELSE %]
94                     <input type="checkbox" name="ordernumber" value="[% order.ordernumber | html %]" />
95                 [% END %]
96             [% END %]
97             [% order.ordernumber | html %]
98             [% IF order.ordernumber != order.parent_ordernumber %]([% order.parent_ordernumber | html %])[% END %]
99         </td>
100         <td>
101             [% SWITCH order.orderstatus %]
102                 [% CASE 'new' %]<span>New</span>
103                 [% CASE 'ordered' %]<span>Ordered</span>
104                 [% CASE 'partial' %]<span>Partially received</span>
105                 [% CASE 'complete' %]<span>Received</span>
106                 [% CASE 'cancelled' %]<span>Cancelled</span>
107             [% END %]
108         </td>
109         <td>[% order.basketname | html %] (<a href="basket.pl?basketno=[% order.basketno | uri %]">[% order.basketno | html %]</a>)</td>
110         <td>[% order.authorisedbyname | html %]</td>
111         <td>
112             [% IF ( order.basketgroupid ) %]
113                 [% order.groupname | html %] (<a href="basketgroup.pl?op=add&booksellerid=[% order.id | uri %]&basketgroupid=[% order.basketgroupid | uri %]">[% order.basketgroupid | html %]</a>)
114             [% ELSE %]
115                 &nbsp;
116             [% END %]
117         </td>
118         <td>[% IF ( order.invoicenumber ) %]
119                 <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% order.invoiceid | uri %]">[% order.invoicenumber | html %]</a>
120             [% ELSE %]
121                 &nbsp;
122             [% END %]
123         </td>
124         <td>
125             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber | uri %]">[% order.title |html %]</a>
126             <br />[% order.author | html %] <br /> [% order.isbn | html %]
127         </td>
128         <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.id | uri %]">[% order.name | html %]</a></td>
129         <td data-order="[% order.creationdate | html %]">[% order.creationdate | $KohaDates %]</td>
130         <td data-order="[% order.datereceived | html %]">
131             [% order.datereceived | $KohaDates %]
132         </td>
133         <td>[% order.quantityreceived | html %]</td>
134         <td>[% order.quantity | html %]</td>
135         <td>[% order.ecost | html %]</td>
136         <td>[% order.budget_name | html %]</td>
137     </tr>
138 [% END %]
139
140
141 [% IF op == 'select' && ( result_order_loop || selected_order_loop ) %]
142     <div id="xxx">
143         <form method="post" action="/cgi-bin/koha/acqui/duplicate_orders.pl">
144         <table id="table_orders">
145             <caption>
146                 <span class="actions"><a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
147                 | <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a></span>
148             </caption>
149
150             <thead>
151                     <tr>
152                     <th>Order line (parent)</th>
153                     <th>Status</th>
154                     <th>Basket</th>
155                     <th>Basket creator</th>
156                     <th>Basket group</th>
157                     <th>Invoice number</th>
158                     <th class="anti-the">Summary</th>
159                     <th>Vendor</th>
160                     <th>Placed on</th>
161                     <th>Received on</th>
162                     <th>Quantity received</th>
163                     <th>Quantity ordered</th>
164                     <th>Unit cost</th>
165                     <th>Fund</th>
166                 </tr>
167             </thead>
168             <tfoot>
169             [% FOREACH order IN selected_order_loop %]
170                 [% INCLUDE display_order_line selected => 1 can_check => 1%]
171             [% END %]
172             </tfoot>
173             <tbody>
174             [% FOREACH order IN result_order_loop %]
175                 [% INCLUDE display_order_line can_check => 1 %]
176             [% END %]
177             </tbody>
178         </table>
179         <fieldset class="action">
180             <input type="hidden" name="op" value="batch_edit" />
181             <input type="hidden" name="basketno" value="[% basket.basketno | html %]" />
182             <button type="submit" class="btn btn-default go_to_batch_edit">Next <i class="fa fa-fw fa-arrow-right"></i></button>
183         </fieldset>
184         </form>
185     </div>
186
187 [% ELSIF op == "batch_edit" %]
188
189 <form method="post" action="/cgi-bin/koha/acqui/duplicate_orders.pl" id="batch_edit_form">
190     <div id="accounting_details">
191       <p>Duplicate all the orders with the following accounting details:</p>
192       <fieldset class="rows" style="float:none;">
193           <legend>Accounting details</legend>
194           <div class="hint" style="margin: 1em 1em 0">Check boxes to duplicate the original values</div>
195           <ol>
196               <li>
197                   <label for="all_currency">Currency:</label>
198                   <input type="checkbox" name="copy_existing_value" value="currency" title="Copy existing value" />
199                   <select name="all_currency" id="all_currency">
200                   [% FOREACH currency IN currencies %]
201                       [% IF currency.currency == vendor.listprice %]
202                           <option value="[% currency.currency | html %]" selected="selected">[% currency.currency | html %]</option>
203                       [% ELSIF not currency.archived %]
204                           <option value="[% currency.currency | html %]">[% currency.currency | html %]</option>
205                       [% END %]
206                   [% END %]
207                   </select>
208                   <span class="hint" id="hint_currency">The original currency value will be copied</span>
209               </li>
210               <li>
211                   <label for="all_budget_id">Fund: </label>
212                   <input type="checkbox" name="copy_existing_value" value="budget_id" title="Copy existing value" />
213                   <select id="all_budget_id" name="all_budget_id">
214                     <option value="">Select a fund</option>
215                   [% FOREACH budget_loo IN budget_loop %]
216                       [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id | html %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">[% budget_loo.b_txt | html %]</option>
217                       [% ELSE %]<option value="[% budget_loo.b_id | html %]" class="b_inactive" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">[% budget_loo.b_txt | html %] (inactive)</option>
218                       [% END %]
219                   [% END %]
220                   </select>
221                   <label for="all_showallbudgets" style="float:none;width:auto;margin-right:0;">&nbsp;Show inactive:</label>
222                   <input type="checkbox" id="all_showallbudgets" />
223                   <span class="hint" id="hint_budget_id">The original fund will be used</span>
224               </li>
225               <li>
226                   <label for="all_order_internalnote">Internal note: </label>
227                   <input type="checkbox" name="copy_existing_value" value="order_internalnote" title="Copy existing value" />
228                   <textarea id="all_order_internalnote" cols="30" rows="3" name="all_order_internalnote"></textarea>
229                   <span class="hint" id="hint_order_internalnote">The original internal note will be used</span>
230               </li>
231               <li>
232                   <label for="all_order_vendornote">Vendor note: </label>
233                   <input type="checkbox" name="copy_existing_value" value="order_vendornote" title="Copy existing value" />
234                   <textarea id="all_order_vendornote" cols="30" rows="3" name="all_order_vendornote"></textarea>
235                   <span class="hint" id="hint_order_vendornote">The original vendor note will be used</span>
236               </li>
237               <li>
238                   <div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
239                   <label for="all_sort1">Statistic 1: </label>
240                   <input type="checkbox" name="copy_existing_value" value="sort1" title="Copy existing value" />
241                   <input type="text" id="all_sort1" size="20" name="all_sort1" value="" />
242                   <span class="hint" id="hint_sort1">The original statistic 1 will be used</span>
243
244               </li>
245               <li>
246                   <label for="all_sort2">Statistic 2: </label>
247                   <input type="checkbox" name="copy_existing_value" value="sort2" title="Copy existing value" />
248                   <input type="text" id="all_sort2" size="20" name="all_sort2" value="" />
249                   <span class="hint" id="hint_sort2">The original statistic 2 will be used</span>
250               </li>
251           </ol>
252       </fieldset>
253     </div>
254
255     <fieldset class="action">
256         [% FOREACH ordernumber IN ordernumbers %]
257             <input type="hidden" name="ordernumber" value="[% ordernumber | html %]" />
258         [% END %]
259         <input type="hidden" name="op" value="do_duplicate" />
260         <input type="hidden" name="basketno" value="[% basket.basketno | html %]" />
261         <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, useful when receiveing an order -->
262         <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
263         <button type="submit" class="btn btn-default">Duplicate orders</button>
264         <a class="cancel" href="/cgi-bin/koha/acqui/duplicate_orders.pl?basketno=[% basket.basketno | html %]">Cancel</a>
265     </fieldset>
266 </form>
267
268 [% ELSIF op == 'duplication_done' %]
269     [% IF new_orders %]
270         <table id="table_neworders">
271             <thead>
272                 <tr>
273                     <th>Order line</th>
274                     <th>Status</th>
275                     <th>Basket</th>
276                     <th>Basket creator</th>
277                     <th>Basket group</th>
278                     <th>Invoice number</th>
279                     <th class="anti-the">Summary</th>
280                     <th>Vendor</th>
281                     <th>Placed on</th>
282                     <th>Received on</th>
283                     <th>Quantity received</th>
284                     <th>Quantity ordered</th>
285                     <th>Unit cost</th>
286                     <th>Fund</th>
287                 </tr>
288             </thead>
289             <tbody>
290             [% FOREACH order IN new_orders %]
291                 [% INCLUDE display_order_line %]
292             [% END %]
293             </tbody>
294         </table>
295         <a class="btn btn-default" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | html %]"><i class="fa fa-fw fa-arrow-left"></i> Return to the basket</a
296     [% ELSE %]
297         <span>No order has been duplicated. Maybe something wrong happened?</span>
298     [% END %]
299 [% END %]
300
301 </main>
302 </div> <!-- /.col-sm-10.col-sm-push-2 -->
303
304 <div class="col-sm-2 col-sm-pull-10">
305     <aside>
306         [% INCLUDE 'acquisitions-menu.inc' %]
307     </aside>
308 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
309 </div>
310
311 [% MACRO jsinclude BLOCK %]
312     [% Asset.js("js/acquisitions-menu.js") | $raw %]
313     [% INCLUDE 'calendar.inc' %]
314     [% INCLUDE 'datatables.inc' %]
315     [% INCLUDE 'columns_settings.inc' %]
316     [% Asset.js("js/autocomplete/patrons.js") | $raw %]
317     [% Asset.js("js/acq.js") | $raw %]
318     [% Asset.js("js/funds_sorts.js") | $raw %]
319     <script>
320         function update_ordernumber_list(){
321             var ordernumbers = [];
322             $("input[name='ordernumber']").filter(":checked").each(function(){
323                 ordernumbers.push($(this).val());
324             });
325             $("input[name='ordernumbers']").val(ordernumbers.join(','));
326         }
327
328         var MSG_REMOVE_PATRON = _("Remove");
329         var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
330         var MSG_NO_FUND_SELECTED = _("No fund selected.");
331         $(document).ready(function() {
332             $('span.hint').hide();
333             KohaTable("table_orders", {
334                 "bPaginate": false
335             });
336
337             [% IF op == 'search' OR op == 'select' %]
338                 patron_autocomplete({
339                     patron_container: $("#basket_creators"),
340                     input_autocomplete: $("#find_patron"),
341                     patron_input_name: 'created_by',
342                     field_to_retrieve: 'borrowernumber'
343                 });
344             [% END %]
345
346             $("#show_orders_filters, #hide_orders_filters").on('click', function(e) {
347                 e.preventDefault();
348                 $('#orders_filters').toggle();
349                 $('.toggle_orders_filters').toggle();
350             });
351             [% IF op == 'search' OR op == 'select' AND NOT result_order_loop %]
352                 $("#show_orders_filters").hide();
353                 $("#orders_filters").show();
354             [% ELSE %]
355                 $("#hide_orders_filters").hide();
356                 $("#orders_filters").hide();
357             [% END %]
358
359             $("input[name='ordernumber']").on("change", function(){
360                 if ( $(this).is(':checked') ) {
361                     $(this).parents("tr").addClass("picked_to_duplicate");
362                 } else {
363                     $(this).parents("tr").removeClass("picked_to_duplicate");
364                 }
365             }).on("click", function(e){
366                 update_ordernumber_list();
367             });
368
369             $("#select_all").on("click",function(e){
370                 e.preventDefault();
371                 selectAll();
372                 update_ordernumber_list();
373             });
374
375             $("#clear_all").on("click",function(e){
376                 e.preventDefault();
377                 clearAll();
378                 update_ordernumber_list();
379             });
380             function selectAll () {
381                 $("#table_orders").find("input[type='checkbox'][name='ordernumber']").each(function(){
382                     $(this).prop("checked", true).change();
383                 });
384                 return false;
385             }
386             function clearAll () {
387                 $("#table_orders").find("input[type='checkbox'][name='ordernumber']").each(function(){
388                     $(this).prop("checked", false).change();
389                 });
390                 return false;
391             }
392
393             $(".go_to_batch_edit").on("click",function(e){
394                 if ($("input[name='ordernumber']").filter(":checked").length == 0){
395                     alert(MSG_NO_ITEM_SELECTED);
396                     e.preventDefault();
397                 }
398             });
399
400             $("#batch_edit_form").on("submit", function(e){
401                 var budget_value_will_be_reused = $("input[name='copy_existing_value'][value='budget_id']").is(':checked');
402                 if ( ! budget_value_will_be_reused ) {
403                     if ($("#all_budget_id").find("option:selected").attr("value") == "" ) {
404                         alert(MSG_NO_FUND_SELECTED);
405                         e.preventDefault();
406                     }
407                 }
408             });
409             $("input[name='copy_existing_value']").click(function(){
410                 render_disabled(this);
411             });
412
413             $("input[name='copy_existing_value']").each(function(){
414                 render_disabled(this);
415             });
416         });
417         function render_disabled (elt) {
418             var field = $(elt).val();
419             var hint_node = $("#hint_" + field);
420             var input_element = $(elt).parent().find("[name='all_"+field+"']");
421             if ($(elt).is(":checked")) {
422                 $(input_element).prop('disabled', true);
423                 $(hint_node).show();
424             } else {
425                 $(input_element).prop('disabled', false);
426                 $(hint_node).hide();
427             }
428         }
429     </script>
430 [% END %]
431
432 [% INCLUDE 'intranet-bottom.inc' %]