Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4c84466a

Von Tamino Steinert vor 9 Monaten hinzugefügt

  • ID 4c84466a11b2694923638e065c66c5df8e297564
  • Vorgänger 0ecf5cf7
  • Nachfolger 65987c7f

FIX: S:C:RecordBase: rufe alle Funktionen auf self auf.

Damit die richtige Funktion aus der Klasse gefunden wird, muss das
Objekt immer mit gegeben werden.

Unterschiede anzeigen:

SL/Controller/Order.pm
1084 1084

  
1085 1085
  return unless $form_attr->{parts_id};
1086 1086

  
1087
  my $item = new_item($self->order, $form_attr);
1087
  my $item = $self->new_item($self->order, $form_attr);
1088 1088

  
1089 1089
  $self->order->add_items($item);
1090 1090

  
......
1115 1115
                   unit     => $assortment_item->unit,
1116 1116
                   description => $assortment_item->part->description,
1117 1117
                 };
1118
      my $item = new_item($self->order, $attr);
1118
      my $item = $self->new_item($self->order, $attr);
1119 1119

  
1120 1120
      # set discount to 100% if item isn't supposed to be charged, overwriting any customer discount
1121 1121
      $item->discount(1) unless $assortment_item->charge;
......
1163 1163

  
1164 1164
  my @items;
1165 1165
  foreach my $attr (@form_attr) {
1166
    my $item = new_item($self->order, $attr);
1166
    my $item = $self->new_item($self->order, $attr);
1167 1167
    push @items, $item;
1168 1168
    if ( $item->part->is_assortment ) {
1169 1169
      foreach my $assortment_item ( @{$item->part->assortment_items} ) {
......
1172 1172
                     unit     => $assortment_item->unit,
1173 1173
                     description => $assortment_item->part->description,
1174 1174
                   };
1175
        my $item = new_item($self->order, $attr);
1175
        my $item = $self->new_item($self->order, $attr);
1176 1176

  
1177 1177
        # set discount to 100% if item isn't supposed to be charged, overwriting any customer discount
1178 1178
        $item->discount(1) unless $assortment_item->charge;
......
1369 1369
  foreach my $item_id (@{ $::form->{item_ids} }) {
1370 1370
    my $idx   = first_index { $_ eq $item_id } @{ $::form->{orderitem_ids} };
1371 1371
    my $item  = $self->order->items_sorted->[$idx];
1372
    my $texts = get_part_texts($item->part, $self->order->language_id);
1372
    my $texts = $self->get_part_texts($item->part, $self->order->language_id);
1373 1373

  
1374 1374
    $item->description($texts->{description});
1375 1375
    $item->longdescription($texts->{longdescription});
......
1870 1870
#
1871 1871
# This is used to add one item
1872 1872
sub new_item {
1873
  my ($record, $attr) = @_;
1873
  my ($self, $record, $attr) = @_;
1874 1874

  
1875 1875
  my $item = SL::DB::OrderItem->new;
1876 1876

  
......
1904 1904
  # saved. Adding empty custom_variables to new orderitem here solves this problem.
1905 1905
  $new_attr{custom_variables} = [];
1906 1906

  
1907
  my $texts = get_part_texts($item->part, $record->language_id, description => $new_attr{description}, longdescription => $new_attr{longdescription});
1907
  my $texts = $self->get_part_texts($item->part, $record->language_id, description => $new_attr{description}, longdescription => $new_attr{longdescription});
1908 1908

  
1909 1909
  $item->assign_attributes(%new_attr, %{ $texts });
1910 1910

  
......
2664 2664
}
2665 2665

  
2666 2666
sub get_part_texts {
2667
  my ($part_or_id, $language_or_id, %defaults) = @_;
2667
  my ($self, $part_or_id, $language_or_id, %defaults) = @_;
2668 2668

  
2669 2669
  my $part        = ref($part_or_id)     ? $part_or_id         : SL::DB::Part->load_cached($part_or_id);
2670 2670
  my $language_id = ref($language_or_id) ? $language_or_id->id : $language_or_id;
SL/Controller/RecordBase.pm
81 81
  my @items;
82 82
  my $pos = 1;
83 83
  foreach my $form_attr (@{$form_items}) {
84
    my $item = make_item($record, $form_attr);
84
    my $item = $self->make_item($record, $form_attr);
85 85
    $item->position($pos);
86 86
    push @items, $item;
87 87
    $pos++;
......
96 96
# Make item objects from form values. For items already existing read from db.
97 97
# Create a new item else. And assign attributes.
98 98
sub make_item {
99
  my ($record, $attr) = @_;
99
  my ($self, $record, $attr) = @_;
100 100

  
101 101
  my $item;
102 102
  $item = first { $_->id == $attr->{id} } @{$record->items} if $attr->{id};
......
111 111
  $item->assign_attributes(%$attr);
112 112

  
113 113
  if ($is_new) {
114
    my $texts = get_part_texts($item->part, $record->language_id);
114
    my $texts = $self->get_part_texts($item->part, $record->language_id);
115 115
    $item->longdescription($texts->{longdescription})              if !defined $attr->{longdescription};
116 116
    $item->project_id($record->globalproject_id)                   if !defined $attr->{project_id};
117 117
    $item->lastcost($record->is_sales ? $item->part->lastcost : 0) if !defined $attr->{lastcost_as_number};

Auch abrufbar als: Unified diff