epic-ts
[kivitendo-erp.git] / SL / Presenter / GL.pm
1 package SL::Presenter::GL;
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(gl_transaction);
9
10 use Carp;
11
12 sub gl_transaction {
13   my ($gl_transaction, %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="gl.pl?action=edit&amp;id=' . escape($gl_transaction->id) . '">',
21     escape($gl_transaction->reference),
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::GL - Presenter module for GL transaction
39
40 =head1 SYNOPSIS
41
42   my $object = SL::DB::Manager::GLTransaction->get_first();
43   my $html   = SL::Presenter::GL::gl_transaction($object, display => 'inline');
44
45 =head1 FUNCTIONS
46
47 =over 4
48
49 =item C<gl_transaction $object, %params>
50
51 Returns a rendered version (actually an instance of
52 L<SL::Presenter::EscapedText>) of a gl object C<$object>.
53
54 C<%params> can include:
55
56 =over 2
57
58 =item * display
59
60 Either C<inline> (the default) or C<table-cell>. At the moment both
61 representations are identical and produce the trans_id number linked
62 to the corresponding 'edit' action.
63
64 =item * no_link
65
66 If falsish (the default) then the trans_id number will be linked to the
67 "edit gl" dialog.
68
69
70 =back
71
72 =back
73
74 =head1 BUGS
75
76 Nothing here yet.
77
78 =head1 AUTHOR
79
80 G. Richardson E<lt>information@kivitendo-premium.deE<gt>
81
82 =cut