summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2002-03-18 15:52:12 +0000
committerivan <ivan>2002-03-18 15:52:12 +0000
commit14d6b3092a296ada5a0252752fd15a0087c63374 (patch)
treed21426316a5e9eb52f2f84f1f35b22143a453201 /httemplate
parentc2f8491538edaf54ed976c7a4f2c238eea1e3772 (diff)
added (incomplete) export foo
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/part_export.cgi80
-rw-r--r--httemplate/edit/process/part_export.cgi43
2 files changed, 123 insertions, 0 deletions
diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi
new file mode 100644
index 000000000..ffce0438f
--- /dev/null
+++ b/httemplate/edit/part_export.cgi
@@ -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
index 000000000..9ee1c5974
--- /dev/null
+++ b/httemplate/edit/process/part_export.cgi
@@ -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");
+
+%>