Auftrags-Controller: Speichern und E-Mail-Dialog über vorhandene Funktion
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 22 Sep 2020 14:18:31 +0000 (16:18 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 22 Sep 2020 15:42:13 +0000 (17:42 +0200)
Die js-Funktion email() tut praktisch das gleiche wie save(). Dann kann
auch diese benutzt werden.
Damit auch klar ist, dass vor dem Aufruf des E-Mail-Dialogs gespeichert
wird, ist die action im Controller umbenannt worden.

SL/Controller/Order.pm
js/kivi.Order.js

index 4f2abe5..12b9bae 100644 (file)
@@ -350,7 +350,7 @@ sub action_print {
 }
 
 # open the email dialog
-sub action_show_email_dialog {
+sub action_save_and_show_email_dialog {
   my ($self) = @_;
 
   my $errors = $self->save();
@@ -1884,7 +1884,7 @@ sub setup_edit_action_bar {
         ],
         action => [
           t8('Save and E-mail'),
-          call => [ 'kivi.Order.email', $::instance_conf->get_order_warn_duplicate_parts ],
+          call => [ 'kivi.Order.save', 'save_and_show_email_dialog', $::instance_conf->get_order_warn_duplicate_parts ],
         ],
         action => [
           t8('Download attachments of all parts'),
index a62be88..288af2d 100644 (file)
@@ -28,7 +28,7 @@ namespace('kivi.Order', function(ns) {
     }
 
     if (pos.length > 0) {
-      question = question || kivi.t8("Do you really want to save?");
+      question = question || kivi.t8("Do you really want to continue?");
       return confirm(kivi.t8("There are duplicate parts at positions") + "\n"
                      + pos.join(', ') + "\n"
                      + question);
@@ -89,17 +89,6 @@ namespace('kivi.Order', function(ns) {
     $.post("controller.pl", data, kivi.eval_json_result);
   };
 
-  ns.email = function(warn_on_duplicates) {
-    if (warn_on_duplicates && !ns.check_duplicate_parts(kivi.t8("Do you really want to send by mail?"))) return;
-    if (!ns.check_cv()) return;
-
-    var data = $('#order_form').serializeArray();
-    data.push({ name: 'order.language_id', value: $('#language_id').val() }); // language from print options
-    data.push({ name: 'action', value: 'Order/show_email_dialog' });
-
-    $.post("controller.pl", data, kivi.eval_json_result);
-  };
-
   var email_dialog;
 
   ns.setup_send_email_dialog = function() {