X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/47550141e063ee82dbf29e39d1bb7bd5907e7a01..48c71a4b51f5359a7ab7e9bc51280baf9bc9b9b2:/SL/Controller/Order.pm diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index abe6b0eb8..47ab4e7de 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -10,6 +10,7 @@ use SL::SessionFile::Random; use SL::PriceSource; use SL::Webdav; use SL::File; +use SL::MIME; use SL::Util qw(trim); use SL::YAML; use SL::DB::Order; @@ -47,10 +48,12 @@ use Rose::Object::MakeMethods::Generic __PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('recalc', - only => [ qw(save save_as_new save_and_delivery_order save_and_invoice print send_email) ]); + only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction + print send_email) ]); __PACKAGE__->run_before('get_unalterable_data', - only => [ qw(save save_as_new save_and_delivery_order save_and_invoice print send_email) ]); + only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction + print send_email) ]); # # actions @@ -360,7 +363,7 @@ sub action_download_pdf { my $tmp_filename = $::auth->get_session_value("Order::print-${key}"); return $self->send_file( $tmp_filename, - type => 'application/pdf', + type => SL::MIME->mime_type_from_ext($::form->{pdf_filename}), name => $::form->{pdf_filename}, ); } @@ -647,6 +650,33 @@ sub action_purchase_order { $_[0]->workflow_sales_or_purchase_order(); } +# workflow from purchase order to ap transaction +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 = ( + 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 # # This action is called on an change of the customer/vendor picker. @@ -1694,6 +1724,12 @@ sub setup_edit_action_bar { call => [ 'kivi.Order.save', 'save_and_invoice', $::instance_conf->get_order_warn_duplicate_parts ], checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], ], + action => [ + t8('Save and AP Transaction'), + call => [ 'kivi.Order.save', 'save_and_ap_transaction', $::instance_conf->get_order_warn_duplicate_parts ], + only_if => (any { $self->type eq $_ } (purchase_order_type())) + ], + ], # end of combobox "Workflow" combobox => [