Revision 4c84466a
Von Tamino Steinert vor etwa 1 Jahr hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
|
||
return unless $form_attr->{parts_id};
|
||
|
||
my $item = new_item($self->order, $form_attr);
|
||
my $item = $self->new_item($self->order, $form_attr);
|
||
|
||
$self->order->add_items($item);
|
||
|
||
... | ... | |
unit => $assortment_item->unit,
|
||
description => $assortment_item->part->description,
|
||
};
|
||
my $item = new_item($self->order, $attr);
|
||
my $item = $self->new_item($self->order, $attr);
|
||
|
||
# set discount to 100% if item isn't supposed to be charged, overwriting any customer discount
|
||
$item->discount(1) unless $assortment_item->charge;
|
||
... | ... | |
|
||
my @items;
|
||
foreach my $attr (@form_attr) {
|
||
my $item = new_item($self->order, $attr);
|
||
my $item = $self->new_item($self->order, $attr);
|
||
push @items, $item;
|
||
if ( $item->part->is_assortment ) {
|
||
foreach my $assortment_item ( @{$item->part->assortment_items} ) {
|
||
... | ... | |
unit => $assortment_item->unit,
|
||
description => $assortment_item->part->description,
|
||
};
|
||
my $item = new_item($self->order, $attr);
|
||
my $item = $self->new_item($self->order, $attr);
|
||
|
||
# set discount to 100% if item isn't supposed to be charged, overwriting any customer discount
|
||
$item->discount(1) unless $assortment_item->charge;
|
||
... | ... | |
foreach my $item_id (@{ $::form->{item_ids} }) {
|
||
my $idx = first_index { $_ eq $item_id } @{ $::form->{orderitem_ids} };
|
||
my $item = $self->order->items_sorted->[$idx];
|
||
my $texts = get_part_texts($item->part, $self->order->language_id);
|
||
my $texts = $self->get_part_texts($item->part, $self->order->language_id);
|
||
|
||
$item->description($texts->{description});
|
||
$item->longdescription($texts->{longdescription});
|
||
... | ... | |
#
|
||
# This is used to add one item
|
||
sub new_item {
|
||
my ($record, $attr) = @_;
|
||
my ($self, $record, $attr) = @_;
|
||
|
||
my $item = SL::DB::OrderItem->new;
|
||
|
||
... | ... | |
# saved. Adding empty custom_variables to new orderitem here solves this problem.
|
||
$new_attr{custom_variables} = [];
|
||
|
||
my $texts = get_part_texts($item->part, $record->language_id, description => $new_attr{description}, longdescription => $new_attr{longdescription});
|
||
my $texts = $self->get_part_texts($item->part, $record->language_id, description => $new_attr{description}, longdescription => $new_attr{longdescription});
|
||
|
||
$item->assign_attributes(%new_attr, %{ $texts });
|
||
|
||
... | ... | |
}
|
||
|
||
sub get_part_texts {
|
||
my ($part_or_id, $language_or_id, %defaults) = @_;
|
||
my ($self, $part_or_id, $language_or_id, %defaults) = @_;
|
||
|
||
my $part = ref($part_or_id) ? $part_or_id : SL::DB::Part->load_cached($part_or_id);
|
||
my $language_id = ref($language_or_id) ? $language_or_id->id : $language_or_id;
|
SL/Controller/RecordBase.pm | ||
---|---|---|
my @items;
|
||
my $pos = 1;
|
||
foreach my $form_attr (@{$form_items}) {
|
||
my $item = make_item($record, $form_attr);
|
||
my $item = $self->make_item($record, $form_attr);
|
||
$item->position($pos);
|
||
push @items, $item;
|
||
$pos++;
|
||
... | ... | |
# Make item objects from form values. For items already existing read from db.
|
||
# Create a new item else. And assign attributes.
|
||
sub make_item {
|
||
my ($record, $attr) = @_;
|
||
my ($self, $record, $attr) = @_;
|
||
|
||
my $item;
|
||
$item = first { $_->id == $attr->{id} } @{$record->items} if $attr->{id};
|
||
... | ... | |
$item->assign_attributes(%$attr);
|
||
|
||
if ($is_new) {
|
||
my $texts = get_part_texts($item->part, $record->language_id);
|
||
my $texts = $self->get_part_texts($item->part, $record->language_id);
|
||
$item->longdescription($texts->{longdescription}) if !defined $attr->{longdescription};
|
||
$item->project_id($record->globalproject_id) if !defined $attr->{project_id};
|
||
$item->lastcost($record->is_sales ? $item->part->lastcost : 0) if !defined $attr->{lastcost_as_number};
|
Auch abrufbar als: Unified diff
FIX: S:C:RecordBase: rufe alle Funktionen auf self auf.