Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 361a3f88

Von Tamino Steinert vor 6 Tagen hinzugefügt

  • ID 361a3f88c2234b4678c0d644032677fb61ba15bb
  • Vorgänger 930fcc0f
  • Nachfolger 8e6ec576

Varianten: Schnellbearbeitung von Varianten (EAN, Auf Lager)

Unterschiede anzeigen:

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

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

  
303 301
  $self->redirect_to(
......
889 887
  my %sort_keys = (
890 888
    partnumber       => sub { $_[0]->partnumber },
891 889
    description      => sub { $_[0]->description },
890
    ean              => sub { $_[0]->ean },
891
    listprice        => sub { $_[0]->listprice },
892 892
    sellprice        => sub { $_[0]->sellprice },
893 893
    lastcost         => sub { $_[0]->lastcost },
894
    onhand           => sub { $_[0]->onhand },
895
    rop              => sub { $_[0]->rop },
894 896
    variant_values   => sub { $_[0]->variant_values },
895 897
  );
896 898
  foreach my $variant_property (@{$part->variant_properties}) {
......
909 911
    @{$::form->{variants}};
910 912

  
911 913
  my @to_sort = map { { old_pos => $variant_id_to_position{$_->id}, order_by => $method->($_) } } @items;
912
  if ($::form->{order_by} =~ /^(sellprice|lastcost)$/ ||
914
  if ($::form->{order_by} =~ /^(listpirce|sellprice|lastcost|onhand|rop)$/ ||
913 915
      $::form->{order_by} =~ /^variant_property_/) {
914 916
    if ($::form->{sort_dir}) {
915 917
      @to_sort = sort { $a->{order_by} <=> $b->{order_by} } @to_sort;

Auch abrufbar als: Unified diff