Zeilenumbrueche entfernt und einmal locales.pl
[kivitendo-erp.git] / SL / Form.pm
index 95034e5..fe9d2b8 100644 (file)
@@ -143,7 +143,6 @@ sub new {
   $self->{action} =~ s/( |-|,|#)/_/g;
 
   $self->{version}   = "2.2.0";
-  $self->{dbversion} = "2.2.0";
 
   $main::lxdebug->leave_sub();
 
@@ -198,7 +197,7 @@ sub quote {
   my ($self, $str) = @_;
 
   if ($str && !ref($str)) {
-    $str =~ s/"/"/g;
+    $str =~ s/\"/"/g;
   }
 
   $str;
@@ -209,7 +208,7 @@ sub unquote {
   my ($self, $str) = @_;
 
   if ($str && !ref($str)) {
-    $str =~ s/"/"/g;
+    $str =~ s/"/\"/g;
   }
 
   $str;
@@ -245,17 +244,7 @@ sub error {
     $msg =~ s/\n/<br>/g;
 
     $self->header;
-
-    print qq|
-    <body>
-
-    <h2 class=error>Error!</h2>
-
-    <p><b>$msg</b>
-
-    </body>
-    </html>
-    |;
+    $self->show_generic_error($msg);
 
     die "Error: $msg\n";
 
@@ -421,19 +410,38 @@ function fokus(){document.$self->{fokus}.focus();}
   $main::lxdebug->leave_sub();
 }
 
+use Data::Dumper;
 sub parse_html_template {
   $main::lxdebug->enter_sub();
 
-  my ($self, $myconfig, $file, $additional_params) = @_;
+  my ($self, $file, $additional_params) = @_;
+  my $language;
+
+  if (!defined($main::myconfig) || !defined($main::myconfig{"countrycode"})) {
+    $language = $main::language;
+  } else {
+    $language = $main::myconfig{"countrycode"};
+  }
+
+  if (-f "templates/webpages/${file}_${language}.html") {
+    if ((-f ".developer") &&
+        (-f "templates/webpages/${file}_master.html") &&
+        ((stat("templates/webpages/${file}_master.html"))[9] >
+         (stat("templates/webpages/${file}_${language}.html"))[9])) {
+      my $info = "Developper information: templates/webpages/${file}_master.html is newer than the localized version.\n" .
+        "Please re-run 'locales.pl' in 'locale/${language}'.";
+      print(qq|<pre>$info</pre>|);
+      die($info);
+    }
 
-  if (-f "templates/webpages/${file}_" . $myconfig->{"countrycode"} .
-      ".html") {
-    $file = "templates/webpages/${file}_" . $myconfig->{"countrycode"} .
-      ".html";
+    $file = "templates/webpages/${file}_${language}.html";
   } elsif (-f "templates/webpages/${file}.html") {
     $file = "templates/webpages/${file}.html";
   } else {
-    $self->error("Web page template '${file}' not found.");
+    my $info = "Web page template '${file}' not found.\n" .
+      "Please re-run 'locales.pl' in 'locale/${language}'.";
+    print(qq|<pre>$info</pre>|);
+    die($info);
   }
 
   my $template = HTML::Template->new("filename" => $file,
@@ -471,13 +479,13 @@ sub parse_html_template {
 }
 
 sub show_generic_error {
-  my ($self, $myconfig, $error, $title) = @_;
+  my ($self, $error, $title) = @_;
 
   my $add_params = {};
   $add_params->{"title"} = $title if ($title);
   $self->{"label_error"} = $error;
 
-  print($self->parse_html_template($myconfig, "generic/error", $add_params));
+  print($self->parse_html_template("generic/error", $add_params));
 }
 
 # write Trigger JavaScript-Code ($qty = quantity of Triggers)
@@ -684,7 +692,7 @@ sub parse_amount {
   }
 
   if ($myconfig->{numberformat} eq "1'000.00") {
-    $amount =~ s/'//g;
+    $amount =~ s/\'//g;
   }
 
   $amount =~ s/,//g;