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