e2b5423abd9baccd4d44381addccd3f9e7bb7295
[kivitendo-erp.git] / SL / Presenter / SepaExport.pm
1 package SL::Presenter::SepaExport;
2
3 use strict;
4
5 use SL::Presenter::EscapedText qw(escape is_escaped);
6
7 use Exporter qw(import);
8 our @EXPORT_OK = qw(sepa_export);
9
10 use Carp;
11
12 sub sepa_export {
13   my ($sepa_export, %params) = @_;
14
15   $params{display} ||= 'inline';
16
17   croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
18
19   my $text = join '', (
20     $params{no_link} ? '' : '<a href="sepa.pl?action=bank_transfer_edit&amp;vc=' . escape($sepa_export->vc) . '&amp;id=' . escape($sepa_export->id) . '">',
21     escape($sepa_export->id),
22     $params{no_link} ? '' : '</a>',
23   );
24   is_escaped($text);
25 }
26
27 1;
28
29 __END__
30
31 =pod
32
33 =encoding utf8
34
35 =head1 NAME
36
37 SL::Presenter::SepaExport - Presenter module for Rose::DB objects
38 for SEPA transfers and collections
39
40 =head1 SYNOPSIS
41
42   # Collections from an invoice:
43   my $invoice = SL::DB::Invoice->new(id => 123)->load;
44   my $object  = $invoice->sepa_export_items->[0]->sepa_export;
45   my $html    = SL::Presenter->get->sepa_export($object, display => 'inline');
46
47   # Transfers from a purchase invoice:
48   my $invoice = SL::DB::PurchaseInvoice->new(id => 123)->load;
49   my $object  = $invoice->sepa_export_items->[0]->sepa_export;
50   my $html    = SL::Presenter->get->sepa_export($object, display => 'inline');
51
52 =head1 FUNCTIONS
53
54 =over 4
55
56 =item C<sepa_export $object, %params>
57
58 Returns a rendered version (actually an instance of
59 L<SL::Presenter::EscapedText>) of the SEPA collection/transfer object
60 C<$object>.
61
62 C<%params> can include:
63
64 =over 2
65
66 =item * display
67
68 Either C<inline> (the default) or C<table-cell>. At the moment both
69 representations are identical and produce the objects's delivery
70 order number linked to the corresponding 'edit' action.
71
72 =item * no_link
73
74 If falsish (the default) then the delivery order number will be linked
75 to the "edit SEPA transfer" dialog from the 'cash' menu.
76
77 =back
78
79 =back
80
81 =head1 BUGS
82
83 Nothing here yet.
84
85 =head1 AUTHOR
86
87 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
88
89 =cut