+ # Check templates
+ $::form->{new_templates} =~ s:/::g;
+ $::form->{new_master_templates} =~ s:/::g;
+
+ if (($::form->{use_templates} eq 'existing') && ($self->defaults->templates !~ m:^templates/[^/]+$:)) {
+ push @errors, t8('You must select existing print templates or create a new set.');
+
+ } elsif ($::form->{use_templates} eq 'new') {
+ if (!$::form->{new_templates}) {
+ push @errors, t8('You must enter a name for your new print templates.');
+ } elsif (-d "templates/" . $::form->{new_templates}) {
+ push @errors, t8('A directory with the name for the new print templates exists already.');
+ } elsif (! -d "templates/print/" . $::form->{new_master_templates}) {
+ push @errors, t8('The master templates where not found.');
+ }
+ }
+
+ my $cleaned_ustid = SL::VATIDNr->clean($defaults->{co_ustid});
+ if ($cleaned_ustid && !SL::VATIDNr->validate($cleaned_ustid)) {
+ push @errors, t8("The VAT ID number '#1' is invalid.", $defaults->{co_ustid});
+ }
+
+ # Show form again if there were any errors. Nothing's been changed
+ # yet in the database.