1 <% include('/elements/header.html', "$action Export", '', ' onLoad="visualize()"') %>
3 <% include('/elements/error.html') %>
6 <INPUT TYPE="hidden" NAME="exportnum" VALUE="<% $part_export->exportnum %>">
8 <% ntable("#cccccc",2) %>
10 <TD ALIGN="right">Export host</TD>
12 <INPUT TYPE="text" NAME="machine" VALUE="<% $part_export->machine %>">
16 <TD ALIGN="right">Export</TD>
17 <TD><% $widget->html %>
19 <% include('/elements/footer.html') %>
23 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
25 #if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
26 # $cgi->param('clone', $1);
28 # $cgi->param('clone', '');
31 my($query) = $cgi->keywords;
34 if ( $cgi->param('error') ) {
35 $part_export = new FS::part_export ( {
36 map { $_, scalar($cgi->param($_)) } fields('part_export')
38 } elsif ( $query =~ /^(\d+)$/ ) {
39 $part_export = qsearchs('part_export', { 'exportnum' => $1 } );
41 $part_export = new FS::part_export;
43 $action ||= $part_export->exportnum ? 'Edit' : 'Add';
45 #my $exports = FS::part_export::export_info($svcdb);
46 my $exports = FS::part_export::export_info();
48 my %layers = map { $_ => "$_ - ". $exports->{$_}{desc} } keys %$exports;
51 my $widget = new HTML::Widgets::SelectLayers(
52 'selected_layer' => $part_export->exporttype,
53 'options' => \%layers,
54 'form_name' => 'dummy',
55 'form_action' => 'process/part_export.cgi',
56 'form_text' => [qw( exportnum machine )],
57 # 'form_checkbox' => [qw()],
58 'html_between' => "</TD></TR></TABLE>\n",
59 'layer_callback' => sub {
61 my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!.
64 $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'.
65 $exports->{$layer}{notes}. '</TD></TR>'
68 foreach my $option ( keys %{$exports->{$layer}{options}} ) {
69 my $optinfo = $exports->{$layer}{options}{$option};
70 die "Retreived non-ref export info option from $layer export: $optinfo"
72 my $label = $optinfo->{label};
73 my $type = defined($optinfo->{type}) ? $optinfo->{type} : 'text';
74 my $value = $cgi->param($option)
75 || ( $part_export->exportnum && $part_export->option($option) )
76 || ( (exists $optinfo->{default} && !$part_export->exportnum)
80 $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!;
81 if ( $type eq 'select' ) {
82 my $size = defined($optinfo->{size}) ? " SIZE=" . $optinfo->{size} : '';
83 my $multi = defined($optinfo->{multi}) ? ' MULTIPLE' : '';
84 $html .= qq!<SELECT NAME="$option"$multi$size>!;
85 my @values = split '\s+', $value if $multi;
87 if (defined($optinfo->{option_values})) {
88 my $valsub = $optinfo->{option_values};
89 @options = &$valsub();
90 } elsif (defined($optinfo->{options})) {
91 @options = @{$optinfo->{options}};
93 foreach my $select_option ( @options ) {
94 #if ( ref($select_option) ) {
96 my $selected = ($multi ? grep {$_ eq $select_option} @values : $select_option eq $value ) ? ' SELECTED' : '';
97 my $label = $select_option;
98 if (defined($optinfo->{option_label})) {
99 my $labelsub = $optinfo->{option_label};
100 $label = &$labelsub($select_option);
102 $html .= qq!<OPTION VALUE="$select_option"$selected>!.
106 $html .= '</SELECT>';
107 } elsif ( $type eq 'textarea' ) {
108 $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!.
109 encode_entities($value). '</TEXTAREA>';
110 } elsif ( $type eq 'text' ) {
111 $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!.
112 encode_entities($value). '" SIZE=64>';
113 } elsif ( $type eq 'checkbox' ) {
114 $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!;
115 $html .= ' CHECKED' if $value;
118 $html .= "unknown type $type";
120 $html .= '</TD></TR>';
124 $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
125 join(',', keys %{$exports->{$layer}{options}} ). '">';
127 $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
128 $exports->{$layer}{nodomain}. '">';
130 $html .= '<INPUT TYPE="submit" VALUE="'.
131 ( $part_export->exportnum ? "Apply changes" : "Add export" ).