Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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 <%once>
7 RT::Init();
8 </%once>
9 <%init>
10 my %opt = @_;
11 my $lookuptype = $opt{lookuptype};
12 my $valuetype = $opt{valuetype};
13 # get a list of TimeValue-type custom fields
14 my $CurrentUser = RT::CurrentUser->new();
15 $CurrentUser->LoadByName($FS::CurrentUser::CurrentUser->username);
16 die "RT not configured" unless $CurrentUser->id;
17 my $CFs = RT::CustomFields->new($CurrentUser);
18
19 $CFs->Limit(FIELD => 'LookupType',
20             OPERATOR => 'ENDSWITH',
21             VALUE => $lookuptype)
22     if $lookuptype;
23
24 $CFs->Limit(FIELD => 'Type',
25             VALUE => $valuetype)
26     if $valuetype;
27
28 my @fields;
29 push @fields, '', $opt{empty_label} if exists($opt{empty_label});
30
31 while (my $CF = $CFs->Next) {
32   push @fields, $CF->Name, ($CF->Description || $CF->Name);
33 }
34 </%init>