Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b7afa934

Von Moritz Bunkus vor etwa 4 Jahren hinzugefügt

  • ID b7afa934d4ce656536645a97253e4d7ec27e380c
  • Vorgänger a5038d8d
  • Nachfolger 9ff2730f

Neuer Angebots-/Auftragscontroller: Unterstützung für Artikelübersetzungen 1

Bisher nur beim Hinzfügen von Artikeln.

Unterschiede anzeigen:

SL/Controller/Order.pm
22 22
use SL::DB::Language;
23 23
use SL::DB::RecordLink;
24 24
use SL::DB::Shipto;
25
use SL::DB::Translation;
25 26

  
26 27
use SL::Helper::CreatePDF qw(:all);
27 28
use SL::Helper::PrintOptions;
......
1005 1006
  if ($::form->{item_id}) {
1006 1007
    $longdescription = SL::DB::OrderItem->new(id => $::form->{item_id})->load->longdescription;
1007 1008
  } elsif ($::form->{parts_id}) {
1008
    $longdescription = SL::DB::Part->new(id => $::form->{parts_id})->load->notes;
1009
    $longdescription = get_part_texts($::form->{parts_id}, $::form->{language_id})->{longdescription};
1009 1010
  }
1010 1011
  $_[0]->render(\ $longdescription, { type => 'text' });
1011 1012
}
......
1459 1460
  $item ||= SL::DB::OrderItem->new(custom_variables => []);
1460 1461

  
1461 1462
  $item->assign_attributes(%$attr);
1462
  $item->longdescription($item->part->notes)                     if $is_new && !defined $attr->{longdescription};
1463
  $item->project_id($record->globalproject_id)                   if $is_new && !defined $attr->{project_id};
1464
  $item->lastcost($record->is_sales ? $item->part->lastcost : 0) if $is_new && !defined $attr->{lastcost_as_number};
1463

  
1464
  if ($is_new) {
1465
    my $texts = get_part_texts($item->part, $record->language_id);
1466
    $item->longdescription($texts->{longdescription})              if !defined $attr->{longdescription};
1467
    $item->project_id($record->globalproject_id)                   if !defined $attr->{project_id};
1468
    $item->lastcost($record->is_sales ? $item->part->lastcost : 0) if !defined $attr->{lastcost_as_number};
1469
  }
1465 1470

  
1466 1471
  return $item;
1467 1472
}
......
1533 1538
  # saved. Adding empty custom_variables to new orderitem here solves this problem.
1534 1539
  $new_attr{custom_variables} = [];
1535 1540

  
1536
  $item->assign_attributes(%new_attr);
1541
  my $texts = get_part_texts($part, $record->language_id, description => $new_attr{description}, longdescription => $new_attr{longdescription});
1542

  
1543
  $item->assign_attributes(%new_attr, %{ $texts });
1537 1544

  
1538 1545
  return $item;
1539 1546
}
......
2069 2076
  }
2070 2077
}
2071 2078

  
2079
sub get_part_texts {
2080
  my ($part_or_id, $language_or_id, %defaults) = @_;
2081

  
2082
  my $part        = ref($part_or_id)     ? $part_or_id         : SL::DB::Part->load_cached($part_or_id);
2083
  my $language_id = ref($language_or_id) ? $language_or_id->id : $language_or_id;
2084
  my $texts       = {
2085
    description     => $defaults{description}     // $part->description,
2086
    longdescription => $defaults{longdescription} // $part->notes,
2087
  };
2088

  
2089
  return $texts unless $language_id;
2090

  
2091
  my $translation = SL::DB::Manager::Translation->get_first(
2092
    where => [
2093
      parts_id    => $part->id,
2094
      language_id => $language_id,
2095
    ]);
2096

  
2097
  $texts->{description}     = $translation->translation     if $translation && $translation->translation;
2098
  $texts->{longdescription} = $translation->longdescription if $translation && $translation->longdescription;
2099

  
2100
  return $texts;
2101
}
2102

  
2072 2103
sub sales_order_type {
2073 2104
  'sales_order';
2074 2105
}

Auch abrufbar als: Unified diff