From: Bernd Bleßmann Date: Mon, 19 Nov 2018 15:38:27 +0000 (+0100) Subject: Auftrags-Controller: Positions-Update aus Artikel-Stamm X-Git-Tag: release-3.5.6.1~475 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ff5279eda2b2e7fb378bfc65ea582b10a06ed604;p=kivitendo-erp.git Auftrags-Controller: Positions-Update aus Artikel-Stamm --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 47ab4e7de..9b4c1bf4f 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -1015,6 +1015,47 @@ sub action_load_second_rows { $self->js->render(); } +# update description, notes and sellprice from master data +sub action_update_row_from_master_data { + my ($self) = @_; + + foreach my $item_id (@{ $::form->{item_ids} }) { + my $idx = first_index { $_ eq $item_id } @{ $::form->{orderitem_ids} }; + my $item = $self->order->items_sorted->[$idx]; + + $item->description($item->part->description); + $item->longdescription($item->part->notes); + + my $price_source = SL::PriceSource->new(record_item => $item, record => $self->order); + + my $price_src; + if ($item->part->is_assortment) { + # add assortment items with price 0, as the components carry the price + $price_src = $price_source->price_from_source(""); + $price_src->price(0); + } else { + $price_src = $price_source->best_price + ? $price_source->best_price + : $price_source->price_from_source(""); + $price_src->price(0) if !$price_source->best_price; + } + + $item->sellprice($price_src->price); + $item->active_price_source($price_src); + + $self->js + ->run('kivi.Order.update_sellprice', $item_id, $item->sellprice_as_number) + ->val('.row_entry:has(#item_' . $item_id . ') [name = "order.orderitems[].description"]', $item->description) + ->val('.row_entry:has(#item_' . $item_id . ') [name = "order.orderitems[].longdescription"]', $item->longdescription); + } + + $self->recalc(); + $self->js_redisplay_line_values; + $self->js_redisplay_amounts_and_taxes; + + $self->js->render(); +} + sub js_load_second_row { my ($self, $item, $item_id, $do_parse) = @_; diff --git a/css/kivitendo/main.css b/css/kivitendo/main.css index 8611462d9..0c2249314 100644 --- a/css/kivitendo/main.css +++ b/css/kivitendo/main.css @@ -531,6 +531,15 @@ span.toggle_selected { max-width: 16px; max-height: 16px; } +#update_from_master { + cursor: pointer; + display: block; + max-width: 16px; + max-height: 16px; +} +#update_from_master:hover { + background: #ddd; +} /* Bank transactions */ #bank_transactions_proposals .invoice_number_highlight a, diff --git a/css/lx-office-erp/main.css b/css/lx-office-erp/main.css index 8cf9a67a8..a2a4ad02e 100644 --- a/css/lx-office-erp/main.css +++ b/css/lx-office-erp/main.css @@ -525,6 +525,15 @@ a.red { max-width: 16px; max-height: 16px; } +#update_from_master { + cursor: pointer; + display: block; + max-width: 16px; + max-height: 16px; +} +#update_from_master:hover { + background: darkgrey; +} /* Bank transactions */ #bank_transactions_proposals .invoice_number_highlight a, diff --git a/image/rotate_cw.svg b/image/rotate_cw.svg new file mode 100644 index 000000000..fc747b393 --- /dev/null +++ b/image/rotate_cw.svg @@ -0,0 +1,51 @@ + + + + + + + Part of the Flat Icon Collection (Wed Aug 25 23:29:46 2004) + + + + hash + + action + computer + icons + theme + + + + + Danny Allen + + + + + Danny Allen + + + + + Danny Allen + + + + image/svg+xml + + + en + + + + + + + + + + + + diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 94de1bc0a..3421f9ff6 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -725,6 +725,34 @@ namespace('kivi.Order', function(ns) { return true; }; + ns.update_row_from_master_data = function(clicked) { + var row = $(clicked).parents("tbody").first(); + var item_id_dom = $(row).find('[name="orderitem_ids[+]"]'); + + var data = $('#order_form').serializeArray(); + data.push({ name: 'action', value: 'Order/update_row_from_master_data' }); + data.push({ name: 'item_ids[]', value: item_id_dom.val() }); + + $.post("controller.pl", data, kivi.eval_json_result); + }; + + ns.update_all_rows_from_master_data = function() { + var item_ids = $.map($('.row_entry'), function(elt) { + var item_id = $(elt).find('[name="orderitem_ids[+]"]').val(); + return { name: 'item_ids[]', value: item_id }; + }); + + if (item_ids.length == 0) { + return; + } + + var data = $('#order_form').serializeArray(); + data.push({ name: 'action', value: 'Order/update_row_from_master_data' }); + data = data.concat(item_ids); + + $.post("controller.pl", data, kivi.eval_json_result); + }; + 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'); diff --git a/locale/de/all b/locale/de/all index 380aafd51..949125b0a 100755 --- a/locale/de/all +++ b/locale/de/all @@ -312,6 +312,8 @@ $self->{texts} = { 'Apr' => 'Apr', 'April' => 'April', 'Ar aging on %s' => 'Offene Forderungen zum %s', + 'Are you sure to update all positions from master data?' => 'Alle Positionen aus den Stammdaten aktualisieren?', + 'Are you sure to update this position from master data?' => 'Diese Position aus den Stammdaten aktualisieren?', 'Are you sure you want to delete Invoice Number' => 'Soll die Rechnung mit folgender Nummer wirklich gelöscht werden:', 'Are you sure you want to delete this letter?' => 'Sind Sie sicher, dass Sie diesen Brief löschen wollen?', 'Are you sure you want to remove the marked entries from the queue?' => 'Sind Sie sicher, dass die markierten Einträge von der Warteschlange gelöscht werden sollen?', @@ -3730,6 +3732,7 @@ $self->{texts} = { 'Update Prices' => 'Preise aktualisieren', 'Update SKR04: new tax account 3804 (19%)' => 'Update SKR04: neues Steuerkonto 3804 (19%) für innergemeinschaftlichen Erwerb', 'Update customer using billing address' => 'Kunde mit Shop-Rechnungsadresse überschreiben', + 'Update from master data' => 'Aktualisieren aus Stammdaten', 'Update prices' => 'Preise aktualisieren', 'Update prices of existing entries' => 'Preise von vorhandenen Artikeln aktualisieren', 'Update prices of existing entries / skip non-existent' => 'Preise von vorhandenen Artikel aktualisieren / Nicht vorhandene überspringen', diff --git a/locale/en/all b/locale/en/all index a28c655ce..bbd4098a5 100644 --- a/locale/en/all +++ b/locale/en/all @@ -312,6 +312,8 @@ $self->{texts} = { 'Apr' => '', 'April' => '', 'Ar aging on %s' => '', + 'Are you sure to update all positions from master data?' => '', + 'Are you sure to update this position from master data?' => '', 'Are you sure you want to delete Invoice Number' => '', 'Are you sure you want to delete this letter?' => '', 'Are you sure you want to remove the marked entries from the queue?' => '', @@ -3729,6 +3731,7 @@ $self->{texts} = { 'Update Prices' => '', 'Update SKR04: new tax account 3804 (19%)' => '', 'Update customer using billing address' => '', + 'Update from master data' => '', 'Update prices' => '', 'Update prices of existing entries' => '', 'Update prices of existing entries / skip non-existent' => '', diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index 69c8eb5bc..20755d26b 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -32,6 +32,13 @@ LxERP.t8("X"), confirm=LxERP.t8("Are you sure?")) %] + + [%- L.img_tag(src="image/rotate_cw.svg", + alt=LxERP.t8('Update from master data'), + title= LxERP.t8('Update from master data'), + onclick="if (!confirm('" _ LxERP.t8("Are you sure to update this position from master data?") _ "')) return false; kivi.Order.update_row_from_master_data(this);", + id='update_from_master') %] +
[% HTML.escape(ITEM.part.partnumber) %]
diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index 11735808d..26aedd524 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -213,6 +213,13 @@ [%- 'position' | $T8 %] [%- LxERP.t8('reorder item') %] [%- LxERP.t8('delete item') %] + + [%- L.img_tag(src="image/rotate_cw.svg", + alt=LxERP.t8('Update from master data'), + title= LxERP.t8('Update from master data'), + onclick="if (!confirm('" _ LxERP.t8("Are you sure to update all positions from master data?") _ "')) return false; kivi.Order.update_all_rows_from_master_data();", + id='update_from_master') %] + [%- 'Partnumber' | $T8 %] [%- IF SELF.search_cvpartnumber -%] [%- SELF.cv == "customer" ? LxERP.t8('Customer Part Number') : LxERP.t8('Model') %]