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