From: Bernd Bleßmann Date: Tue, 15 Sep 2015 10:25:53 +0000 (+0200) Subject: Auftrags-Controller: linetotal nach Ändern von Menge/Preis/Rabatt neu berechnen. X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d59c544786c8f76756e2ec10dc3b8f803355efdc;p=kivitendo-erp.git Auftrags-Controller: linetotal nach Ändern von Menge/Preis/Rabatt neu berechnen. --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 469eb40f0..836351e4b 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -175,6 +175,7 @@ sub action_add_item { ->val('#add_item_discount_as_percent', '') ->run('row_table_scroll_down') ->run('row_set_keyboard_events_by_id', $item_id) + ->on('.recalc', 'change', 'recalc_amounts_and_taxes') ->focus('#add_item_parts_id_name'); $self->_js_redisplay_amounts_and_taxes; @@ -186,10 +187,19 @@ sub action_recalc_amounts_and_taxes { $self->_recalc(); + $self->_js_redisplay_linetotals; $self->_js_redisplay_amounts_and_taxes; $self->js->render($self); } +sub _js_redisplay_linetotals { + my ($self) = @_; + + my @data = map {$::form->format_amount(\%::myconfig, $_->{linetotal}, 2, 0)} @{ $self->order->items }; + $self->js + ->run('redisplay_linetotals', \@data); +} + sub _js_redisplay_amounts_and_taxes { my ($self) = @_; diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index c5892ecc7..fcc0b3f34 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -30,30 +30,35 @@ [%- L.input_tag("order.orderitems[].qty_as_number", ITEM.qty_as_number, size = 5, - style='text-align:right') %] + style='text-align:right', + class="recalc") %] [%- L.input_tag("order.orderitems[].price_factor", ITEM.price_factor, size = 5, - style='text-align:right') %] + style='text-align:right', + class="recalc") %] [%- L.input_tag("order.orderitems[].unit", ITEM.unit, - size = 5) %] + size = 5, + class="recalc") %] [%- L.input_tag("order.orderitems[].sellprice_as_number", ITEM.sellprice_as_number, size = 10, - style='text-align:right') %] + style='text-align:right', + class="recalc") %] [%- L.input_tag("order.orderitems[].discount_as_percent", ITEM.discount_as_percent, size = 5, - style='text-align:right') %] + style='text-align:right', + class="recalc") %] [%- L.div_tag(LxERP.format_amount(ITEM.linetotal, 2, 0), name="linetotal") %] diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index 0d7362f6e..2c9598d52 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -216,6 +216,12 @@ function recalc_amounts_and_taxes() { $.post("controller.pl", data, kivi.eval_json_result); } +function redisplay_linetotals(data) { + $('.row_entry [name="linetotal"]').each(function(idx, elt) { + $(elt).html(data[idx]); + }); +} + function row_table_scroll_down() { $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight); } @@ -264,6 +270,7 @@ $(function(){ } }); row_set_keyboard_events($('.row_entry')); + $('.recalc').change(recalc_amounts_and_taxes); });