- #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
-}
-</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="svcdb" VALUE="<%= $svcdb %>">
-<%
- print "$svcdb" unless $svcdb eq 'konq_kludge';
- print "<BR><TABLE BORDER=1><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>";
-%>
+ my $columns = 3;
+ my $count = 0;
+ my @part_export =
+ map { qsearch( 'part_export', {exporttype => $_ } ) }
+ keys %{FS::part_export::export_info($layer)};
+ $html .= '<BR><BR>'. table().
+ table(). "<TR><TH COLSPAN=$columns>Exports</TH></TR><TR>";
+ foreach my $part_export ( @part_export ) {
+ $html .= '<TD><INPUT TYPE="checbox"'.
+ ' NAME="exportnum'. $part_export->exportnum. '" VALUE="1" ';
+ $html .= 'CHECKED'
+ if ( $clone || $part_svc->svcpart ) #null svcpart search causing error
+ && qsearchs( 'export_svc', {
+ exportnum => $part_export->exportnum,
+ svcpart => $clone || $part_svc->svcpart });
+ $html .= '>'. $part_export->exportnum. ': '. $part_export->exporttype.
+ ' to '. $part_export->machine. '</TD>';
+ $count++;
+ $html .= '</TR><TR>' unless $count % $columns;
+ }
+ $html .= '</TR></TABLE><BR><BR>';
+
+ $html .= table(). "<TH>Field</TH><TH COLSPAN=2>Modifier</TH>";
+ #yucky kludge
+ my @fields = defined( $FS::Record::dbdef->table($layer) )
+ ? grep { $_ ne 'svcnum' } fields($layer)
+ : ();
+ push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge
+ $part_svc->svcpart($clone) if $clone; #haha, undone below
+ foreach my $field (@fields) {
+ my $part_svc_column = $part_svc->part_svc_column($field);
+ my $value = $cgi->param('error')
+ ? $cgi->param("${layer}__${field}")
+ : $part_svc_column->columnvalue;
+ my $flag = $cgi->param('error')
+ ? $cgi->param("${layer}__${field}_flag")
+ : $part_svc_column->columnflag;
+ my $def = $defs{$layer}{$field};
+ my $desc = ref($def) ? $def->{desc} : $def;
+
+ $html .= "<TR><TD>$field";
+ $html .= "- <FONT SIZE=-1>$desc</FONT>" if $desc;
+ $html .= "</TD>";
+ $flag = '' if ref($def) && $def->{type} eq 'disabled';
+ $html .=
+ qq!<TD><INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE=""!.
+ ' CHECKED'x($flag eq ''). ">Off</TD>".
+ '<TD>';
+ unless ( ref($def) && $def->{type} eq 'disabled' ) {
+ $html .=
+ qq!<INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="D"!.
+ ' CHECKED'x($flag eq 'D'). ">Default ".
+ qq!<INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="F"!.
+ ' CHECKED'x($flag eq 'F'). ">Fixed ";
+ $html .= '<BR>';
+ }
+ if ( ref($def) ) {
+ if ( $def->{type} eq 'select' ) {
+ $html .= qq!<SELECT NAME="${layer}__${field}">!;
+ $html .= '<OPTION> </OPTION>' unless $value;
+ if ( $def->{select_table} ) {
+ foreach my $record ( qsearch( $def->{select_table}, {} ) ) {
+ my $rvalue = $record->getfield($def->{select_key});
+ $html .= qq!<OPTION VALUE="$rvalue"!.
+ ( $rvalue==$value ? ' SELECTED>' : '>' ).
+ $record->getfield($def->{select_label}). '</OPTION>';
+ } #next $record
+ } else { # select_list
+ foreach my $item ( @{$def->{select_list}} ) {
+ $html .= qq!<OPTION VALUE="$item"!.
+ ( $item eq $value ? ' SELECTED>' : '>' ).
+ $item. '</OPTION>';
+ } #next $item
+ } #endif
+ $html .= '</SELECT>';
+ } elsif ( $def->{type} eq 'radius_usergroup_selector' ) {
+ $html .= FS::svc_acct::radius_usergroup_selector(
+ [ split(',', $value) ], "${layer}__${field}" );
+ } elsif ( $def->{type} eq 'disabled' ) {
+ $html .=
+ qq!<INPUT TYPE="hidden" NAME="${layer}__${field}" VALUE="">!;
+ } else {
+ $html .= '<font color="#ff0000">unknown type'. $def->{type};
+ }
+ } else {
+ $html .=
+ qq!<INPUT TYPE="text" NAME="${layer}__${field}" VALUE="$value">!;
+ }
+
+ if($vfields{$layer}->{$field}) {
+ $html .= qq!<BR><INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="X"!.
+ ' CHECKED'x($flag eq 'X'). ">Excluded ";
+ }
+ $html .= "</TD></TR>\n";
+ }
+ $part_svc->svcpart('') if $clone; #undone
+ $html .= "</TABLE>";