Auftrags-Controller: Funktion "Speichern und Lieferschein".
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 23 Sep 2015 11:44:38 +0000 (13:44 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Mon, 16 Nov 2015 15:15:58 +0000 (16:15 +0100)
SL/Controller/Order.pm
templates/webpages/order/form.html

index 17e1d7d..8c3ca54 100644 (file)
@@ -36,7 +36,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) ]);
 
 
 #
@@ -212,6 +212,29 @@ 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($self);
+  }
+
+  my $delivery_order = $self->order->convert_to_delivery_order($self->order);
+
+  flash_later('info', $::locale->text('The order has been saved'));
+  my @redirect_params = (
+    controller => 'do.pl',
+    action     => 'edit',
+    type       => $delivery_order->type,
+    id         => $delivery_order->id,
+    vc         => $delivery_order->is_sales ? 'customer' : 'vendor',
+  );
+
+  $self->redirect_to(@redirect_params);
+}
 
 sub action_customer_vendor_changed {
   my ($self) = @_;
index ae226b0..a1d90e1 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')) %]
 
 </form>
 
@@ -68,4 +69,11 @@ function email() {
   $.post("controller.pl", data, kivi.eval_json_result);
 }
 
+function save_and_delivery_order() {
+  var data = $('#order_form').serialize();
+  data += '&action=Order/save_and_delivery_order';
+
+  $.post("controller.pl", data, kivi.eval_json_result);
+}
+
 </script>