From df52f0a4ee134e780337a7822fdf64ab43d619cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 30 Aug 2019 16:28:18 +0200 Subject: [PATCH] =?utf8?q?Kundenartikelnummern=20in=20Vorlagen=20verwenden?= =?utf8?q?=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Einsortierung in das template array wie Lieferantenartikelnummern als customer_make und customer_model. Standard-Druckvorlagen Angebot/Auftrag/Lieferschein/Rechnung für Verkauf exemplarisch angepasst. --- SL/IC.pm | 37 ++++++++++++++++++--- templates/print/RB/deutsch.tex | 1 + templates/print/RB/english.tex | 1 + templates/print/RB/invoice.tex | 5 +++ templates/print/RB/sales_delivery_order.tex | 5 +++ templates/print/RB/sales_order.tex | 5 +++ templates/print/RB/sales_quotation.tex | 5 +++ 7 files changed, 55 insertions(+), 4 deletions(-) diff --git a/SL/IC.pm b/SL/IC.pm index 7783c5f65..16ebef0b8 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -906,6 +906,25 @@ sub prepare_parts_for_printing { $sth->finish(); + $query = qq|SELECT + cp.parts_id, + cp.customer_partnumber AS customer_model, + c.name AS customer_make + FROM part_customer_prices cp + LEFT JOIN customer c ON (cp.customer_id = c.id) + WHERE cp.parts_id IN ($placeholders)|; + + my %customermodel = (); + + $sth = prepare_execute_query($form, $dbh, $query, @part_ids); + + while (my $ref = $sth->fetchrow_hashref()) { + $customermodel{$ref->{parts_id}} ||= []; + push @{ $customermodel{$ref->{parts_id}} }, $ref; + } + + $sth->finish(); + my @columns = qw(ean image microfiche drawing); $query = qq|SELECT id, | . join(', ', @columns) . qq| @@ -915,7 +934,7 @@ sub prepare_parts_for_printing { my %data = selectall_as_map($form, $dbh, $query, 'id', \@columns, @part_ids); my %template_arrays; - map { $template_arrays{$_} = [] } (qw(make model), @columns); + map { $template_arrays{$_} = [] } (qw(make model customer_make customer_model), @columns); foreach my $i (1 .. $rowcount) { my $id = $form->{"${prefix}${i}"}; @@ -929,11 +948,21 @@ sub prepare_parts_for_printing { push @{ $template_arrays{make} }, []; push @{ $template_arrays{model} }, []; - next if (!$makemodel{$id}); + if ($makemodel{$id}) { + foreach my $ref (@{ $makemodel{$id} }) { + map { push @{ $template_arrays{$_}->[-1] }, $ref->{$_} } qw(make model); + } + } + + push @{ $template_arrays{customer_make} }, []; + push @{ $template_arrays{customer_model} }, []; - foreach my $ref (@{ $makemodel{$id} }) { - map { push @{ $template_arrays{$_}->[-1] }, $ref->{$_} } qw(make model); + if ($customermodel{$id}) { + foreach my $ref (@{ $customermodel{$id} }) { + push @{ $template_arrays{$_}->[-1] }, $ref->{$_} for qw(customer_make customer_model); + } } + } my $parts = SL::DB::Manager::Part->get_all(query => [ id => \@part_ids ]); diff --git a/templates/print/RB/deutsch.tex b/templates/print/RB/deutsch.tex index 85bb98c2d..d8384302f 100644 --- a/templates/print/RB/deutsch.tex +++ b/templates/print/RB/deutsch.tex @@ -23,6 +23,7 @@ \newcommand{\position} {Pos.} \newcommand{\artikelnummer} {Art.-Nr.} +\newcommand{\kundenartnr} {Ihre Art.-Nr.} \newcommand{\bild} {Bild} \newcommand{\keinbild} {kein Bild} \newcommand{\menge} {Menge} diff --git a/templates/print/RB/english.tex b/templates/print/RB/english.tex index 4cbf253e6..326d0411f 100644 --- a/templates/print/RB/english.tex +++ b/templates/print/RB/english.tex @@ -22,6 +22,7 @@ \newcommand{\position} {Pos.} \newcommand{\artikelnummer} {Part No.} +\newcommand{\kundenartnr} {Your Part No.} \newcommand{\bild} {Picture} \newcommand{\keinbild} {n/a} \newcommand{\menge} {Qty} diff --git a/templates/print/RB/invoice.tex b/templates/print/RB/invoice.tex index f3a7761f2..ea3945d6b 100644 --- a/templates/print/RB/invoice.tex +++ b/templates/print/RB/invoice.tex @@ -157,6 +157,11 @@ <%if serialnumber%> && \scriptsize \seriennummer: <%serialnumber%>\\<%end serialnumber%> <%if ean%> && \scriptsize \ean: <%ean%>\\<%end ean%> <%if projectnumber%> && \scriptsize \projektnummer: <%projectnumber%>\\<%end projectnumber%> + <%if customer_make%> + <%foreach customer_make%> + \ifthenelse{\equal{<%customer_make%>}{<%name%>}}{&& \kundenartnr: <%customer_model%>\\}{} + <%end foreach%> + <%end if%> \\[-0.8em] <%end number%> diff --git a/templates/print/RB/sales_delivery_order.tex b/templates/print/RB/sales_delivery_order.tex index 39ad90bcc..fcda41a7e 100644 --- a/templates/print/RB/sales_delivery_order.tex +++ b/templates/print/RB/sales_delivery_order.tex @@ -126,6 +126,11 @@ <%if serialnumber%> && \scriptsize \seriennummer: <%serialnumber%>\\<%end serialnumber%> <%if ean%> && \scriptsize \ean: <%ean%>\\<%end ean%> <%if projectnumber%> && \scriptsize \projektnummer: <%projectnumber%>\\<%end projectnumber%> + <%if customer_make%> + <%foreach customer_make%> + \ifthenelse{\equal{<%customer_make%>}{<%name%>}}{&& \kundenartnr: <%customer_model%>\\}{} + <%end foreach%> + <%end if%> <%foreach si_number%><%if si_chargenumber%> && \scriptsize \charge: <%si_chargenumber%> <%if si_bestbefore%> \mhd: <%si_bestbefore%><%end if%> <%si_qty%>~<%si_unit%><%end si_chargenumber%>\\<%end si_number%> \\[-0.8em] diff --git a/templates/print/RB/sales_order.tex b/templates/print/RB/sales_order.tex index 1949fe54d..f51223440 100644 --- a/templates/print/RB/sales_order.tex +++ b/templates/print/RB/sales_order.tex @@ -149,6 +149,11 @@ <%if serialnumber%> && \scriptsize \seriennummer: <%serialnumber%>\\<%end serialnumber%> <%if ean%> && \scriptsize \ean: <%ean%>\\<%end ean%> <%if projectnumber%> && \scriptsize \projektnummer: <%projectnumber%>\\<%end projectnumber%> + <%if customer_make%> + <%foreach customer_make%> + \ifthenelse{\equal{<%customer_make%>}{<%name%>}}{&& \kundenartnr: <%customer_model%>\\}{} + <%end foreach%> + <%end if%> \\[-0.8em] <%end number%> diff --git a/templates/print/RB/sales_quotation.tex b/templates/print/RB/sales_quotation.tex index 90df78555..1d67c0bd1 100644 --- a/templates/print/RB/sales_quotation.tex +++ b/templates/print/RB/sales_quotation.tex @@ -145,6 +145,11 @@ <%if serialnumber%> && \scriptsize \seriennummer: <%serialnumber%>\\<%end serialnumber%> <%if ean%> && \scriptsize \ean: <%ean%>\\<%end ean%> <%if projectnumber%> && \scriptsize \projektnummer: <%projectnumber%>\\<%end projectnumber%> + <%if customer_make%> + <%foreach customer_make%> + \ifthenelse{\equal{<%customer_make%>}{<%name%>}}{&& \kundenartnr: <%customer_model%>\\}{} + <%end foreach%> + <%end if%> \\[-0.8em] <%end number%> -- 2.20.1