From: Bernd Bleßmann Date: Mon, 5 Aug 2019 11:00:28 +0000 (+0200) Subject: Auftrags-Controller: Kunden- bzw. Lieferanten-Art-Nr. in Pos-Zeile anzeigen. X-Git-Tag: release-3.5.6.1~546 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a66591ccf74ff3d32ac31b6a91849a0476e54eb7;p=kivitendo-erp.git Auftrags-Controller: Kunden- bzw. Lieferanten-Art-Nr. in Pos-Zeile anzeigen. … sofern in den Benutzereinstellungen auch die Suche danach ausgewählt ist. --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index e27c10eea..2f4a68f2b 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -39,7 +39,7 @@ use Sort::Naturally; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(item_ids_to_delete) ], - 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors) ], + 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber) ], ); @@ -685,6 +685,7 @@ sub action_customer_vendor_changed { ->focus( '#order_' . $self->cv . '_id'); $self->js_redisplay_amounts_and_taxes; + $self->js_redisplay_cvpartnumbers; $self->js->render(); } @@ -755,12 +756,15 @@ sub action_add_item { $self->recalc(); + $self->get_item_cvpartnumber($item); + my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); my $row_as_html = $self->p->render('order/tabs/_row', - ITEM => $item, - ID => $item_id, - TYPE => $self->type, - ALL_PRICE_FACTORS => $self->all_price_factors + ITEM => $item, + ID => $item_id, + TYPE => $self->type, + ALL_PRICE_FACTORS => $self->all_price_factors, + SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, ); $self->js @@ -781,12 +785,14 @@ sub action_add_item { $self->order->add_items( $item ); $self->recalc(); + $self->get_item_cvpartnumber($item); my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); my $row_as_html = $self->p->render('order/tabs/_row', - ITEM => $item, - ID => $item_id, - TYPE => $self->type, - ALL_PRICE_FACTORS => $self->all_price_factors + ITEM => $item, + ID => $item_id, + TYPE => $self->type, + ALL_PRICE_FACTORS => $self->all_price_factors, + SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, ); $self->js ->append('#row_table_id', $row_as_html); @@ -862,12 +868,14 @@ sub action_add_multi_items { $self->recalc(); foreach my $item (@items) { + $self->get_item_cvpartnumber($item); my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); my $row_as_html = $self->p->render('order/tabs/_row', - ITEM => $item, - ID => $item_id, - TYPE => $self->type, - ALL_PRICE_FACTORS => $self->all_price_factors + ITEM => $item, + ID => $item_id, + TYPE => $self->type, + ALL_PRICE_FACTORS => $self->all_price_factors, + SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, ); $self->js->append('#row_table_id', $row_as_html); @@ -900,13 +908,16 @@ sub action_reorder_items { my ($self) = @_; my %sort_keys = ( - partnumber => sub { $_[0]->part->partnumber }, - description => sub { $_[0]->description }, - qty => sub { $_[0]->qty }, - sellprice => sub { $_[0]->sellprice }, - discount => sub { $_[0]->discount }, + partnumber => sub { $_[0]->part->partnumber }, + description => sub { $_[0]->description }, + qty => sub { $_[0]->qty }, + sellprice => sub { $_[0]->sellprice }, + discount => sub { $_[0]->discount }, + cvpartnumber => sub { $_[0]->{cvpartnumber} }, ); + $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; + my $method = $sort_keys{$::form->{order_by}}; my @to_sort = map { { old_pos => $_->position, order_by => $method->($_) } } @{ $self->order->items_sorted }; if ($::form->{sort_dir}) { @@ -1054,6 +1065,17 @@ sub js_redisplay_amounts_and_taxes { ->insertBefore($self->build_tax_rows, '#amount_row_id'); } +sub js_redisplay_cvpartnumbers { + my ($self) = @_; + + $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; + + my @data = map {[$_->{cvpartnumber}]} @{ $self->order->items_sorted }; + + $self->js + ->run('kivi.Order.redisplay_cvpartnumbers', \@data); +} + sub js_reset_order_and_item_ids_after_save { my ($self) = @_; @@ -1104,6 +1126,17 @@ sub init_cv { return $cv; } +sub init_search_cvpartnumber { + my ($self) = @_; + + my $user_prefs = SL::Helper::UserPreferences::PartPickerSearch->new(); + my $search_cvpartnumber; + $search_cvpartnumber = !!$user_prefs->get_sales_search_customer_partnumber() if $self->cv eq 'customer'; + $search_cvpartnumber = !!$user_prefs->get_purchase_search_makemodel() if $self->cv eq 'vendor'; + + return $search_cvpartnumber; +} + sub init_p { SL::Presenter->get; } @@ -1564,10 +1597,6 @@ sub pre_render { $self->{order_probabilities} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; $self->{positions_scrollbar_height} = SL::Helper::UserPreferences::PositionsScrollbar->new()->get_height(); - my $user_prefs = SL::Helper::UserPreferences::PartPickerSearch->new(); - $self->{search_cvpartnumber} = !!$user_prefs->get_sales_search_customer_partnumber() if $self->cv eq 'customer'; - $self->{search_cvpartnumber} = !!$user_prefs->get_purchase_search_makemodel() if $self->cv eq 'vendor'; - my $print_form = Form->new(''); $print_form->{type} = $self->type; $print_form->{printers} = SL::DB::Manager::Printer->get_all_sorted; @@ -1605,6 +1634,8 @@ sub pre_render { } } @all_objects; } + $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; + $::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; } @@ -1834,6 +1865,18 @@ sub get_title_for { : ''; } +sub get_item_cvpartnumber { + my ($self, $item) = @_; + + if ($self->cv eq 'vendor') { + my @mms = grep { $_->make eq $self->order->customervendor->id } @{$item->part->makemodels}; + $item->{cvpartnumber} = $mms[0]->model if scalar @mms; + } elsif ($self->cv eq 'customer') { + my @cps = grep { $_->customer_id eq $self->order->customervendor->id } @{$item->part->customerprices}; + $item->{cvpartnumber} = $cps[0]->customer_partnumber if scalar @cps; + } +} + sub sales_order_type { 'sales_order'; } diff --git a/js/kivi.Order.js b/js/kivi.Order.js index e7815d497..94de1bc0a 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -334,6 +334,12 @@ namespace('kivi.Order', function(ns) { }); }; + ns.redisplay_cvpartnumbers = function(data) { + $('.row_entry').each(function(idx, elt) { + $(elt).find('[name="cvpartnumber"]').html(data[idx][0]); + }); + }; + ns.renumber_positions = function() { $('.row_entry [name="position"]').each(function(idx, elt) { $(elt).html(idx+1); diff --git a/locale/de/all b/locale/de/all index 59e6c764f..54972ae0d 100755 --- a/locale/de/all +++ b/locale/de/all @@ -3517,6 +3517,8 @@ $self->{texts} = { 'These wrong entries cannot be fixed automatically.' => 'Diese Einträge können nicht automatisch bereinigt werden.', 'They will be updated, new ones for additional parts without a line item added automatically.' => 'Diese Positionen werden automatisch aktualisiert bzw. ergänzt, wenn es noch keine Position zu einem zusätzlichen Artikel gibt.', 'This Price Rule is no longer valid' => 'Diese Preisregel ist nicht mehr gültig', + 'This also enables displaying a column with the customer partnumber (new order controller).' => 'Hiermit wird auch die Anzeige der Kunden-Art.-Nr. eingeschaltet (neuer Auftrags-Controller).', + 'This also enables displaying a column with the vendor partnumber (model) (new order controller).' => 'Hiermit wird auch die Anzeige der Lieferanten-Art.-Nr. eingeschaltet (neuer Auftrags-Controller).', 'This can be done with the following query:' => 'Dies kann mit der folgenden Datenbankabfrage erreicht werden:', 'This could have happened for two reasons:' => 'Dies kann aus zwei Gründen geschehen sein:', 'This customer has already been added.' => 'Für diesen Kunden ist bereits ein Preis hinzugefügt.', diff --git a/locale/en/all b/locale/en/all index 303ce94c5..1c0fc7712 100644 --- a/locale/en/all +++ b/locale/en/all @@ -3516,6 +3516,8 @@ $self->{texts} = { 'These wrong entries cannot be fixed automatically.' => '', 'They will be updated, new ones for additional parts without a line item added automatically.' => '', 'This Price Rule is no longer valid' => '', + 'This also enables displaying a column with the customer partnumber (new order controller).' => '', + 'This also enables displaying a column with the vendor partnumber (model) (new order controller).' => '', 'This can be done with the following query:' => '', 'This could have happened for two reasons:' => '', 'This customer has already been added.' => '', diff --git a/templates/webpages/am/config.html b/templates/webpages/am/config.html index 06c58f120..b8cef8334 100644 --- a/templates/webpages/am/config.html +++ b/templates/webpages/am/config.html @@ -158,12 +158,14 @@ [% 'Search parts by vendor partnumber (model) in purchase order forms' | $T8 %] [% L.yes_no_tag('purchase_search_makemodel', purchase_search_makemodel) %] + [%- 'This also enables displaying a column with the vendor partnumber (model) (new order controller).' | $T8 %] [% 'Search parts by customer partnumber in sales order forms' | $T8 %] [% L.yes_no_tag('sales_search_customer_partnumber', sales_search_customer_partnumber) %] + [%- 'This also enables displaying a column with the customer partnumber (new order controller).' | $T8 %] [%- END -%] diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index effb32dc0..69c8eb5bc 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -35,6 +35,11 @@
[% HTML.escape(ITEM.part.partnumber) %]
+ [%- IF SEARCH_CVPARTNUMBER -%] + +
[% HTML.escape(ITEM.cvpartnumber) %]
+ + [%- END -%]
[% ITEM.part.presenter.typeclass_abbreviation %]
diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index cad409f97..11735808d 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -213,13 +213,16 @@ [%- 'position' | $T8 %] [%- LxERP.t8('reorder item') %] [%- LxERP.t8('delete item') %] - [%- 'Partnumber' | $T8 %] - [%- 'Type' | $T8 %] - [%- 'Description' | $T8 %] + [%- 'Partnumber' | $T8 %] + [%- IF SELF.search_cvpartnumber -%] + [%- SELF.cv == "customer" ? LxERP.t8('Customer Part Number') : LxERP.t8('Model') %] + [%- END -%] + [%- 'Type' | $T8 %] + [%- 'Description' | $T8 %] [%- IF (SELF.type == "sales_order" || SELF.type == "purchase_order") -%] - [%- 'Delivered' | $T8 %] + [%- 'Delivered' | $T8 %] [%- END -%] - [%- 'Qty' | $T8 %] + [%- 'Qty' | $T8 %] [%- 'Price Factor' | $T8 %] [%- 'Unit' | $T8 %] [%- 'Price Source' | $T8 %] @@ -230,7 +233,7 @@ [%- FOREACH item = SELF.order.items_sorted %] - [%- PROCESS order/tabs/_row.html ITEM=item ID=(item.id||item.new_fake_id) TYPE=SELF.type ALL_PRICE_FACTORS=SELF.all_price_factors %] + [%- PROCESS order/tabs/_row.html ITEM=item ID=(item.id||item.new_fake_id) TYPE=SELF.type ALL_PRICE_FACTORS=SELF.all_price_factors SEARCH_CVPARTNUMBER=SELF.search_cvpartnumber %] [%- END %]