X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FOrder.pm;h=72a27ae85c9a370dcec0551401b1168e4effe57a;hb=6ac03ba6aedbcfa3377a5803033d7fdbba002750;hp=88ff3d296a7862f59a1db828676820b4bde0578b;hpb=8ad661b7c9af26d9b0b5b565121bbdd735db6217;p=kivitendo-erp.git diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 88ff3d296..72a27ae85 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -598,6 +598,16 @@ sub action_save_and_invoice { ); } +# workflow from sales order to sales quotation +sub action_sales_quotation { + $_[0]->workflow_sales_or_request_for_quotation(); +} + +# workflow from sales order to sales quotation +sub action_request_for_quotation { + $_[0]->workflow_sales_or_request_for_quotation(); +} + # workflow from sales quotation to sales order sub action_sales_order { $_[0]->workflow_sales_or_purchase_order(); @@ -1580,6 +1590,49 @@ sub save { return $errors; } +sub workflow_sales_or_request_for_quotation { + my ($self) = @_; + + # always save + my $errors = $self->save(); + + if (scalar @{ $errors }) { + $self->js->flash('error', $_) for @{ $errors }; + return $self->js->render(); + } + + my $destination_type = $::form->{type} eq sales_order_type() ? sales_quotation_type() : request_quotation_type(); + + $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type)); + $self->{converted_from_oe_id} = delete $::form->{id}; + + # set item ids to new fake id, to identify them as new items + foreach my $item (@{$self->order->items_sorted}) { + $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); + } + + # change form type + $::form->{type} = $destination_type; + $self->type($self->init_type); + $self->cv ($self->init_cv); + $self->check_auth; + + $self->recalc(); + $self->get_unalterable_data(); + $self->pre_render(); + + # trigger rendering values for second row as hidden, because they + # are loaded only on demand. So we need to keep the values from the + # source. + $_->{render_second_row} = 1 for @{ $self->order->items_sorted }; + + $self->render( + 'order/form', + title => $self->get_title_for('edit'), + %{$self->{template_args}} + ); +} + sub workflow_sales_or_purchase_order { my ($self) = @_; @@ -1738,6 +1791,16 @@ sub setup_edit_action_bar { action => [ t8('Workflow'), ], + action => [ + t8('Save and Quotation'), + submit => [ '#order_form', { action => "Order/sales_quotation" } ], + only_if => (any { $self->type eq $_ } (sales_order_type())), + ], + action => [ + t8('Save and RFQ'), + submit => [ '#order_form', { action => "Order/request_for_quotation" } ], + only_if => (any { $self->type eq $_ } (purchase_order_type())), + ], action => [ t8('Save and Sales Order'), submit => [ '#order_form', { action => "Order/sales_order" } ], @@ -2148,10 +2211,6 @@ java script functions =item * testing -=item * credit limit - -=item * more workflows (quotation, rfq) - =item * price sources: little symbols showing better price / better discount =item * select units in input row?