Auftrags-Controller: Funktion "Speichern und Lieferschein".
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 23 Sep 2015 11:44:38 +0000 (13:44 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 11 Mar 2016 11:45:30 +0000 (12:45 +0100)
SL/Controller/Order.pm
bin/mozilla/oe.pl
locale/de/all
templates/webpages/order/form.html

index 75c636c..858ff00 100644 (file)
@@ -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) = @_;
index f7cf933..91c5a98 100644 (file)
@@ -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();
 
index 64c772b..580cfff 100755 (executable)
@@ -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',
index 63c1d1d..20b39a2 100644 (file)
@@ -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' %]