Debugs in SL/Form.pm eingefuegt fuer konsistentes Tracen
[kivitendo-erp.git] / SL / Form.pm
index 525d732..456cd2e 100644 (file)
@@ -195,6 +195,7 @@ sub _request_to_hash {
 }
 
 sub _recode_recursively {
+  $main::lxdebug->enter_sub();
   my ($iconv, $param) = @_;
 
   if (ref $param eq 'HASH') {
@@ -215,6 +216,7 @@ sub _recode_recursively {
       }
     }
   }
+  $main::lxdebug->leave_sub();
 }
 
 sub new {
@@ -261,7 +263,7 @@ sub new {
   $self->{action}  =  lc $self->{action};
   $self->{action}  =~ s/( |-|,|\#)/_/g;
 
-  $self->{version} =  "2.6.0 beta 1";
+  $self->{version} =  "2.6.0 beta 2";
 
   $main::lxdebug->leave_sub();
 
@@ -394,6 +396,7 @@ sub unescape {
 }
 
 sub quote {
+  $main::lxdebug->enter_sub();
   my ($self, $str) = @_;
 
   if ($str && !ref($str)) {
@@ -402,9 +405,11 @@ sub quote {
 
   $str;
 
+  $main::lxdebug->leave_sub();
 }
 
 sub unquote {
+  $main::lxdebug->enter_sub();
   my ($self, $str) = @_;
 
   if ($str && !ref($str)) {
@@ -413,9 +418,11 @@ sub unquote {
 
   $str;
 
+  $main::lxdebug->leave_sub();
 }
 
 sub hide_form {
+  $main::lxdebug->enter_sub();
   my $self = shift;
 
   if (@_) {
@@ -426,7 +433,7 @@ sub hide_form {
       print($main::cgi->hidden("-name" => $_, "-default" => $self->{$_}) . "\n");
     }
   }
-
+  $main::lxdebug->leave_sub();
 }
 
 sub error {
@@ -979,9 +986,9 @@ sub format_amount {
   $amount .= $d[0].$p[1].(0 x ($places - length $p[1])) if ($places || $p[1] ne '');
 
   $amount = do {
-    ($dash =~ /-/)    ? ($neg ? "($amount)"  : "$amount" )    :
-    ($dash =~ /DRCR/) ? ($neg ? "$amount DR" : "$amount CR" ) :
-                        ($neg ? "-$amount"   : "$amount" )    ;
+    ($dash =~ /-/)    ? ($neg ? "($amount)"                            : "$amount" )                              :
+    ($dash =~ /DRCR/) ? ($neg ? "$amount " . $main::locale->text('DR') : "$amount " . $main::locale->text('CR') ) :
+                        ($neg ? "-$amount"                             : "$amount" )                              ;
   };
 
 
@@ -1312,6 +1319,7 @@ Content-Length: $numbytes
 }
 
 sub get_formname_translation {
+  $main::lxdebug->enter_sub();
   my ($self, $formname) = @_;
 
   $formname ||= $self->{formname};
@@ -1333,10 +1341,12 @@ sub get_formname_translation {
     purchase_delivery_order => $main::locale->text('Delivery Order'),
   );
 
+  $main::lxdebug->leave_sub();
   return $formname_translations{$formname}
 }
 
 sub get_number_prefix_for_type {
+  $main::lxdebug->enter_sub();
   my ($self) = @_;
 
   my $prefix =
@@ -1345,10 +1355,12 @@ sub get_number_prefix_for_type {
     : ($self->{type} =~ /_delivery_order$/)                   ? 'do'
     :                                                           'ord';
 
+  $main::lxdebug->leave_sub();
   return $prefix;
 }
 
 sub get_extension_for_format {
+  $main::lxdebug->enter_sub();
   my ($self)    = @_;
 
   my $extension = $self->{format} =~ /pdf/i          ? ".pdf"
@@ -1357,10 +1369,12 @@ sub get_extension_for_format {
                 : $self->{format} =~ /html/i         ? ".html"
                 :                                      "";
 
+  $main::lxdebug->leave_sub();
   return $extension;
 }
 
 sub generate_attachment_filename {
+  $main::lxdebug->enter_sub();
   my ($self) = @_;
 
   my $attachment_filename = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation());
@@ -1379,10 +1393,12 @@ sub generate_attachment_filename {
   $attachment_filename =  $main::locale->quote_special_chars('filenames', $attachment_filename);
   $attachment_filename =~ s|[\s/\\]+|_|g;
 
+  $main::lxdebug->leave_sub();
   return $attachment_filename;
 }
 
 sub generate_email_subject {
+  $main::lxdebug->enter_sub();
   my ($self) = @_;
 
   my $subject = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation());
@@ -1392,6 +1408,7 @@ sub generate_email_subject {
     $subject .= " " . $self->{"${prefix}number"}
   }
 
+  $main::lxdebug->leave_sub();
   return $subject;
 }
 
@@ -3168,9 +3185,8 @@ sub get_history {
       qq|SELECT h.employee_id, h.itime::timestamp(0) AS itime, h.addition, h.what_done, emp.name, h.snumbers, h.trans_id AS id | .
       qq|FROM history_erp h | .
       qq|LEFT JOIN employee emp ON (emp.id = h.employee_id) | .
-      qq|WHERE trans_id = | . $trans_id
-      . $restriction . qq| |
-      . $order;
+      qq|WHERE (trans_id = | . $trans_id . qq|) $restriction | .
+      $order;
 
     my $sth = $dbh->prepare($query) || $self->dberror($query);
 
@@ -3383,7 +3399,7 @@ sub backup_vars {
   my $self = shift;
   my @vars = @_;
 
-  map { $self->{_VAR_BACKUP}->{$_} = $self->{$_} if $self->{$_} } @vars;
+  map { $self->{_VAR_BACKUP}->{$_} = $self->{$_} if exists $self->{$_} } @vars;
 
   $main::lxdebug->leave_sub();
 }
@@ -3394,7 +3410,7 @@ sub restore_vars {
   my $self = shift;
   my @vars = @_;
 
-  map { $self->{$_} = $self->{_VAR_BACKUP}->{$_} if $self->{_VAR_BACKUP}->{$_} } @vars;
+  map { $self->{$_} = $self->{_VAR_BACKUP}->{$_} if exists $self->{_VAR_BACKUP}->{$_} } @vars;
 
   $main::lxdebug->leave_sub();
 }