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