Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 564d8509

Von Sven Schöling vor mehr als 17 Jahren hinzugefügt

  • ID 564d8509117493b1b4b28c08d95ba4d1df8d599b
  • Vorgänger fd6900cc
  • Nachfolger 4ff0cb66

Attachment Filenmaes werden nun von einer SL/Form.pm Objektfunktion generiert

Unterschiede anzeigen:

SL/Form.pm
404 404
    foreach $item (@ { $self->{AJAX} }) {
405 405
      $ajax .= $item->show_javascript();
406 406
    }
407
    print qq|Content-Type: text/html
407
    print qq|Content-Type: text/html; charset=$self->{charset};
408 408

  
409 409
<html>
410 410
<head>
......
774 774
  # OUT is used for the media, screen, printer, email
775 775
  # for postscript we store a copy in a temporary file
776 776
  my $fileid = time;
777
  $self->{tmpfile} = "$userspath/${fileid}.$self->{IN}" if ( $self->{tmpfile} eq '' );
777
  $self->{tmpfile} ||= "$userspath/${fileid}.$self->{IN}";
778 778
  if ($template->uses_temp_file() || $self->{media} eq 'email') {
779 779
    $out = $self->{OUT};
780 780
    $self->{OUT} = ">$self->{tmpfile}";
......
861 861
          open(OUT, $self->{OUT})
862 862
            or $self->error($self->cleanup . "$self->{OUT} : $!");
863 863
        } else {
864
          $self->{attachment_filename} = $self->{tmpfile} if ($self->{attachment_filename} eq '');
864
          $self->{attachment_filename} = $self->generate_attachment_filename();
865

  
865 866
          # launch application
866 867
          print qq|Content-Type: | . $template->get_mime_type() . qq|
867 868
Content-Disposition: attachment; filename="$self->{attachment_filename}"
......
893 894
  $main::lxdebug->leave_sub();
894 895
}
895 896

  
897
sub generate_attachment_filename {
898
  my ($self) = @_;
899

  
900
  my %formname_translations = (
901
     bin_list            => $main::locale->text('Bin List'),
902
     credit_note         => $main::locale->text('Credit Note'),
903
     invoice             => $main::locale->text('Invoice'),
904
     packing_list        => $main::locale->text('Packing List'),
905
     pick_list           => $main::locale->text('Pick List'),
906
     proforma            => $main::locale->text('Proforma Invoice'),
907
     purchase_order      => $main::locale->text('Purchase Order'),
908
     request_quotation   => $main::locale->text('RFQ'),
909
     sales_order         => $main::locale->text('Confirmation'),
910
     sales_quotation     => $main::locale->text('Quotation'),
911
     storno_invoice      => $main::locale->text('Storno Invoice'),
912
     storno_packing_list => $main::locale->text('Storno Packing List'),
913
  );
914

  
915
  my $attachment_filename = $formname_translations{$self->{"formname"}};
916
  my $prefix = 
917
      (grep { $self->{"type"} eq $_ } qw(invoice credit_note)) ? "inv"
918
    : ($self->{"type"} =~ /_quotation$/)                       ? "quo"
919
    :                                                            "ord";
920

  
921
  if ($attachment_filename && $self->{"${prefix}number"}) {
922
    $attachment_filename .= "_" . $self->{"${prefix}number"}
923
                            . (  $self->{format} =~ /pdf/i          ? ".pdf"
924
                               : $self->{format} =~ /postscript/i   ? ".ps"
925
                               : $self->{format} =~ /opendocument/i ? ".odt"
926
                               : $self->{format} =~ /html/i         ? ".html"
927
                               :                                      "");
928
    $attachment_filename =~ s/ /_/g;
929
    my %umlaute = ( "?" => "ae", "?" => "oe", "?" => "ue", 
930
                    "?" => "Ae", "?" => "Oe", "?" => "Ue", "?" => "ss");
931
    map { $attachment_filename =~ s/$_/$umlaute{$_}/g } keys %umlaute;
932
  } else {
933
    $attachment_filename = "";
934
  }
935

  
936
  return $attachment_filename;
937
}
938

  
896 939
sub cleanup {
897 940
  $main::lxdebug->enter_sub();
898 941

  

Auch abrufbar als: Unified diff