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 my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!.
74 $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'.
75 $exports->{$layer}{notes}. '</TD></TR>'
78 foreach my $option ( keys %{$exports->{$layer}{options}} ) {
79 my $optinfo = $exports->{$layer}{options}{$option};
80 die "Retreived non-ref export info option from $layer export: $optinfo"
82 my $label = $optinfo->{label};
83 my $type = defined($optinfo->{type}) ? $optinfo->{type} : 'text';
84 my $value = $cgi->param($option)
85 || ( $part_export->exportnum && $part_export->option($option) )
86 || ( (exists $optinfo->{default} && !$part_export->exportnum)
90 if ( $type eq 'title' ) {
91 $html .= qq!<TR><TH COLSPAN=1 ALIGN="right"><FONT SIZE="+1">! .
97 # 'freeform': disables table formatting of options. Instead, each
98 # option can define "before" and "after" strings which are inserted
99 # around the selector.
100 my $freeform = $optinfo->{freeform};
102 $html .= $optinfo->{before} || '';
105 $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!;
107 if ( $type eq 'select' ) {
108 my $size = defined($optinfo->{size}) ? " SIZE=" . $optinfo->{size} : '';
109 my $multi = defined($optinfo->{multi}) ? ' MULTIPLE' : '';
110 $html .= qq!<SELECT NAME="$option"$multi$size>!;
111 my @values = split '\s+', $value if $multi;
113 if (defined($optinfo->{option_values})) {
114 my $valsub = $optinfo->{option_values};
115 @options = &$valsub();
116 } elsif (defined($optinfo->{options})) {
117 @options = @{$optinfo->{options}};
119 foreach my $select_option ( @options ) {
120 #if ( ref($select_option) ) {
122 my $selected = ($multi ? grep {$_ eq $select_option} @values : $select_option eq $value ) ? ' SELECTED' : '';
123 my $label = $select_option;
124 if (defined($optinfo->{option_label})) {
125 my $labelsub = $optinfo->{option_label};
126 $label = &$labelsub($select_option);
128 $html .= qq!<OPTION VALUE="$select_option"$selected>!.
132 $html .= '</SELECT>';
133 } elsif ( $type eq 'textarea' ) {
134 $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!.
135 encode_entities($value). '</TEXTAREA>';
136 } elsif ( $type eq 'text' ) {
137 $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!. #"
138 encode_entities($value). '" SIZE=64>';
139 } elsif ( $type eq 'checkbox' ) {
140 $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!;
141 $html .= ' CHECKED' if $value;
144 $html .= "unknown type $type";
147 $html .= $optinfo->{after} || '';
150 $html .= '</TD></TR>';
154 if ( $exports->{$layer}{nas} and qsearch('nas',{}) ) {
155 # show NAS checkboxes
156 $html .= '<TR><TD ALIGN="right">Export RADIUS clients</TD><TD>';
158 $html .= include('/elements/checkboxes-table.html',
159 'source_obj' => $part_export,
160 'link_table' => 'export_nas',
161 'target_table' => 'nas',
163 'name_callback' => sub {
164 $_[0]->shortname . ' (' . $_[0]->nasname . ')',
167 'target_link' => $p.'edit/nas.html?',
170 $html .= '</TD></TR>';
175 $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
176 join(',', keys %{$exports->{$layer}{options}} ). '">';
178 $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
179 $exports->{$layer}{nodomain}. '">';
181 $html .= '<INPUT TYPE="submit" VALUE="'.
182 ( $part_export->exportnum ? "Apply changes" : "Add export" ).