__PACKAGE__->run_before('_check_auth');
__PACKAGE__->run_before('_recalc',
- only => [ qw(edit update save create_pdf send_email) ]);
+ only => [ qw(edit update save save_and_delivery_order create_pdf send_email) ]);
__PACKAGE__->run_before('_get_unalterable_data',
only => [ qw(save save_and_delivery_order create_pdf send_email) ]);
->render($self);
}
+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();
+ }
+ flash_later('info', $::locale->text('The order has been saved'));
+
+ my @redirect_params = (
+ controller => 'oe.pl',
+ action => 'oe_delivery_order_from_order',
+ id => $self->order->id,
+ );
+
+ $self->redirect_to(@redirect_params);
+}
sub action_customer_vendor_changed {
my ($self) = @_;
$main::lxdebug->leave_sub();
}
+sub oe_delivery_order_from_order {
+
+ return if !$::form->{id};
+
+ my $order = SL::DB::Order->new(id => $::form->{id})->load;
+ $order->flatten_to_form($::form, format_amounts => 1);
+
+ # fake last empty row
+ $::form->{rowcount}++;
+
+ delivery_order();
+}
+
sub e_mail {
$main::lxdebug->enter_sub();
'Save and AP Transaction' => 'Speichern und Kreditorenbuchung erfassen',
'Save and AR Transaction' => 'Speichern und Debitorenbuchung erfassen',
'Save and Close' => 'Speichern und schließen',
+ 'Save and Delivery Order' => 'Speichern und Lieferschein',
'Save and Invoice' => 'Speichern und Rechnung erfassen',
'Save and Order' => 'Speichern und Auftrag erfassen',
'Save and Quotation' => 'Speichern und Angebot',
[% L.button_tag('save()', LxERP.t8('Save')) %]
[% L.button_tag('create_pdf()', LxERP.t8('Create PDF')) %]
[% L.button_tag('email()', LxERP.t8('E-mail')) %]
+ [% L.button_tag('save_and_delivery_order()', LxERP.t8('Save and Delivery Order')) %]
[%- IF SELF.order.id && ( (SELF.cv == 'customer' && INSTANCE_CONF.get_sales_order_show_delete) || (SELF.cv == 'vendor' && INSTANCE_CONF.get_purchase_order_show_delete) ) %]
[% L.button_tag('delete_order()', LxERP.t8('Delete'), confirm=LxERP.t8("Are you sure?")) %]
[%- END %]
$.post("controller.pl", data, kivi.eval_json_result);
}
+function save_and_delivery_order() {
+ if (!check_cv()) return;
+ var data = $('#order_form').serialize();
+ data += '&action=Order/save_and_delivery_order';
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+}
+
function check_cv() {
if ($('#order_[%- cv_id %]').val() == '') {
[%- IF SELF.cv == 'customer' %]