From d59c544786c8f76756e2ec10dc3b8f803355efdc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 15 Sep 2015 12:25:53 +0200 Subject: [PATCH] =?utf8?q?Auftrags-Controller:=20linetotal=20nach=20=C3=84?= =?utf8?q?ndern=20von=20Menge/Preis/Rabatt=20neu=20berechnen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Order.pm | 10 ++++++++++ templates/webpages/order/tabs/_row.html | 15 ++++++++++----- templates/webpages/order/tabs/basic_data.html | 7 +++++++ 3 files changed, 27 insertions(+), 5 deletions(-) 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); }); -- 2.20.1