X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCustomerVendor.pm;h=767ffa51dd212fb7e36ecb30638a166508e215f3;hb=b623ece7b8ba928117bc2280d64d3ef8cbed2e48;hp=b64c121afe499137d4e4b834bb710e32f0e8410f;hpb=b33396197e203f36a2edc30c3761840130a5d4bd;p=kivitendo-erp.git diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index b64c121af..767ffa51d 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -18,6 +18,7 @@ use SL::DB::PaymentTerm; use SL::DB::Pricegroup; use SL::DB::Contact; use SL::DB::FollowUp; +use SL::DB::FollowUpLink; use SL::DB::History; use SL::DB::Currency; @@ -117,12 +118,25 @@ sub _save { } if( $self->{note}->subject ne '' && $self->{note}->body ne '' ) { + + if ( !$self->{note_followup}->follow_up_date ) { + $::form->error($::locale->text('Date missing!')); + } + $self->{note}->trans_id($self->{cv}->id); $self->{note}->save(); + $self->{note_followup}->save(); + $self->{note_followup_link}->follow_up_id($self->{note_followup}->id); + $self->{note_followup_link}->trans_id($self->{cv}->id); + $self->{note_followup_link}->save(); + + SL::Helper::Flash::flash_later('info', $::locale->text('Follow-Up saved.')); + $self->{note} = SL::DB::Note->new(); $self->{note_followup} = SL::DB::FollowUp->new(); + $self->{note_followup_link} = SL::DB::FollowUpLink->new(); } $self->{shipto}->trans_id($self->{cv}->id); @@ -146,7 +160,21 @@ sub action_save { $self->_save(); - $self->redirect_to(action => 'edit', id => $self->{cv}->id, db => $self->is_vendor() ? 'vendor' : 'customer'); + my @redirect_params = ( + action => 'edit', + id => $self->{cv}->id, + db => ($self->is_vendor() ? 'vendor' : 'customer'), + ); + + if ( $self->{contact}->cp_id ) { + push(@redirect_params, contact_id => $self->{contact}->cp_id); + } + + if ( $self->{shipto}->shipto_id ) { + push(@redirect_params, shipto_id => $self->{shipto}->shipto_id); + } + + $self->redirect_to(@redirect_params); } sub action_save_and_close { @@ -606,6 +634,11 @@ sub _instantiate_args { $self->{note_followup}->note($self->{note}); $self->{note_followup}->created_by($curr_employee->id); + $self->{note_followup_link} = SL::DB::FollowUpLink->new( + trans_type => ($self->is_vendor() ? 'vendor' : 'customer'), + trans_info => $self->{cv}->name + ); + if ( $::form->{shipto}->{shipto_id} ) { $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto}->{shipto_id})->load(); } else { @@ -643,6 +676,7 @@ sub _load_customer_vendor { $self->{note} = SL::DB::Note->new(); $self->{note_followup} = SL::DB::FollowUp->new(); + $self->{note_followup_link} = SL::DB::FollowUpLink->new(); if ( $::form->{shipto_id} ) { $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto_id})->load();