X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCustomerVendor.pm;h=f57c4b8bdd424774896ec3e83827b86e357f0591;hb=049e49fea3e4a3c7c78d7aebf055936b3cab40c5;hp=468e02618d69dd1cef5a26afe166ab842f54e308;hpb=83b3c64ecfdbcd1c3dc1e1586af1260bc0917aeb;p=kivitendo-erp.git diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index 468e02618..f57c4b8bd 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -543,19 +543,27 @@ sub action_ajaj_get_contact { }; $data->{contact_cvars} = { - map( - { - if ( $_->config->type eq 'number' ) { - $_->config->name => $::form->format_amount(\%::myconfig, $_->value, -2); - } else { - $_->config->name => $_->value; - } + map { + my $cvar = $_; + my $result = { type => $cvar->config->type }; + + if ($cvar->config->type eq 'number') { + $result->{value} = $::form->format_amount(\%::myconfig, $cvar->value, -2); + + } elsif ($result->{type} =~ m{customer|vendor|part}) { + my $object = $cvar->value; + my $method = $result->{type} eq 'part' ? 'description' : 'name'; + + $result->{id} = int($cvar->number_value) || undef; + $result->{value} = $object ? $object->$method // '' : ''; + + } else { + $result->{value} = $cvar->value; } - grep( - { $_->is_valid; } - @{$self->{contact}->cvars_by_config} - ) - ) + + ( $cvar->config->name => $result ) + + } grep { $_->is_valid } @{ $self->{contact}->cvars_by_config } }; $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); @@ -637,7 +645,7 @@ sub is_orphaned { } my $arap = $self->is_vendor ? 'ap' : 'ar'; - my $num_args = 2; + my $num_args = 3; my $cv = $self->is_vendor ? 'vendor' : 'customer'; @@ -652,6 +660,13 @@ sub is_orphaned { SELECT a.id FROM oe a JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id) + WHERE ct.id = ? + + UNION + + SELECT a.id + FROM delivery_orders a + JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id) WHERE ct.id = ?';