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