WebshopApi: ShopOrder Presenter
authorWerner Hahn <wh@futureworldsearch.net>
Fri, 22 Sep 2017 00:29:31 +0000 (02:29 +0200)
committerWerner Hahn <wh@futureworldsearch.net>
Tue, 26 Sep 2017 10:25:02 +0000 (12:25 +0200)
SL/Presenter.pm
SL/Presenter/ShopOrder.pm [new file with mode: 0644]

index 5908002..cd4f4e1 100644 (file)
@@ -22,6 +22,7 @@ use SL::Presenter::RequirementSpec;
 use SL::Presenter::RequirementSpecItem;
 use SL::Presenter::RequirementSpecTextBlock;
 use SL::Presenter::SepaExport;
+use SL::Presenter::ShopOrder;
 use SL::Presenter::Text;
 use SL::Presenter::Tag;
 use SL::Presenter::BankAccount;
diff --git a/SL/Presenter/ShopOrder.pm b/SL/Presenter/ShopOrder.pm
new file mode 100644 (file)
index 0000000..77cc86f
--- /dev/null
@@ -0,0 +1,26 @@
+package SL::Presenter::ShopOrder;
+
+use strict;
+
+use parent qw(Exporter);
+
+use Exporter qw(import);
+our @EXPORT = qw(shop_order);
+
+use Carp;
+
+sub shop_order {
+  my ($self, $shop_order, $type, %params) = @_;
+
+  $params{display} ||= 'inline';
+
+  croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
+
+  my $text = join '', (
+    $params{no_link} ? '' : '<a href="controller.pl?action=ShopOrder/show&amp;id='.$self->escape($shop_order->id).'">',
+    $self->escape($shop_order->shop_ordernumber),
+    $params{no_link} ? '' : '</a>',
+  );
+  return $self->escaped_text($text);
+}
+1;