Revision 4694b5fd
Von Tamino Steinert vor 6 Tagen hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
260 | 260 |
$self->js->render(); |
261 | 261 |
} |
262 | 262 |
|
263 |
sub action_add_variant_property {
|
|
263 |
sub action_update_variants {
|
|
264 | 264 |
my ($self) = @_; |
265 | 265 |
|
266 |
my $variant_property_id = $::form->{add_variant_property}; |
|
267 |
die t8("Please select a variant property") unless ($variant_property_id); |
|
268 | 266 |
my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}}; |
269 |
foreach my $variant (@{$self->part->variants}) { |
|
270 |
die t8("Please select a new variant property value for all variants") |
|
271 |
unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"}; |
|
267 |
|
|
268 |
my $variant_property_id = $::form->{add_variant_property}; |
|
269 |
if ($variant_property_id) { |
|
270 |
foreach my $variant (@{$self->part->variants}) { |
|
271 |
die t8("Please select a new variant property value for all variants") |
|
272 |
unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"}; |
|
273 |
} |
|
272 | 274 |
} |
273 | 275 |
|
274 | 276 |
SL::DB->client->with_transaction(sub { |
275 |
SL::DB::VariantPropertyPart->new( |
|
276 |
part_id => $self->part->id, |
|
277 |
variant_property_id => $variant_property_id, |
|
278 |
)->save; |
|
279 | 277 |
foreach my $variant (@{$self->part->variants}) { |
280 |
SL::DB::VariantPropertyValuePart->new( |
|
281 |
part_id => $variant->id, |
|
282 |
variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"}, |
|
278 |
$variant->update_attributes( |
|
279 |
description => $variant_id_to_values{$variant->id}->{description}, |
|
280 |
listprice_as_number => $variant_id_to_values{$variant->id}->{listprice_as_number}, |
|
281 |
sellprice_as_number => $variant_id_to_values{$variant->id}->{sellprice_as_number}, |
|
282 |
lastcost_as_number => $variant_id_to_values{$variant->id}->{lastcost_as_number}, |
|
283 |
rop_as_number => $variant_id_to_values{$variant->id}->{rop_as_number}, |
|
284 |
); |
|
285 |
} |
|
286 |
if ($variant_property_id) { |
|
287 |
SL::DB::VariantPropertyPart->new( |
|
288 |
part_id => $self->part->id, |
|
289 |
variant_property_id => $variant_property_id, |
|
283 | 290 |
)->save; |
291 |
foreach my $variant (@{$self->part->variants}) { |
|
292 |
SL::DB::VariantPropertyValuePart->new( |
|
293 |
part_id => $variant->id, |
|
294 |
variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"}, |
|
295 |
)->save; |
|
296 |
} |
|
284 | 297 |
} |
285 | 298 |
1; |
286 | 299 |
}) or do { |
Auch abrufbar als: Unified diff
Varianten: Schnellbearbeitung von Varianten (LP,VK,EK,ROP)