1 package SL::Presenter::DeliveryOrder;
5 use SL::DB::DeliveryOrder::TypeData ();
6 use SL::Locale::String qw(t8);
7 use SL::Presenter::EscapedText qw(escape is_escaped);
9 use Exporter qw(import);
10 our @EXPORT_OK = qw(sales_delivery_order purchase_delivery_order delivery_order_status_line);
14 sub sales_delivery_order {
15 my ($delivery_order, %params) = @_;
17 return _do_record($delivery_order, 'sales_delivery_order', %params);
20 sub rma_delivery_order {
21 my ($delivery_order, %params) = @_;
23 return _do_new_record($delivery_order, 'rma_delivery_order', %params);
26 sub purchase_delivery_order {
27 my ($delivery_order, %params) = @_;
29 return _do_record($delivery_order, 'purchase_delivery_order', %params);
32 sub supplier_delivery_order {
33 my ($delivery_order, %params) = @_;
35 return _do_new_record($delivery_order, 'supplier_delivery_order', %params);
39 my ($delivery_order, $type, %params) = @_;
41 $params{display} ||= 'inline';
43 croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
46 $params{no_link} ? '' : '<a href="contoller.pl?action=DeliveryOrder/edit&type=' . $type . '&id=' . escape($delivery_order->id) . '">',
47 escape($delivery_order->donumber),
48 $params{no_link} ? '' : '</a>',
54 my ($delivery_order, $type, %params) = @_;
56 $params{display} ||= 'inline';
58 croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
61 $params{no_link} ? '' : '<a href="do.pl?action=edit&type=' . $type . '&id=' . escape($delivery_order->id) . '">',
62 escape($delivery_order->donumber),
63 $params{no_link} ? '' : '</a>',
69 my ($delivery_order) = @_;
71 my $in_out = SL::DB::DeliveryOrder::TypeData::get3($delivery_order->type, "properties", "transfer");
73 if ($in_out eq 'in') {
74 return escape($delivery_order->delivered ? t8('transferred in') : t8('not transferred in yet'));
77 if ($in_out eq 'out') {
78 return escape($delivery_order->delivered ? t8('transferred out') : t8('not transferred out yet'));
83 my ($delivery_order) = @_;
85 return escape($delivery_order->closed ? t8('Closed') : t8('Open'))
89 my ($delivery_order) = @_;
91 return "" unless $delivery_order->id;
93 stock_status($delivery_order) . " ; " . closed_status($delivery_order)
96 sub delivery_order_status_line { goto &status_line };
108 SL::Presenter::DeliveryOrder - Presenter module for Rose::DB objects
109 for sales and purchase delivery orders
113 # Sales delivery orders:
114 my $object = SL::DB::Manager::DeliveryOrder->get_first(where => [ is_sales => 1 ]);
115 my $html = SL::Presenter::DeliveryOrder::sales_delivery_order($object, display => 'inline');
117 # Purchase delivery orders:
118 my $object = SL::DB::Manager::DeliveryOrder->get_first(where => [ or => [ is_sales => undef, is_sales => 0 ]]);
119 my $html = SL::Presenter::DeliveryOrder::purchase_delivery_order($object, display => 'inline');
125 =item C<sales_delivery_order $object, %params>
127 Returns a rendered version (actually an instance of
128 L<SL::Presenter::EscapedText>) of the sales delivery order object
131 C<%params> can include:
137 Either C<inline> (the default) or C<table-cell>. At the moment both
138 representations are identical and produce the objects's delivery
139 order number linked to the corresponding 'edit' action.
143 If falsish (the default) then the delivery order number will be linked
144 to the "edit delivery order" dialog from the sales menu.
148 =item C<purchase_delivery_order $object, %params>
150 Returns a rendered version (actually an instance of
151 L<SL::Presenter::EscapedText>) of the purchase delivery order object
154 C<%params> can include:
160 Either C<inline> (the default) or C<table-cell>. At the moment both
161 representations are identical and produce the objects's delivery
162 order number linked to the corresponding 'edit' action.
166 If falsish (the default) then the delivery order number will be linked
167 to the "edit delivery order" dialog from the purchase menu.
179 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>