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 # 'freeform': disables table formatting of options. Instead, each
81 # option can define "before" and "after" strings which are inserted
82 # around the selector.
83 my $freeform = $optinfo->{freeform};
85 $html .= $optinfo->{before} || '';
88 $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!;
90 if ( $type eq 'select' ) {
91 my $size = defined($optinfo->{size}) ? " SIZE=" . $optinfo->{size} : '';
92 my $multi = defined($optinfo->{multi}) ? ' MULTIPLE' : '';
93 $html .= qq!<SELECT NAME="$option"$multi$size>!;
94 my @values = split '\s+', $value if $multi;
96 if (defined($optinfo->{option_values})) {
97 my $valsub = $optinfo->{option_values};
98 @options = &$valsub();
99 } elsif (defined($optinfo->{options})) {
100 @options = @{$optinfo->{options}};
102 foreach my $select_option ( @options ) {
103 #if ( ref($select_option) ) {
105 my $selected = ($multi ? grep {$_ eq $select_option} @values : $select_option eq $value ) ? ' SELECTED' : '';
106 my $label = $select_option;
107 if (defined($optinfo->{option_label})) {
108 my $labelsub = $optinfo->{option_label};
109 $label = &$labelsub($select_option);
111 $html .= qq!<OPTION VALUE="$select_option"$selected>!.
115 $html .= '</SELECT>';
116 } elsif ( $type eq 'textarea' ) {
117 $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!.
118 encode_entities($value). '</TEXTAREA>';
119 } elsif ( $type eq 'text' ) {
120 $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!. #"
121 encode_entities($value). '" SIZE=64>';
122 } elsif ( $type eq 'checkbox' ) {
123 $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!;
124 $html .= ' CHECKED' if $value;
127 $html .= "unknown type $type";
130 $html .= $optinfo->{after} || '';
133 $html .= '</TD></TR>';
138 $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
139 join(',', keys %{$exports->{$layer}{options}} ). '">';
141 $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
142 $exports->{$layer}{nodomain}. '">';
144 $html .= '<INPUT TYPE="submit" VALUE="'.
145 ( $part_export->exportnum ? "Apply changes" : "Add export" ).