Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b996f6ca

Von Moritz Bunkus vor fast 10 Jahren hinzugefügt

  • ID b996f6ca8984a5c0983fd9541f607ee7307e7182
  • Vorgänger 2bb1c961
  • Nachfolger 8f6d85af

SL::DB::CustomVariable: value_as_text() für customer/vendor/part vereinheitlicht

Unterschiede anzeigen:

SL/DB/CustomVariable.pm
95 95
    return $::locale->reformat_date( { dateformat => 'yy-mm-dd' }, $self->timestamp_value->ymd, $::myconfig{dateformat});
96 96
  } elsif ($type eq 'number') {
97 97
    return $::form->format_amount(\%::myconfig, $self->number_value, $cfg->processed_options->{PRECISION});
98
  } elsif ( $type eq 'customer' ) {
99
    require SL::DB::Customer;
100

  
101
    my $id = int($self->number_value);
102
    my $customer =  $id ? SL::DB::Customer->new(id => $id)->load() : 0;
103
    return $customer ? $customer->name : '';
104
  } elsif ( $type eq 'vendor' ) {
105
    require SL::DB::Vendor;
106

  
107
    my $id = int($self->number_value);
108
    my $vendor =  $id ? SL::DB::Vendor->new(id => $id)->load() : 0;
109
    return $vendor ? $vendor->name : '';
110
  } elsif ( $type eq 'part' ) {
111
    require SL::DB::Part;
112

  
113
    my $id = int($self->number_value);
114
    my $part = $id ? SL::DB::Part->new(id => $id)->load() : 0;
115
    return $part ? $part->description : '';
98
  } elsif ( $type =~ m{^(?:customer|vendor|part)$}) {
99
    my $class = "SL::DB::" . ucfirst($type);
100
    eval "require $class";
101
    my $object =  $class->_get_manager_class->find_by(id => int($self->number_value));
102
    return $object ? $object->displayable_name : '';
116 103
  }
117 104

  
118 105
  goto &text_value; # text, textfield and select

Auch abrufbar als: Unified diff