From: Moritz Bunkus Date: Fri, 28 Nov 2008 14:54:33 +0000 (+0000) Subject: Einige Variablen der Warenstammdaten auch beim Ausdruck zur Verfügung stellen: ean... X-Git-Tag: release-2.6.0beta2~228 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=47c3bf62b5126f914de54609b0cfbb29e0c033b4;p=kivitendo-erp.git Einige Variablen der Warenstammdaten auch beim Ausdruck zur Verfügung stellen: ean, make, model. --- diff --git a/SL/IC.pm b/SL/IC.pm index 45fcebb1b..a643557d7 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -1796,5 +1796,73 @@ sub get_basic_part_info { return %info_map; } +sub prepare_parts_for_printing { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + my $myconfig = \%main::myconfig; + my $form = $main::form; + + my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); + + my $prefix = $params{prefix} || 'id_'; + my $rowcount = defined $params{rowcount} ? $params{rowcount} : $form->{rowcount}; + + my @part_ids = keys %{ { map { $_ => 1 } grep { $_ } map { $form->{"${prefix}${_}"} } (1 .. $rowcount) } }; + + if (!@part_ids) { + $main::lxdebug->leave_sub(); + return; + } + + my $placeholders = join ', ', ('?') x scalar(@part_ids); + my $query = qq|SELECT parts_id, make, model + FROM makemodel + WHERE parts_id IN ($placeholders)|; + my %makemodel = (); + + my $sth = prepare_execute_query($form, $dbh, $query, @part_ids); + + while (my $ref = $sth->fetchrow_hashref()) { + $makemodel{$ref->{parts_id}} ||= []; + push @{ $makemodel{$ref->{parts_id}} }, $ref; + } + + $sth->finish(); + + my @columns = qw(ean); + + $query = qq|SELECT id, | . join(', ', @columns) . qq| + FROM parts + WHERE id IN ($placeholders)|; + + my %data = selectall_as_map($form, $dbh, $query, 'id', \@columns, @part_ids); + + map { $form->{$_} = [] } (qw(make model), @columns); + + foreach my $i (1 .. $rowcount) { + my $id = $form->{"${prefix}${i}"}; + + next if (!$id); + + foreach (@columns) { + push @{ $form->{$_} }, $data{$id}->{$_}; + } + + push @{ $form->{make} }, []; + push @{ $form->{model} }, []; + + next if (!$makemodel{$id}); + + foreach my $ref (@{ $makemodel{$id} }) { + map { push @{ $form->{$_}->[-1] }, $ref->{$_} } qw(make model); + } + } + + $main::lxdebug->leave_sub(); +} + 1; diff --git a/SL/IS.pm b/SL/IS.pm index b782fef26..af47ca7d0 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -43,6 +43,7 @@ use SL::Common; use SL::DBUtils; use SL::DO; use SL::MoreCommon; +use SL::IC; use Data::Dumper; sub invoice_details { @@ -132,6 +133,8 @@ sub invoice_details { $form->{discount} = []; + IC->prepare_parts_for_printing(); + my @arrays = qw(runningnumber number description longdescription qty ship unit bin deliverydate_oe ordnumber_oe transdate_oe licensenumber validuntil diff --git a/SL/OE.pm b/SL/OE.pm index 6013d24c5..3afd46262 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -39,6 +39,7 @@ use List::Util qw(max); use SL::AM; use SL::Common; use SL::DBUtils; +use SL::IC; sub transactions { $main::lxdebug->enter_sub(); @@ -950,6 +951,8 @@ sub order_details { $form->{discount} = []; + IC->prepare_parts_for_printing(); + my @arrays = qw(runningnumber number description longdescription qty ship unit bin partnotes serialnumber reqdate sellprice listprice netprice