]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/io.pl
Rechte zum Bearbeiten von Preisen in Belgen getrennt nach VK/EK anwenden
[mfinanz.git] / bin / mozilla / io.pl
index 8f2a3156ecd79a7d0c89e5d2a478e69e7f0d6d03..eff922e18ba4727166fc8bdbc7d9ce4918cb8853 100644 (file)
@@ -126,8 +126,6 @@ sub _check_io_auth {
 sub display_row {
   $main::lxdebug->enter_sub();
 
-  _check_io_auth();
-
   my $form     = $main::form;
   my %myconfig = %main::myconfig;
   my $locale   = $main::locale;
@@ -373,8 +371,9 @@ sub display_row {
       }
     }
 
-    my $edit_prices     = $main::auth->assert('edit_prices', 1) && (!$::form->{"active_price_source_$i"} || !$price || $price->editable);
-    my $edit_discounts  = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"};
+    my $right_to_edit_prices  = (!$is_purchase && $main::auth->assert('sales_edit_prices', 1)) || ($is_purchase && $main::auth->assert('purchase_edit_prices', 1));
+    my $edit_prices           = $right_to_edit_prices && (!$::form->{"active_price_source_$i"} || !$price || $price->editable);
+    my $edit_discounts        = $right_to_edit_prices && !$::form->{"active_discount_source_$i"};
     $column_data{sellprice}   = (!$edit_prices)
                                 ? $cgi->hidden(   -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value
                                 : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -class => "numeric", -value => $sellprice_value);
@@ -1655,8 +1654,6 @@ sub relink_accounts {
   my $form     = $main::form;
   my %myconfig = %main::myconfig;
 
-  _check_io_auth();
-
   $form->{"taxaccounts"} =~ s/\s*$//;
   $form->{"taxaccounts"} =~ s/^\s*//;
   foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
@@ -2021,17 +2018,29 @@ sub _get_files_for_email_dialog {
 sub show_sales_purchase_email_dialog {
   my $email = '';
   my $email_cc = '';
-  my $inv_email;
+  my $record_email;
   if ($::form->{cp_id}) {
     $email = SL::DB::Contact->load_cached($::form->{cp_id})->cp_email;
   }
+  # write a dispatch table if a third type enters
+  # check record mail for sales_invoice
   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) {
+    $record_email = SL::DB::Customer->load_cached($::form->{vc_id})->invoice_mail;
+    if ($record_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;
+      $email    = $record_email;
+    }
+  }
+  # check record mail for sales_delivery_order
+  if ($::form->{type} eq 'sales_delivery_order') {
+    # check for deliver_order_mail if defined (vc.delivery_order_mail)
+    $record_email = SL::DB::Customer->load_cached($::form->{vc_id})->delivery_order_mail;
+    if ($record_email) {
+      # check if cc for contact is also wanted
+      $email_cc = $email; # always cc to cp
+      $email    = $record_email;
     }
   }
   # still no email? use general mail (vc.email)
@@ -2042,11 +2051,14 @@ sub show_sales_purchase_email_dialog {
 
   $email = '' if $::form->{type} eq 'purchase_delivery_order';
 
+  $::form->{language} = $::form->get_template_language(\%::myconfig);
+  $::form->{language} = "_" . $::form->{language};
+
   my $email_form = {
     to                  => $email,
     cc                  => $email_cc,
     subject             => $::form->generate_email_subject,
-    message             => $::form->generate_email_body,
+    message             => $::form->generate_email_body('record_email' => $record_email),
     attachment_filename => $::form->generate_attachment_filename,
     js_send_function    => 'kivi.SalesPurchase.send_email()',
   };
@@ -2057,7 +2069,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,
+    is_invoice_mail => ($record_email && $::form->{type} eq 'invoice'),
   });
 
   print $::form->ajax_response_header, $html;