sub _save {
my ($self) = @_;
+ my @errors = $self->{cv}->validate;
+ if (@errors) {
+ flash('error', @errors);
+ $self->_pre_render();
+ $self->render(
+ 'customer_vendor/form',
+ title => ($self->is_vendor() ? t8('Edit Vendor') : t8('Edit Customer')),
+ %{$self->{template_args}}
+ );
+ ::end_of_request();
+ }
+
my $db = $self->{cv}->db;
$db->do_transaction(sub {
sub action_save {
my ($self) = @_;
- if (!$self->{cv}->name) {
- flash('error', t8('Customer missing!'));
- $self->_pre_render();
- $self->render(
- 'customer_vendor/form',
- title => ($self->is_vendor() ? t8('Edit Vendor') : t8('Edit Customer')),
- %{$self->{template_args}}
- );
- } else {
-
- $self->_save();
-
- my @redirect_params = (
- action => 'edit',
- id => $self->{cv}->id,
- db => ($self->is_vendor() ? 'vendor' : 'customer'),
- );
+ $self->_save();
- if ( $self->{contact}->cp_id ) {
- push(@redirect_params, contact_id => $self->{contact}->cp_id);
- }
+ my @redirect_params = (
+ action => 'edit',
+ id => $self->{cv}->id,
+ db => ($self->is_vendor() ? 'vendor' : 'customer'),
+ );
- if ( $self->{shipto}->shipto_id ) {
- push(@redirect_params, shipto_id => $self->{shipto}->shipto_id);
- }
+ if ( $self->{contact}->cp_id ) {
+ push(@redirect_params, contact_id => $self->{contact}->cp_id);
+ }
- $self->redirect_to(@redirect_params);
+ if ( $self->{shipto}->shipto_id ) {
+ push(@redirect_params, shipto_id => $self->{shipto}->shipto_id);
}
+
+ $self->redirect_to(@redirect_params);
}
sub action_save_and_close {
return 1;
}
+sub validate {
+ my ($self) = @_;
+
+ my @errors;
+ push @errors, $::locale->text('The customer name is missing.') if !$self->name;
+
+ return @errors;
+}
+
sub short_address {
my ($self) = @_;
return 1;
}
+sub validate {
+ my ($self) = @_;
+
+ my @errors;
+ push @errors, $::locale->text('The vendor name is missing.') if !$self->name;
+
+ return @errors;
+}
+
sub displayable_name {
my $self = shift;
'The custom variable has been deleted.' => 'Die benutzerdefinierte Variable wurde gelöscht.',
'The custom variable has been saved.' => 'Die benutzerdefinierte Variable wurde gespeichert.',
'The custom variable is in use and cannot be deleted.' => 'Die benutzerdefinierte Variable ist in Benutzung und kann nicht gelöscht werden.',
+ 'The customer name is missing.' => 'Der Kundenname fehlt.',
'The database for user management and authentication does not exist. You can create let kivitendo create it with the following parameters:' => 'Die Datenbank für die Benutzeranmeldung existiert nicht. Sie können Sie von kivitendo automatisch mit den folgenden Parametern anlegen lassen:',
'The database host is missing.' => 'Der Datenbankhost fehlt.',
'The database name is missing.' => 'Der Datenbankname fehlt.',
'The user has been deleted.' => 'Der Benutzer wurde gelöscht.',
'The user has been saved.' => 'Der Benutzer wurde gespeichert.',
'The variable name must only consist of letters, numbers and underscores. It must begin with a letter. Example: send_christmas_present' => 'Der Variablenname darf nur aus Zeichen (keine Umlaute), Ziffern und Unterstrichen bestehen. Er muss mit einem Buchstaben beginnen. Beispiel: weihnachtsgruss_verschicken',
+ 'The vendor name is missing.' => 'Der Liefeantenname fehlt.',
'The version number is missing.' => 'Die Versionsnummer fehlt.',
'The warehouse could not be deleted because it has already been used.' => 'Das Lager konnte nicht gelöscht werden, da es bereits in Benutzung war.',
'The warehouse does not contain any bins.' => 'Das Lager enthält keine Lagerplätze.',
'The custom variable has been deleted.' => '',
'The custom variable has been saved.' => '',
'The custom variable is in use and cannot be deleted.' => '',
+ 'The customer name is missing.' => '',
'The database for user management and authentication does not exist. You can create let kivitendo create it with the following parameters:' => '',
'The database host is missing.' => '',
'The database name is missing.' => '',
'The user has been deleted.' => '',
'The user has been saved.' => '',
'The variable name must only consist of letters, numbers and underscores. It must begin with a letter. Example: send_christmas_present' => '',
+ 'The vendor name is missing.' => '',
'The warehouse could not be deleted because it has already been used.' => '',
'The warehouse does not contain any bins.' => '',
'The warehouse or the bin is missing.' => '',