kivitendo/SL/Presenter/SepaExport.pm @ 912e5eff
c8e0c77f | Moritz Bunkus | package SL::Presenter::SepaExport;
|
||
use strict;
|
||||
0e5e3501 | Sven Schöling | use SL::Presenter::EscapedText qw(escape is_escaped);
|
||
ee51b82f | Tamino Steinert | use SL::Presenter::Tag qw(link_tag);
|
||
c8e0c77f | Moritz Bunkus | |||
use Exporter qw(import);
|
||||
0e5e3501 | Sven Schöling | our @EXPORT_OK = qw(sepa_export);
|
||
c8e0c77f | Moritz Bunkus | |||
use Carp;
|
||||
sub sepa_export {
|
||||
0e5e3501 | Sven Schöling | my ($sepa_export, %params) = @_;
|
||
c8e0c77f | Moritz Bunkus | |||
$params{display} ||= 'inline';
|
||||
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
|
||||
ee51b82f | Tamino Steinert | my $text = escape($sepa_export->id);
|
||
if (! delete $params{no_link}) {
|
||||
my $href = 'sepa.pl?action=bank_transfer_edit'
|
||||
. '&vc=' . escape($sepa_export->vc)
|
||||
. '&id=' . escape($sepa_export->id);
|
||||
$text = link_tag($href, $text, %params);
|
||||
}
|
||||
0e5e3501 | Sven Schöling | is_escaped($text);
|
||
c8e0c77f | Moritz Bunkus | }
|
||
1;
|
||||
__END__
|
||||
=pod
|
||||
=encoding utf8
|
||||
=head1 NAME
|
||||
SL::Presenter::SepaExport - Presenter module for Rose::DB objects
|
||||
for SEPA transfers and collections
|
||||
=head1 SYNOPSIS
|
||||
# Collections from an invoice:
|
||||
my $invoice = SL::DB::Invoice->new(id => 123)->load;
|
||||
my $object = $invoice->sepa_export_items->[0]->sepa_export;
|
||||
my $html = SL::Presenter->get->sepa_export($object, display => 'inline');
|
||||
# Transfers from a purchase invoice:
|
||||
my $invoice = SL::DB::PurchaseInvoice->new(id => 123)->load;
|
||||
my $object = $invoice->sepa_export_items->[0]->sepa_export;
|
||||
my $html = SL::Presenter->get->sepa_export($object, display => 'inline');
|
||||
=head1 FUNCTIONS
|
||||
=over 4
|
||||
=item C<sepa_export $object, %params>
|
||||
Returns a rendered version (actually an instance of
|
||||
L<SL::Presenter::EscapedText>) of the SEPA collection/transfer object
|
||||
C<$object>.
|
||||
C<%params> can include:
|
||||
=over 2
|
||||
=item * display
|
||||
Either C<inline> (the default) or C<table-cell>. At the moment both
|
||||
representations are identical and produce the objects's delivery
|
||||
order number linked to the corresponding 'edit' action.
|
||||
=item * no_link
|
||||
If falsish (the default) then the delivery order number will be linked
|
||||
to the "edit SEPA transfer" dialog from the 'cash' menu.
|
||||
=back
|
||||
=back
|
||||
=head1 BUGS
|
||||
Nothing here yet.
|
||||
=head1 AUTHOR
|
||||
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
|
||||
=cut
|