]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/io.pl
Rechnungsversand E-Mail-Body
[mfinanz.git] / bin / mozilla / io.pl
index 96141c0ecf09cb4faef700930cd4abee1f723aef..a4a416b95c1909bfdc9e72710674dd10deb3204d 100644 (file)
@@ -910,7 +910,7 @@ sub order {
 
   _order();
 
-  if ($::instance_conf->get_feature_experimental) {
+  if ($::instance_conf->get_feature_experimental_order) {
     my $order = _make_record();
     $order->globalproject_id(undef) if !$order->globalproject_id;
     $order->payment_id(undef)       if !$order->payment_id;
@@ -1040,7 +1040,7 @@ sub quotation {
   if ($form->{second_run}) {
     $form->{print_and_post} = 0;
   }
delete $form->{$_} foreach (qw(id printed emailed queued quonumber));
 delete $form->{$_} foreach (qw(id printed emailed queued quonumber transaction_description));
 
   my $buysell;
   if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
@@ -2020,10 +2020,21 @@ sub _get_files_for_email_dialog {
 
 sub show_sales_purchase_email_dialog {
   my $email = '';
+  my $email_cc = '';
+  my $inv_email;
   if ($::form->{cp_id}) {
     $email = SL::DB::Contact->load_cached($::form->{cp_id})->cp_email;
   }
-
+  if ($::form->{type} eq 'invoice' && (!$email || $::instance_conf->get_invoice_mail_settings ne 'cp')) {
+    # check for invoice_mail if defined (vc.invoice_email)
+    $inv_email = SL::DB::Customer->load_cached($::form->{vc_id})->invoice_mail;
+    if ($inv_email) {
+      # check if cc for contact is also wanted
+      $email_cc = $email if ($::instance_conf->get_invoice_mail_settings eq 'invoice_mail_cc_cp');
+      $email    = $inv_email;
+    }
+  }
+  # still no email? use general mail (vc.email)
   if (!$email && $::form->{vc} && $::form->{vc_id}) {
     $email = SL::DB::Customer->load_cached($::form->{vc_id})->email if 'customer' eq $::form->{vc};
     $email = SL::DB::Vendor  ->load_cached($::form->{vc_id})->email if 'vendor'   eq $::form->{vc};
@@ -2033,8 +2044,9 @@ sub show_sales_purchase_email_dialog {
 
   my $email_form = {
     to                  => $email,
+    cc                  => $email_cc,
     subject             => $::form->generate_email_subject,
-    message             => $::form->generate_email_body,
+    message             => $::form->generate_email_body('inv_email' => $inv_email),
     attachment_filename => $::form->generate_attachment_filename,
     js_send_function    => 'kivi.SalesPurchase.send_email()',
   };
@@ -2045,6 +2057,7 @@ sub show_sales_purchase_email_dialog {
     show_bcc    => $::auth->assert('email_bcc', 'may fail'),
     FILES       => \%files,
     is_customer => $::form->{vc} eq 'customer',
+    is_invoice_mail => $inv_email,
   });
 
   print $::form->ajax_response_header, $html;