From: Bernd Bleßmann Date: Thu, 5 Nov 2015 10:41:49 +0000 (+0100) Subject: Beim jedem Speichern von Kunden/Lieferanten prüfen, ob der Name angegeben ist. X-Git-Tag: release-3.4.1~595 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=454d4b8fde0a834abf462fbf691d2f563d5aed66;p=kivitendo-erp.git Beim jedem Speichern von Kunden/Lieferanten prüfen, ob der Name angegeben ist. Vorher wurde das nur beim reinen Speichern geprüft, nicht beim Speichern und Schließen oder Fortfahren mit einem Beleg. Behebt #84 (redmine). --- diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index 403413ffc..dbe18274e 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -113,6 +113,18 @@ sub action_show { 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 { @@ -193,34 +205,23 @@ sub _save { 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 { diff --git a/SL/DB/Customer.pm b/SL/DB/Customer.pm index e3e30ddff..048db7c10 100644 --- a/SL/DB/Customer.pm +++ b/SL/DB/Customer.pm @@ -41,6 +41,15 @@ sub _before_save_set_customernumber { 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) = @_; diff --git a/SL/DB/Vendor.pm b/SL/DB/Vendor.pm index ebbe8125f..b1458efc3 100644 --- a/SL/DB/Vendor.pm +++ b/SL/DB/Vendor.pm @@ -41,6 +41,15 @@ sub _before_save_set_vendornumber { 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; diff --git a/locale/de/all b/locale/de/all index aa32256c2..885e9cab6 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2702,6 +2702,7 @@ $self->{texts} = { '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.', @@ -2896,6 +2897,7 @@ $self->{texts} = { '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.', diff --git a/locale/en/all b/locale/en/all index 05375ace6..62a26965b 100644 --- a/locale/en/all +++ b/locale/en/all @@ -2135,6 +2135,7 @@ $self->{texts} = { '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.' => '', @@ -2271,6 +2272,7 @@ $self->{texts} = { '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.' => '',