Letter: "alle" E-Mail-Adressen per Anhaken als Empfänger
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Thu, 31 Mar 2022 13:48:56 +0000 (15:48 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 4 Apr 2022 11:24:24 +0000 (13:24 +0200)
SL/Controller/Letter.pm
js/kivi.SalesPurchase.js

index 4da3e19..4faf452 100644 (file)
@@ -620,6 +620,8 @@ sub setup_load_letter_draft_action_bar {
 sub setup_display_action_bar {
   my ($self, %params) = @_;
 
+  my $vc = $self->is_sales ? 'customer' : 'vendor'; # needed for show_email_dialog
+
   for my $bar ($::request->layout->get('actionbar')) {
     $bar->add(
       action => [
@@ -655,7 +657,7 @@ sub setup_display_action_bar {
         ],
         action => [
           t8('E-mail'),
-          call     => [ 'kivi.SalesPurchase.show_email_dialog', 'Letter/send_email' ],
+          call     => [ 'kivi.SalesPurchase.show_email_dialog', 'Letter/send_email', $vc, '#letter_' . $vc . '_id' ],
           disabled => !$self->letter->id ? t8('The object has not been saved yet.') : undef,
         ],
       ],
index 2b13dd8..a350e19 100644 (file)
@@ -274,10 +274,13 @@ namespace('kivi.SalesPurchase', function(ns) {
     return true;
   };
 
-  this.show_email_dialog = function(send_action) {
+  this.show_email_dialog = function(send_action, vc, vc_id_selector) {
     $('#form').data('send-email-action', send_action || 'send_sales_purchase_email');
 
-    var vc   = $('#vc').val();
+    vc             = vc             || $('#vc').val();
+    vc_id_selector = vc_id_selector || '#' + vc + '_id';
+    var vc_id = $(vc_id_selector).val();
+
     var data = {
       action:       'show_sales_purchase_email_dialog',
       cp_id:        $('#cp_id').val(),
@@ -295,7 +298,7 @@ namespace('kivi.SalesPurchase', function(ns) {
       quonumber:    $('#quonumber').val(),
       type:         $('#type').val(),
       vc:           vc,
-      vc_id:        $('#' + vc + '_id').val(),
+      vc_id:        vc_id,
       project_id:  $('#globalproject_id').val(),
     };