Revision 65690235
Von Moritz Bunkus vor fast 10 Jahren hinzugefügt
SL/Controller/CustomerVendor.pm | ||
---|---|---|
543 | 543 |
}; |
544 | 544 |
|
545 | 545 |
$data->{contact_cvars} = { |
546 |
map( |
|
547 |
{ |
|
548 |
if ( $_->config->type eq 'number' ) { |
|
549 |
$_->config->name => $::form->format_amount(\%::myconfig, $_->value, -2); |
|
550 |
} else { |
|
551 |
$_->config->name => $_->value; |
|
552 |
} |
|
546 |
map { |
|
547 |
my $cvar = $_; |
|
548 |
my $result = { type => $cvar->config->type }; |
|
549 |
|
|
550 |
if ($cvar->config->type eq 'number') { |
|
551 |
$result->{value} = $::form->format_amount(\%::myconfig, $cvar->value, -2); |
|
552 |
|
|
553 |
} elsif ($result->{type} =~ m{customer|vendor|part}) { |
|
554 |
my $object = $cvar->value; |
|
555 |
my $method = $result->{type} eq 'part' ? 'description' : 'name'; |
|
556 |
|
|
557 |
$result->{id} = int($cvar->number_value) || undef; |
|
558 |
$result->{value} = $object ? $object->$method // '' : ''; |
|
559 |
|
|
560 |
} else { |
|
561 |
$result->{value} = $cvar->value; |
|
553 | 562 |
} |
554 |
grep( |
|
555 |
{ $_->is_valid; } |
|
556 |
@{$self->{contact}->cvars_by_config} |
|
557 |
) |
|
558 |
) |
|
563 |
|
|
564 |
( $cvar->config->name => $result ) |
|
565 |
|
|
566 |
} grep { $_->is_valid } @{ $self->{contact}->cvars_by_config } |
|
559 | 567 |
}; |
560 | 568 |
|
561 | 569 |
$self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); |
Auch abrufbar als: Unified diff
CustomerVendor: CVars bei Wechsel von Ansprechpersonen richtig befüllen