From 3a35d09fe5d6dbba593d2560888e7c44421c59e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 26 Sep 2018 16:05:28 +0200 Subject: [PATCH] Auftrags-Controller: Beleg vor drucken und E-mailen speichern. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Das nur bei "speichern" auch gespeichert wird, ist vielleicht konsequent, aber im Alltag eher unpraktisch. Viele Anwender hatten damit ein Problem, dass die verschickte oder gedruckte Version des Belegs anders ist, als die gespeicherte, weil oft nicht daran gedacht wurde, nach der letzten Änderung und nach dem Drucken/versenden nochmals zu speichern. Deshalb wird jetzt beim Drucken und E-Mailen immer gespeichert. --- SL/Controller/Order.pm | 36 +++++++++++++++++++++++++++--------- js/kivi.Order.js | 16 ++++++++++------ js/locale/de.js | 2 ++ js/locale/en.js | 2 ++ locale/de/all | 4 ++++ locale/en/all | 4 ++++ 6 files changed, 49 insertions(+), 15 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 976f62f0c..56326b51c 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -210,6 +210,16 @@ sub action_save_as_new { sub action_print { my ($self) = @_; + my $errors = $self->save(); + + if (scalar @{ $errors }) { + $self->js->flash('error', $_) foreach @{ $errors }; + return $self->js->render(); + } + + $self->js->val('#id', $self->order->id) + ->val('#order_' . $self->nr_key(), $self->order->number); + my $format = $::form->{print_options}->{format}; my $media = $::form->{print_options}->{media}; my $formname = $::form->{print_options}->{formname}; @@ -370,6 +380,17 @@ sub action_show_email_dialog { sub action_send_email { my ($self) = @_; + my $errors = $self->save(); + + if (scalar @{ $errors }) { + $self->js->run('kivi.Order.close_email_dialog'); + $self->js->flash('error', $_) foreach @{ $errors }; + return $self->js->render(); + } + + $self->js->val('#id', $self->order->id) + ->val('#order_' . $self->nr_key(), $self->order->number); + my $email_form = delete $::form->{email_form}; my %field_names = (to => 'email'); @@ -417,6 +438,8 @@ sub action_send_email { $intnotes .= t8('Subject') . ": " . $::form->{subject} . "\n\n"; $intnotes .= t8('Message') . ": " . $::form->{message}; + $self->order->update_attributes(intnotes => $intnotes); + $self->js ->val('#order_intnotes', $intnotes) ->run('kivi.Order.close_email_dialog') @@ -1565,12 +1588,12 @@ sub setup_edit_action_bar { t8('Export'), ], action => [ - t8('Print'), - call => [ 'kivi.Order.show_print_options' ], + t8('Save and print'), + call => [ 'kivi.Order.show_print_options', $::instance_conf->get_order_warn_duplicate_parts ], ], action => [ - t8('E-mail'), - call => [ 'kivi.Order.email' ], + t8('Save and E-mail'), + call => [ 'kivi.Order.email', $::instance_conf->get_order_warn_duplicate_parts ], ], action => [ t8('Download attachments of all parts'), @@ -1790,11 +1813,6 @@ Possibility to enter more than one item at once. =item * -Save order only on "save" (and "save and delivery order"-workflow). No -hidden save on "print" or "email". - -=item * - Item list in a scrollable area, so that the workflow buttons stay at the bottom. diff --git a/js/kivi.Order.js b/js/kivi.Order.js index a5a8c3168..3e065522d 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -14,7 +14,7 @@ namespace('kivi.Order', function(ns) { return true; }; - ns.check_save_duplicate_parts = function() { + ns.check_duplicate_parts = function(question) { var id_arr = $('[name="order.orderitems[].parts_id"]').map(function() { return this.value; }).get(); var i, obj = {}, pos = []; @@ -28,9 +28,10 @@ namespace('kivi.Order', function(ns) { } if (pos.length > 0) { + question = question || kivi.t8("Do you really want to save?"); return confirm(kivi.t8("There are duplicate parts at positions") + "\n" + pos.join(', ') + "\n" - + kivi.t8("Do you really want to save?")); + + question); } return true; }; @@ -46,8 +47,8 @@ namespace('kivi.Order', function(ns) { ns.save = function(action, warn_on_duplicates, warn_on_reqdate) { if (!ns.check_cv()) return; - if (warn_on_duplicates && !ns.check_save_duplicate_parts()) return; - if (warn_on_reqdate && !ns.check_valid_reqdate()) return; + if (warn_on_duplicates && !ns.check_duplicate_parts()) return; + if (warn_on_reqdate && !ns.check_valid_reqdate()) return; var data = $('#order_form').serializeArray(); data.push({ name: 'action', value: 'Order/' + action }); @@ -62,8 +63,9 @@ namespace('kivi.Order', function(ns) { $.post("controller.pl", data, kivi.eval_json_result); }; - ns.show_print_options = function() { + ns.show_print_options = function(warn_on_duplicates) { if (!ns.check_cv()) return; + if (warn_on_duplicates && !ns.check_duplicate_parts(kivi.t8("Do you really want to print?"))) return; kivi.popup_dialog({ id: 'print_options', @@ -93,8 +95,10 @@ namespace('kivi.Order', function(ns) { $.download("controller.pl", data); }; - ns.email = function() { + 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: 'action', value: 'Order/show_email_dialog' }); diff --git a/js/locale/de.js b/js/locale/de.js index 13218ae2a..daad4caf4 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -43,8 +43,10 @@ namespace("kivi").setupLocale({ "Do you really want to delete the selected documents?":"Möchten Sie wirklich diese Dateien löschen?", "Do you really want to delete this draft?":"Möchten Sie diesen Entwurf wirklich löschen?", "Do you really want to delete this record template?":"Möchten Sie diese Belegvorlage wirklich löschen?", +"Do you really want to print?":"Wollen Sie wirklich drucken?", "Do you really want to revert to this version?":"Möchten Sie wirklich auf diese Version zurücksetzen?", "Do you really want to save?":"Möchten Sie wirklich speichern?", +"Do you really want to send by mail?":"Wollen Sie den Beleg wirklich per Mail verschicken?", "Do you really want to unimport the selected documents?":"Möchten Sie wirklich diese Dateien an die Quelle zurückgeben?", "Do you want to set the account number \"#1\" to \"#2\" and the name \"#3\" to \"#4\"?":"Soll die Kontonummer \"#1\" zu \"#2\" und den Name \"#3\" zu \"#4\" geändert werden?", "Download picture":"Bild herunterladen", diff --git a/js/locale/en.js b/js/locale/en.js index dfcfb0101..87bc1b7b7 100644 --- a/js/locale/en.js +++ b/js/locale/en.js @@ -43,8 +43,10 @@ namespace("kivi").setupLocale({ "Do you really want to delete the selected documents?":"", "Do you really want to delete this draft?":"", "Do you really want to delete this record template?":"", +"Do you really want to print?":"", "Do you really want to revert to this version?":"", "Do you really want to save?":"", +"Do you really want to send by mail?":"", "Do you really want to unimport the selected documents?":"", "Do you want to set the account number \"#1\" to \"#2\" and the name \"#3\" to \"#4\"?":"", "Download picture":"", diff --git a/locale/de/all b/locale/de/all index 72aab61e7..79784f9c3 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1033,8 +1033,10 @@ $self->{texts} = { 'Do you really want to delete this draft?' => 'Möchten Sie diesen Entwurf wirklich löschen?', 'Do you really want to delete this object?' => 'Möchten Sie dieses Objekt wirklich löschen?', 'Do you really want to delete this record template?' => 'Möchten Sie diese Belegvorlage wirklich löschen?', + 'Do you really want to print?' => 'Wollen Sie wirklich drucken?', 'Do you really want to revert to this version?' => 'Möchten Sie wirklich auf diese Version zurücksetzen?', 'Do you really want to save?' => 'Möchten Sie wirklich speichern?', + 'Do you really want to send by mail?' => 'Wollen Sie den Beleg wirklich per Mail verschicken?', 'Do you really want to undo the selected SEPA exports? You have to reassign the export again.' => 'Möchten Sie wirklich die ausgewählten SEPA-Exports rückgängig machen? Der Export muss anschließend neu erzeugt werden.', 'Do you really want to unimport the selected documents?' => 'Möchten Sie wirklich diese Dateien an die Quelle zurückgeben?', 'Do you want to limit your search?' => 'Möchten Sie Ihre Suche spezialisieren?', @@ -2703,6 +2705,7 @@ $self->{texts} = { 'Save and AR Transaction' => 'Speichern und Debitorenbuchung erfassen', 'Save and Close' => 'Speichern und schließen', 'Save and Delivery Order' => 'Speichern und Lieferschein', + 'Save and E-mail' => 'Speichern und E-Mail', 'Save and Invoice' => 'Speichern und Rechnung erfassen', 'Save and Order' => 'Speichern und Auftrag erfassen', 'Save and Quotation' => 'Speichern und Angebot', @@ -2710,6 +2713,7 @@ $self->{texts} = { 'Save and close' => 'Speichern und schließen', 'Save and execute' => 'Speichern und ausführen', 'Save and keep open' => 'Speichern und geöffnet lassen', + 'Save and print' => 'Speichern und drucken', 'Save as a new draft.' => 'Als neuen Entwurf speichern', 'Save as new' => 'Als neu speichern', 'Save document in WebDAV repository' => 'Dokument in WebDAV-Ablage speichern', diff --git a/locale/en/all b/locale/en/all index 2cdf5b8ff..8d898c4bb 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1033,8 +1033,10 @@ $self->{texts} = { 'Do you really want to delete this draft?' => '', 'Do you really want to delete this object?' => '', 'Do you really want to delete this record template?' => '', + 'Do you really want to print?' => '', 'Do you really want to revert to this version?' => '', 'Do you really want to save?' => '', + 'Do you really want to send by mail?' => '', 'Do you really want to undo the selected SEPA exports? You have to reassign the export again.' => '', 'Do you really want to unimport the selected documents?' => '', 'Do you want to limit your search?' => '', @@ -2700,6 +2702,7 @@ $self->{texts} = { 'Save and AR Transaction' => '', 'Save and Close' => '', 'Save and Delivery Order' => '', + 'Save and E-mail' => '', 'Save and Invoice' => '', 'Save and Order' => '', 'Save and Quotation' => '', @@ -2707,6 +2710,7 @@ $self->{texts} = { 'Save and close' => '', 'Save and execute' => '', 'Save and keep open' => '', + 'Save and print' => '', 'Save as a new draft.' => '', 'Save as new' => '', 'Save document in WebDAV repository' => '', -- 2.20.1