]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Form.pm
Merge von 682 aus unstable: sql-performance
[mfinanz.git] / SL / Form.pm
index 21508383067ac8023d3f6d64fec8cb82a5374ea3..a0fa96a2ce6283852b21cd913aa8da349369a22c 100644 (file)
@@ -1,4 +1,4 @@
-#=====================================================================
+#====================================================================
 # LX-Office ERP
 # Copyright (C) 2004
 # Based on SQL-Ledger Version 2.1.9
@@ -1030,7 +1030,7 @@ sub format_string {
     next unless ($self->{$field} =~ /\<pagebreak\>/);
     $self->{$field} =~ s/\<pagebreak\>//g;
     if ($field =~ /.*_(\d+)$/) {
-      if ($self->{"_forced_pagebreaks"}) {
+      if (!$self->{"_forced_pagebreaks"}) {
         $self->{"_forced_pagebreaks"} = [];
       }
       push(@{ $self->{"_forced_pagebreaks"} }, "$1");
@@ -1100,9 +1100,6 @@ sub format_string {
                           'u' => 'underline');
 
     foreach my $field (@fields) {
-      if ($field =~ /descrip/) {
-        print(STDERR "QFT: ${field}: " . $self->{$field} . "\n");
-      }
       foreach my $key (keys(%markup_replace)) {
         my $new = $markup_replace{$key};
         $self->{$field} =~
@@ -1280,6 +1277,11 @@ sub get_exchangerate {
   $main::lxdebug->enter_sub();
 
   my ($self, $dbh, $curr, $transdate, $fld) = @_;
+  
+  unless ($transdate) {
+    $main::lxdebug->leave_sub();
+    return "";
+  }
 
   my $query = qq|SELECT e.$fld FROM exchangerate e
                  WHERE e.curr = '$curr'
@@ -1763,10 +1765,9 @@ sub lastname_used {
     $where = "quotation = '1'";
   }
 
-  my $query = qq|SELECT id FROM $arap
-                 WHERE id IN (SELECT MAX(id) FROM $arap
+  my $query = qq|SELECT MAX(id) FROM $arap
                              WHERE $where
-                             AND ${table}_id > 0)|;
+                             AND ${table}_id > 0|;
   my $sth = $dbh->prepare($query);
   $sth->execute || $self->dberror($query);
 
@@ -2212,7 +2213,7 @@ sub audittrail {
        $query = qq|INSERT INTO audittrail (trans_id, tablename, reference,
                    formname, action, employee_id, transdate) VALUES (
                    $audittrail->{id}, '$audittrail->{tablename}', |
-                   .$dbh->quote($audittrail->{reference}).qq|',
+                   .$dbh->quote($audittrail->{reference}).qq|,
                    '$audittrail->{formname}', '$audittrail->{action}',
                    $employee_id, '$audittrail->{transdate}')|;
       } else {