Revision 5144a28b
Von Tamino Steinert vor etwa 1 Jahr hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
33 | 33 |
use SL::DB::Shipto; |
34 | 34 |
use SL::DB::Translation; |
35 | 35 |
use SL::DB::ValidityToken; |
36 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_ITEM_ID);
|
|
36 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_TYPE_REF RECORD_ITEM_ID RECORD_ITEM_TYPE_REF);
|
|
37 | 37 |
use SL::DB::Helper::TypeDataProxy; |
38 | 38 |
use SL::DB::Helper::Record qw(get_object_name_from_type get_class_from_type); |
39 | 39 |
use SL::Model::Record; |
... | ... | |
120 | 120 |
my $order = SL::Model::Record->new_from_workflow($record, $self->type, %flags); |
121 | 121 |
$self->order($order); |
122 | 122 |
|
123 |
if (ref($record) eq 'SL::DB::Reclamation') { |
|
124 |
$self->{converted_from_reclamation_id} = $order->{ RECORD_ID() }; |
|
125 |
$_ ->{converted_from_reclamation_items_id} = $_ ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted }; |
|
126 |
} |
|
127 |
if (ref($record) eq 'SL::DB::Order') { |
|
128 |
$self->{converted_from_oe_id} = $order->{ RECORD_ID() }; |
|
129 |
$_ ->{converted_from_oe_items_id} = $_ ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted }; |
|
130 |
} |
|
131 |
|
|
132 |
|
|
133 | 123 |
$self->recalc(); |
134 | 124 |
$self->pre_render(); |
135 | 125 |
|
... | ... | |
230 | 220 |
|
231 | 221 |
# make new order from given orders |
232 | 222 |
my @multi_orders = map { SL::DB::Order->new(id => $_)->load } @multi_ids; |
233 |
$self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders; |
|
234 |
my $target_type = "sales_order"; |
|
223 |
my $target_type = SALES_ORDER_TYPE(); |
|
235 | 224 |
my $order = SL::Model::Record->new_from_workflow_multi(\@multi_orders, $target_type, sort_sources_by => 'transdate'); |
236 | 225 |
$self->order($order); |
237 | 226 |
|
... | ... | |
1626 | 1615 |
|
1627 | 1616 |
$self->js |
1628 | 1617 |
->val('#id', $self->order->id) |
1629 |
->val('#converted_from_oe_id', '')
|
|
1630 |
->val('#converted_from_reclamation_id', '')
|
|
1618 |
->val('#converted_from_record_type_ref', '')
|
|
1619 |
->val('#converted_from_record_id', '')
|
|
1631 | 1620 |
->val('#order_' . $self->nr_key(), $self->order->number); |
1632 | 1621 |
|
1633 | 1622 |
my $idx = 0; |
... | ... | |
1641 | 1630 |
} continue { |
1642 | 1631 |
$idx++; |
1643 | 1632 |
} |
1644 |
$self->js->val('[name="converted_from_orderitems_ids[+]"]', '');
|
|
1645 |
$self->js->val('[name="converted_from_reclamation_items_ids[+]"]', '');
|
|
1633 |
$self->js->val('[name="converted_from_record_item_type_refs[+]"]', '');
|
|
1634 |
$self->js->val('[name="converted_from_record_item_ids[+]"]', '');
|
|
1646 | 1635 |
$self->js->val('[name="basket_item_ids[+]"]', ''); |
1647 | 1636 |
} |
1648 | 1637 |
|
... | ... | |
2097 | 2086 |
sub save { |
2098 | 2087 |
my ($self) = @_; |
2099 | 2088 |
|
2089 |
my $is_new = !$self->order->id; |
|
2090 |
|
|
2100 | 2091 |
$self->parse_phone_note if $::form->{phone_note}->{subject} || $::form->{phone_note}->{body}; |
2101 | 2092 |
|
2102 | 2093 |
# create first version if none exists |
2103 | 2094 |
$self->order->add_order_version(SL::DB::OrderVersion->new(version => 1)) if !$self->order->order_version; |
2104 | 2095 |
|
2096 |
set_record_link_conversions($self->order, |
|
2097 |
delete $::form->{RECORD_TYPE_REF()} |
|
2098 |
=> delete $::form->{RECORD_ID()}, |
|
2099 |
delete $::form->{RECORD_ITEM_TYPE_REF()} |
|
2100 |
=> delete $::form->{RECORD_ITEM_ID()}, |
|
2101 |
); |
|
2102 |
|
|
2105 | 2103 |
my @converted_from_oe_ids; |
2106 |
if ($::form->{converted_from_oe_id}) { |
|
2107 |
@converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
|
2108 |
set_record_link_conversions( |
|
2109 |
$self->order, |
|
2110 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
2111 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
2112 |
); |
|
2113 |
} |
|
2114 |
if ($::form->{converted_from_reclamation_id}) { |
|
2115 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
|
2116 |
set_record_link_conversions( |
|
2117 |
$self->order, |
|
2118 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
2119 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
2120 |
); |
|
2104 |
if ($self->order->{RECORD_TYPE_REF()} eq 'SL::DB::Order' |
|
2105 |
&& $self->order->{RECORD_ID()}) { |
|
2106 |
@converted_from_oe_ids = split ' ', $self->order->{RECORD_ID()}; |
|
2121 | 2107 |
} |
2122 | 2108 |
|
2123 | 2109 |
# check for purchase basket items |
... | ... | |
2141 | 2127 |
} |
2142 | 2128 |
} |
2143 | 2129 |
|
2144 |
my $is_new = !$self->order->id; |
|
2145 |
|
|
2146 | 2130 |
my $objects_to_close = scalar @converted_from_oe_ids |
2147 | 2131 |
? SL::DB::Manager::Order->get_all(where => [ |
2148 | 2132 |
id => \@converted_from_oe_ids, |
Auch abrufbar als: Unified diff
Order: Nutze Type und ID zum Erstellen von verknüpften Belegen