Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dfdaa70d

Von Tamino Steinert vor 3 Monaten hinzugefügt

  • ID dfdaa70d0c1ef959216e0c220658b4389c8a3dc7
  • Vorgänger b18c27aa
  • Nachfolger 67f3e4cd

Varianten: Schnellbearbeitung von Varianten (EAN, Auf Lager)

Unterschiede anzeigen:

SL/Controller/Part.pm
273 273
  }
274 274

  
275 275
  SL::DB->client->with_transaction(sub {
276
    foreach my $variant (@{$self->part->variants}) {
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
    }
276
    my $new_variant_property;
285 277
    if ($variant_property_id) {
286
      SL::DB::VariantPropertyPart->new(
278
      $new_variant_property = SL::DB::VariantPropertyPart->new(
287 279
        part_id             => $self->part->id,
288 280
        variant_property_id => $variant_property_id,
289 281
      )->save;
290
      foreach my $variant (@{$self->part->variants}) {
282
    }
283
    foreach my $variant (@{$self->part->variants}) {
284
      my $variant_attributes = $variant_id_to_values{$variant->id};
285
      my $variant_property_value_id = delete $variant_attributes->{add_variant_property_value};
286
      delete $variant_attributes->{$_} for qw(id position);
287
      $variant->update_attributes(%$variant_attributes);
288
      if ($new_variant_property) {
291 289
        SL::DB::VariantPropertyValuePart->new(
292 290
          part_id                   => $variant->id,
293
          variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
291
          variant_property_value_id => $variant_property_value_id,
294 292
        )->save;
295 293
      }
296 294
    }
297 295
    1;
298 296
  }) or do {
299
    return $self->js->error(t8('Error while adding variant property: ' . @_))->render();
297
    return $self->js->error(t8('Error while adding variant property: #1', SL::DB->client->error))->render();
300 298
  };
301 299

  
302 300
  $self->redirect_to(
......
882 880
  my %sort_keys = (
883 881
    partnumber       => sub { $_[0]->partnumber },
884 882
    description      => sub { $_[0]->description },
883
    ean              => sub { $_[0]->ean },
884
    listprice        => sub { $_[0]->listprice },
885 885
    sellprice        => sub { $_[0]->sellprice },
886 886
    lastcost         => sub { $_[0]->lastcost },
887
    onhand           => sub { $_[0]->onhand },
888
    rop              => sub { $_[0]->rop },
887 889
    variant_values   => sub { $_[0]->variant_values },
888 890
  );
889 891
  foreach my $variant_property (@{$part->variant_properties}) {
......
902 904
    @{$::form->{variants}};
903 905

  
904 906
  my @to_sort = map { { old_pos => $variant_id_to_position{$_->id}, order_by => $method->($_) } } @items;
905
  if ($::form->{order_by} =~ /^(sellprice|lastcost)$/ ||
907
  if ($::form->{order_by} =~ /^(listpirce|sellprice|lastcost|onhand|rop)$/ ||
906 908
      $::form->{order_by} =~ /^variant_property_/) {
907 909
    if ($::form->{sort_dir}) {
908 910
      @to_sort = sort { $a->{order_by} <=> $b->{order_by} } @to_sort;

Auch abrufbar als: Unified diff