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 name</TD>
12 <INPUT TYPE="text" NAME="exportname" VALUE="<% $part_export->exportname %>">
16 <TD ALIGN="right">Export host</TD>
18 <INPUT TYPE="text" NAME="machine" VALUE="<% $part_export->machine %>">
22 <TD ALIGN="right">Export</TD>
23 <TD><% $widget->html %>
25 <% include('/elements/footer.html') %>
29 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
31 #if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
32 # $cgi->param('clone', $1);
34 # $cgi->param('clone', '');
37 my($query) = $cgi->keywords;
40 if ( $cgi->param('error') ) {
41 $part_export = new FS::part_export ( {
42 map { $_, scalar($cgi->param($_)) } fields('part_export')
44 } elsif ( $query =~ /^(\d+)$/ ) {
45 $part_export = qsearchs('part_export', { 'exportnum' => $1 } );
47 $part_export = new FS::part_export;
49 $action ||= $part_export->exportnum ? 'Edit' : 'Add';
51 #my $exports = FS::part_export::export_info($svcdb);
52 my $exports = FS::part_export::export_info();
54 my %layers = map { $_ => "$_ - ". $exports->{$_}{desc} } keys %$exports;
57 my $widget = new HTML::Widgets::SelectLayers(
58 'selected_layer' => $part_export->exporttype,
59 'options' => \%layers,
60 'form_name' => 'dummy',
61 'form_action' => 'process/part_export.cgi',
62 'form_text' => [qw( exportnum exportname machine )],
63 # 'form_checkbox' => [qw()],
64 'html_between' => "</TD></TR></TABLE>\n",
65 'layer_callback' => sub {
67 my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!.
70 $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'.
71 $exports->{$layer}{notes}. '</TD></TR>'
74 foreach my $option ( keys %{$exports->{$layer}{options}} ) {
75 my $optinfo = $exports->{$layer}{options}{$option};
76 die "Retreived non-ref export info option from $layer export: $optinfo"
78 my $label = $optinfo->{label};
79 my $type = defined($optinfo->{type}) ? $optinfo->{type} : 'text';
80 my $value = $cgi->param($option)
81 || ( $part_export->exportnum && $part_export->option($option) )
82 || ( (exists $optinfo->{default} && !$part_export->exportnum)
86 # 'freeform': disables table formatting of options. Instead, each
87 # option can define "before" and "after" strings which are inserted
88 # around the selector.
89 my $freeform = $optinfo->{freeform};
91 $html .= $optinfo->{before} || '';
94 $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!;
96 if ( $type eq 'select' ) {
97 my $size = defined($optinfo->{size}) ? " SIZE=" . $optinfo->{size} : '';
98 my $multi = defined($optinfo->{multi}) ? ' MULTIPLE' : '';
99 $html .= qq!<SELECT NAME="$option"$multi$size>!;
100 my @values = split '\s+', $value if $multi;
102 if (defined($optinfo->{option_values})) {
103 my $valsub = $optinfo->{option_values};
104 @options = &$valsub();
105 } elsif (defined($optinfo->{options})) {
106 @options = @{$optinfo->{options}};
108 foreach my $select_option ( @options ) {
109 #if ( ref($select_option) ) {
111 my $selected = ($multi ? grep {$_ eq $select_option} @values : $select_option eq $value ) ? ' SELECTED' : '';
112 my $label = $select_option;
113 if (defined($optinfo->{option_label})) {
114 my $labelsub = $optinfo->{option_label};
115 $label = &$labelsub($select_option);
117 $html .= qq!<OPTION VALUE="$select_option"$selected>!.
121 $html .= '</SELECT>';
122 } elsif ( $type eq 'textarea' ) {
123 $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!.
124 encode_entities($value). '</TEXTAREA>';
125 } elsif ( $type eq 'text' ) {
126 $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!. #"
127 encode_entities($value). '" SIZE=64>';
128 } elsif ( $type eq 'checkbox' ) {
129 $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!;
130 $html .= ' CHECKED' if $value;
133 $html .= "unknown type $type";
136 $html .= $optinfo->{after} || '';
139 $html .= '</TD></TR>';
144 $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
145 join(',', keys %{$exports->{$layer}{options}} ). '">';
147 $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
148 $exports->{$layer}{nodomain}. '">';
150 $html .= '<INPUT TYPE="submit" VALUE="'.
151 ( $part_export->exportnum ? "Apply changes" : "Add export" ).