Neue Variable <%cumulatelinetotal%> fuer zeilenweise kumulierte
[kivitendo-erp.git] / SL / Template.pm
index d30b928..9e25f39 100644 (file)
@@ -196,7 +196,7 @@ sub parse_foreach {
         # replace the special variables <%sumcarriedforward%>
         # and <%lastpage%>
 
-        my $psum = $form->format_amount($myconfig, $sum, 2);
+        my $psum = $form->format_amount($self->{"myconfig"}, $sum, 2);
         $pb =~ s/<%sumcarriedforward%>/$psum/g;
         $pb =~ s/<%lastpage%>/$current_page/g;
 
@@ -210,9 +210,12 @@ sub parse_foreach {
       $current_line += $lines;
     }
     if ($i < scalar(@{$form->{"linetotal"}})) {
-      $sum += $form->parse_amount($myconfig, $form->{"linetotal"}->[$i]);
+      $sum += $form->parse_amount($self->{"myconfig"},
+                                  $form->{"linetotal"}->[$i]);
     }
-
+    
+    $form->{"cumulatelinetotal"}[$i] = $form->format_amount($self->{"myconfig"}, $sum, 2);
+    
     my $new_text = $self->parse_block($text, (@indices, $i));
     return undef unless (defined($new_text));
     $new_contents .= $start_tag . $new_text . $end_tag;
@@ -1258,4 +1261,63 @@ sub uses_temp_file {
   return 1;
 }
 
+
+##########################################################
+####
+#### XMLTemplate
+####
+##########################################################
+
+package XMLTemplate; 
+
+use vars qw(@ISA);
+
+@ISA = qw(HTMLTemplate);
+
+sub new {
+  #evtl auskommentieren
+  my $type = shift;
+
+  return $type->SUPER::new(@_);
+}
+
+sub format_string {
+  my ($self, $variable) = @_;
+  my $form = $self->{"form"};
+
+  my %replace =
+    ('order' => ['<', '>', quotemeta("\n")],
+     '<'             => '&lt;',
+     '>'             => '&gt;',
+     quotemeta("\n") => '<br>',
+     );
+
+  map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
+
+  # Allow no markup to be converted into the output format
+  my @markup_replace = ('b', 'i', 's', 'u', 'sub', 'sup');
+
+  foreach my $key (@markup_replace) {
+    $variable =~ s/\&lt;(\/?)${key}\&gt;//g;
+  }
+
+  return $variable;
+}
+
+sub get_mime_type() {
+  my ($self) = @_;
+
+  if ($self->{"form"}->{"format"} =~ /xml/i) {
+    return "application/xml ";
+  } else {
+    return "text/xml";
+  }
+}
+
+sub uses_temp_file {
+#  my ($self) = @_;
+  # no tempfile needet for XML Output
+  return 1;
+}
+
 1;