Merge branch 'auftrag-loeschen-und-wiedervorlagen-2310'
[kivitendo-erp.git] / bin / mozilla / amtemplates.pl
index 9f21e22..f8c6972 100644 (file)
@@ -33,6 +33,7 @@
 
 use File::Find;
 
+use SL::DB::Default;
 use SL::AM;
 use SL::Form;
 
@@ -115,6 +116,9 @@ sub display_template_form {
 
   $main::auth->assert('admin');
 
+  my $defaults = SL::DB::Default->get;
+  $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
+
   if ($form->{"formname"} =~ m|\.\.| || $form->{"formname"} =~ m|^/|) {
     $form->{"formname"} =~ s|.*/||;
   }
@@ -205,13 +209,13 @@ sub display_template_form {
 
           my $fname = $File::Find::name;
           # remove template dir from name
-          $fname =~ s|^$myconfig{templates}/||;
+          $fname =~ s|^templates/[^/+]/||;
           # remove .tex from name
           $fname =~ s|.tex$||;
 
           push(@all_files, $fname);
 
-          }, $myconfig{templates});
+          }, $defaults->templates);
 
       # filter all files already set up (i.e. not already in @values)
       my @other_files = grep { my $a=$_; not grep {$a eq $_->{value}} @values } @all_files;
@@ -271,10 +275,7 @@ sub display_template_form {
 
     $options{"CAN_EDIT"} = $form->{"edit"};
 
-    if ($form->{edit}) {
-      $::request->{layout}->focus("#edit_content");
-
-    } else {
+    if (!$form->{edit}) {
       $options{"content"}                 = "\n\n" if (!$options{"content"});
       $options{"SHOW_SECOND_EDIT_BUTTON"} = $options{"lines"} > 25;
     }