This commit was generated by cvs2svn to compensate for changes in r5562,
[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 %      my $optinfo = $exports->{$layer}{options}{$option};
49 %      die "Retreived non-ref export info option from $layer export: $optinfo"
50 %        unless ref($optinfo);
51 %      my $label = $optinfo->{label};
52 %      my $type = defined($optinfo->{type}) ? $optinfo->{type} : 'text';
53 %      my $value = $cgi->param($option)
54 %                 || ( $part_export->exportnum && $part_export->option($option) )
55 %                 || ( (exists $optinfo->{default} && !$part_export->exportnum)
56 %                      ? $optinfo->{default}
57 %                      : ''
58 %                    );
59 %      $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!;
60 %      if ( $type eq 'select' ) {
61 %        $html .= qq!<SELECT NAME="$option">!;
62 %        foreach my $select_option ( @{$optinfo->{options}} ) {
63 %          #if ( ref($select_option) ) {
64 %          #} else {
65 %            my $selected = $select_option eq $value ? ' SELECTED' : '';
66 %            $html .= qq!<OPTION VALUE="$select_option"$selected>!.
67 %                     qq!$select_option</OPTION>!;
68 %          #}
69 %        }
70 %        $html .= '</SELECT>';
71 %      } elsif ( $type eq 'textarea' ) {
72 %        $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!.
73 %                 encode_entities($value). '</TEXTAREA>';
74 %      } elsif ( $type eq 'text' ) {
75 %        $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!.
76 %                 encode_entities($value). '" SIZE=64>';
77 %      } elsif ( $type eq 'checkbox' ) {
78 %        $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!;
79 %        $html .= ' CHECKED' if $value;
80 %        $html .= '>';
81 %      } else {
82 %        $html .= "unknown type $type";
83 %      }
84 %      $html .= '</TD></TR>';
85 %    }
86 %    $html .= '</TABLE>';
87 %
88 %    $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
89 %             join(',', keys %{$exports->{$layer}{options}} ). '">';
90 %
91 %    $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
92 %             $exports->{$layer}{nodomain}. '">';
93 %
94 %    $html .= '<INPUT TYPE="submit" VALUE="'.
95 %             ( $part_export->exportnum ? "Apply changes" : "Add export" ).
96 %             '">';
97 %
98 %    $html;
99 %  },
100 %);
101 %
102 %
103
104 <% include("/elements/header.html","$action Export", menubar(
105   'Main Menu' => popurl(2),
106 ), ' onLoad="visualize()"')
107 %>
108 % if ( $cgi->param('error') ) { 
109
110   <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
111   <BR><BR>
112 % } 
113
114
115 <FORM NAME="dummy">
116 <INPUT TYPE="hidden" NAME="exportnum" VALUE="<% $part_export->exportnum %>">
117
118 <% ntable("#cccccc",2) %>
119 <TR>
120   <TD ALIGN="right">Export host</TD>
121   <TD>
122     <INPUT TYPE="text" NAME="machine" VALUE="<% $part_export->machine %>">
123   </TD>
124 </TR>
125 <TR>
126   <TD ALIGN="right">Export</TD>
127   <TD><% $widget->html %>
128 </BODY>
129 </HTML>
130