Revision be5edc51
Von Sven Schöling vor fast 11 Jahren hinzugefügt
SL/DB/CustomVariable.pm | ||
---|---|---|
43 | 43 |
goto &text_value; # text, textfield, date and select |
44 | 44 |
} |
45 | 45 |
|
46 |
sub value_as_text { |
|
47 |
my $self = $_[0]; |
|
48 |
my $type = $self->config->type; |
|
49 |
|
|
50 |
die 'not an accessor' if @_ > 1; |
|
51 |
|
|
52 |
if ($type eq 'boolean') { |
|
53 |
return $self->bool_value ? $::locale->text('Yes') : $::locale->text('No'); |
|
54 |
} elsif ($type eq 'timestamp') { |
|
55 |
return $::locale->reformat_date( { dateformat => 'yy-mm-dd' }, $self->timestamp_value->ymd, $::myconfig{dateformat}); |
|
56 |
} elsif ($type eq 'number') { |
|
57 |
return $::form->format_amount(\%::myconfig, $self->number_value, $self->config->processed_options->{PRECISION}); |
|
58 |
} elsif ( $type eq 'customer' ) { |
|
59 |
require SL::DB::Customer; |
|
60 |
|
|
61 |
my $id = int($self->number_value); |
|
62 |
my $customer = $id ? SL::DB::Customer->new(id => $id)->load() : 0; |
|
63 |
return $customer ? $customer->name : ''; |
|
64 |
} elsif ( $type eq 'vendor' ) { |
|
65 |
require SL::DB::Vendor; |
|
66 |
|
|
67 |
my $id = int($self->number_value); |
|
68 |
return $id ? SL::DB::Vendor->new(id => $id)->load() : 0; |
|
69 |
} elsif ( $type eq 'part' ) { |
|
70 |
require SL::DB::Part; |
|
71 |
|
|
72 |
my $id = int($self->number_value); |
|
73 |
my $vendor = $id ? SL::DB::Part->new(id => $id)->load() : 0; |
|
74 |
return $vendor ? $vendor->name : ''; |
|
75 |
} |
|
76 |
|
|
77 |
goto &text_value; # text, textfield, date and select |
|
78 |
} |
|
79 |
|
|
46 | 80 |
sub is_valid { |
47 | 81 |
my ($self) = @_; |
48 | 82 |
|
Auch abrufbar als: Unified diff
Neuer Accessor value_as_text, der alle Daten formatiert ausgibt