99 |
99 |
);
|
100 |
100 |
}
|
101 |
101 |
|
|
102 |
# edit a collective order (consisting of one or more existing orders)
|
|
103 |
sub action_edit_collective {
|
|
104 |
my ($self) = @_;
|
|
105 |
|
|
106 |
# collect order ids
|
|
107 |
my @multi_ids = map {
|
|
108 |
$_ =~ m{^multi_id_(\d+)$} && $::form->{'multi_id_' . $1} && $::form->{'trans_id_' . $1} && $::form->{'trans_id_' . $1}
|
|
109 |
} grep { $_ =~ m{^multi_id_\d+$} } keys %$::form;
|
|
110 |
|
|
111 |
# fall back to add if no ids are given
|
|
112 |
if (scalar @multi_ids == 0) {
|
|
113 |
$self->action_add();
|
|
114 |
return;
|
|
115 |
}
|
|
116 |
|
|
117 |
# fall back to save as new if only one id is given
|
|
118 |
if (scalar @multi_ids == 1) {
|
|
119 |
$self->order(SL::DB::Order->new(id => $multi_ids[0])->load);
|
|
120 |
$self->action_save_as_new();
|
|
121 |
return;
|
|
122 |
}
|
|
123 |
|
|
124 |
# make new order from given orders
|
|
125 |
my @multi_orders = map { SL::DB::Order->new(id => $_)->load } @multi_ids;
|
|
126 |
$self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders;
|
|
127 |
$self->order(SL::DB::Order->new_from_multi(\@multi_orders, sort_sources_by => 'transdate'));
|
|
128 |
|
|
129 |
$self->action_edit();
|
|
130 |
}
|
|
131 |
|
102 |
132 |
# delete the order
|
103 |
133 |
sub action_delete {
|
104 |
134 |
my ($self) = @_;
|
... | ... | |
1400 |
1430 |
my $db = $self->order->db;
|
1401 |
1431 |
|
1402 |
1432 |
$db->with_transaction(sub {
|
1403 |
|
SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete};
|
|
1433 |
SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete || []};
|
1404 |
1434 |
$self->order->save(cascade => 1);
|
1405 |
1435 |
|
1406 |
1436 |
# link records
|
1407 |
1437 |
if ($::form->{converted_from_oe_id}) {
|
1408 |
|
my $src = SL::DB::Order->new(id => $::form->{converted_from_oe_id})->load;
|
1409 |
|
# implement OE::_close_quotations_rfqs - this a 1 : 1 connection
|
1410 |
|
# close only if workflow: quotation -> order. TODO test case
|
1411 |
|
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/;
|
1412 |
|
$src->link_to_record($self->order);
|
1413 |
|
|
|
1438 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id};
|
|
1439 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) {
|
|
1440 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load;
|
|
1441 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/;
|
|
1442 |
$src->link_to_record($self->order);
|
|
1443 |
}
|
1414 |
1444 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) {
|
1415 |
1445 |
my $idx = 0;
|
1416 |
1446 |
foreach (@{ $self->order->items_sorted }) {
|
Auftrags-Controller: Aufträge auch mit neuem Controller zusammenfassen können