X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a66591ccf74ff3d32ac31b6a91849a0476e54eb7..48c71a4b51f5359a7ab7e9bc51280baf9bc9b9b2:/SL/Controller/Order.pm?ds=sidebyside diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 2f4a68f2b..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 => [ @@ -1916,9 +1952,8 @@ SL::Controller::Order - controller for orders This is a new form to enter orders, completely rewritten with the use of controller and java script techniques. -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. +The aim is to provide the user a better experience and a faster workflow. Also +the code should be more readable, more reliable and better to maintain. =head2 Key Features @@ -1949,7 +1984,7 @@ possible (by partnumber, description, qty, sellprice and discount for now). =item * No C is necessary. All entries and calculations are managed -with ajax-calls and the page does only reload on C. +with ajax-calls and the page only reloads on C. =item *