From 5f0dde28fbedc190991b94b7d4128dc7adb6a715 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 17 Aug 2015 12:15:50 +0200 Subject: [PATCH] Auftrags-Controller: Pos.-Zeile ohne Part-Picker, aber mit Nummer u. Beschreibung. --- SL/Controller/Order.pm | 45 +------------------ .../webpages/order/tabs/_item_input.html | 2 + templates/webpages/order/tabs/_row.html | 10 +++-- templates/webpages/order/tabs/basic_data.html | 28 ++---------- 4 files changed, 14 insertions(+), 71 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 6be5b5d0c..d12596893 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -153,57 +153,16 @@ sub action_add_item { ->append('#row_table_id tbody', $row_as_html) ->val('#add_item_parts_id', '') ->val('#add_item_parts_id_name', '') + ->val('#add_item_description', '') ->val('#add_item_qty_as_number', '') ->val('#add_item_sellprice_as_number', '') ->val('#add_item_discount_as_percent', '') - ->focus('#add_item_parts_id_name') - ->off('[id^="order_orderitems"][id$="parts_id"]', 'change', 'set_item_values') - ->on('[id^="order_orderitems"][id$="parts_id"]', 'change', 'set_item_values'); + ->focus('#add_item_parts_id_name'); $self->_js_redisplay_amounts_and_taxes; $self->js->render($self); } -sub action_set_item_values { - my ($self) = @_; - - my $is_new = $::form->{item_id} =~ m{^new_}; - my $item_id = $::form->{item_id}; - - my $item = first {$_->id eq $::form->{item_id}} @{$self->order->items}; - my $form_attr = first {$_->{id} eq $::form->{item_id}} @{ $::form->{order}->{orderitems} }; - - delete $form_attr->{id}; - - my $part = SL::DB::Part->new(id => $form_attr->{parts_id})->load; - - my $cv_class = "SL::DB::" . ucfirst($self->cv); - my $cv_discount = $::form->{cv_id}? $cv_class->new(id => $::form->{$self->cv . '_id'})->load->discount :0.0; - - - my %new_attr; - $new_attr{sellprice} = $part->sellprice if ! $form_attr->{sellprice_as_number}; - $new_attr{discount} = $cv_discount if ! $form_attr->{discount_as_percent}; - $new_attr{unit} = $part->unit if ! $form_attr->{unit}; - $new_attr{qty} = 1.0 if ! $form_attr->{qty_as_number}; - - $item->assign_attributes(%new_attr); - - - $self->_recalc(); - - $self->js - ->val( '#' . $::form->{qty_dom_id}, $item->qty_as_number) - ->val( '#' . $::form->{unit_dom_id}, $item->unit) - ->val( '#' . $::form->{sellprice_dom_id}, $item->sellprice_as_number) - ->val( '#' . $::form->{discount_dom_id}, $item->discount_as_percent) - ->run('display_linetotal', $::form->{item_id}, $::form->format_amount(\%::myconfig, $item->{linetotal}, -2)); - - $self->_js_redisplay_amounts_and_taxes; - $self->js->render($self); -} - - sub action_recalc_amounts_and_taxes { my ($self) = @_; diff --git a/templates/webpages/order/tabs/_item_input.html b/templates/webpages/order/tabs/_item_input.html index e3f4db17a..f59c22628 100644 --- a/templates/webpages/order/tabs/_item_input.html +++ b/templates/webpages/order/tabs/_item_input.html @@ -5,6 +5,7 @@ [%- 'Part' | $T8 %] + [%- 'Description' | $T8 %] [%- 'Qty' | $T8 %] [%- 'Price' | $T8 %] [%- 'Discount' | $T8 %] @@ -14,6 +15,7 @@ [% L.part_picker('add_item.parts_id', '', fat_set_item=1, style='width: 300px', class="add_item_input") %] + [% L.input_tag('add_item.description', '', class="add_item_input") %] [% L.input_tag('add_item.qty_as_number', '', size = 5, style='text-align:right', class="add_item_input") %] [% L.input_tag('add_item.sellprice_as_number', '', size = 10, style='text-align:right', class="add_item_input") %] [% L.input_tag('add_item.discount_as_percent', '', size = 5, style='text-align:right', class="add_item_input") %] diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index 2201666c2..0cd3bde80 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -6,6 +6,7 @@ [% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ITEM.id, ) %] + [% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %] [%- LxERP.t8('reorder item') %] @@ -15,9 +16,12 @@ LxERP.t8("X"), confirm=LxERP.t8("Are you sure?")) %] - [% L.part_picker("order.orderitems[].parts_id", - ITEM.part, - style='width: 300px') %] + [% HTML.escape(ITEM.part.partnumber) %] + + + [% L.input_tag("order.orderitems[].description", + ITEM.description, + style='width: 300px') %] [%- L.input_tag("order.orderitems[].qty_as_number", diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index a46f7898b..3bc64558e 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -113,7 +113,8 @@ [%- LxERP.t8('reorder item') %] [%- LxERP.t8('delete item') %] - [%- 'Part' | $T8 %] + [%- 'Partnumber' | $T8 %] + [%- 'Description' | $T8 %] [%- 'Qty' | $T8 %] [%- 'Price Factor' | $T8 %] [%- 'Unit' | $T8 %] @@ -193,29 +194,6 @@ function delete_order_item_row(clicked) { recalc_amounts_and_taxes() } -function set_item_values(event) { - var cv_id = $('#order_[%- cv_id %]').val(); - var parts_id = $(event.target).val(); - var row = $(event.target).parents("tr").first(); - - var item_id_dom = $(row).find('[name="order.orderitems[+].id"]'); - var qty_dom = $(row).find('[id^="order_orderitems"][id$="qty_as_number"]'); - var unit_dom = $(row).find('[id^="order_orderitems"][id$="unit"]'); - var sellprice_dom = $(row).find('[id^="order_orderitems"][id$="sellprice_as_number"]'); - var discount_dom = $(row).find('[id^="order_orderitems"][id$="discount_as_percent"]'); - - var data = $('#order_form').serialize(); - data += '&action=Order/set_item_values'; - data += '&type=' + $('#type').val(); - data += '&item_id=' + item_id_dom.val(); - data += '&qty_dom_id=' + qty_dom.attr("id"); - data += '&unit_dom_id=' + unit_dom.attr("id"); - data += '&sellprice_dom_id=' + sellprice_dom.attr("id"); - data += '&discount_dom_id=' + discount_dom.attr("id"); - - $.post("controller.pl", data, kivi.eval_json_result); -} - function recalc_amounts_and_taxes() { var data = $('#order_form').serialize(); data += '&action=Order/recalc_amounts_and_taxes'; @@ -231,8 +209,8 @@ function display_linetotal(item_id, amount) { $(function(){ $('#order_[%- cv_id %]').change(reload_cv_dependend_selections); - $('[id^="order_orderitems"][id$="parts_id"]').change(set_item_values); $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) }); + $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) }); $('.add_item_input').keydown(function(event) { if(event.keyCode == 13) { event.preventDefault(); -- 2.20.1