Revision b07f8ec2
Von Tamino Steinert vor etwa 2 Jahren hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
105 | 105 |
|
106 | 106 |
require SL::DB::Reclamation; |
107 | 107 |
my $reclamation = SL::DB::Reclamation->new(id => $::form->{from_id})->load; |
108 |
my ($delivery_order, $error) = $reclamation->convert_to_delivery_order(); |
|
109 |
if($error) { |
|
110 |
croak("Error while converting: " . $error); |
|
111 |
} |
|
112 |
|
|
108 |
my $delivery_order = SL::DB::DeliveryOrder->new_from($reclamation); |
|
109 |
$self->{converted_from_reclamation_id} = $::form->{from_id}; |
|
113 | 110 |
$self->order($delivery_order); |
114 | 111 |
|
115 | 112 |
$self->action_add; |
... | ... | |
1173 | 1170 |
$self->js |
1174 | 1171 |
->val('#id', $self->order->id) |
1175 | 1172 |
->val('#converted_from_oe_id', '') |
1173 |
->val('#converted_from_reclamation_id', '') |
|
1176 | 1174 |
->val('#order_' . $self->nr_key(), $self->order->number); |
1177 | 1175 |
|
1178 | 1176 |
my $idx = 0; |
... | ... | |
1187 | 1185 |
$idx++; |
1188 | 1186 |
} |
1189 | 1187 |
$self->js->val('[name="converted_from_orderitems_ids[+]"]', ''); |
1188 |
$self->js->val('[name="converted_from_reclamation_items_ids[+]"]', ''); |
|
1190 | 1189 |
} |
1191 | 1190 |
|
1192 | 1191 |
# |
... | ... | |
1639 | 1638 |
} |
1640 | 1639 |
} |
1641 | 1640 |
} |
1641 |
if ($::form->{converted_from_reclamation_id}) { |
|
1642 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
|
1643 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
1644 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
1645 |
$src->link_to_record($self->order); |
|
1646 |
} |
|
1647 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
1648 |
my $idx = 0; |
|
1649 |
foreach (@{ $self->order->items_sorted }) { |
|
1650 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
1651 |
next if !$from_id; |
|
1652 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
1653 |
from_id => $from_id, |
|
1654 |
to_table => 'orderitems', |
|
1655 |
to_id => $_->id |
|
1656 |
)->save; |
|
1657 |
$idx++; |
|
1658 |
} |
|
1659 |
} |
|
1660 |
} |
|
1642 | 1661 |
|
1643 | 1662 |
$self->save_history('SAVED'); |
1644 | 1663 |
|
Auch abrufbar als: Unified diff
Reclamation: don't save delivery_order after converting