Revision 47dc096c
Von Sven Schöling vor fast 2 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
32 | 32 |
use SL::DB::Shipto; |
33 | 33 |
use SL::DB::Translation; |
34 | 34 |
use SL::DB::ValidityToken; |
35 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions); |
|
35 | 36 |
use SL::Model::Record; |
36 | 37 |
|
37 | 38 |
use SL::Helper::CreatePDF qw(:all); |
... | ... | |
2156 | 2157 |
# link records |
2157 | 2158 |
if ($::form->{converted_from_oe_id}) { |
2158 | 2159 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
2159 |
|
|
2160 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
2161 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
2162 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/; |
|
2163 |
$src->link_to_record($self->order); |
|
2164 |
} |
|
2165 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
2166 |
my $idx = 0; |
|
2167 |
foreach (@{ $self->order->items_sorted }) { |
|
2168 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
2169 |
next if !$from_id; |
|
2170 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
2171 |
from_id => $from_id, |
|
2172 |
to_table => 'orderitems', |
|
2173 |
to_id => $_->id |
|
2174 |
)->save; |
|
2175 |
$idx++; |
|
2176 |
} |
|
2177 |
} |
|
2160 |
set_record_link_conversions( |
|
2161 |
$self->order, |
|
2162 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
2163 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
2164 |
); |
|
2178 | 2165 |
|
2179 | 2166 |
$self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids); |
2180 | 2167 |
} |
2181 | 2168 |
if ($::form->{converted_from_reclamation_id}) { |
2182 | 2169 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
2183 |
|
|
2184 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
2185 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
2186 |
$src->link_to_record($self->order); |
|
2187 |
} |
|
2188 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
2189 |
my $idx = 0; |
|
2190 |
foreach (@{ $self->order->items_sorted }) { |
|
2191 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
2192 |
next if !$from_id; |
|
2193 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
2194 |
from_id => $from_id, |
|
2195 |
to_table => 'orderitems', |
|
2196 |
to_id => $_->id |
|
2197 |
)->save; |
|
2198 |
$idx++; |
|
2199 |
} |
|
2200 |
} |
|
2170 |
set_record_links_conversions( |
|
2171 |
$self->order, |
|
2172 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
2173 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
2174 |
); |
|
2201 | 2175 |
} |
2202 | 2176 |
|
2203 | 2177 |
$self->set_project_in_linked_requirement_specs if $self->order->globalproject_id; |
Auch abrufbar als: Unified diff
RecordLink: conversions nicht mehr manuell in Controllern machen
stattdessen per Helper setzen lassen