Revision 60a2e713
Von Tamino Steinert vor 12 Monaten 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 |
|
... | ... | |
1587 | 1576 |
|
1588 | 1577 |
$self->js |
1589 | 1578 |
->val('#id', $self->order->id) |
1590 |
->val('#converted_from_oe_id', '')
|
|
1591 |
->val('#converted_from_reclamation_id', '')
|
|
1579 |
->val('#converted_from_record_type_ref', '')
|
|
1580 |
->val('#converted_from_record_id', '')
|
|
1592 | 1581 |
->val('#order_' . $self->nr_key(), $self->order->number); |
1593 | 1582 |
|
1594 | 1583 |
my $idx = 0; |
... | ... | |
1602 | 1591 |
} continue { |
1603 | 1592 |
$idx++; |
1604 | 1593 |
} |
1605 |
$self->js->val('[name="converted_from_orderitems_ids[+]"]', '');
|
|
1606 |
$self->js->val('[name="converted_from_reclamation_items_ids[+]"]', '');
|
|
1594 |
$self->js->val('[name="converted_from_record_item_type_refs[+]"]', '');
|
|
1595 |
$self->js->val('[name="converted_from_record_item_ids[+]"]', '');
|
|
1607 | 1596 |
$self->js->val('[name="basket_item_ids[+]"]', ''); |
1608 | 1597 |
} |
1609 | 1598 |
|
... | ... | |
2058 | 2047 |
sub save { |
2059 | 2048 |
my ($self) = @_; |
2060 | 2049 |
|
2050 |
my $is_new = !$self->order->id; |
|
2051 |
|
|
2061 | 2052 |
$self->parse_phone_note if $::form->{phone_note}->{subject} || $::form->{phone_note}->{body}; |
2062 | 2053 |
|
2063 | 2054 |
# create first version if none exists |
2064 | 2055 |
$self->order->add_order_version(SL::DB::OrderVersion->new(version => 1)) if !$self->order->order_version; |
2065 | 2056 |
|
2057 |
set_record_link_conversions($self->order, |
|
2058 |
delete $::form->{RECORD_TYPE_REF()} |
|
2059 |
=> delete $::form->{RECORD_ID()}, |
|
2060 |
delete $::form->{RECORD_ITEM_TYPE_REF()} |
|
2061 |
=> delete $::form->{RECORD_ITEM_ID()}, |
|
2062 |
); |
|
2063 |
|
|
2066 | 2064 |
my @converted_from_oe_ids; |
2067 |
if ($::form->{converted_from_oe_id}) { |
|
2068 |
@converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
|
2069 |
set_record_link_conversions( |
|
2070 |
$self->order, |
|
2071 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
2072 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
2073 |
); |
|
2074 |
} |
|
2075 |
if ($::form->{converted_from_reclamation_id}) { |
|
2076 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
|
2077 |
set_record_link_conversions( |
|
2078 |
$self->order, |
|
2079 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
2080 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
2081 |
); |
|
2065 |
if ($self->order->{RECORD_TYPE_REF()} eq 'SL::DB::Order' |
|
2066 |
&& $self->order->{RECORD_ID()}) { |
|
2067 |
@converted_from_oe_ids = split ' ', $self->order->{RECORD_ID()}; |
|
2082 | 2068 |
} |
2083 | 2069 |
|
2084 | 2070 |
# check for purchase basket items |
... | ... | |
2102 | 2088 |
} |
2103 | 2089 |
} |
2104 | 2090 |
|
2105 |
my $is_new = !$self->order->id; |
|
2106 |
|
|
2107 | 2091 |
my $objects_to_close = scalar @converted_from_oe_ids |
2108 | 2092 |
? SL::DB::Manager::Order->get_all(where => [ |
2109 | 2093 |
id => \@converted_from_oe_ids, |
SL/DB/Helper/RecordLink.pm | ||
---|---|---|
71 | 71 |
my $idx = 0; |
72 | 72 |
my $items = $record->items_sorted; |
73 | 73 |
|
74 |
$item_ids ||= []; |
|
74 | 75 |
croak "more item ids than items in record" if @$item_ids > @$items; |
75 | 76 |
|
76 | 77 |
for my $idx (0..$#$item_ids) { |
SL/DB/Order.pm | ||
---|---|---|
514 | 514 |
any { $from_to->{abbr} eq $_ } @_; |
515 | 515 |
}; |
516 | 516 |
|
517 |
my ($item_parent_id_column, $item_parent_column); |
|
518 |
|
|
519 |
if (ref($source) eq 'SL::DB::Order') { |
|
520 |
$item_parent_id_column = 'trans_id'; |
|
521 |
$item_parent_column = 'order'; |
|
522 |
} elsif ( ref($source) eq 'SL::DB::Reclamation') { |
|
523 |
$item_parent_id_column = 'reclamation_id'; |
|
524 |
$item_parent_column = 'reclamation'; |
|
525 |
} |
|
526 |
|
|
527 | 517 |
my %args; |
528 | 518 |
if (ref($source) eq 'SL::DB::Order') { |
529 | 519 |
%args = ( map({ ( $_ => $source->$_ ) } qw(amount cp_id currency_id cusordnumber customer_id delivery_customer_id delivery_term_id delivery_vendor_id |
... | ... | |
613 | 603 |
$order->assign_attributes(%{ $params{attributes} }) if $params{attributes}; |
614 | 604 |
my $items = delete($params{items}) || $source->items_sorted; |
615 | 605 |
|
616 |
my %item_parents; |
|
617 |
|
|
618 | 606 |
my @items = map { |
619 | 607 |
my $source_item = $_; |
620 |
my $source_item_id = $_->$item_parent_id_column; |
|
621 | 608 |
my @custom_variables = map { _clone_orderitem_cvar($_) } @{ $source_item->custom_variables }; |
622 | 609 |
|
623 |
$item_parents{$source_item_id} ||= $source_item->$item_parent_column; |
|
624 |
my $item_parent = $item_parents{$source_item_id}; |
|
625 |
|
|
626 | 610 |
my $current_oe_item; |
627 | 611 |
if (ref($source) eq 'SL::DB::Order') { |
628 | 612 |
$current_oe_item = SL::DB::OrderItem->new(map({ ( $_ => $source_item->$_ ) } |
... | ... | |
654 | 638 |
$current_oe_item->lastcost($source_item->sellprice); |
655 | 639 |
} |
656 | 640 |
unless ($params{no_linked_records}) { |
657 |
$current_oe_item->{ RECORD_ITEM_ID() } = $_->{id};
|
|
641 |
$current_oe_item->{ RECORD_ITEM_ID() } = $source_item->{id};
|
|
658 | 642 |
$current_oe_item->{ RECORD_ITEM_TYPE_REF() } = ref($source_item); |
659 | 643 |
} |
660 | 644 |
$current_oe_item; |
... | ... | |
742 | 726 |
attributes => \%attributes, |
743 | 727 |
items => \@items, |
744 | 728 |
%params); |
729 |
$order->{RECORD_ID()} = join ' ', map { $_->id } @$sources; # link all sources |
|
745 | 730 |
|
746 | 731 |
return $order; |
747 | 732 |
} |
templates/design40_webpages/order/form.html | ||
---|---|---|
21 | 21 |
[% L.hidden_tag('callback', FORM.callback) %] |
22 | 22 |
[% L.hidden_tag('type', FORM.type) %] |
23 | 23 |
[% L.hidden_tag('id', SELF.order.id) %] |
24 |
[% L.hidden_tag('converted_from_oe_id', SELF.converted_from_oe_id) %]
|
|
25 |
[% L.hidden_tag('converted_from_reclamation_id', SELF.converted_from_reclamation_id) %]
|
|
24 |
[% L.hidden_tag('converted_from_record_type_ref', SELF.order.converted_from_record_type_ref) %]
|
|
25 |
[% L.hidden_tag('converted_from_record_id', SELF.order.converted_from_record_id) %]
|
|
26 | 26 |
|
27 | 27 |
[% IF !SELF.order.id %] |
28 | 28 |
[% L.hidden_tag('form_validity_token', FORM.form_validity_token) %] |
templates/design40_webpages/order/tabs/_row.html | ||
---|---|---|
15 | 15 |
alt=LxERP.t8('Show details'), title=LxERP.t8('Show details'), class="expand") %] |
16 | 16 |
[% END %] |
17 | 17 |
[% L.hidden_tag("orderitem_ids[+]", ID) %] |
18 |
[% L.hidden_tag("converted_from_orderitems_ids[+]", ITEM.converted_from_orderitems_id) %]
|
|
19 |
[% L.hidden_tag("converted_from_reclamation_items_ids[+]", ITEM.converted_from_reclamation_items_id) %]
|
|
18 |
[% L.hidden_tag("converted_from_record_item_type_ref[+]", ITEM.converted_from_record_item_type_ref) %]
|
|
19 |
[% L.hidden_tag("converted_from_record_item_id[+]", ITEM.converted_from_record_item_id) %]
|
|
20 | 20 |
[% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ID) %] |
21 | 21 |
[% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %] |
22 | 22 |
[% L.hidden_tag("basket_item_ids[+]", ITEM.basket_item_id) %] |
templates/webpages/order/form.html | ||
---|---|---|
21 | 21 |
[% L.hidden_tag('callback', FORM.callback) %] |
22 | 22 |
[% L.hidden_tag('type', FORM.type) %] |
23 | 23 |
[% L.hidden_tag('id', SELF.order.id) %] |
24 |
[% L.hidden_tag('converted_from_oe_id', SELF.converted_from_oe_id) %]
|
|
25 |
[% L.hidden_tag('converted_from_reclamation_id', SELF.converted_from_reclamation_id) %]
|
|
24 |
[% L.hidden_tag('converted_from_record_type_ref', SELF.order.converted_from_record_type_ref) %]
|
|
25 |
[% L.hidden_tag('converted_from_record_id', SELF.order.converted_from_record_id) %]
|
|
26 | 26 |
|
27 | 27 |
[% IF !SELF.order.id %] |
28 | 28 |
[% L.hidden_tag('form_validity_token', FORM.form_validity_token) %] |
templates/webpages/order/tabs/_row.html | ||
---|---|---|
15 | 15 |
alt=LxERP.t8('Show details'), title=LxERP.t8('Show details'), class="expand") %] |
16 | 16 |
[%- END %] |
17 | 17 |
[% L.hidden_tag("orderitem_ids[+]", ID) %] |
18 |
[% L.hidden_tag("converted_from_orderitems_ids[+]", ITEM.converted_from_orderitems_id) %]
|
|
19 |
[% L.hidden_tag("converted_from_reclamation_items_ids[+]", ITEM.converted_from_reclamation_items_id) %]
|
|
18 |
[% L.hidden_tag("converted_from_record_item_type_ref[+]", ITEM.converted_from_record_item_type_ref) %]
|
|
19 |
[% L.hidden_tag("converted_from_record_item_id[+]", ITEM.converted_from_record_item_id) %]
|
|
20 | 20 |
[% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ID) %] |
21 | 21 |
[% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %] |
22 | 22 |
[% L.hidden_tag("purchase_basket_item_ids[+]", ITEM.purchase_basket_item_ids) %] |
Auch abrufbar als: Unified diff
Order: Nutze Type und ID zum Erstellen von verknüpften Belegen