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 tie my %layers, 'Tie::IxHash',
56 map { $_ => "$_ - ". $exports->{$_}{desc} }
61 my $widget = new HTML::Widgets::SelectLayers(
62 'selected_layer' => $part_export->exporttype,
63 'options' => \%layers,
64 'form_name' => 'dummy',
65 'form_action' => 'process/part_export.cgi',
66 'form_text' => [qw( exportnum exportname machine )],
67 # 'form_checkbox' => [qw()],
68 'html_between' => "</TD></TR></TABLE>\n",
69 'layer_callback' => sub {
71 # create 'config_element' to generate the whole layer with a Mason component
72 if ( my $include = $exports->{$layer}{config_element} ) {
73 # might need to adjust the scope of this at some point
74 return $m->scomp($include,
75 part_export => $part_export,
77 export_info => $exports->{$layer}
80 my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!.
83 $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'.
84 $exports->{$layer}{notes}. '</TD></TR>'
87 foreach my $option ( keys %{$exports->{$layer}{options}} ) {
88 my $optinfo = $exports->{$layer}{options}{$option};
89 die "Retreived non-ref export info option from $layer export: $optinfo"
91 my $label = $optinfo->{label};
92 my $type = defined($optinfo->{type}) ? $optinfo->{type} : 'text';
93 my $value = $cgi->param($option)
94 || ( $part_export->exportnum && $part_export->option($option) )
95 || ( (exists $optinfo->{default} && !$part_export->exportnum)
99 if ( $type eq 'title' ) {
100 $html .= qq!<TR><TH COLSPAN=1 ALIGN="right"><FONT SIZE="+1">! .
106 # 'freeform': disables table formatting of options. Instead, each
107 # option can define "before" and "after" strings which are inserted
108 # around the selector.
109 my $freeform = $optinfo->{freeform};
111 $html .= $optinfo->{before} || '';
114 $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!;
116 if ( $type eq 'select' ) {
117 my $size = defined($optinfo->{size}) ? " SIZE=" . $optinfo->{size} : '';
118 my $multi = ($optinfo->{multi} || $optinfo->{multiple})
120 $html .= qq!<SELECT NAME="$option"$multi$size>!;
121 my @values = split '\s+', $value if $multi;
123 if (defined($optinfo->{option_values})) {
124 my $valsub = $optinfo->{option_values};
125 @options = &$valsub();
126 } elsif (defined($optinfo->{options})) {
127 @options = @{$optinfo->{options}};
129 foreach my $select_option ( @options ) {
130 #if ( ref($select_option) ) {
132 my $selected = ($multi ? grep {$_ eq $select_option} @values : $select_option eq $value ) ? ' SELECTED' : '';
133 my $label = $select_option;
134 if (defined($optinfo->{option_label})) {
135 my $labelsub = $optinfo->{option_label};
136 $label = &$labelsub($select_option);
138 $html .= qq!<OPTION VALUE="$select_option"$selected>!.
142 $html .= '</SELECT>';
143 } elsif ( $type eq 'textarea' ) {
144 $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!.
145 encode_entities($value). '</TEXTAREA>';
146 } elsif ( $type eq 'text' ) {
147 $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!. #"
148 encode_entities($value). '" SIZE=64>';
149 } elsif ( $type eq 'checkbox' ) {
150 $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!;
151 $html .= ' CHECKED' if $value;
154 $html .= "unknown type $type";
157 $html .= $optinfo->{after} || '';
160 $html .= '</TD></TR>';
164 if ( $exports->{$layer}{nas} and qsearch('nas',{}) ) {
165 # show NAS checkboxes
166 $html .= '<TR><TD ALIGN="right">Export RADIUS clients</TD><TD>';
168 $html .= include('/elements/checkboxes-table.html',
169 'source_obj' => $part_export,
170 'link_table' => 'export_nas',
171 'target_table' => 'nas',
173 'name_callback' => sub {
174 $_[0]->shortname . ' (' . $_[0]->nasname . ')',
177 'target_link' => $p.'edit/nas.html?',
180 $html .= '</TD></TR>';
185 $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
186 join(',', keys %{$exports->{$layer}{options}} ). '">';
188 $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
189 $exports->{$layer}{nodomain}. '">';
191 $html .= '<INPUT TYPE="submit" VALUE="'.
192 ( $part_export->exportnum ? "Apply changes" : "Add export" ).