epic-s6g
[kivitendo-erp.git] / SL / Presenter / Letter.pm
1 package SL::Presenter::Letter;
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(letter);
9
10 use Carp;
11
12 sub letter {
13   my ($letter, %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="controller.pl?action=Letter/edit&amp;letter.id=' . escape($letter->id) . '">',
21     escape($letter->letternumber),
22     $params{no_link} ? '' : '</a>',
23   );
24
25   is_escaped($text);
26 }
27
28 1;
29
30 __END__
31
32 =pod
33
34 =encoding utf8
35
36 =head1 NAME
37
38 SL::Presenter::Letter - Presenter module for letter objects
39
40 =head1 SYNOPSIS
41
42   my $letter = SL::DB::Manager::Letter->get_first(where => [ … ]);
43   my $html   = SL::Presenter::Letter::letter($letter, display => 'inline');
44
45 =head1 FUNCTIONS
46
47 =over 4
48
49 =item C<letter $object, %params>
50
51 Returns a rendered version (actually an instance of
52 L<SL::Presenter::EscapedText>) of the letter object C<$object>
53 .
54
55 C<%params> can include:
56
57 =over 2
58
59 =item * display
60
61 Either C<inline> (the default) or C<table-cell>. At the moment both
62 representations are identical and produce the invoice number linked
63 to the corresponding 'edit' action.
64
65 =item * no_link
66
67 If falsish (the default) then the invoice number will be linked to the
68 "edit invoice" dialog from the general ledger menu.
69
70 =back
71
72 =back
73
74 =head1 BUGS
75
76 Nothing here yet.
77
78 =head1 AUTHOR
79
80 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
81
82 =cut