From 048a4ee5e01aaa8cfb416abe919923ffe389ee00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 23 Sep 2015 13:44:38 +0200 Subject: [PATCH] Auftrags-Controller: Funktion "Speichern und Lieferschein". --- SL/Controller/Order.pm | 21 ++++++++++++++++++++- bin/mozilla/oe.pl | 13 +++++++++++++ locale/de/all | 1 + templates/webpages/order/form.html | 9 +++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 75c636ced..858ff0021 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -37,7 +37,7 @@ use Rose::Object::MakeMethods::Generic __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) ]); @@ -241,6 +241,25 @@ sub action_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) = @_; diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index f7cf9331f..91c5a9838 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1934,6 +1934,19 @@ sub delivery_order { $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(); diff --git a/locale/de/all b/locale/de/all index 64c772b38..580cfff76 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2371,6 +2371,7 @@ $self->{texts} = { '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', diff --git a/templates/webpages/order/form.html b/templates/webpages/order/form.html index 63c1d1df3..20b39a232 100644 --- a/templates/webpages/order/form.html +++ b/templates/webpages/order/form.html @@ -33,6 +33,7 @@ [% 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 %] @@ -81,6 +82,14 @@ function email() { $.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' %] -- 2.20.1