From 8470071b1eea86117e6cece01bb5952c29a0cbc6 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Thu, 26 Jul 2012 14:29:48 +0200 Subject: [PATCH] Preisgruppen in all_parts Lieferanten MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (Implementierung grösstenteils von Geoffrey, leicht modifiziert von mir) --- SL/IC.pm | 20 ++++++++++++++++++++ bin/mozilla/ic.pl | 29 ++++++++++++++++++++++++----- templates/webpages/ic/search.html | 4 ++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/SL/IC.pm b/SL/IC.pm index 79d661837..8895bf888 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -1121,6 +1121,26 @@ sub all_parts { $form->{parts} = \@assemblies; } + if ($form->{l_pricegroups} ) { + my $query = <{parts} }) { + do_statement($form, $sth, $query, conv_i($part->{id})); + + while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { + $part->{"pricegroup_$ref->{pricegroup_id}"} = $ref->{price}; + } + $sth->finish; + } + }; + + $main::lxdebug->leave_sub(); return wantarray ? @{ $form->{parts} } : $form->{parts}; diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index d6ecbb5c5..249c99ea0 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1010,7 +1010,7 @@ sub addtop100 { # bought sold onorder ordered rfq quoted # l_partnumber l_description l_serialnumber l_unit l_listprice l_sellprice l_lastcost # l_linetotal l_priceupdate l_bin l_rop l_weight l_image l_drawing l_microfiche -# l_partsgroup l_subtotal l_soldtotal l_deliverydate +# l_partsgroup l_subtotal l_soldtotal l_deliverydate l_pricegroups # # hiddens: # nextsub revers lastsort sort ndxs_counter @@ -1220,18 +1220,33 @@ sub generate_report { transdate name serialnumber deliverydate ean projectnumber projectdescription ); + my $pricegroups = SL::DB::Manager::Pricegroup->get_all(sort => 'id'); + my @pricegroup_columns; + my %column_defs_pricegroups; + if ($form->{l_pricegroups}) { + @pricegroup_columns = map { "pricegroup_" . $_->id } @{ $pricegroups }; + %column_defs_pricegroups = map { + "pricegroup_" . $_->id => { + text => $::locale->text('Pricegroup') . ' ' . $_->pricegroup, + visible => 1, + }, + } @{ $pricegroups }; + } + push @columns, @pricegroup_columns; + my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs }; my @searchable_custom_variables = grep { $_->{searchable} } @{ $cvar_configs }; my %column_defs_cvars = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables; push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables; - %column_defs = (%column_defs,%column_defs_cvars); # nochmal die cvars als überschrift hinzufügen - map { $column_defs{$_}->{visible} = $form->{"l_$_"} ? 1 : 0 } @columns; - map { $column_defs{$_}->{align} = 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal); + %column_defs = (%column_defs, %column_defs_cvars, %column_defs_pricegroups); + map { $column_defs{$_}->{visible} ||= $form->{"l_$_"} ? 1 : 0 } @columns; + map { $column_defs{$_}->{align} = 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal), @pricegroup_columns; - my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom), @itemstatus_keys, @callback_keys, + my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom l_pricegroups), @itemstatus_keys, @callback_keys, map({ "cvar_$_->{name}" } @searchable_custom_variables), map { "l_$_" } @columns); + my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables); my @sort_full = qw(partnumber description onhand soldtotal deliverydate); @@ -1319,6 +1334,10 @@ sub generate_report { $row->{$_}{data} = $form->format_amount(\%myconfig, $ref->{$_}, -2); $row->{"linetotal$_"}{data} = $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{$_}, 2); } + foreach ( @pricegroup_columns ) { + $row->{$_}{data} = $form->format_amount(\%myconfig, $ref->{"$_"}, -2); + }; + map { $row->{$_}{data} = $form->format_amount(\%myconfig, $ref->{$_}); } qw(onhand rop weight soldtotal); diff --git a/templates/webpages/ic/search.html b/templates/webpages/ic/search.html index c679f0f8b..4d32924bf 100644 --- a/templates/webpages/ic/search.html +++ b/templates/webpages/ic/search.html @@ -281,6 +281,10 @@ + + + + [% CUSTOM_VARIABLES_INCLUSION_CODE %] -- 2.20.1