X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FOrder.pm;h=5af72f50a1e3350c47bef578e4a7d7cd05afbc6b;hb=340b402aec62c199176bd58596a79353f7f56d70;hp=508fdfef630383ff6ac04c707f82b1fa927f866b;hpb=95278e0ace83c7d82633799ac638582184df552e;p=kivitendo-erp.git diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 508fdfef6..5af72f50a 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -93,7 +93,7 @@ sub action_delete { flash_later('info', $::locale->text('The order has been deleted')); my @redirect_params = ( - action => 'edit', + action => 'add', type => $self->type, ); @@ -401,6 +401,7 @@ sub action_add_item { return unless $form_attr->{parts_id}; my $item = _new_item($self->order, $form_attr); + $self->order->add_items($item); $self->_recalc(); @@ -413,7 +414,31 @@ sub action_add_item { ); $self->js - ->append('#row_table_id', $row_as_html) + ->append('#row_table_id', $row_as_html); + + if ( $item->part->is_assortment ) { + $form_attr->{qty_as_number} = 1 unless $form_attr->{qty_as_number}; + foreach my $assortment_item ( @{$item->part->assortment_items} ) { + my $attr = { parts_id => $assortment_item->parts_id, + qty => $assortment_item->qty * $::form->parse_amount(\%::myconfig, $form_attr->{qty_as_number}), # TODO $form_attr->{unit} + unit => $assortment_item->unit, + description => $assortment_item->part->description, + }; + my $item = _new_item($self->order, $attr); + $self->order->add_items( $item ); + $self->_recalc(); + my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); + my $row_as_html = $self->p->render('order/tabs/_row', + ITEM => $item, + ID => $item_id, + ALL_PRICE_FACTORS => $self->all_price_factors + ); + $self->js + ->append('#row_table_id', $row_as_html); + }; + }; + + $self->js ->val('.add_item_input', '') ->run('kivi.Order.init_row_handlers') ->run('kivi.Order.row_table_scroll_down') @@ -783,6 +808,8 @@ sub _make_item { $item->assign_attributes(%$attr); $item->longdescription($item->part->notes) if $is_new && !defined $attr->{longdescription}; + # item fields that currently can't be set in in row but are needed: + $item->lastcost($item->part->lastcost) if $is_new; return $item; } @@ -847,7 +874,7 @@ sub _new_item { # recalculate prices and taxes # -# Using the PriceTaxCalclulator. Store linetotals in the item objects. +# Using the PriceTaxCalculator. Store linetotals in the item objects. sub _recalc { my ($self) = @_; @@ -891,9 +918,9 @@ sub _delete { my ($self) = @_; my $errors = []; - my $db = $self->order->db; + my $db = $self->order->db; - $db->do_transaction( + $db->with_transaction( sub { my @spoolfiles = grep { $_ } map { $_->spoolfile } @{ SL::DB::Manager::Status->get_all(where => [ trans_id => $self->order->id ]) }; $self->order->delete; @@ -913,12 +940,11 @@ sub _save { my ($self) = @_; my $errors = []; - my $db = $self->order->db; + my $db = $self->order->db; - $db->do_transaction( - sub { - SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete}; - $self->order->save(cascade => 1); + $db->with_transaction(sub { + SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete}; + $self->order->save(cascade => 1); }) || push(@{$errors}, $db->error); return $errors; @@ -1058,36 +1084,44 @@ The aim is to provide the user a better expirience and a faster flow of work. Also the code should be more readable, more reliable and better to maintain. -=head2 key features +=head2 Key Features -=over 2 +=over 4 =item * + One input row, so that input happens every time at the same place. =item * + Use of pickers where possible. =item * + Possibility to enter more than one item at once. =item * + Save order only on "save" (and "save and delivery order"-workflow). No -hidden save on "print" or "email". +hidden save on "print" or "email". =item * + Item list in a scrollable area, so that the workflow buttons stay at the bottom. =item * + Reordering item rows with drag and drop is possible. Sorting item rows is possible (by partnumber, description, qty, sellprice and discount for now). =item * -No "update" is necessary. All entries and calculations are managed -with ajax-calls and the page does only reload on "save". + +No C is necessary. All entries and calculations are managed +with ajax-calls and the page does only reload on C. =item * + User can see changes immediately, because of the use of java script and ajax. @@ -1095,128 +1129,151 @@ and ajax. =head1 CODE -=head2 layout +=head2 Layout -=over 2 +=over 4 -=item * -SL/Controller/Order.pm: the controller +=item * C -=item * -template/webpages/order/form.html: main form +the controller -=item * -template/webpages/order/tabs/basic_data.html: main tab for basic_data +=item * C