Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3f055eaf

Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt

  • ID 3f055eafce38dafed88437c5d428a72cceb22b6b
  • Vorgänger 6daa0eca
  • Nachfolger 966976a7

Auftrags-Controller: neuen Artikel aus Maske heraus anlegen können

Todo: Im Moment können nur Waren angelegt werden. Es müsste ein Mini-Select
geben, wo man zwischen Waren/Dienstleistungen/Erzeugnissen/Sortimenten/...
wählen kann.

Übernahme aus anderem Kundenprojekt

Unterschiede anzeigen:

SL/Controller/Order.pm
976 976
  $self->render_price_dialog($item);
977 977
}
978 978

  
979
# save the order in a session variable and redirect to the part controller
980
sub action_create_part {
981
  my ($self) = @_;
982

  
983
  my $previousform = $::auth->save_form_in_session(non_scalars => 1);
984

  
985
  my $callback     = $self->url_for(
986
    action       => 'return_from_create_part',
987
    type         => $self->type, # type is needed for check_auth on return
988
    previousform => $previousform,
989
  );
990

  
991
  flash_later('info', t8('You are adding a new part while you are editing another document. You will be redirected to your document when saving the new part or aborting this form.'));
992

  
993
  my @redirect_params = (
994
    controller => 'Part',
995
    action     => 'add',
996
    part_type  => 'part',
997
    callback   => $callback,
998
    show_abort => 1,
999
  );
1000

  
1001
  $self->redirect_to(@redirect_params);
1002
}
1003

  
1004
sub action_return_from_create_part {
1005
  my ($self) = @_;
1006

  
1007
  $self->{created_part} = SL::DB::Part->new(id => delete $::form->{new_parts_id})->load if $::form->{new_parts_id};
1008

  
1009
  $::auth->restore_form_from_session(delete $::form->{previousform});
1010

  
1011
  # set item ids to new fake id, to identify them as new items
1012
  foreach my $item (@{$self->order->items_sorted}) {
1013
    $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
1014
  }
1015

  
1016
  $self->recalc();
1017
  $self->get_unalterable_data();
1018
  $self->pre_render();
1019

  
1020
  # trigger rendering values for second row/longdescription as hidden,
1021
  # because they are loaded only on demand. So we need to keep the values
1022
  # from the source.
1023
  $_->{render_second_row}      = 1 for @{ $self->order->items_sorted };
1024
  $_->{render_longdescription} = 1 for @{ $self->order->items_sorted };
1025

  
1026
  $self->render(
1027
    'order/form',
1028
    title => $self->get_title_for('edit'),
1029
    %{$self->{template_args}}
1030
  );
1031

  
1032
}
1033

  
979 1034
# load the second row for one or more items
980 1035
#
981 1036
# This action gets the html code for all items second rows by rendering a template for

Auch abrufbar als: Unified diff