DeliveryOrder: Presenter für die Statuszeile
authorSven Schöling <s.schoeling@googlemail.com>
Fri, 17 Dec 2021 18:16:35 +0000 (19:16 +0100)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 14:02:19 +0000 (15:02 +0100)
SL/Presenter/DeliveryOrder.pm
templates/webpages/delivery_order/tabs/basic_data.html

index 7c1a2db..9f525b3 100644 (file)
@@ -2,10 +2,12 @@ package SL::Presenter::DeliveryOrder;
 
 use strict;
 
+use SL::DB::DeliveryOrder::TypeData ();
+use SL::Locale::String qw(t8);
 use SL::Presenter::EscapedText qw(escape is_escaped);
 
 use Exporter qw(import);
-our @EXPORT_OK = qw(sales_delivery_order purchase_delivery_order);
+our @EXPORT_OK = qw(sales_delivery_order purchase_delivery_order delivery_order_status_line);
 
 use Carp;
 
@@ -63,6 +65,36 @@ sub _do_record {
   is_escaped($text);
 }
 
+sub stock_status {
+  my ($delivery_order) = @_;
+
+  my $in_out = SL::DB::DeliveryOrder::TypeData::get3($delivery_order->type, "properties", "transfer");
+
+  if ($in_out eq 'in') {
+    return escape($delivery_order->delivered ? t8('transferred in') : t8('not transferred in yet'));
+  }
+
+  if ($in_out eq 'out') {
+    return escape($delivery_order->delivered ? t8('transferred out') : t8('not transferred out yet'));
+  }
+}
+
+sub closed_status {
+  my ($delivery_order) = @_;
+
+  return escape($delivery_order->closed ? t8('Closed') : t8('Open'))
+}
+
+sub status_line {
+  my ($delivery_order) = @_;
+
+  return "" unless $delivery_order->id;
+
+  stock_status($delivery_order) . " ; " . closed_status($delivery_order)
+}
+
+sub delivery_order_status_line { goto &status_line };
+
 1;
 
 __END__
index 4e0a8ce..f4c052b 100644 (file)
         <table>
 
           <tr>
-            <td colspan="2" align="center">
-              [%- IF SELF.order.id %]
-                [%- IF SELF.order.delivered %]
-                  [%- IF SELF.type_data.transfer == 'out' %]
-                  [% 'transferred out' | $T8 %]
-                  [%- ELSE %]
-                  [% 'transferred in' | $T8 %]
-                  [%- END %]
-                [%- ELSE %]
-                  [%- IF SELF.type_data.transfer == 'out' %]
-                  [% 'not transferred out yet' | $T8 %]
-                  [%- ELSE %]
-                  [% 'not transferred in yet' | $T8 %]
-                  [%- END %]
-                [%- END %]
-               ;
-                [%- IF SEF.order.closed %]
-                  [% 'Closed' | $T8 %]
-                [%- ELSE %]
-                  [% 'Open' | $T8 %]
-                [%- END %]
-              [%- END %]
-            </td>
+            <td colspan="2" align="center" id="data-status-line">[% SELF.order.presenter.status_line %]</td>
           </tr>
 
           <tr>