RT#38973: Bill for time worked on ticket resolution [checkpoint, not ready for backport]
[freeside.git] / httemplate / elements / select-rt-customfield.html
index 85758d5..488acca 100644 (file)
@@ -1,31 +1,27 @@
-<SELECT NAME="<% $opt{name} %>">
+<SELECT NAME="<% $opt{'name'} %>"<% $opt{'multiple'} ? ' MULTIPLE' : '' %>>
 % while ( @fields ) {
-<OPTION VALUE="<% shift @fields %>"><% shift @fields %></OPTION>
+%   my $value = shift @fields;
+%   my $label = shift @fields;
+<OPTION VALUE="<% $value %>"<% $curr_value{$value} ? ' SELECTED' : '' %>><% $label %></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 %curr_value = map { $_ => 1 } split(', ',$opt{'curr_value'});
 
 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);
+my $conf = new FS::Conf;
+
+if ($conf->config('ticket_system') eq 'RT_Internal') {
+
+  push @fields, FS::TicketSystem->custom_fields(
+    lookuptype => $opt{lookuptype},
+    valuetype  => $opt{valuetype},
+  );
+
 }
+
 </%init>