5bdfcd887fef3831b2bff75bdc5bc2019876a435
[kivitendo-erp.git] / SL / Presenter / EmailJournal.pm
1 package SL::Presenter::EmailJournal;
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(email_journal);
9
10 use Carp;
11
12 sub email_journal {
13   my ($email_journal_entry, %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=EmailJournal/show&amp;id=' . escape($email_journal_entry->id) . '">',
21     escape($email_journal_entry->subject),
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::EmailJournal - Presenter module for mail entries in email_journal
39
40 =head1 SYNOPSIS
41
42   use SL::Presenter::EmailJournal;
43
44   my $journal_entry = SL::DB::Manager::EmailJournal->get_first();
45   my $html   = SL::Presenter::EmailJournal::email_journal($journal_entry, display => 'inline');
46
47   # pp $html
48   # <a href="controller.pl?action=EmailJournal/show&amp;id=1">IDEV Daten fuer webdav/idev/2017-KW-26.csv erzeugt</a>
49
50 =head1 FUNCTIONS
51
52 =over 4
53
54 =item C<email_journal $object, %params>
55
56 Returns a rendered version (actually an instance of
57 L<SL::Presenter::EscapedText>) of the email journal object C<$object>
58 .
59
60
61 C<%params> can include:
62
63 =over 2
64
65 =item * display
66
67 Either C<inline> (the default) or C<table-cell>. At the moment both
68 representations are identical and produce the invoice number linked
69 to the corresponding 'edit' action.
70
71 =item * no_link
72
73 If falsish (the default) then the mail subject will be linked to the
74 'view details of email' dialog from the email journal report.
75
76 =back
77
78 =back
79
80 =head1 BUGS
81
82 Nothing here yet.
83
84 =head1 AUTHOR
85
86 copied from Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
87 by Jan Büren E<lt>jan@kivitendo-premium.deE<gt>
88
89 =cut