X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d5f8550f93598ba0eb6d65a5dcaaa18e1b7cb880..b647f3f3a3357e366d2faa25069230eb1cf8e9e9:/SL/Controller/Order.pm diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 631ab16dd..741476603 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -326,7 +326,7 @@ sub action_save_and_delivery_order { $self->redirect_to(@redirect_params); } -# set form elements in respect of a changed customer or vendor +# set form elements in respect to a changed customer or vendor # # This action is called on an change of the customer/vendor picker. sub action_customer_vendor_changed { @@ -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') @@ -452,7 +477,7 @@ sub action_multi_items_update_result { } } -# add item rows for multiple items add once +# add item rows for multiple items at once sub action_add_multi_items { my ($self) = @_; @@ -500,7 +525,7 @@ sub action_recalc_amounts_and_taxes { $self->js->render(); } -# redisplay item rows if the are sorted by an attribute +# redisplay item rows if they are sorted by an attribute sub action_reorder_items { my ($self) = @_; @@ -538,7 +563,7 @@ sub action_price_popup { # longdescription was opened and the longdescription is empty # # If this item is new, get the longdescription from Part. -# Get it from OrderItem else. +# Otherwise get it from OrderItem. sub action_get_item_longdescription { my $longdescription;