summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-rt-customfield.html
blob: 85758d585cb718762d3d53e896a1288748eb775c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<SELECT NAME="<% $opt{name} %>">
% while ( @fields ) {
<OPTION VALUE="<% shift @fields %>"><% shift @fields %></OPTION>
% }
</SELECT>
<%init>
my %opt = @_;
my $lookuptype = $opt{lookuptype};
my $valuetype = $opt{valuetype};
# get a list of TimeValue-type custom fields
my $CurrentUser = RT::CurrentUser->new();
$CurrentUser->LoadByName($FS::CurrentUser::CurrentUser->username);
die "RT not configured" unless $CurrentUser->id;
my $CFs = RT::CustomFields->new($CurrentUser);

$CFs->Limit(FIELD => 'LookupType',
            OPERATOR => 'ENDSWITH',
            VALUE => $lookuptype)
    if $lookuptype;

$CFs->Limit(FIELD => 'Type',
            VALUE => $valuetype)
    if $valuetype;

my @fields;
push @fields, '', $opt{empty_label} if exists($opt{empty_label});

while (my $CF = $CFs->Next) {
  push @fields, $CF->Name, ($CF->Description || $CF->Name);
}
</%init>