Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9a18eb21

Von Tamino Steinert vor fast 2 Jahren hinzugefügt

  • ID 9a18eb2165acfa23b1f8532439e800c4feb2b793
  • Vorgänger a52a2f81
  • Nachfolger 4d23decc

Reclamation: Presenter added

Unterschiede anzeigen:

SL/Presenter/Reclamation.pm
1
package SL::Presenter::Reclamation;
2

  
3
use strict;
4

  
5
use SL::Presenter::EscapedText qw(escape is_escaped);
6
use SL::Presenter::Tag qw(html_tag);
7

  
8
use Exporter qw(import);
9
our @EXPORT_OK = qw(sales_reclamation purchase_reclamation);
10

  
11
use Carp;
12

  
13
sub sales_reclamation {
14
  my ($reclamation, %params) = @_;
15

  
16
  return _reclamation_record($reclamation, 'sales_reclamation', %params);
17
}
18

  
19
sub purchase_reclamation {
20
  my ($reclamation, %params) = @_;
21

  
22
  return _reclamation_record($reclamation, 'purchase_reclamation', %params);
23
}
24

  
25
sub _reclamation_record {
26
  my ($reclamation, $type, %params) = @_;
27

  
28
  $params{display} ||= 'inline';
29

  
30
  croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
31

  
32
  my $text = escape($reclamation->record_number);
33
  unless ($params{no_link}) {
34
    my $id = $reclamation->id;
35
    $text =  html_tag('a', $text, href => escape("controller.pl?action=Reclamation/edit&type=${type}&id=${id}"));
36
  }
37

  
38
  is_escaped($text);
39
}
40

  
41
1;
42

  
43
__END__
44

  
45
=pod
46

  
47
=encoding utf8
48

  
49
=head1 NAME
50

  
51
SL::Presenter::Reclamation - Presenter module for Rose::DB objects for sales
52
reclamations and purchase reclamations
53

  
54
=head1 SYNOPSIS
55

  
56
  # Sales reclamations:
57
  my $object = SL::DB::Manager::Reclamation->get_first(
58
    where => [ SL::DB::Manager::Reclamation->type_filter('sales_reclamation') ]
59
  );
60
  my $html   = SL::Presenter::Reclamation::sales_reclamation(
61
    $object, display => 'inline'
62
  );
63

  
64
  # Purchase reclamations:
65
  my $object = SL::DB::Manager::Reclamation->get_first(
66
    where => [ SL::DB::Manager::Reclamation->type_filter('purchase_reclamation') ]
67
  );
68
  my $html   = SL::Presenter::Reclamation::purchase_reclamation(
69
    $object, display => 'inline'
70
  );
71

  
72
=head1 FUNCTIONS
73

  
74
=over 4
75

  
76
=item C<sales_reclamation $object, %params>
77

  
78
Returns a rendered version (actually an instance of
79
L<SL::Presenter::EscapedText>) of the sales reclamation object C<$object>.
80

  
81
C<%params> can include:
82

  
83
=over 2
84

  
85
=item * display
86

  
87
Either C<inline> (the default) or C<table-cell>. At the moment both
88
representations are identical and produce the objects's
89
reclamation number linked to the corresponding 'edit' action.
90

  
91
=item * no_link
92

  
93
If falsish (the default) then the  reclamation number will be linked to the
94
"edit reclamation" dialog from the sales menu.
95

  
96
=back
97

  
98
=item C<purchase_reclamation $object, %params>
99

  
100
Returns a rendered version (actually an instance of
101
L<SL::Presenter::EscapedText>) of the purchase reclamation object C<$object>.
102

  
103
C<%params> can include:
104

  
105
=over 2
106

  
107
=item * display
108

  
109
Either C<inline> (the default) or C<table-cell>. At the moment both
110
representations are identical and produce the objects's reclamation number
111
linked to the corresponding 'edit' action.
112

  
113
=item * no_link
114

  
115
If falsish (the default) then the  reclamation number will be linked to the
116
"edit reclamation" dialog from the purchase menu.
117

  
118
=back
119

  
120
=back
121

  
122
=head1 BUGS
123

  
124
Nothing here yet.
125

  
126
=head1 AUTHOR
127

  
128
Tamino Steinert E<lt>tamino.steinert@tamino.stE<gt>
129

  
130
=cut

Auch abrufbar als: Unified diff