X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d4338f3d74459e64da07c4b73839cea80aec3108..454d4b8fde0a834abf462fbf691d2f563d5aed66:/SL/Controller/CustomerVendor.pm 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 {