commit 78e36cfd9021212db652db06c18054644861c687
Author: Bernd Bleßmann <bernd@kivitendo-premium.de>
Date:   Mon Dec 11 16:05:11 2017 +0100

    Auftrags-Controller: Fehler bei Anzeige von EK und Marge in 2. Zeile behoben
    
    Wenn das Order-Objekt noch nicht gespeichert ist, kann darauf nicht über
    $item->order zugegriffen werden. Darum muss an die 2. Zeile eine weitere
    Variable durchgereicht werden, um zu bestimmen, ob wir im Verkauf sind und
    EK und Margen angezeigt werden sollen.

diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm
index 04319e04a..0421e08f5 100644
--- a/SL/Controller/Order.pm
+++ b/SL/Controller/Order.pm
@@ -447,6 +447,7 @@ sub action_add_item {
   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
   );
 
@@ -472,6 +473,7 @@ sub action_add_item {
       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
       );
       $self->js
@@ -553,6 +555,7 @@ sub action_add_multi_items {
     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
     );
 
@@ -665,7 +668,7 @@ sub _js_load_second_row {
     $item->parse_custom_variable_values;
   }
 
-  my $row_as_html = $self->p->render('order/tabs/_second_row', ITEM => $item);
+  my $row_as_html = $self->p->render('order/tabs/_second_row', ITEM => $item, TYPE => $self->type);
 
   $self->js
     ->html('.row_entry:has(#item_' . $item_id . ') [name = "second_row"]', $row_as_html)
diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html
index f000ba6fd..c057747fb 100644
--- a/templates/webpages/order/tabs/_row.html
+++ b/templates/webpages/order/tabs/_row.html
@@ -115,7 +115,7 @@
     <td colspan="100%">
       [%- IF MYCONFIG.show_form_details %]
         <div name="second_row" data-loaded="1">
-          [%- PROCESS order/tabs/_second_row.html ITEM=ITEM %]
+          [%- PROCESS order/tabs/_second_row.html ITEM=ITEM TYPE=TYPE %]
         </div>
       [%- ELSE %]
         <div name="second_row">
diff --git a/templates/webpages/order/tabs/_second_row.html b/templates/webpages/order/tabs/_second_row.html
index 1a09f0f69..d8d8a8644 100644
--- a/templates/webpages/order/tabs/_second_row.html
+++ b/templates/webpages/order/tabs/_second_row.html
@@ -14,7 +14,7 @@
     [% L.date_tag("order.orderitems[].reqdate", ITEM.reqdate) %]&nbsp;
     <b>[%- 'Subtotal' | $T8 %]</b>&nbsp;
     [% L.yes_no_tag("order.orderitems[].subtotal", ITEM.subtotal) %]&nbsp;
-    [%- IF ITEM.order.is_sales %]
+    [%- IF TYPE == "sales_order" %]
       <b>[%- 'Ertrag' | $T8 %]</b>&nbsp;
         <span name="linemargin">
           <span[%- IF ITEM.marge_total < 0 -%] class="plus0"[%- END -%]>
diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html
index ad41537f9..39b953101 100644
--- a/templates/webpages/order/tabs/basic_data.html
+++ b/templates/webpages/order/tabs/basic_data.html
@@ -180,7 +180,7 @@
             </thead>
 
             [%- FOREACH item = SELF.order.items_sorted %]
-              [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id ALL_PRICE_FACTORS=SELF.all_price_factors %]
+              [%- PROCESS order/tabs/_row.html ITEM=item ID=item.id TYPE=SELF.type ALL_PRICE_FACTORS=SELF.all_price_factors %]
             [%- END %]
 
           </table>
