- documentation updates
[freeside.git] / httemplate / edit / part_export.cgi
1 <!-- mason kludge -->
2 <%
3
4 #if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
5 #  $cgi->param('clone', $1);
6 #} else {
7 #  $cgi->param('clone', '');
8 #}
9
10 my($query) = $cgi->keywords;
11 my $action = '';
12 my $part_export = '';
13 if ( $cgi->param('error') ) {
14   $part_export = new FS::part_export ( {
15     map { $_, scalar($cgi->param($_)) } fields('part_export')
16   } );
17 } elsif ( $query =~ /^(\d+)$/ ) {
18   $part_export = qsearchs('part_export', { 'exportnum' => $1 } );
19 } else {
20   $part_export = new FS::part_export;
21 }
22 $action ||= $part_export->exportnum ? 'Edit' : 'Add';
23
24 #my $exports = FS::part_export::export_info($svcdb);
25 my $exports = FS::part_export::export_info();
26
27 my %layers = map { $_ => "$_ - ". $exports->{$_}{desc} } keys %$exports;
28 $layers{''}='';
29
30 my $widget = new HTML::Widgets::SelectLayers(
31   'selected_layer' => $part_export->exporttype,
32   'options'        => \%layers,
33   'form_name'      => 'dummy',
34   'form_action'    => 'process/part_export.cgi',
35   'form_text'      => [qw( exportnum machine )],
36 #  'form_checkbox'  => [qw()],
37   'html_between'    => "</TD></TR></TABLE>\n",
38   'layer_callback'  => sub {
39     my $layer = shift;
40     my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!.
41                ntable("#cccccc",2);
42
43     $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'.
44              $exports->{$layer}{notes}. '</TD></TR>'
45       if $layer;
46
47     foreach my $option ( keys %{$exports->{$layer}{options}} ) {
48 #    foreach my $option ( qw(url login password groupID ) ) {
49       my $optinfo = $exports->{$layer}{options}{$option};
50       my $label = $optinfo->{label};
51       my $value = $cgi->param($option) || $part_export->option($option);
52       $html .= qq!<TR><TD ALIGN="right">$label</TD>!.
53                qq!<TD><INPUT TYPE="text" NAME="$option" VALUE="$value"></TD>!.
54                '</TR>';
55     }
56     $html .= '</TABLE>';
57
58     $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
59              join(',', keys %{$exports->{$layer}{options}} ). '">';
60
61     $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
62              $exports->{$layer}{nodomain}. '">';
63
64     $html .= '<INPUT TYPE="submit" VALUE="'.
65              ( $part_export->exportnum ? "Apply changes" : "Add export" ).
66              '">';
67
68     $html;
69   },
70 );
71
72 %>
73 <%= header("$action Export", menubar(
74   'Main Menu' => popurl(2),
75 ), ' onLoad="visualize()"')
76 %>
77
78 <% if ( $cgi->param('error') ) { %>
79   <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
80   <BR><BR>
81 <% } %>
82
83 <FORM NAME="dummy">
84 <INPUT TYPE="hidden" NAME="exportnum" VALUE="<%= $part_export->exportnum %>">
85
86 <%= ntable("#cccccc",2) %>
87 <TR>
88   <TD ALIGN="right">Export host</TD>
89   <TD>
90     <INPUT TYPE="text" NAME="machine" VALUE="<%= $part_export->machine %>">
91   </TD>
92 </TR>
93 <TR>
94   <TD ALIGN="right">Export</TD>
95   <TD><%= $widget->html %>
96 </BODY>
97 </HTML>
98