Bei print_options() die Parameterübergabe umgestellt, sodass der Aufrufer das Verhalt...
[kivitendo-erp.git] / bin / mozilla / io.pl
index 2afa3bb..7f8f65a 100644 (file)
@@ -646,12 +646,12 @@ sub select_item {
 
     my @new_fields =
       qw(bin listprice inventory_accno income_accno expense_accno unit weight
-         assembly taxaccounts partsgroup formel logdescription not_discountable
-         part_payment_id partnodes id);
+         assembly taxaccounts partsgroup formel longdescription not_discountable
+         part_payment_id partnotes id);
     push(@new_fields, "lizenzen") if ($lizenzen);
 
-    map({ print($cgi->hidden("-name" => "new_${_}_$i",
-                             "-value" => $ref->{$_})); } @new_fields);
+    print join "\n", map { $cgi->hidden("-name" => "new_${_}_$i", "-value" => $ref->{$_}) } @new_fields;
+    print "\n";
   }
 
   print qq|
@@ -1270,45 +1270,7 @@ sub edit_e_mail {
   $form->{oldmedia} = $form->{media};
   $form->{media}    = "email";
 
-  my %formname_translations = (
-     "bin_list" => $locale->text('Bin List'),
-     "credit_note" => $locale->text('Credit Note'),
-     "invoice" => $locale->text('Invoice'),
-     "packing_list" => $locale->text('Packing List'),
-     "pick_list" => $locale->text('Pick List'),
-     "proforma" => $locale->text('Proforma Invoice'),
-     "purchase_order" => $locale->text('Purchase Order'),
-     "request_quotation" => $locale->text('RFQ'),
-     "sales_order" => $locale->text('Confirmation'),
-     "sales_quotation" => $locale->text('Quotation'),
-     "storno_invoice" => $locale->text('Storno Invoice'),
-     "storno_packing_list" => $locale->text('Storno Packing List'),
-  );
-
-  my $attachment_filename = $formname_translations{$form->{"formname"}};
-  my $prefix;
-
-  if (grep({ $form->{"type"} eq $_ } qw(invoice credit_note))) {
-    $prefix = "inv";
-  } elsif ($form->{"type"} =~ /_quotation$/) {
-    $prefix = "quo";
-  } else {
-    $prefix = "ord";
-  }
-
-  if ($attachment_filename && $form->{"${prefix}number"}) {
-    $attachment_filename .= "_" . $form->{"${prefix}number"} .
-      ($form->{"format"} =~ /pdf/i ? ".pdf" :
-       $form->{"format"} =~ /postscript/i ? ".ps" :
-       $form->{"format"} =~ /opendocument/i ? ".odt" :
-       $form->{"format"} =~ /html/i ? ".html" : "");
-    $attachment_filename =~ s/ /_/g;
-    my %umlaute = ( "ä" => "ae", "ö" => "oe", "ü" => "ue", 
-                    "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue", "ß" => "ss");
-    map { $attachment_filename =~ s/$_/$umlaute{$_}/g } keys %umlaute;
-  } else {
-    $attachment_filename = "";
-  }
+  my $attachment_filename = $form->generate_attachment_filename();
 
   $form->{"fokus"} = $form->{"email"} ? "Form.subject" : "Form.email";
   $form->header;
@@ -1321,7 +1283,7 @@ sub edit_e_mail {
   print $form->parse_html_template('generic/edit_email', 
                                   { title           => $title,
                                     a_filename      => $attachment_filename,
-                                    _print_options_ => print_options('inline'),
+                                    _print_options_ => print_options({ 'inline' => 1 }),
                                     HIDDEN          => [ map +{ name => $_, value => $form->{$_} }, @hidden_keys ],
                                     SHOW_BCC        => $myconfig{role} eq 'admin' });
 
@@ -1353,7 +1315,11 @@ sub send_email {
 #
 # the inline options is untested, but intended to be used later in metatemplating
 sub print_options {
-  $lxdebug->enter_sub() and my ($inline) = @_;
+  $lxdebug->enter_sub();
+
+  my ($options) = @_;
+
+  $options ||= { };
 
   # names 3 parameters and returns a hashref, for use in templates
   sub opthash { +{ value => shift, selected => shift, oname => shift } }
@@ -1408,7 +1374,7 @@ sub print_options {
       opthash("screen", $form->{OP}{screen}, $locale->text('Screen')),
     (scalar @{ $form->{printers} } && $latex_templates) ?
       opthash("printer", $form->{OP}{printer}, $locale->text('Printer')) : undef,
-    ($latex_templates) ? 
+    ($latex_templates && !$options{no_queue}) ?
       opthash("queue", $form->{OP}{queue}, $locale->text('Queue')) : undef
         if ($form->{media} ne 'email');
 
@@ -1433,16 +1399,21 @@ sub print_options {
 
   @SELECTS = map { sname => lc $_, DATA => \@$_, show => scalar @$_ }, qw(FORMNAME LANGUAGE_ID FORMAT SENDMODE MEDIA PRINTER_ID);
 
+  my %dont_display_groupitems = (
+    'dunning' => 1,
+    );
+
   %template_vars = (
     display_copies       => scalar @{ $form->{printers} } && $latex_templates && $form->{media} ne 'email',
     display_remove_draft => (!$form->{id} && $form->{draft_id}),
+    display_groupitems   => !$dont_display_groupitems{$form->{type}},
     groupitems_checked   => $form->{groupitems} ? "checked" : '',
     remove_draft_checked => $form->{remove_draft} ? "checked" : ''
   );
 
   my $print_options = $form->parse_html_template("generic/print_options", { SELECTS  => \@SELECTS, %template_vars } );
 
-  if ($inline) {
+  if ($options{inline}) {
     $lxdebug->leave_sub() and return $print_options;
   } else {
     print $print_options; $lxdebug->leave_sub();
@@ -1711,6 +1682,8 @@ sub print_form {
 
   $form->{templates} = "$myconfig{templates}";
 
+  delete $form->{printer_command};
+
   $form->{language} = $form->get_template_language(\%myconfig);
   $form->{printer_code} = $form->get_printer_code(\%myconfig);
 
@@ -1740,13 +1713,16 @@ sub print_form {
   reformat_numbers($output_numberformat, 2,
                    qw(invtotal ordtotal quototal subtotal linetotal
                       listprice sellprice netprice discount
-                      tax taxbase),
+                      tax taxbase total paid),
                    grep({ /^linetotal_\d+$/ ||
                             /^listprice_\d+$/ ||
                             /^sellprice_\d+$/ ||
                             /^netprice_\d+$/ ||
                             /^taxbase_\d+$/ ||
                             /^discount_\d+$/ ||
+                            /^paid_\d+$/ ||
+                            /^subtotal_\d+$/ ||
+                            /^total_\d+$/ ||
                             /^tax_\d+$/
                         } keys(%{$form})));
 
@@ -1775,6 +1751,8 @@ sub print_form {
     $form->{"IN"} =~ s/html$/odt/;
   }
 
+  delete $form->{OUT};
+
   if ($form->{media} eq 'printer') {
     $form->{OUT} = "| $form->{printer_command} &>/dev/null";
     $form->{printed} .= " $form->{formname}";
@@ -1786,15 +1764,13 @@ sub print_form {
     $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
       unless $form->{subject};
 
-    $form->{OUT} = "$sendmail";
-
     $form->{emailed} .= " $form->{formname}";
     $form->{emailed} =~ s/^ //;
   }
   $emailed = $form->{emailed};
 
   if ($form->{media} eq 'queue') {
-    %queued = split / /, $form->{queued};
+    %queued = map { s|.*/|| } split / /, $form->{queued};
 
     if ($filename = $queued{ $form->{formname} }) {
       $form->{queued} =~ s/$form->{formname} $filename//;