X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d445880375bce1462b8f9a8b1a502b34c296d41f..5b5dbec0272c91697acf33c4842ee9d63f041f22:/SL/Presenter/Order.pm diff --git a/SL/Presenter/Order.pm b/SL/Presenter/Order.pm new file mode 100644 index 000000000..19d8483ec --- /dev/null +++ b/SL/Presenter/Order.pm @@ -0,0 +1,190 @@ +package SL::Presenter::Order; + +use strict; + +use parent qw(Exporter); + +use Exporter qw(import); +our @EXPORT = qw(sales_quotation sales_order request_quotation purchase_order); + +use Carp; + +sub sales_quotation { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'sales_quotation', %params); +} + +sub sales_order { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'sales_order', %params); +} + +sub request_quotation { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'request_quotation', %params); +} + +sub purchase_order { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'purchase_order', %params); +} + +sub _oe_record { + my ($self, $order, $type, %params) = @_; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + my $number_method = $order->quotation ? 'quonumber' : 'ordnumber'; + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($order->$number_method), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} + +1; + + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::Order - Presenter module for Rose::DB objects for sales +quotations, sales orders, requests for quotations and purchase orders + +=head1 SYNOPSIS + + # Sales quotations: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('sales_quotation') ]); + my $html = SL::Presenter->get->sales_quotation($object, display => 'inline'); + + # Sales orders: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('sales_order') ]); + my $html = SL::Presenter->get->sales_order($object, display => 'inline'); + + # Requests for quotations: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('request_quotation') ]); + my $html = SL::Presenter->get->request_quotation($object, display => 'inline'); + + # Purchase orders: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('purchase_order') ]); + my $html = SL::Presenter->get->purchase_order($object, display => 'inline'); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the sales quotation object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +quotation number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked to the +"edit quotation" dialog from the sales menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the sales order object C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +order number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked +to the "edit order" dialog from the sales menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the request for quotation object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +quotation number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked to the +"edit request for quotation" dialog from the purchase menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the purchase order object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +order number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked +to the "edit order" dialog from the purchase menu. + +=back + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut