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