Revision 389 (by ahitrov, 2013/10/28 17:55:00) |
status_multi control now can get values from the table
|
<%args>
$object
$name => undef
$SETS => undef
</%args>
<%init>
return undef unless ref $SETS;
return undef unless $name;
my @props = $object->structure();
my ($prop) = grep { $_->{attr} eq $name } @props;
return undef unless ref $prop;
my @values;
if ( $prop && ref $prop ) {
if ( exists $prop->{lookup_opts} && ref $prop->{lookup_opts} eq 'HASH' ) {
@values = $keeper->get_documents (
%{$prop->{lookup_opts}},
names => 1,
);
} elsif ( exists $prop->{values} && ref $prop->{values} eq 'ARRAY' ) {
@values = @{ $prop->{values} };
} elsif ( exists $prop->{cases} && ref $prop->{cases} eq 'ARRAY' ) {
@values = @{ $prop->{cases} };
}
}
return undef unless @values;
my @ids;
foreach my $val ( @values ) {
if ( ref $val eq 'ARRAY' && scalar @$val == 2 ) {
if ( exists $SETS->{$name."_".$val->[0]} && $SETS->{$name."_".$val->[0]} ) {
push @ids, $val->[0];
}
} else {
if ( exists $SETS->{$name."_".$val} && $SETS->{$name."_".$val} ) {
push @ids, $val;
}
}
}
return \@ids;
</%init>