X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/dcf47a5679795c959e663f7f6b6dd78eb786b1b7..cac2ae9bcd47fc55d35c37e25dbb03cd6ac6edeb:/SL/Controller/CustomerVendor.pm diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index 46270bc7d..de7749037 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -147,6 +147,19 @@ sub _save { employee_id => SL::DB::Manager::Employee->current->id, addition => 'SAVED', )->save(); + + if ( $::form->{delete_notes} ) { + foreach my $note_id (@{ $::form->{delete_notes} }) { + my $note = SL::DB::Note->new(id => $note_id)->load(); + if ( $note->follow_up ) { + if ( $note->follow_up->follow_up_link ) { + $note->follow_up->follow_up_link->delete(cascade => 'delete'); + } + $note->follow_up->delete(cascade => 'delete'); + } + $note->delete(cascade => 'delete'); + } + } }) || die($db->error); } @@ -381,6 +394,8 @@ sub action_search_contact { sub action_get_delivery { my ($self) = @_; + $::auth->assert('sales_all_edit'); + my $dbh = $::form->get_standard_dbh(); my ($arap, $db, $qty_sign); @@ -394,21 +409,24 @@ sub action_get_delivery { $qty_sign = ''; } - my $where = ' WHERE 1=1 '; + my $where = ' WHERE 1=1'; my @values; if ( !$self->is_vendor() && $::form->{shipto_id} && $::form->{shipto_id} ne 'all' ) { - $where .= "AND ${arap}.shipto_id = ?"; + $where .= " AND ${arap}.shipto_id = ?"; push(@values, $::form->{shipto_id}); + } else { + $where .= " AND ${arap}.${db}_id = ?"; + push(@values, $::form->{id}); } if ( $::form->{delivery_from} ) { - $where .= "AND ${arap}.transdate >= ?"; + $where .= " AND ${arap}.transdate >= ?"; push(@values, conv_date($::form->{delivery_from})); } if ( $::form->{delivery_to} ) { - $where .= "AND ${arap}.transdate <= ?"; + $where .= " AND ${arap}.transdate <= ?"; push(@values, conv_date($::form->{delivery_to})); } @@ -622,17 +640,8 @@ sub _instantiate_args { if ( $::form->{note}->{id} ) { $self->{note} = SL::DB::Note->new(id => $::form->{note}->{id})->load(); - - $self->{note_followup_link} = SL::DB::Manager::FollowUpLink->get_all( - query => [ - 'follow_up.note_id' => $self->{note}->id, - trans_id => $self->{cv}->id, - trans_type => ($self->is_vendor() ? 'vendor' : 'customer'), - ], - with_objects => ['follow_up'], - )->[0]; - - $self->{note_followup} = $self->{note_followup_link}->follow_up; + $self->{note_followup} = $self->{note}->follow_up; + $self->{note_followup_link} = $self->{note_followup}->follow_up_link; } else { $self->{note} = SL::DB::Note->new(); $self->{note_followup} = SL::DB::FollowUp->new(); @@ -687,17 +696,8 @@ sub _load_customer_vendor { if ( $::form->{note_id} ) { $self->{note} = SL::DB::Note->new(id => $::form->{note_id})->load(); - - $self->{note_followup_link} = SL::DB::Manager::FollowUpLink->get_all( - query => [ - 'follow_up.note_id' => $self->{note}->id, - trans_id => $self->{cv}->id, - trans_type => ($self->is_vendor() ? 'vendor' : 'customer'), - ], - with_objects => ['follow_up'], - )->[0]; - - $self->{note_followup} = $self->{note_followup_link}->follow_up; + $self->{note_followup} = $self->{note}->follow_up; + $self->{note_followup_link} = $self->{note_followup}->follow_up_link; } else { $self->{note} = SL::DB::Note->new(); $self->{note_followup} = SL::DB::FollowUp->new(); @@ -812,6 +812,8 @@ sub _pre_render { $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all(); + $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all(); + $self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all(); $query = @@ -832,6 +834,14 @@ sub _pre_render { $self->{shiptos} = $self->{cv}->shipto; $self->{shiptos} ||= []; + $self->{notes} = SL::DB::Manager::Note->get_all( + query => [ + trans_id => $self->{cv}->id, + trans_module => 'ct', + ], + with_objects => ['follow_up'], + ); + $self->{template_args} ||= {}; $::request->{layout}->add_javascripts('autocomplete_customer.js');