Locales zu 1424
[kivitendo-erp.git] / SL / Form.pm
index e0a3d23..8296280 100644 (file)
@@ -219,6 +219,25 @@ sub unquote {
 
 }
 
+sub quote_html {
+  $main::lxdebug->enter_sub(2);
+
+  my ($self, $str) = @_;
+
+  my %replace =
+    ('order' => ['"', '<', '>'],
+     '<'             => '&lt;',
+     '>'             => '&gt;',
+     '"'             => '&quot;',
+    );
+
+  map({ $str =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
+
+  $main::lxdebug->leave_sub(2);
+
+  return $str;
+}
+
 sub hide_form {
   my $self = shift;
 
@@ -778,6 +797,7 @@ sub parse_template {
       $mail->{to}     = qq|$self->{email}|;
       $mail->{from}   = qq|"$myconfig->{name}" <$myconfig->{email}>|;
       $mail->{fileid} = "$fileid.";
+      $myconfig->{signature} =~ s/\\r\\n/\\n/g;
 
       # if we send html or plain text inline
       if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) {
@@ -785,7 +805,7 @@ sub parse_template {
 
         $mail->{message}       =~ s/\r\n/<br>\n/g;
         $myconfig->{signature} =~ s/\\n/<br>\n/g;
-        $mail->{message} .= "<br>\n--<br>\n$myconfig->{signature}\n<br>";
+        $mail->{message} .= "<br>\n-- <br>\n$myconfig->{signature}\n<br>";
 
         open(IN, $self->{tmpfile})
           or $self->error($self->cleanup . "$self->{tmpfile} : $!");
@@ -799,8 +819,9 @@ sub parse_template {
 
         @{ $mail->{attachments} } = ($self->{tmpfile}) unless ($form->{do_not_attach});
 
-        $myconfig->{signature} =~ s/\\n/\r\n/g;
-        $mail->{message} .= "\r\n--\r\n$myconfig->{signature}";
+        $mail->{message}       =~ s/\r\n/\n/g;
+        $myconfig->{signature} =~ s/\\n/\n/g;
+        $mail->{message} .= "\n-- \n$myconfig->{signature}";
 
       }
 
@@ -1208,7 +1229,7 @@ sub get_shipto {
 
 
     my $query = qq|SELECT s.* FROM shipto s
-                  WHERE s.id = $self->{shipto_id}|;
+                  WHERE s.shipto_id = $self->{shipto_id}|;
     my $sth = $dbh->prepare($query);
     $sth->execute || $self->dberror($query);
     $ref = $sth->fetchrow_hashref(NAME_lc);
@@ -1235,7 +1256,6 @@ sub add_shipto {
     }
     $self->{"shipto$item"} =~ s/\'/\'\'/g;
   }
-
   if ($shipto) {
     if ($self->{shipto_id}) {
       my $query = qq| UPDATE shipto set
@@ -1250,7 +1270,7 @@ sub add_shipto {
                       shiptophone = '$self->{shiptophone}',
                       shiptofax = '$self->{shiptofax}',
                       shiptoemail = '$self->{shiptoemail}'
-                      WHERE id = $self->{shipto_id}|;
+                      WHERE shipto_id = $self->{shipto_id}|;
       $dbh->do($query) || $self->dberror($query);
     } else {
       my $query =
@@ -1562,18 +1582,6 @@ sub language_payment {
   }
   $sth->finish;
 
-  # get adr
-  $query = qq|SELECT id, adr_description, adr_code
-              FROM adr|;
-  $sth = $dbh->prepare($query);
-  $sth->execute || $form->dberror($query);
-
-
-  $self->{ADR} = [];
-  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
-    push @{ $self->{ADR} }, $ref;
-  }
-  $sth->finish;
   $dbh->disconnect;
   $main::lxdebug->leave_sub();
 }
@@ -2311,10 +2319,14 @@ sub new {
   my ($type, $country, $NLS_file) = @_;
   my $self = {};
 
-  %self = ();
   if ($country && -d "locale/$country") {
+    local *IN;
     $self->{countrycode} = $country;
-    eval { require "locale/$country/$NLS_file"; };
+    if (open(IN, "locale/$country/$NLS_file")) {
+      my $code = join("", <IN>);
+      eval($code);
+      close(IN);
+    }
   }
 
   $self->{NLS_file} = $NLS_file;
@@ -2334,7 +2346,7 @@ sub new {
 sub text {
   my ($self, $text) = @_;
 
-  return (exists $self{texts}{$text}) ? $self{texts}{$text} : $text;
+  return (exists $self->{texts}{$text}) ? $self->{texts}{$text} : $text;
 }
 
 sub findsub {
@@ -2342,8 +2354,8 @@ sub findsub {
 
   my ($self, $text) = @_;
 
-  if (exists $self{subs}{$text}) {
-    $text = $self{subs}{$text};
+  if (exists $self->{subs}{$text}) {
+    $text = $self->{subs}{$text};
   } else {
     if ($self->{countrycode} && $self->{NLS_file}) {
       Form->error(