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

  
bin/mozilla/io.pl
1270 1270
  $form->{oldmedia} = $form->{media};
1271 1271
  $form->{media}    = "email";
1272 1272

  
1273
  my %formname_translations = (
1274
     "bin_list" => $locale->text('Bin List'),
1275
     "credit_note" => $locale->text('Credit Note'),
1276
     "invoice" => $locale->text('Invoice'),
1277
     "packing_list" => $locale->text('Packing List'),
1278
     "pick_list" => $locale->text('Pick List'),
1279
     "proforma" => $locale->text('Proforma Invoice'),
1280
     "purchase_order" => $locale->text('Purchase Order'),
1281
     "request_quotation" => $locale->text('RFQ'),
1282
     "sales_order" => $locale->text('Confirmation'),
1283
     "sales_quotation" => $locale->text('Quotation'),
1284
     "storno_invoice" => $locale->text('Storno Invoice'),
1285
     "storno_packing_list" => $locale->text('Storno Packing List'),
1286
  );
1287

  
1288
  my $attachment_filename = $formname_translations{$form->{"formname"}};
1289
  my $prefix;
1290

  
1291
  if (grep({ $form->{"type"} eq $_ } qw(invoice credit_note))) {
1292
    $prefix = "inv";
1293
  } elsif ($form->{"type"} =~ /_quotation$/) {
1294
    $prefix = "quo";
1295
  } else {
1296
    $prefix = "ord";
1297
  }
1298

  
1299
  if ($attachment_filename && $form->{"${prefix}number"}) {
1300
    $attachment_filename .= "_" . $form->{"${prefix}number"} .
1301
      ($form->{"format"} =~ /pdf/i ? ".pdf" :
1302
       $form->{"format"} =~ /postscript/i ? ".ps" :
1303
       $form->{"format"} =~ /opendocument/i ? ".odt" :
1304
       $form->{"format"} =~ /html/i ? ".html" : "");
1305
    $attachment_filename =~ s/ /_/g;
1306
    my %umlaute = ( "?" => "ae", "?" => "oe", "?" => "ue", 
1307
                    "?" => "Ae", "?" => "Oe", "?" => "Ue", "?" => "ss");
1308
    map { $attachment_filename =~ s/$_/$umlaute{$_}/g } keys %umlaute;
1309
  } else {
1310
    $attachment_filename = "";
1311
  }
1273
  my $attachment_filename = $form->generate_attachment_filename();
1312 1274

  
1313 1275
  $form->{"fokus"} = $form->{"email"} ? "Form.subject" : "Form.email";
1314 1276
  $form->header;

Auch abrufbar als: Unified diff