]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Form.pm
Mehr Updates.
[mfinanz.git] / SL / Form.pm
index ef05c85915f62cd69847b32713d21dbb6c8a2756..3606073f995a55d5195100e720dcf26f18fcded6 100644 (file)
@@ -146,7 +146,7 @@ sub new {
   $self->{action} = lc $self->{action};
   $self->{action} =~ s/( |-|,|\#)/_/g;
 
-  $self->{version}   = "2.4-RC2";
+  $self->{version}   = "2.4.0";
 
   $main::lxdebug->leave_sub();
 
@@ -754,6 +754,19 @@ sub parse_template {
   } elsif (($self->{"format"} =~ /html/i) ||
            (!$self->{"format"} && ($self->{"IN"} =~ /html$/i))) {
     $template = HTMLTemplate->new($self->{"IN"}, $self, $myconfig, $userspath);
+  } elsif (($self->{"format"} =~ /xml/i) ||
+             (!$self->{"format"} && ($self->{"IN"} =~ /xml$/i))) {
+    $template = XMLTemplate->new($self->{"IN"}, $self, $myconfig, $userspath);
+  } elsif ( $self->{"format"} =~ /elsterwinston/i ) {
+    $template = XMLTemplate->new($self->{"IN"}, $self, $myconfig, $userspath);  
+  } elsif ( $self->{"format"} =~ /elstertaxbird/i ) {
+    $template = XMLTemplate->new($self->{"IN"}, $self, $myconfig, $userspath);
+  } elsif ( defined $self->{'format'}) {
+    $self->error("Outputformat not defined. This may be a future feature: $self->{'format'}");
+  } elsif ( $self->{'format'} eq '' ) {
+    $self->error("No Outputformat given: $self->{'format'}");
+  } else { #Catch the rest
+    $self->error("Outputformat not defined: $self->{'format'}");  
   }
 
   # Copy the notes from the invoice/sales order etc. back to the variable "notes" because that is where most templates expect it to be.
@@ -767,7 +780,7 @@ sub parse_template {
   # OUT is used for the media, screen, printer, email
   # for postscript we store a copy in a temporary file
   my $fileid = time;
-  $self->{tmpfile} = "$userspath/${fileid}.$self->{IN}";
+  $self->{tmpfile} = "$userspath/${fileid}.$self->{IN}" if ( $self->{tmpfile} eq '' );
   if ($template->uses_temp_file() || $self->{media} eq 'email') {
     $out = $self->{OUT};
     $self->{OUT} = ">$self->{tmpfile}";
@@ -786,9 +799,6 @@ sub parse_template {
   }
 
   close(OUT);
-  
-  use Data::Dumper;
-  #print(STDERR Dumper($self));
 
   if ($template->uses_temp_file() || $self->{media} eq 'email') {
 
@@ -2533,4 +2543,33 @@ sub parse_date {
   return ($yy, $mm, $dd);
 }
 
+sub reformat_date {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $myconfig, $date, $output_format, $longformat) = @_;
+
+  $main::lxdebug->leave_sub() and return "" unless ($date);
+
+  my ($yy, $mm, $dd) = $self->parse_date($myconfig, $date);
+
+  $output_format =~ /d+/;
+  substr($output_format, $-[0], $+[0] - $-[0]) =
+    sprintf("%0" . (length($&)) . "d", $dd);
+
+  $output_format =~ /m+/;
+  substr($output_format, $-[0], $+[0] - $-[0]) =
+    sprintf("%0" . (length($&)) . "d", $mm);
+
+  $output_format =~ /y+/;
+  if (length($&) == 2) {
+    $yy -= $yy >= 2000 ? 2000 : 1900;
+  }
+  substr($output_format, $-[0], $+[0] - $-[0]) =
+    sprintf("%0" . (length($&)) . "d", $yy);
+
+  $main::lxdebug->leave_sub();
+
+  return $output_format;
+}
+
 1;