added (incomplete) export foo
authorivan <ivan>
Mon, 18 Mar 2002 15:52:12 +0000 (15:52 +0000)
committerivan <ivan>
Mon, 18 Mar 2002 15:52:12 +0000 (15:52 +0000)
httemplate/edit/part_export.cgi [new file with mode: 0644]
httemplate/edit/process/part_export.cgi [new file with mode: 0644]

diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi
new file mode 100644 (file)
index 0000000..ffce043
--- /dev/null
@@ -0,0 +1,80 @@
+<!-- mason kludge -->
+<%
+
+#if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
+#  $cgi->param('clone', $1);
+#} else {
+#  $cgi->param('clone', '');
+#}
+#if ( $cgi->param('svcpart') && $cgi->param('svcpart') =~ /^(\d+)$/ ) {
+#  $cgi->param('svcpart', $1);
+#} else {
+#  $cgi->param('svcpart', '');
+#}
+
+my($query) = $cgi->keywords;
+my $action = '';
+my $part_export = '';
+my $options = {};
+if ( $cgi->param('error') ) {
+  $part_export = new FS::part_export ( {
+    map { $_, scalar($cgi->param($_)) } fields('part_export')
+  } );
+}
+
+warn "***$query***";
+if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
+  $action = 'Add';
+  my $old_part_export = qsearchs('part_export', { 'exportnum' => $1 } );
+  unless ( $part_export ) {
+    ($part_export, $options) = $old_part_export->clone;
+  }
+} elsif ( $cgi->param('new_with_svcpart') 
+          && $cgi->param('new_with_svcpart') =~ /^(\d+)$/ ) {
+  $part_export ||= new FS::part_export ( { 'svcpart' => $1 } );
+} elsif ( $query =~ /^(\d+)$/ ) {
+  $part_export ||= qsearchs('part_export', { 'exportnum' => $1 } );
+}
+$action ||= $part_export->exportnum ? 'Edit' : 'Add';
+
+my @types = qw(shell bsdshell textradius sqlradius cp);
+
+%>
+<%= header("$action Export", menubar(
+  'Main Menu' => popurl(2),
+), ' onLoad="visualize()"')
+%>
+
+<% if ( $cgi->param('error') ) { %>
+<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
+<% } %>
+
+<FORM ACTION="<%= popurl(1) %>process/part_export.cgi" METHOD=POST>
+<% #print '<FORM NAME="dummy">'; %>
+
+<%= ntable("#cccccc",2) %>
+<TR>
+  <TD ALIGN="right">Service</TD>
+  <TD BGCOLOR="#ffffff">
+    <%= $part_export->svcpart %> - <%= $part_export->part_svc->svc %>
+  </TD>
+</TR>
+<TR>
+  <TD ALIGN="right">Export</TD>
+  <TD><SELECT NAME="exporttype"><OPTION></OPTION>
+<% foreach my $type ( @types ) { %>
+    <OPTION><%= $type %></OPTION>
+<% } %>
+  </SELECT></TD>
+</TR>
+<TR>
+  <TD ALIGN="right">Export host</TD>
+  <TD>
+    <INPUT TYPE="text" NAME="machine" VALUE="<%= $part_export->machine %>">
+  </TD>
+</TR>
+</TABLE>
+</FORM>
+</BODY>
+</HTML>
+
diff --git a/httemplate/edit/process/part_export.cgi b/httemplate/edit/process/part_export.cgi
new file mode 100644 (file)
index 0000000..9ee1c59
--- /dev/null
@@ -0,0 +1,43 @@
+<%
+
+my $dbh = dbh;
+
+my $exportnum = $cgi->param('exportnum');
+
+my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum;
+
+my $new = new FS::part_export ( {
+  map {
+    $_, scalar($cgi->param($_));
+  } fields('part_export')
+} );
+
+local $SIG{HUP} = 'IGNORE';
+local $SIG{INT} = 'IGNORE';
+local $SIG{QUIT} = 'IGNORE';
+local $SIG{TERM} = 'IGNORE';
+local $SIG{TSTP} = 'IGNORE';
+local $SIG{PIPE} = 'IGNORE';
+
+local $FS::UID::AutoCommit = 0;
+
+my $error;
+if ( $exportnum ) {
+  $error = $new->replace($old);
+} else {
+  $error = $new->insert;
+  $exportnum = $new->exportnum;
+}
+if ( $error ) {
+  $dbh->rollback;
+  $cgi->param('error', $error );
+  print $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string );
+  myexit();
+}
+
+#options
+
+$dbh->commit or die $dbh->errstr;
+print $cgi->redirect(popurl(3). "browse/part_svc.cgi");
+
+%>