-# svc_acct svc_domain svc_acct_sm svc_charge svc_wo
-foreach my $svcdb ( qw(
- konq_kludge svc_acct svc_domain svc_acct_sm svc_forward svc_www
-) ) {
-
-# my(@fields) = $svcdb eq 'konq_kludge'
-# ? ()
-# : grep { $_ ne 'svcnum' } fields($svcdb);
- #yucky kludge
- my(@fields) = defined( $FS::Record::dbdef->table($svcdb) )
- ? grep { $_ ne 'svcnum' } fields($svcdb)
- : ();
- #my($rowspan)=scalar(@rows);
-
- #my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
-# $visibility = $svcdb eq $part_svc->svcdb ? "SHOW" : "HIDDEN";
-# $visibility = $svcdb eq $p_svcdb ? "visible" : "hidden";
- my $visibility = "hidden";
-%>
-<SCRIPT>
-if (document.getElementById) {
- document.write("<DIV ID=\"d<%= $svcdb %>\" STYLE=\"visibility: <%= $visibility %>; position: absolute\">");
-} else {
-<% $visibility="show" if $visibility eq "visible"; %>
- document.write("<LAYER ID=\"l<%= $svcdb %>\" VISIBILITY=\"<%= $visibility %>\">");
-}
-
-function fixup(what) {
- what.svc.value = document.dummy.svc.value;
- what.svcdb.value = document.dummy.svcdb.options[document.dummy.svcdb.selectedIndex].value;
- if (document.dummy.disabled.checked)
- what.disabled.value = 'Y';
- else
- what.disabled.value = '';
-}
-</SCRIPT>
-<FORM NAME="<%= $svcdb %>" ACTION="process/part_svc.cgi" METHOD=POST onSubmit="fixup(this)">
-<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $hashref->{svcpart} %>">
-<INPUT TYPE="hidden" NAME="svc" VALUE="<%= $hashref->{svc} %>">
-<INPUT TYPE="hidden" NAME="disabled" VALUE="<%= $hashref->{disabled} %>">
-<INPUT TYPE="hidden" NAME="svcdb" VALUE="<%= $svcdb %>">
-<%
- #print "$svcdb<BR>" unless $svcdb eq 'konq_kludge';
- print table(). "<TH>Field</TH><TH COLSPAN=2>Modifier</TH>" unless $svcdb eq 'konq_kludge';
-
- foreach my $field (@fields) {
- my $part_svc_column = $part_svc->part_svc_column($field);
- my $value = $cgi->param('error')
- ? $cgi->param("${svcdb}__${field}")
- : $part_svc_column->columnvalue;
- my $flag = $cgi->param('error')
- ? $cgi->param("${svcdb}__${field}_flag")
- : $part_svc_column->columnflag;
- #print "<TR>$ptmp<TD>$field";
- print "<TR><TD>$field";
- print "- <FONT SIZE=-1>$defs{$svcdb}{$field}</FONT>"
- if defined $defs{$svcdb}{$field};
- print "</TD>";
- print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE=""!.
- ' CHECKED'x($flag eq ''). ">Off</TD>";
- print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE="D"!.
- ' CHECKED'x($flag eq 'D'). ">Default ";
- print qq!<INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE="F"!.
- ' CHECKED'x($flag eq 'F'). ">Fixed ";
- print qq!<INPUT TYPE="text" NAME="${svcdb}__${field}" VALUE="$value">!,
- "</TD></TR>\n";
- #$ptmp='';
- }
- print "</TABLE>" unless $svcdb eq 'konq_kludge';
-
-print qq!\n<BR><INPUT TYPE="submit" VALUE="!,
- $hashref->{svcpart} ? "Apply changes" : "Add service",
- qq!">! unless $svcdb eq 'konq_kludge';
-
- print "</FORM>";
- print <<END;
- <SCRIPT>
- if (document.getElementById) {
- document.write("</DIV>");
- } else {
- document.write("</LAYER>");
- }
- </SCRIPT>
-END
-}
-#print "</TABLE>";
-%>
+ foreach my $svcdb (grep dbdef->table($_), keys %defs ) {
+ my $self = "FS::$svcdb"->new;
+ $vfields{$svcdb} = {};
+ foreach my $field ($self->virtual_fields) { # svc_Common::virtual_fields with a null svcpart returns all of them
+ my $pvf = $self->pvf($field);
+ my @list = $pvf->list;
+ if (scalar @list) {
+ $defs{$svcdb}->{$field} = { desc => $pvf->label,
+ type => 'select',
+ select_list => \@list };
+ } else {
+ $defs{$svcdb}->{$field} = $pvf->label;
+ } #endif
+ $vfields{$svcdb}->{$field} = $pvf;
+ warn "\$vfields{$svcdb}->{$field} = $pvf";
+ } #next $field
+ } #next $svcdb
+
+ my @dbs = $hashref->{svcdb}
+ ? ( $hashref->{svcdb} )
+ : qw( svc_acct svc_domain svc_forward svc_www svc_broadband );