1 package SL::Presenter::CustomerVendor;
5 use parent qw(Exporter);
7 use Exporter qw(import);
8 our @EXPORT = qw(customer vendor);
13 my ($self, $customer, %params) = @_;
14 return _customer_vendor($self, $customer, 'customer', %params);
18 my ($self, $vendor, %params) = @_;
19 return _customer_vendor($self, $vendor, 'vendor', %params);
22 sub _customer_vendor {
23 my ($self, $cv, $type, %params) = @_;
25 $params{display} ||= 'inline';
27 croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
29 my $callback = $params{callback} ? '&callback=' . $::form->escape($params{callback}) : '';
32 $params{no_link} ? '' : '<a href="controller.pl?action=CustomerVendor/edit&db=' . $type . '&id=' . $self->escape($cv->id) . '">',
33 $self->escape($cv->name),
34 $params{no_link} ? '' : '</a>',
36 return $self->escaped_text($text);
49 SL::Presenter::CustomerVendor - Presenter module for customer and
50 vendor Rose::DB objects
55 my $customer = SL::DB::Manager::Customer->get_first;
56 my $html = SL::Presenter->get->customer($customer, display => 'inline');
59 my $vendor = SL::DB::Manager::Vendor->get_first;
60 my $html = SL::Presenter->get->vendor($customer, display => 'inline');
66 =item C<customer $object, %params>
68 Returns a rendered version (actually an instance of
69 L<SL::Presenter::EscapedText>) of the customer object C<$object>.
71 C<%params> can include:
77 Either C<inline> (the default) or C<table-cell>. At the moment both
78 representations are identical and produce the customer's name linked
79 to the corresponding 'edit' action.
83 If falsish (the default) then the customer's name will be linked to
84 the "edit customer" dialog from the master data menu.
88 =item C<vendor $object, %params>
90 Returns a rendered version (actually an instance of
91 L<SL::Presenter::EscapedText>) of the vendor object C<$object>.
93 C<%params> can include:
99 Either C<inline> (the default) or C<table-cell>. At the moment both
100 representations are identical and produce the vendor's name linked
101 to the corresponding 'edit' action.
105 If falsish (the default) then the vendor's name will be linked to
106 the "edit vendor" dialog from the master data menu.
118 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>