Kundenartikelnummern in Vorlagen verwenden können
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 30 Aug 2019 14:28:18 +0000 (16:28 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 30 Aug 2019 15:03:11 +0000 (17:03 +0200)
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
templates/print/RB/deutsch.tex
templates/print/RB/english.tex
templates/print/RB/invoice.tex
templates/print/RB/sales_delivery_order.tex
templates/print/RB/sales_order.tex
templates/print/RB/sales_quotation.tex

index 7783c5f..16ebef0 100644 (file)
--- 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 ]);
index 85bb98c..d838430 100644 (file)
@@ -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}
index 4cbf253..326d041 100644 (file)
@@ -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}
index f3a7761..ea3945d 100644 (file)
           <%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%>
index 39ad90b..fcda41a 100644 (file)
           <%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]
index 1949fe5..f512234 100644 (file)
           <%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%>
 
index 90df785..1d67c0b 100644 (file)
           <%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%>