Projekt

Allgemein

Profil

Herunterladen (4,83 KB) Statistiken
| Zweig: | Markierung: | Revision:
5b5dbec0 Moritz Bunkus
package SL::Presenter::Order;

use strict;

0e5e3501 Sven Schöling
use SL::Presenter::EscapedText qw(escape is_escaped);
ee51b82f Tamino Steinert
use SL::Presenter::Tag qw(link_tag);
5b5dbec0 Moritz Bunkus
use Exporter qw(import);
0e5e3501 Sven Schöling
our @EXPORT_OK = qw(sales_quotation sales_order request_quotation purchase_order);
5b5dbec0 Moritz Bunkus
use Carp;

sub sales_quotation {
0e5e3501 Sven Schöling
my ($order, %params) = @_;
5b5dbec0 Moritz Bunkus
0e5e3501 Sven Schöling
return _oe_record($order, 'sales_quotation', %params);
5b5dbec0 Moritz Bunkus
}

7d40c44b Bernd Bleßmann
sub sales_order_intake {
my ($order, %params) = @_;

return _oe_record($order, 'sales_order_intake', %params);
}

5b5dbec0 Moritz Bunkus
sub sales_order {
0e5e3501 Sven Schöling
my ($order, %params) = @_;
5b5dbec0 Moritz Bunkus
0e5e3501 Sven Schöling
return _oe_record($order, 'sales_order', %params);
5b5dbec0 Moritz Bunkus
}

sub request_quotation {
0e5e3501 Sven Schöling
my ($order, %params) = @_;
5b5dbec0 Moritz Bunkus
0e5e3501 Sven Schöling
return _oe_record($order, 'request_quotation', %params);
5b5dbec0 Moritz Bunkus
}

sub purchase_order {
0e5e3501 Sven Schöling
my ($order, %params) = @_;
5b5dbec0 Moritz Bunkus
0e5e3501 Sven Schöling
return _oe_record($order, 'purchase_order', %params);
5b5dbec0 Moritz Bunkus
}

sub _oe_record {
0e5e3501 Sven Schöling
my ($order, $type, %params) = @_;
5b5dbec0 Moritz Bunkus
$params{display} ||= 'inline';

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

my $number_method = $order->quotation ? 'quonumber' : 'ordnumber';

ee51b82f Tamino Steinert
my $text = escape($order->$number_method);
if (! delete $params{no_link}) {
984f6322 Bernd Bleßmann
my $action = $::instance_conf->get_feature_experimental_order
f825d995 Bernd Bleßmann
? 'controller.pl?action=Order/edit'
: 'oe.pl?action=edit';
ee51b82f Tamino Steinert
my $href = $action
. '&type=' . $type
. '&id=' . escape($order->id);
$text = link_tag($href, $text, %params);
f825d995 Bernd Bleßmann
}

0e5e3501 Sven Schöling
is_escaped($text);
5b5dbec0 Moritz Bunkus
}

1;


__END__

=pod

=encoding utf8

=head1 NAME

SL::Presenter::Order - Presenter module for Rose::DB objects for sales
7d40c44b Bernd Bleßmann
quotations, sales order_intakes, sales orders,
requests for quotations and purchase orders
5b5dbec0 Moritz Bunkus
=head1 SYNOPSIS

# Sales quotations:
my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('sales_quotation') ]);
0e5e3501 Sven Schöling
my $html = SL::Presenter::Order::sales_quotation($object, display => 'inline');
5b5dbec0 Moritz Bunkus
# Sales orders:
my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('sales_order') ]);
0e5e3501 Sven Schöling
my $html = SL::Presenter::Order::sales_order($object, display => 'inline');
5b5dbec0 Moritz Bunkus
# Requests for quotations:
my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('request_quotation') ]);
0e5e3501 Sven Schöling
my $html = SL::Presenter::Order::request_quotation($object, display => 'inline');
5b5dbec0 Moritz Bunkus
# Purchase orders:
my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('purchase_order') ]);
0e5e3501 Sven Schöling
my $html = SL::Presenter::Order::purchase_order($object, display => 'inline');
5b5dbec0 Moritz Bunkus
=head1 FUNCTIONS

=over 4

=item C<sales_quotation $object, %params>

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

ee51b82f Tamino Steinert
Remaining C<%params> are passed to the function
C<SL::Presenter::Tag::link_tag>. It can include:
5b5dbec0 Moritz Bunkus
=over 2

=item * display

ee51b82f Tamino Steinert
Either C<inline> (the default) or C<table-cell>. Is passed to the function
C<SL::Presenter::Tag::link_tag>.
5b5dbec0 Moritz Bunkus
=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<sales_order $object, %params>

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

ee51b82f Tamino Steinert
Remaining C<%params> are passed to the function
C<SL::Presenter::Tag::link_tag>. It can include:
5b5dbec0 Moritz Bunkus
=over 2

=item * display

ee51b82f Tamino Steinert
Either C<inline> (the default) or C<table-cell>. Is passed to the function
C<SL::Presenter::Tag::link_tag>.
5b5dbec0 Moritz Bunkus
=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<request_quotation $object, %params>

Returns a rendered version (actually an instance of
L<SL::Presenter::EscapedText>) of the request for quotation object
C<$object>.

ee51b82f Tamino Steinert
Remaining C<%params> are passed to the function
C<SL::Presenter::Tag::link_tag>. It can include:
5b5dbec0 Moritz Bunkus
=over 2

=item * display

ee51b82f Tamino Steinert
Either C<inline> (the default) or C<table-cell>. Is passed to the function
C<SL::Presenter::Tag::link_tag>.
5b5dbec0 Moritz Bunkus
=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<purchase_order $object, %params>

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

ee51b82f Tamino Steinert
Remaining C<%params> are passed to the function
C<SL::Presenter::Tag::link_tag>. It can include:
5b5dbec0 Moritz Bunkus
=over 2

=item * display

ee51b82f Tamino Steinert
Either C<inline> (the default) or C<table-cell>. Is passed to the function
C<SL::Presenter::Tag::link_tag>.
5b5dbec0 Moritz Bunkus
=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 E<lt>m.bunkus@linet-services.deE<gt>

=cut