use SL::PriceSource;
use SL::Webdav;
use SL::File;
+use SL::MIME;
use SL::Util qw(trim);
use SL::YAML;
use SL::DB::Order;
__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
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},
);
}
$_[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.
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 => [
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
=item *
No C<update> is necessary. All entries and calculations are managed
-with ajax-calls and the page does only reload on C<save>.
+with ajax-calls and the page only reloads on C<save>.
=item *