From 7749e0e61e5d431a59e33cf497addf9ad682b8af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 15 May 2019 15:18:21 +0200 Subject: [PATCH] =?utf8?q?OrderController:=20nach=20Speichern=20hiddens=20?= =?utf8?q?der=20ids=20wieder=20setzen,=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … falls die Makse nicht neu geladen wird. --- SL/Controller/Order.pm | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 86ccb7297..46e31c336 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -252,8 +252,7 @@ sub action_print { return $self->js->render(); } - $self->js->val('#id', $self->order->id) - ->val('#order_' . $self->nr_key(), $self->order->number); + $self->js_reset_order_and_item_ids_after_save; my $format = $::form->{print_options}->{format}; my $media = $::form->{print_options}->{media}; @@ -423,8 +422,7 @@ sub action_send_email { return $self->js->render(); } - $self->js->val('#id', $self->order->id) - ->val('#order_' . $self->nr_key(), $self->order->number); + $self->js_reset_order_and_item_ids_after_save; my $email_form = delete $::form->{email_form}; my %field_names = (to => 'email'); @@ -1055,6 +1053,27 @@ sub js_redisplay_amounts_and_taxes { ->insertBefore($self->build_tax_rows, '#amount_row_id'); } +sub js_reset_order_and_item_ids_after_save { + my ($self) = @_; + + $self->js + ->val('#id', $self->order->id) + ->val('#converted_from_oe_id', '') + ->val('#order_' . $self->nr_key(), $self->order->number); + + my $idx = 0; + foreach my $form_item_id (@{ $::form->{orderitem_ids} }) { + next if !$self->order->items_sorted->[$idx]->id; + next if $form_item_id !~ m{^new}; + $self->js + ->val ('[name="orderitem_ids[+]"][value="' . $form_item_id . '"]', $self->order->items_sorted->[$idx]->id) + ->val ('#item_' . $form_item_id, $self->order->items_sorted->[$idx]->id) + ->attr('#item_' . $form_item_id, "id", 'item_' . $self->order->items_sorted->[$idx]->id); + $idx++; + } + $self->js->val('[name="converted_from_orderitems_ids[+]"]', ''); +} + # # helpers # -- 2.20.1