f3127403e96f1b5a9795ad20c95daccb2a29225b
[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 = (
25   'svc_acct' => {
26     'sysvshell' => {
27       'desc' =>
28         'Batch export of /etc/passwd and /etc/shadow files (Linux/SysV)',
29       'options' => {},
30     },
31     'bsdshell' => {
32       'desc' =>
33         'Batch export of /etc/passwd and /etc/master.passwd files (BSD)',
34       'options' => {},
35     },
36 #    'nis' => {
37 #      'desc' =>
38 #        'Batch export of /etc/global/passwd and /etc/global/shadow for NIS ',
39 #      'options' => {},
40 #    },
41     'bsdshell' => {
42       'desc' =>
43         'Batch export of /etc/passwd and /etc/master.passwd files (BSD)',
44       'options' => {},
45     },
46     'textradius' => {
47       'desc' => 'Batch export of a text /etc/raddb/users file (Livingston, Cistron)',
48     },
49     'sqlradius' => {
50       'desc' => 'Real-time export to SQL-backed RADIUS (ICRADIUS, FreeRADIUS)',
51       'options' => {
52         'datasrc'  => { label=>'DBI data source' },
53         'username' => { label=>'Database username' },
54         'password' => { label=>'Database password' },
55       },
56       'nodomain' => 'Y',
57       'notes' => 'Not specifying datasrc will export to the freeside database? (no...  notes on MySQL replication, DBI::Proxy, etc., from Conf.pm && export.html etc., reset with bin/sqlradius_reset',
58     },
59     'cyrus' => {
60       'desc' => 'Real-time export to Cyrus IMAP server',
61     },
62     'cp' => {
63       'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
64     },
65     'infostreet' => {
66       'desc' => 'Real-time export to InfoStreet streetSmartAPI',
67       'options' => {
68         'url'      => { label=>'XML-RPC Access URL', },
69         'login'    => { label=>'InfoStreet login', },
70         'password' => { label=>'InfoStreet password', },
71         'groupID'  => { label=>'InfoStreet groupID', },
72       },
73       'nodomain' => 'Y',
74       'notes' => 'Real-time export to <a href="http://www.infostreet.com/">InfoStreet</a> streetSmartAPI.  Requires installation of <a href="http://search.cpan.org/search?dist=Frontier-Client">Frontier::Client</a> from CPAN.',
75     }
76   },
77
78   'svc_domain' => {},
79
80   'svc_acct_sm' => {},
81
82   'svc_forward' => {},
83
84   'svc_www' => {},
85
86 );
87
88 #my $svcdb = $part_export->part_svc->svcdb;
89 #YUCK
90 my $svcdb = 'svc_acct';
91
92 my %layers = map { $_ => "$_ - ". $exports{$svcdb}{$_}{desc} }
93                keys %{$exports{$svcdb}};
94 $layers{''}='';
95
96 my $widget = new HTML::Widgets::SelectLayers(
97   'selected_layer' => $part_export->exporttype,
98   'options'        => \%layers,
99   'form_name'      => 'dummy',
100   'form_action'    => 'process/part_export.cgi',
101   'form_text'      => [qw( exportnum machine )],
102 #  'form_checkbox'  => [qw()],
103   'html_between'    => "</TD></TR></TABLE>\n",
104   'layer_callback'  => sub {
105     my $layer = shift;
106     my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!.
107                ntable("#cccccc",2);
108     foreach my $option ( keys %{$exports{$svcdb}->{$layer}{options}} ) {
109 #    foreach my $option ( qw(url login password groupID ) ) {
110       my $optinfo = $exports{$svcdb}->{$layer}{options}{$option};
111       my $label = $optinfo->{label};
112       my $value = $cgi->param($option) || $part_export->option($option);
113       $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!.
114                qq!<TD><INPUT TYPE="text" NAME="$option" VALUE="$value"></TD>!.
115                '</TR>';
116     }
117     $html .= '</TABLE>';
118
119     $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'.
120              join(',', keys %{$exports{$svcdb}->{$layer}{options}} ). '">';
121
122     $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'.
123              $exports{$svcdb}->{$layer}{nodomain}. '">';
124
125     $html .= '<INPUT TYPE="submit" VALUE="'.
126              ( $part_export->exportnum ? "Apply changes" : "Add export" ).
127              '">';
128
129     $html;
130   },
131 );
132
133 %>
134 <%= header("$action Export", menubar(
135   'Main Menu' => popurl(2),
136 ), ' onLoad="visualize()"')
137 %>
138
139 <% if ( $cgi->param('error') ) { %>
140   <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
141   <BR><BR>
142 <% } %>
143
144 <FORM NAME="dummy">
145 <INPUT TYPE="hidden" NAME="exportnum" VALUE="<%= $part_export->exportnum %>">
146
147 <%= ntable("#cccccc",2) %>
148 <TR>
149   <TD ALIGN="right">Export host</TD>
150   <TD>
151     <INPUT TYPE="text" NAME="machine" VALUE="<%= $part_export->machine %>">
152   </TD>
153 </TR>
154 <TR>
155   <TD ALIGN="right">Export</TD>
156   <TD><%= $widget->html %>
157 </BODY>
158 </HTML>
159