X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FOrder.pm;h=b51802f629835ba7f9852e650fe6e1b7d3f9c876;hb=ea13b69d6d3a70c5432ae6b6d29a0a0531e51da9;hp=29ff0ac49e7f7d52a1383f27d8e81a751a7274a1;hpb=aeaaea529da843a2e2cd9da37e08d468e5700d9c;p=kivitendo-erp.git diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 29ff0ac49..b51802f62 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -581,27 +581,10 @@ sub action_get_has_active_periodic_invoices { sub action_save_and_delivery_order { my ($self) = @_; - my $errors = $self->save(); - - if (scalar @{ $errors }) { - $self->js->flash('error', $_) foreach @{ $errors }; - return $self->js->render(); - } - - my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved') - : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') - : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') - : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') - : ''; - flash_later('info', $text); - - my @redirect_params = ( + $self->save_and_redirect_to( controller => 'oe.pl', action => 'oe_delivery_order_from_order', - id => $self->order->id, ); - - $self->redirect_to(@redirect_params); } # save the order and redirect to the frontend subroutine for a new @@ -609,27 +592,10 @@ sub action_save_and_delivery_order { sub action_save_and_invoice { my ($self) = @_; - my $errors = $self->save(); - - if (scalar @{ $errors }) { - $self->js->flash('error', $_) foreach @{ $errors }; - return $self->js->render(); - } - - my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved') - : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') - : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') - : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') - : ''; - flash_later('info', $text); - - my @redirect_params = ( + $self->save_and_redirect_to( controller => 'oe.pl', action => 'oe_invoice_from_order', - id => $self->order->id, ); - - $self->redirect_to(@redirect_params); } # workflow from sales quotation to sales order @@ -646,27 +612,10 @@ sub action_purchase_order { sub action_save_and_ap_transaction { my ($self) = @_; - my $errors = $self->save(); - - if (scalar @{ $errors }) { - $self->js->flash('error', $_) foreach @{ $errors }; - return $self->js->render(); - } - - my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved') - : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') - : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') - : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') - : ''; - flash_later('info', $text); - - my @redirect_params = ( + $self->save_and_redirect_to( controller => 'ap.pl', action => 'add_from_purchase_order', - id => $self->order->id, ); - - $self->redirect_to(@redirect_params); } # set form elements in respect to a changed customer or vendor @@ -2111,6 +2060,26 @@ sub nr_key { : ''; } +sub save_and_redirect_to { + my ($self, %params) = @_; + + my $errors = $self->save(); + + if (scalar @{ $errors }) { + $self->js->flash('error', $_) foreach @{ $errors }; + return $self->js->render(); + } + + my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved') + : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved') + : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved') + : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved') + : ''; + flash_later('info', $text); + + $self->redirect_to(%params, id => $self->order->id); +} + 1; __END__