85758d585cb718762d3d53e896a1288748eb775c
[freeside.git] / httemplate / elements / select-rt-customfield.html
1 <SELECT NAME="<% $opt{name} %>">
2 % while ( @fields ) {
3 <OPTION VALUE="<% shift @fields %>"><% shift @fields %></OPTION>
4 % }
5 </SELECT>
6 <%init>
7 my %opt = @_;
8 my $lookuptype = $opt{lookuptype};
9 my $valuetype = $opt{valuetype};
10 # get a list of TimeValue-type custom fields
11 my $CurrentUser = RT::CurrentUser->new();
12 $CurrentUser->LoadByName($FS::CurrentUser::CurrentUser->username);
13 die "RT not configured" unless $CurrentUser->id;
14 my $CFs = RT::CustomFields->new($CurrentUser);
15
16 $CFs->Limit(FIELD => 'LookupType',
17             OPERATOR => 'ENDSWITH',
18             VALUE => $lookuptype)
19     if $lookuptype;
20
21 $CFs->Limit(FIELD => 'Type',
22             VALUE => $valuetype)
23     if $valuetype;
24
25 my @fields;
26 push @fields, '', $opt{empty_label} if exists($opt{empty_label});
27
28 while (my $CF = $CFs->Next) {
29   push @fields, $CF->Name, ($CF->Description || $CF->Name);
30 }
31 </%init>