Auftrags-Controller: Formelberechnung
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 9 May 2018 12:36:31 +0000 (14:36 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 14 May 2018 13:48:08 +0000 (15:48 +0200)
Sollte evtl. auf Dialog umgestellt werden.

SL/Controller/Order.pm
bin/mozilla/io.pl
js/kivi.Order.js
templates/webpages/order/tabs/_row.html

index 864cc67..845115c 100644 (file)
@@ -1435,7 +1435,7 @@ sub _pre_render {
                                                 } } @all_objects;
   }
 
-  $::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase kivi.Order kivi.File ckeditor/ckeditor ckeditor/adapters/jquery edit_periodic_invoices_config);
+  $::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase kivi.Order kivi.File ckeditor/ckeditor ckeditor/adapters/jquery edit_periodic_invoices_config calculate_qty);
   $self->_setup_edit_action_bar;
 }
 
index fa63004..d376d4c 100644 (file)
@@ -319,7 +319,7 @@ sub display_row {
     my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2;
 
     $column_data{qty}  = $cgi->textfield(-name => "qty_$i", -size => 5, -class => "numeric", -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec));
-    $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', '', 'formel_$i')", -value => $locale->text('*/'))
+    $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', '', 'formel_$i', '')", -value => $locale->text('*/'))
                        . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"})
       if $form->{"formel_$i"};
 
index 441a3dc..b6a9642 100644 (file)
@@ -623,6 +623,15 @@ namespace('kivi.Order', function(ns) {
     return true;
   };
 
+  ns.show_calculate_qty_dialog = function(clicked) {
+    var row = $(clicked).parents("tbody").first();
+    var input_id = $(row).find('[name="order.orderitems[].qty_as_number"]').attr('id');
+    var formula_id = $(row).find('[name="formula"]').attr('id');
+
+    calculate_qty_selection_window("", input_id, "", formula_id);
+    return true;
+  }
+
 });
 
 $(function(){
index 0de680f..f955604 100644 (file)
       [%- END -%]
       [%- L.button_tag("kivi.Order.show_longdescription_dialog(this)", LxERP.t8("L")) %]
     </td>
-    <td>
+    <td nowrap>
       [%- L.input_tag("order.orderitems[].qty_as_number",
                       ITEM.qty_as_number,
                       size = 5,
                       class="recalc reformat_number numeric") %]
+      [%- IF ITEM.part.formel -%]
+        [%- L.button_tag("kivi.Order.show_calculate_qty_dialog(this)", LxERP.t8("*/")) %]
+        [%- L.hidden_tag("formula", ITEM.part.formel) -%]
+      [%- END -%]
     </td>
     <td>
       [%- L.select_tag("order.orderitems[].price_factor_id",