Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 04c54ebf

Von Tamino Steinert vor 10 Monaten hinzugefügt

  • ID 04c54ebf7bab800ffd4753d266548b8dc323db1f
  • Vorgänger e8aea3fc
  • Nachfolger 46ee23a1

Varianten: Schnellbearbeitung von Varianten (LP,VK,EK,ROP)

Unterschiede anzeigen:

SL/Controller/Part.pm
259 259
  $self->js->render();
260 260
}
261 261

  
262
sub action_add_variant_property {
262
sub action_update_variants {
263 263
  my ($self) = @_;
264 264

  
265
  my $variant_property_id = $::form->{add_variant_property};
266
  die t8("Please select a variant property") unless ($variant_property_id);
267 265
  my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}};
268
  foreach my $variant (@{$self->part->variants}) {
269
    die t8("Please select a new variant property value for all variants")
270
      unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"};
266

  
267
  my $variant_property_id = $::form->{add_variant_property};
268
  if ($variant_property_id) {
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"};
272
    }
271 273
  }
272 274

  
273 275
  SL::DB->client->with_transaction(sub {
274
    SL::DB::VariantPropertyPart->new(
275
      part_id             => $self->part->id,
276
      variant_property_id => $variant_property_id,
277
    )->save;
278 276
    foreach my $variant (@{$self->part->variants}) {
279
      SL::DB::VariantPropertyValuePart->new(
280
        part_id                   => $variant->id,
281
        variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
277
      $variant->update_attributes(
278
        description         => $variant_id_to_values{$variant->id}->{description},
279
        listprice_as_number => $variant_id_to_values{$variant->id}->{listprice_as_number},
280
        sellprice_as_number => $variant_id_to_values{$variant->id}->{sellprice_as_number},
281
        lastcost_as_number  => $variant_id_to_values{$variant->id}->{lastcost_as_number},
282
        rop_as_number       => $variant_id_to_values{$variant->id}->{rop_as_number},
283
      );
284
    }
285
    if ($variant_property_id) {
286
      SL::DB::VariantPropertyPart->new(
287
        part_id             => $self->part->id,
288
        variant_property_id => $variant_property_id,
282 289
      )->save;
290
      foreach my $variant (@{$self->part->variants}) {
291
        SL::DB::VariantPropertyValuePart->new(
292
          part_id                   => $variant->id,
293
          variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
294
        )->save;
295
      }
283 296
    }
284 297
    1;
285 298
  }) or do {

Auch abrufbar als: Unified diff