commit a731cd269130cd68f9c3fb5b8a2c26dc20afe82e
Author: Moritz Bunkus <m.bunkus@linet.de>
Date:   Fri Apr 20 07:28:07 2007 +0000

    Den Code für das Bearbeiten von Vorlagen in eine eigene Datei ausgelagert. Zusätzlich den HTML-Code in eine HTML-Vorlage ausgelagert.

diff --git a/amtemplates.pl b/amtemplates.pl
new file mode 120000
index 000000000..385000d1b
--- /dev/null
+++ b/amtemplates.pl
@@ -0,0 +1 @@
+am.pl
\ No newline at end of file
diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl
index e34957f94..5b6b16b0b 100644
--- a/bin/mozilla/am.pl
+++ b/bin/mozilla/am.pl
@@ -2434,226 +2434,6 @@ sub swap_payment_terms {
   $lxdebug->leave_sub();
 }
 
-sub display_template {
-  $lxdebug->enter_sub();
-
-  $form->{edit} = 0;
-  display_template_form();
-
-  $lxdebug->leave_sub();
-}
-
-sub edit_template {
-  $lxdebug->enter_sub();
-
-  $form->{edit} = 1;
-  display_template_form();
-
-  $lxdebug->leave_sub();
-}
-
-sub save_template {
-  $lxdebug->enter_sub();
-
-  $form->isblank("formname", $locale->text("You're not editing a file.")) unless ($form->{type} eq "stylesheet");
-
-  my ($filename) = AM->prepare_template_filename(\%myconfig, $form);
-  if (my $error = AM->save_template($filename, $form->{content})) {
-    $form->error(sprintf($locale->text("Saving the file '%s' failed. OS error message: %s"), $filename, $error));
-  }
-
-  $form->{edit} = 0;
-  display_template_form();
-
-  $lxdebug->leave_sub();
-}
-
-sub display_template_form {
-  $lxdebug->enter_sub();
-
-  $form->{formname} =~ s|.*/||;
-  my $format = $form->{format} eq "html" ? "html" : "tex";
-
-  my $title = $form->{type} eq "stylesheet" ? $locale->text("Edit the stylesheet") : $locale->text("Edit templates");
-  $form->{title} = $title;
-
-  my $edit_options;
-
-  my @hidden = qw(login path password type format);
-
-  if (($form->{type} ne "stylesheet") && !$form->{edit}) {
-    $edit_options = "<p>";
-
-    my %formname_setup =
-      (
-       "balance_sheet" => { "translation" => $locale->text('Balance Sheet'), "html" => 1 },
-       "bin_list" => $locale->text('Bin List'),
-       "bwa" => { "translation" => $locale->text('BWA'), "html" => 1 },
-       "check" => { "translation" => $locale->text('Check'), "html" => 1 },
-       "credit_note" => $locale->text('Credit Note'),
-       "income_statement" => { "translation" => $locale->text('Income Statement'), "html" => 1 },
-       "invoice" => $locale->text('Invoice'),
-       "packing_list" => $locale->text('Packing List'),
-       "pick_list" => $locale->text('Pick List'),
-       "proforma" => $locale->text('Proforma Invoice'),
-       "purchase_order" => $locale->text('Purchase Order'),
-       "receipt" => { "translation" => $locale->text('Receipt'), "tex" => 1 },
-       "request_quotation" => $locale->text('RFQ'),
-       "sales_order" => $locale->text('Confirmation'),
-       "sales_quotation" => $locale->text('Quotation'),
-       "statement" => $locale->text('Statement'),
-       "storno_invoice" => $locale->text('Storno Invoice'),
-       "storno_packing_list" => $locale->text('Storno Packing List'),
-       "ustva-2004" => { "translation" => $locale->text("USTVA 2004"), "tex" => 1 },
-       "ustva-2005" => { "translation" => $locale->text("USTVA 2005"), "tex" => 1 },
-       "ustva-2006" => { "translation" => $locale->text("USTVA 2006"), "tex" => 1 },
-       "ustva-2007" => { "translation" => $locale->text("USTVA 2007"), "tex" => 1 },
-       "ustva" => $locale->text("USTVA"),
-       "zahlungserinnerung" => $locale->text('Payment Reminder'),
-      );
-
-    my (@values, %labels, $file, $setup);
-
-    while (($file, $setup) = each(%formname_setup)) {
-      next unless (!ref($setup) || $setup->{$format});
-
-      push(@values, $file);
-      $labels{$file} = ref($setup) ? $setup->{translation} : $setup;
-    }
-    @values = sort({ $labels{$a} cmp $labels{$b} } @values);
-
-    $edit_options .=
-      $locale->text("Template") . " " .
-      NTI($cgi->popup_menu("-name" => "formname", "-default" => $form->{formname},
-                           "-values" => \@values, "-labels" => \%labels));
-
-    $form->get_lists("printers" => "ALL_PRINTERS",
-                     "languages" => "ALL_LANGUAGES");
-
-    @values = ("");
-    %labels = ();
-
-    foreach my $item (@{ $form->{ALL_LANGUAGES} }) {
-      next unless ($item->{template_code});
-      my $key = "$item->{id}--$item->{template_code}";
-      push(@values, $key);
-      $labels{$key} = $item->{description};
-    }
-
-    if (1 != scalar(@values)) {
-      $edit_options .=
-        " " . $locale->text("Language") . " " .
-        NTI($cgi->popup_menu("-name" => "language", "-default" => $form->{language},
-                             "-values" => \@values, "-labels" => \%labels));
-    }
-
-    @values = ("");
-    %labels = ();
-
-    foreach my $item (@{ $form->{ALL_PRINTERS} }) {
-      next unless ($item->{template_code});
-      my $key = "$item->{id}--$item->{template_code}";
-      push(@values, $key);
-      $labels{$key} = $item->{printer_description};
-    }
-
-    if (1 != scalar(@values)) {
-      $edit_options .=
-        " " . $locale->text("Printer") . " " .
-        NTI($cgi->popup_menu("-name" => "printer", "-default" => $form->{printer},
-                             "-values" => \@values, "-labels" => \%labels));
-    }
-
-    $edit_options .= qq|
-
-  <input type="hidden" name="display_nextsub" value="display_template">
-
-  <input name="action" type="submit" class="submit" value="|
-    . $locale->text('Display') . qq|">
-
- </p>
-
- <hr>
-|;
-
-  } else {
-    push(@hidden, qw(formname language printer));
-  }
-
-  if ($form->{formname} || ($form->{type} eq "stylesheet")) {
-    my ($filename, $display_filename) = AM->prepare_template_filename(\%myconfig, $form);
-    my ($content, $lines) = AM->load_template($filename);
-
-    $body = qq|
-|;
-
-    if ($form->{edit}) {
-      $form->{fokus} = "Form.content";
-      $body = qq|\n<p><div class="listtop">| . $locale->text('Edit file') . " '" . H($display_filename) . qq|'</div></p>\n<p>|
-        . NTI($cgi->textarea("-name" => "content",
-                             "-id" => "content",
-                             "-default" => $content,
-                             "-columns" => 100,
-                             "-rows" => 25))
-        . qq|</p>
-
- <p>
-  <input type="hidden" name="save_nextsub" value="save_template">
-
-  <input type="submit" name="action" value="| . $locale->text('Save') . qq|">
- </p>
-|;
-
-    } else {
-      $content = "\n\n" unless ($content);
-
-      $body = qq|
-  <p><div class="listtop">| . $locale->text('Display file') . " '" . H($display_filename) . qq|'</div></p>
-
-  <input type="hidden" name="edit_nextsub" value="edit_template">
-
-  <p><input name="action" type="submit" class="submit" value="| . $locale->text('Edit') . qq|"></p>
-
-  <p>
-    <pre class="filecontent">| . H($content) . qq|</pre>
-  </p>
-|;
-
-      if ($lines > 25) {
-        $body .= qq|
-  <input name="action" type="submit" class="submit" value="|
-    . $locale->text('Edit') . qq|">
-|;
-      }
-    }
-  }
-
-  $form->header;
-
-  print qq|
-<body>
-
-<div class="listheading">$title</div>
-
-<form method="post" name="Form" action="am.pl">
-
-|;
-  $form->hide_form(@hidden);
-
-  print qq|
-$edit_options
-
-$body
-
-</form>
-
-</body>
-</html>
-|;
-
-  $lxdebug->leave_sub();
-}
-
 sub config {
   $lxdebug->enter_sub();
 
diff --git a/bin/mozilla/amtemplates.pl b/bin/mozilla/amtemplates.pl
new file mode 100644
index 000000000..d13046d1a
--- /dev/null
+++ b/bin/mozilla/amtemplates.pl
@@ -0,0 +1,240 @@
+#=====================================================================
+# LX-Office ERP
+# Copyright (C) 2004
+# Based on SQL-Ledger Version 2.1.9
+# Web http://www.lx-office.org
+#
+#=====================================================================
+# SQL-Ledger Accounting
+# Copyright (c) 1998-2002
+#
+#  Author: Dieter Simader
+#   Email: dsimader@sql-ledger.org
+#     Web: http://www.sql-ledger.org
+#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#======================================================================
+#
+# administration
+#
+#======================================================================
+
+use SL::AM;
+use SL::Form;
+
+use Data::Dumper;
+
+1;
+
+require "$form->{path}/common.pl";
+
+# end of main
+
+sub display {
+  if ($form->{display_nextsub}) {
+    &{ $form->{display_nextsub} }();
+  } else {
+    die "display_nextsub not defined";
+  }
+}
+
+sub save {
+  if ($form->{save_nextsub}) {
+    &{ $form->{save_nextsub} }();
+  } else {
+    die "save_nextsub not defined";
+  }
+}
+
+sub edit {
+  if ($form->{edit_nextsub}) {
+    &{ $form->{edit_nextsub} }();
+  } else {
+    die "edit_nextsub not defined";
+  }
+}
+
+sub display_template {
+  $lxdebug->enter_sub();
+
+  $form->{edit} = 0;
+  display_template_form();
+
+  $lxdebug->leave_sub();
+}
+
+sub edit_template {
+  $lxdebug->enter_sub();
+
+  $form->{edit} = 1;
+  display_template_form();
+
+  $lxdebug->leave_sub();
+}
+
+sub save_template {
+  $lxdebug->enter_sub();
+
+  $form->isblank("formname", $locale->text("You're not editing a file.")) unless ($form->{type} eq "stylesheet");
+
+  my ($filename) = AM->prepare_template_filename(\%myconfig, $form);
+  if (my $error = AM->save_template($filename, $form->{content})) {
+    $form->error(sprintf($locale->text("Saving the file '%s' failed. OS error message: %s"), $filename, $error));
+  }
+
+  $form->{edit} = 0;
+  display_template_form();
+
+  $lxdebug->leave_sub();
+}
+
+sub display_template_form {
+  $lxdebug->enter_sub();
+
+  $form->{"formname"} =~ s|.*/||;
+  my $format = $form->{"format"} eq "html" ? "html" : "tex";
+
+  $form->{"title"} = $form->{"type"} eq "stylesheet" ? $locale->text("Edit the stylesheet") : $locale->text("Edit templates");
+
+  my %options;
+
+  my @hidden = qw(login path password type format);
+
+  if (($form->{"type"} ne "stylesheet") && !$form->{"edit"}) {
+    $options{"SHOW_EDIT_OPTIONS"} = 1;
+
+    #
+    # Setup "formname" selection
+    #
+
+    my %formname_setup =
+      (
+       "balance_sheet" => { "translation" => $locale->text('Balance Sheet'), "html" => 1 },
+       "bin_list" => $locale->text('Bin List'),
+       "bwa" => { "translation" => $locale->text('BWA'), "html" => 1 },
+       "check" => { "translation" => $locale->text('Check'), "html" => 1 },
+       "credit_note" => $locale->text('Credit Note'),
+       "income_statement" => { "translation" => $locale->text('Income Statement'), "html" => 1 },
+       "invoice" => $locale->text('Invoice'),
+       "packing_list" => $locale->text('Packing List'),
+       "pick_list" => $locale->text('Pick List'),
+       "proforma" => $locale->text('Proforma Invoice'),
+       "purchase_order" => $locale->text('Purchase Order'),
+       "receipt" => { "translation" => $locale->text('Receipt'), "tex" => 1 },
+       "request_quotation" => $locale->text('RFQ'),
+       "sales_order" => $locale->text('Confirmation'),
+       "sales_quotation" => $locale->text('Quotation'),
+       "statement" => $locale->text('Statement'),
+       "storno_invoice" => $locale->text('Storno Invoice'),
+       "storno_packing_list" => $locale->text('Storno Packing List'),
+       "ustva-2004" => { "translation" => $locale->text("USTVA 2004"), "tex" => 1 },
+       "ustva-2005" => { "translation" => $locale->text("USTVA 2005"), "tex" => 1 },
+       "ustva-2006" => { "translation" => $locale->text("USTVA 2006"), "tex" => 1 },
+       "ustva-2007" => { "translation" => $locale->text("USTVA 2007"), "tex" => 1 },
+       "ustva" => $locale->text("USTVA"),
+       "zahlungserinnerung" => $locale->text('Payment Reminder'),
+      );
+
+    my (@values, $file, $setup);
+
+    while (($file, $setup) = each(%formname_setup)) {
+      next unless (!ref($setup) || $setup->{$format});
+
+      push(@values,
+           { "value"   => $file,
+             "label"   => ref($setup) ? $setup->{"translation"} : $setup,
+             "default" => $file eq $form->{"formname"} });
+    }
+
+    @values = sort({ $a->{"label"} cmp $b->{"label"} } @values);
+
+    $options{"FORMNAME"} = [ @values ];
+
+    #
+    # Setup "language" selection
+    #
+
+    $form->get_lists("printers" => "ALL_PRINTERS",
+                     "languages" => "ALL_LANGUAGES");
+
+    @values = ( { "value" => "", "label" => "", "default" => 0 } );
+
+    foreach my $item (@{ $form->{"ALL_LANGUAGES"} }) {
+      next unless ($item->{"template_code"});
+
+      my $key = "$item->{id}--$item->{template_code}";
+
+      push(@values,
+           { "value"   => $key,
+             "label"   => $item->{"description"},
+             "default" => $key eq $form->{"language"} });
+    }
+
+    $options{"LANGUAGE"} = [ @values ];
+    $options{"SHOW_LANGUAGE"} = scalar(@values) > 1;
+
+    @values = ( { "value" => "", "label" => "", "default" => 0 } );
+
+    #
+    # Setup "printer" selection
+    #
+
+    foreach my $item (@{ $form->{"ALL_PRINTERS"} }) {
+      next unless ($item->{"template_code"});
+
+      my $key = "$item->{id}--$item->{template_code}";
+
+      push(@values,
+           { "value"   => $key,
+             "label"   => $item->{"printer_description"},
+             "default" => $key eq $form->{"printer"} });
+    }
+
+    $options{"PRINTER"} = [ @values ];
+    $options{"SHOW_PRINTER"} = scalar(@values) > 1;
+
+  } else {
+    push(@hidden, qw(formname language printer));
+  }
+
+  if ($form->{formname} || ($form->{type} eq "stylesheet")) {
+    $options{"SHOW_CONTENT"} = 1;
+
+    ($options{"filename"}, $options{"display_filename"})
+      = AM->prepare_template_filename(\%myconfig, $form);
+
+    ($options{"content"}, $options{"lines"})
+      = AM->load_template($options{"filename"});
+
+    $options{"CAN_EDIT"} = $form->{"edit"};
+
+    if ($form->{edit}) {
+      $form->{fokus} = "Form.content";
+
+    } else {
+      $options{"content"}                 = "\n\n" if (!$options{"content"});
+      $options{"SHOW_SECOND_EDIT_BUTTON"} = $options{"lines"} > 25;
+    }
+  }
+
+  $options{"HIDDEN"} = [ map(+{ "name" => $_, "value" => $form->{$_} }, @hidden) ];
+
+  $form->header;
+  print($form->parse_html_template("am/edit_templates", \%options));
+
+  $lxdebug->leave_sub();
+}
+
+1;
diff --git a/locale/de/am b/locale/de/am
index 70620429e..075e171bd 100644
--- a/locale/de/am
+++ b/locale/de/am
@@ -64,10 +64,8 @@ $self->{texts} = {
   'Aufwand EU o. UStId'         => 'Aufwand EU o. UStId',
   'Aufwand Inland'              => 'Aufwand Inland',
   'BWA'                         => 'BWA',
-  'Balance Sheet'               => 'Bilanz',
   'Bestandskonto'               => 'Bestandskonto',
   'Bilanz'                      => 'Bilanz',
-  'Bin List'                    => 'Lagerliste',
   'Books are open'              => 'Die B�cher sind ge�ffnet.',
   'Buchungsgruppe'              => 'Buchungsgruppe',
   'Buchungsgruppe bearbeiten'   => 'Buchungsgruppe bearbeiten',
@@ -83,14 +81,11 @@ $self->{texts} = {
   'Cannot save account!'        => 'Konto kann nicht gespeichert werden!',
   'Cannot save preferences!'    => 'Benutzereinstellungen k�nnen nicht gespeichert werden!',
   'Chart of Accounts'           => 'Konten�bersicht',
-  'Check'                       => 'Check',
   'Close Books up to'           => 'Die B�cher abschlie�en bis zum',
   'Company'                     => 'Firma',
-  'Confirmation'                => 'Auftragsbest�tigung',
   'Continue'                    => 'Weiter',
   'Cost Center'                 => 'Kostenstelle',
   'Costs'                       => 'Kosten',
-  'Credit Note'                 => 'Gutschrift',
   'Customer Number'             => 'Kundennummer',
   'Customernumberinit'          => 'Kunden-/Lieferantennummernkreis',
   'DELETED'                     => 'Gel�scht',
@@ -109,13 +104,10 @@ $self->{texts} = {
   'Description'                 => 'Beschreibung',
   'Description missing!'        => 'Beschreibung fehlt.',
   'Discount'                    => 'Rabatt',
-  'Display'                     => 'Anzeigen',
-  'Display file'                => 'Datei anzeigen',
   'Dropdown Limit'              => 'Auswahllistenbegrenzung',
   'E-mail'                      => 'eMail',
   'ELSE'                        => 'Zusatz',
   'EUER'                        => 'Einnahmen-/�berschussrechnung',
-  'Edit'                        => 'Bearbeiten',
   'Edit Account'                => 'Kontodaten bearbeiten',
   'Edit Buchungsgruppe'         => 'Buchungsgruppe bearbeiten',
   'Edit Business'               => 'Kunden-/Lieferantentyp bearbeiten',
@@ -125,9 +117,6 @@ $self->{texts} = {
   'Edit Payment Terms'          => 'Zahlungskonditionen bearbeiten',
   'Edit Preferences for'        => 'Benutzereinstellungen f�r',
   'Edit Printer'                => 'Drucker bearbeiten',
-  'Edit file'                   => 'Datei bearbeiten',
-  'Edit templates'              => 'Vorlage bearbeiten',
-  'Edit the stylesheet'         => 'Stilvorlage bearbeiten',
   'Enforce transaction reversal for all dates' => 'Gegenbuchungen f�r jeden Zeitraum aktualisieren',
   'Enter longdescription'       => 'Langtext eingeben',
   'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies' => 'Geben Sie Ihre und weitere W�hrungen mit bis zu drei Buchstaben pro W�hrung und W�hrungen durch Doppelpunkte getrennt ein (z.B. EUR:USD:CAD)',
@@ -151,10 +140,8 @@ $self->{texts} = {
   'History'                     => 'Historie',
   'History Search'              => 'Historien Suche',
   'Include in drop-down menus'  => 'In Aufklappmen� aufnehmen',
-  'Income Statement'            => 'GuV',
   'Inventory'                   => 'Inventar',
   'Inventory Account'           => 'Warenbestand',
-  'Invoice'                     => 'Rechnung',
   'Is this a summary account to record' => 'Buchungskonto in',
   'Language'                    => 'Sprache',
   'Language deleted!'           => 'Sprache gel�scht!',
@@ -201,19 +188,16 @@ $self->{texts} = {
   'POSTED'                      => 'Gebucht',
   'POSTED AS NEW'               => 'Als neu gebucht',
   'PRINTED'                     => 'Gedruckt',
-  'Packing List'                => 'Lieferschein',
   'Part Number'                 => 'Artikelnummer',
   'Part description'            => 'Artikelbeschreibung',
   'Parts Inventory'             => 'Warenliste',
   'Password'                    => 'Passwort',
   'Payables'                    => 'Verbindlichkeiten',
   'Payment'                     => 'Zahlungsausgang',
-  'Payment Reminder'            => 'Zahlungserinnerung',
   'Payment Terms'               => 'Zahlungskonditionen',
   'Payment Terms saved!'        => 'Zahlungskonditionen gespeichert!',
   'Payment terms deleted!'      => 'Zahlungskonditionen gel�scht!',
   'Phone'                       => 'Telefon',
-  'Pick List'                   => 'Sammelliste',
   'Please enter values'         => 'Bitte Werte eingeben',
   'Postscript'                  => 'Postscript',
   'Preferences saved!'          => 'Einstellungen gespeichert!',
@@ -225,13 +209,9 @@ $self->{texts} = {
   'Printer deleted!'            => 'Drucker gel�scht!',
   'Printer saved!'              => 'Drucker gespeichert!',
   'Profit Center'               => 'Erfolgsbereich',
-  'Proforma Invoice'            => 'Proformarechnung',
   'Project Number'              => 'Projektnummer',
   'Project description'         => 'Projektbeschreibung',
-  'Purchase Order'              => 'Lieferantenauftrag',
   'Queue'                       => 'Warteschlange',
-  'Quotation'                   => 'Angebot',
-  'RFQ'                         => 'Anfrage',
   'Rate'                        => 'Rate',
   'Receipt'                     => 'Zahlungseingang',
   'Receivables'                 => 'Forderungen',
@@ -241,7 +221,6 @@ $self->{texts} = {
   'SAVED FOR DUNNING'           => 'Gespeichert',
   'SCREENED'                    => 'Angezeigt',
   'Save'                        => 'Speichern',
-  'Saving the file \'%s\' failed. OS error message: %s' => 'Das Speichern der Datei \'%s\' schlug fehl. Fehlermeldung des Betriebssystems: %s',
   'Screen'                      => 'Bildschirm',
   'Select a Customer'           => 'Endkunde ausw�hlen',
   'Select a part'               => 'Artikel ausw&auml;hlen',
@@ -253,14 +232,10 @@ $self->{texts} = {
   'Signature'                   => 'Unterschrift',
   'Skonto'                      => 'Skonto',
   'Skonto Terms'                => 'Zahlungsziel Skonto',
-  'Statement'                   => 'Sammelrechnung',
   'Steuersatz'                  => 'Steuersatz',
-  'Storno Invoice'              => 'Stornorechnung',
-  'Storno Packing List'         => 'Stornolieferschein',
   'Stylesheet'                  => 'Stilvorlage',
   'Tax'                         => 'Steuer',
   'Tax Accounts'                => 'Steuerkonto',
-  'Template'                    => 'Druckvorlage',
   'Template Code'               => 'Vorlagenk�rzel',
   'Template Code missing!'      => 'Vorlagenk�rzel fehlt!',
   'The \'tag\' field must only consist of alphanumeric characters or the carachters - _ ( )' => 'Das Feld \'tag\' darf nur aus alphanumerischen Zeichen und den Zeichen - _ ( ) bestehen.',
@@ -282,11 +257,6 @@ $self->{texts} = {
   'Transaction reversal enforced up to' => 'Fehleintragungen k�nnen bis zu dem angegebenen Zeitraum nur mit einer Kontraeintragung ausgebessert werden!',
   'Translation (%s)'            => '&Uuml;bersetzung (%s)',
   'Type of Business'            => 'Kunden-/Lieferantentyp',
-  'USTVA'                       => 'USTVA',
-  'USTVA 2004'                  => 'USTVA 2004',
-  'USTVA 2005'                  => 'USTVA 2005',
-  'USTVA 2006'                  => 'USTVA 2006',
-  'USTVA 2007'                  => 'USTVA 2007',
   'UStVA-Nr. 35'                => 'Kz. 35',
   'UStVA-Nr. 36'                => 'Kz. 36',
   'UStVA-Nr. 39'                => 'Kz. 37',
@@ -343,7 +313,6 @@ $self->{texts} = {
   'Year End'                    => 'Jahresende',
   'Yes'                         => 'Ja',
   'You can use the following strings in the long description and all translations. They will be replaced by their actual values by Lx-Office before they\'re output.' => 'Sie k&ouml;nnen im Langtext und allen �bersetzungen die folgenden Variablen benutzen, die vor der Ausgabe von Lx-Office automatisch ersetzt werden:',
-  'You\'re not editing a file.' => 'Sie bearbeiten momentan keine Datei.',
   'bin_list'                    => 'Lagerliste',
   'dimension units'             => 'Ma&szlig;einheiten',
   'down'                        => 'runter',
@@ -397,8 +366,6 @@ $self->{subs} = {
   'delivery_customer_selection' => 'delivery_customer_selection',
   'department_header'           => 'department_header',
   'display'                     => 'display',
-  'display_template'            => 'display_template',
-  'display_template_form'       => 'display_template_form',
   'doclose'                     => 'doclose',
   'edit'                        => 'edit',
   'edit_account'                => 'edit_account',
@@ -409,7 +376,6 @@ $self->{subs} = {
   'edit_lead'                   => 'edit_lead',
   'edit_payment'                => 'edit_payment',
   'edit_printer'                => 'edit_printer',
-  'edit_template'               => 'edit_template',
   'edit_units'                  => 'edit_units',
   'employee_selection_internal' => 'employee_selection_internal',
   'form_footer'                 => 'form_footer',
@@ -442,7 +408,6 @@ $self->{subs} = {
   'save_payment'                => 'save_payment',
   'save_preferences'            => 'save_preferences',
   'save_printer'                => 'save_printer',
-  'save_template'               => 'save_template',
   'save_unit'                   => 'save_unit',
   'select_employee'             => 'select_employee',
   'select_employee_internal'    => 'select_employee_internal',
@@ -461,8 +426,6 @@ $self->{subs} = {
   'konto_erfassen'              => 'add_account',
   'weiter'                      => 'continue',
   'l�schen'                     => 'delete',
-  'anzeigen'                    => 'display',
-  'bearbeiten'                  => 'edit',
   'kontodaten_bearbeiten'       => 'edit_account',
   'speichern'                   => 'save',
   'abschicken'                  => 'abschicken',
diff --git a/locale/de/amtemplates b/locale/de/amtemplates
new file mode 100644
index 000000000..8e17295a7
--- /dev/null
+++ b/locale/de/amtemplates
@@ -0,0 +1,118 @@
+$self->{texts} = {
+  'ADDED'                       => 'Hinzugef�gt',
+  'Address'                     => 'Adresse',
+  'BWA'                         => 'BWA',
+  'Balance Sheet'               => 'Bilanz',
+  'Bin List'                    => 'Lagerliste',
+  'Check'                       => 'Check',
+  'Confirmation'                => 'Auftragsbest�tigung',
+  'Credit Note'                 => 'Gutschrift',
+  'Customer Number'             => 'Kundennummer',
+  'DELETED'                     => 'Gel�scht',
+  'DUNNING STARTED'             => 'DUNNING STARTED',
+  'Dataset upgrade'             => 'Datenbankaktualisierung',
+  'Dependency loop detected:'   => 'Schleife in den Abh&auml;ngigkeiten entdeckt:',
+  'ELSE'                        => 'Zusatz',
+  'Edit templates'              => 'Vorlage bearbeiten',
+  'Edit the stylesheet'         => 'Stilvorlage bearbeiten',
+  'Enter longdescription'       => 'Langtext eingeben',
+  'Error in database control file \'%s\': %s' => 'Fehler in Datenbankupgradekontrolldatei \'%s\': %s',
+  'History'                     => 'Historie',
+  'Income Statement'            => 'GuV',
+  'Invoice'                     => 'Rechnung',
+  'MAILED'                      => 'Gesendet',
+  'Missing \'description\' field.' => 'Fehlendes Feld \'description\'.',
+  'Missing \'tag\' field.'      => 'Fehlendes Feld \'tag\'.',
+  'More than one control file with the tag \'%s\' exist.' => 'Es gibt mehr als eine Kontrolldatei mit dem Tag \'%s\'.',
+  'Name'                        => 'Name',
+  'No Customer was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Endkunde gefunden',
+  'No Vendor was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein H�ndler gefunden',
+  'No employee was found matching the search parameters.' => 'Es wurde kein Angestellter gefunden, auf den die Suchparameter zutreffen.',
+  'No part was found matching the search parameters.' => 'Es wurde kein Artikel gefunden, auf den die Suchparameter zutreffen.',
+  'No project was found matching the search parameters.' => 'Es wurde kein Projekt gefunden, auf das die Suchparameter zutreffen.',
+  'PAYMENT POSTED'              => 'Rechung gebucht',
+  'POSTED'                      => 'Gebucht',
+  'POSTED AS NEW'               => 'Als neu gebucht',
+  'PRINTED'                     => 'Gedruckt',
+  'Packing List'                => 'Lieferschein',
+  'Part Number'                 => 'Artikelnummer',
+  'Part description'            => 'Artikelbeschreibung',
+  'Payment Reminder'            => 'Zahlungserinnerung',
+  'Pick List'                   => 'Sammelliste',
+  'Please enter values'         => 'Bitte Werte eingeben',
+  'Proforma Invoice'            => 'Proformarechnung',
+  'Project Number'              => 'Projektnummer',
+  'Project description'         => 'Projektbeschreibung',
+  'Purchase Order'              => 'Lieferantenauftrag',
+  'Quotation'                   => 'Angebot',
+  'RFQ'                         => 'Anfrage',
+  'Receipt'                     => 'Zahlungseingang',
+  'SAVED'                       => 'Gespeichert',
+  'SAVED FOR DUNNING'           => 'Gespeichert',
+  'SCREENED'                    => 'Angezeigt',
+  'Saving the file \'%s\' failed. OS error message: %s' => 'Das Speichern der Datei \'%s\' schlug fehl. Fehlermeldung des Betriebssystems: %s',
+  'Select a Customer'           => 'Endkunde ausw�hlen',
+  'Select a part'               => 'Artikel ausw&auml;hlen',
+  'Select a project'            => 'Projekt ausw&auml;hlen',
+  'Select an employee'          => 'Angestellten ausw&auml;hlen',
+  'Statement'                   => 'Sammelrechnung',
+  'Storno Invoice'              => 'Stornorechnung',
+  'Storno Packing List'         => 'Stornolieferschein',
+  'The \'tag\' field must only consist of alphanumeric characters or the carachters - _ ( )' => 'Das Feld \'tag\' darf nur aus alphanumerischen Zeichen und den Zeichen - _ ( ) bestehen.',
+  'USTVA'                       => 'USTVA',
+  'USTVA 2004'                  => 'USTVA 2004',
+  'USTVA 2005'                  => 'USTVA 2005',
+  'USTVA 2006'                  => 'USTVA 2006',
+  'USTVA 2007'                  => 'USTVA 2007',
+  'Unit'                        => 'Einheit',
+  'Unknown dependency \'%s\'.'  => 'Unbekannte Abh&auml;ngigkeit \'%s\'.',
+  'Value'                       => 'Wert',
+  'Variable'                    => 'Variable',
+  'You\'re not editing a file.' => 'Sie bearbeiten momentan keine Datei.',
+  'bin_list'                    => 'Lagerliste',
+  'invoice'                     => 'Rechnung',
+  'packing_list'                => 'Versandliste',
+  'pick_list'                   => 'Entnahmeliste',
+  'proforma'                    => 'Proforma',
+  'purchase_order'              => 'Auftrag',
+  'request_quotation'           => 'Angebotsanforderung',
+  'sales_order'                 => 'Kundenauftrag',
+  'sales_quotation'             => 'Verkaufsangebot',
+};
+
+$self->{subs} = {
+  'E'                           => 'E',
+  'H'                           => 'H',
+  'NTI'                         => 'NTI',
+  'Q'                           => 'Q',
+  'build_std_url'               => 'build_std_url',
+  'calculate_qty'               => 'calculate_qty',
+  'delivery_customer_selection' => 'delivery_customer_selection',
+  'display'                     => 'display',
+  'display_template'            => 'display_template',
+  'display_template_form'       => 'display_template_form',
+  'edit'                        => 'edit',
+  'edit_template'               => 'edit_template',
+  'employee_selection_internal' => 'employee_selection_internal',
+  'format_dates'                => 'format_dates',
+  'part_selection_internal'     => 'part_selection_internal',
+  'project_selection_internal'  => 'project_selection_internal',
+  'reformat_numbers'            => 'reformat_numbers',
+  'restore_form'                => 'restore_form',
+  'save'                        => 'save',
+  'save_form'                   => 'save_form',
+  'save_template'               => 'save_template',
+  'select_employee'             => 'select_employee',
+  'select_employee_internal'    => 'select_employee_internal',
+  'select_part'                 => 'select_part',
+  'select_part_internal'        => 'select_part_internal',
+  'set_longdescription'         => 'set_longdescription',
+  'show_history'                => 'show_history',
+  'vendor_selection'            => 'vendor_selection',
+  'weiter'                      => 'continue',
+  'anzeigen'                    => 'display',
+  'bearbeiten'                  => 'edit',
+  'speichern'                   => 'save',
+};
+
+1;
diff --git a/menu.ini b/menu.ini
index 3bd1350bb..0d5b8b615 100644
--- a/menu.ini
+++ b/menu.ini
@@ -574,19 +574,19 @@ target=acc_menu
 submenu=1
 
 [System--Templates--HTML Templates]
-module=am.pl
+module=amtemplates.pl
 action=display_template_form
 type=templates
 format=html
 
 [System--Templates--LaTeX Templates]
-module=am.pl
+module=amtemplates.pl
 action=display_template_form
 type=templates
 format=tex
 
 [System--Templates--Stylesheet]
-module=am.pl
+module=amtemplates.pl
 action=display_template_form
 type=stylesheet
 
diff --git a/templates/webpages/am/edit_templates_de.html b/templates/webpages/am/edit_templates_de.html
new file mode 100644
index 000000000..ca0e62f40
--- /dev/null
+++ b/templates/webpages/am/edit_templates_de.html
@@ -0,0 +1,75 @@
+<body>
+
+ <div class="listheading"><TMPL_VAR title></div>
+
+ <form method="post" name="Form" action="amtemplates.pl">
+
+  <TMPL_LOOP HIDDEN><input type="hidden" name="<TMPL_VAR name ESCAPE=HTML>" value="<TMPL_VAR value ESCAPE=HTML>"></TMPL_LOOP>
+
+  <TMPL_IF SHOW_EDIT_OPTIONS>
+   <p>
+    Druckvorlage
+    <select name="formname">
+     <TMPL_LOOP FORMNAME><option value="<TMPL_VAR value ESCAPE=HTML>" <TMPL_IF default>selected</TMPL_IF>><TMPL_VAR label ESCAPE=HTML></option></TMPL_LOOP>
+    </select>
+
+    <TMPL_IF SHOW_LANGUAGE>
+     Sprache
+     <select name="language">
+      <TMPL_LOOP LANGUAGE><option value="<TMPL_VAR value ESCAPE=HTML>" <TMPL_IF default>selected</TMPL_IF>><TMPL_VAR label ESCAPE=HTML></option></TMPL_LOOP>
+     </select>
+    </TMPL_IF>
+
+    <TMPL_IF SHOW_PRINTER>
+     Drucker
+     <select name="printer">
+      <TMPL_LOOP PRINTER><option value="<TMPL_VAR value ESCAPE=HTML>" <TMPL_IF default>selected</TMPL_IF>><TMPL_VAR label ESCAPE=HTML></option></TMPL_LOOP>
+     </select>
+    </TMPL_IF>
+
+    <input type="hidden" name="display_nextsub" value="display_template">
+
+    <input name="action" type="submit" class="submit" value="Anzeigen">
+
+   </p>
+
+   <hr>
+  </TMPL_IF>
+
+
+
+  <TMPL_IF SHOW_CONTENT>
+   <p>
+    <div class="listtop">
+     <TMPL_IF CAN_EDIT>Datei bearbeiten<TMPL_ELSE>Datei anzeigen</TMPL_IF> <TMPL_VAR display_filename ESCAPE=HTML>
+    </div>
+   </p>
+
+   <TMPL_IF CAN_EDIT>
+    <p><textarea name="content" id="content" cols="100" rows="25"><TMPL_VAR content ESCAPE=HTML></textarea></p>
+
+    <p>
+     <input type="hidden" name="save_nextsub" value="save_template">
+     <input type="submit" name="action" value="Speichern">
+    </p>
+
+    <TMPL_ELSE>
+
+    <input type="hidden" name="edit_nextsub" value="edit_template">
+
+    <p><input name="action" type="submit" class="submit" value="Bearbeiten"></p>
+
+    <p><pre class="filecontent"><TMPL_VAR content ESCAPE=HTML></pre></p>
+
+    <TMPL_IF SHOW_SECOND_EDIT_BUTTON>
+     <p><input name="action" type="submit" class="submit" value="Bearbeiten"></p>
+    </TMPL_IF>
+
+   </TMPL_IF> <!-- CAN_EDIT -->
+
+  </TMPL_IF> <!-- SHOW_CONTENT -->
+
+ </form>
+
+</body>
+</html>
diff --git a/templates/webpages/am/edit_templates_master.html b/templates/webpages/am/edit_templates_master.html
new file mode 100644
index 000000000..3a166ec3a
--- /dev/null
+++ b/templates/webpages/am/edit_templates_master.html
@@ -0,0 +1,75 @@
+<body>
+
+ <div class="listheading"><TMPL_VAR title></div>
+
+ <form method="post" name="Form" action="amtemplates.pl">
+
+  <TMPL_LOOP HIDDEN><input type="hidden" name="<TMPL_VAR name ESCAPE=HTML>" value="<TMPL_VAR value ESCAPE=HTML>"></TMPL_LOOP>
+
+  <TMPL_IF SHOW_EDIT_OPTIONS>
+   <p>
+    <translate>Template</translate>
+    <select name="formname">
+     <TMPL_LOOP FORMNAME><option value="<TMPL_VAR value ESCAPE=HTML>" <TMPL_IF default>selected</TMPL_IF>><TMPL_VAR label ESCAPE=HTML></option></TMPL_LOOP>
+    </select>
+
+    <TMPL_IF SHOW_LANGUAGE>
+     <translate>Language</translate>
+     <select name="language">
+      <TMPL_LOOP LANGUAGE><option value="<TMPL_VAR value ESCAPE=HTML>" <TMPL_IF default>selected</TMPL_IF>><TMPL_VAR label ESCAPE=HTML></option></TMPL_LOOP>
+     </select>
+    </TMPL_IF>
+
+    <TMPL_IF SHOW_PRINTER>
+     <translate>Printer</translate>
+     <select name="printer">
+      <TMPL_LOOP PRINTER><option value="<TMPL_VAR value ESCAPE=HTML>" <TMPL_IF default>selected</TMPL_IF>><TMPL_VAR label ESCAPE=HTML></option></TMPL_LOOP>
+     </select>
+    </TMPL_IF>
+
+    <input type="hidden" name="display_nextsub" value="display_template">
+
+    <input name="action" type="submit" class="submit" value="<translate>Display</translate>">
+
+   </p>
+
+   <hr>
+  </TMPL_IF>
+
+
+
+  <TMPL_IF SHOW_CONTENT>
+   <p>
+    <div class="listtop">
+     <TMPL_IF CAN_EDIT><translate>Edit file</translate><TMPL_ELSE><translate>Display file</translate></TMPL_IF> <TMPL_VAR display_filename ESCAPE=HTML>
+    </div>
+   </p>
+
+   <TMPL_IF CAN_EDIT>
+    <p><textarea name="content" id="content" cols="100" rows="25"><TMPL_VAR content ESCAPE=HTML></textarea></p>
+
+    <p>
+     <input type="hidden" name="save_nextsub" value="save_template">
+     <input type="submit" name="action" value="<translate>Save</translate>">
+    </p>
+
+    <TMPL_ELSE>
+
+    <input type="hidden" name="edit_nextsub" value="edit_template">
+
+    <p><input name="action" type="submit" class="submit" value="<translate>Edit</translate>"></p>
+
+    <p><pre class="filecontent"><TMPL_VAR content ESCAPE=HTML></pre></p>
+
+    <TMPL_IF SHOW_SECOND_EDIT_BUTTON>
+     <p><input name="action" type="submit" class="submit" value="<translate>Edit</translate>"></p>
+    </TMPL_IF>
+
+   </TMPL_IF> <!-- CAN_EDIT -->
+
+  </TMPL_IF> <!-- SHOW_CONTENT -->
+
+ </form>
+
+</body>
+</html>
