Revision d9676896
Von Sven Schöling 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); |
|
36 | 37 |
use SL::Model::Record; |
37 | 38 |
|
38 | 39 |
use SL::Helper::CreatePDF qw(:all); |
... | ... | |
2222 | 2223 |
# link records |
2223 | 2224 |
if ($::form->{converted_from_oe_id}) { |
2224 | 2225 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
2225 |
|
|
2226 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
2227 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
2228 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/; |
|
2229 |
$src->update_attributes(closed => 1) if $src->type eq purchase_quotation_intake_type() && $self->type eq purchase_order_type(); |
|
2230 |
$src->link_to_record($self->order); |
|
2231 |
} |
|
2232 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
2233 |
my $idx = 0; |
|
2234 |
foreach (@{ $self->order->items_sorted }) { |
|
2235 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
2236 |
next if !$from_id; |
|
2237 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
2238 |
from_id => $from_id, |
|
2239 |
to_table => 'orderitems', |
|
2240 |
to_id => $_->id |
|
2241 |
)->save; |
|
2242 |
$idx++; |
|
2243 |
} |
|
2244 |
} |
|
2226 |
set_record_link_conversions( |
|
2227 |
$self->order, |
|
2228 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
2229 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
2230 |
); |
|
2245 | 2231 |
|
2246 | 2232 |
$self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids); |
2247 | 2233 |
} |
2248 | 2234 |
if ($::form->{converted_from_reclamation_id}) { |
2249 | 2235 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
2250 |
|
|
2251 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
2252 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
2253 |
$src->link_to_record($self->order); |
|
2254 |
} |
|
2255 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
2256 |
my $idx = 0; |
|
2257 |
foreach (@{ $self->order->items_sorted }) { |
|
2258 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
2259 |
next if !$from_id; |
|
2260 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
2261 |
from_id => $from_id, |
|
2262 |
to_table => 'orderitems', |
|
2263 |
to_id => $_->id |
|
2264 |
)->save; |
|
2265 |
$idx++; |
|
2266 |
} |
|
2267 |
} |
|
2236 |
set_record_links_conversions( |
|
2237 |
$self->order, |
|
2238 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
2239 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
2240 |
); |
|
2268 | 2241 |
} |
2269 | 2242 |
|
2270 | 2243 |
$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