summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2002-04-11 22:05:31 +0000
committerivan <ivan>2002-04-11 22:05:31 +0000
commita7c1b602f88c177db34477ed4cdc1f72603f8995 (patch)
tree116d090127ee48b041eeb9ff21a0d62c0c768250 /httemplate
parent52a07a405e197fda1654fc61eefa538450f269e8 (diff)
(almost) everything for bug#375 - create export_svc table - part_svc to
part_export is now properly many-to-many, not one-to-many still need to finish service editing (choosing exports) in httemplate/edit/part_svc.cgi and httemplate/edti/process/part_svc.cgi and do somethinga about that manual $svcdb = 'svc_acct' in httemplate/edit/part_export.cgi (do part_export records need a svcdb? probably not... should be able to just pass an svcdb on creation of new exports, move the big %exports hash into part_export.pm and allow httemplate/edit/part_svc.cgi to query it for exports that can apply to a given svcdb....
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_export.cgi42
-rwxr-xr-xhttemplate/browse/part_svc.cgi25
-rw-r--r--httemplate/docs/schema.html7
-rw-r--r--httemplate/docs/upgrade8.html10
-rw-r--r--httemplate/edit/part_export.cgi39
-rw-r--r--httemplate/edit/process/part_export.cgi3
-rw-r--r--httemplate/index.html2
-rwxr-xr-xhttemplate/misc/delete-part_export.cgi2
8 files changed, 72 insertions, 58 deletions
diff --git a/httemplate/browse/part_export.cgi b/httemplate/browse/part_export.cgi
new file mode 100755
index 000000000..e9d9fa3d4
--- /dev/null
+++ b/httemplate/browse/part_export.cgi
@@ -0,0 +1,42 @@
+<!-- mason kludge -->
+<%= header("Export Listing", menubar( 'Main Menu' => $p )) %>
+Provisioning services to external machines, databases and APIs.<BR><BR>
+
+<SCRIPT>
+function part_export_areyousure(href) {
+ if (confirm("Are you sure you want to delete this export?") == true)
+ window.location.href = href;
+}
+</SCRIPT>
+
+<%= table() %>
+ <TR>
+ <TH COLSPAN=2>Export</TH>
+ <TH>Options</TH>
+ </TR>
+
+<% foreach my $part_export ( sort {
+ $a->getfield('exportnum') <=> $b->getfield('exportnum')
+ } qsearch('part_export',{}) ) {
+%>
+ <TR>
+ <TD><A HREF="<%= $p %>edit/part_export.cgi?<%= $part_export->exportnum %>"><%= $part_export->exportnum %></A></TD>
+ <TD><%= $part_export->exporttype %> to <%= $part_export->machine %> (<A HREF="<%= $p %>edit/part_export.cgi?<%= $part_export->exportnum %>">edit</A>&nbsp;|&nbsp;<A HREF="javascript:part_export_areyousure('<%= $p %>misc/delete-part_export.cgi?<%= $part_export->exportnum %>')">delete</A>)</TD>
+ <TD>
+ <%= itable() %>
+ <% my %opt = $part_export->options;
+ foreach my $opt ( keys %opt ) { %>
+ <TR><TD><%= $opt %></TD><TD><%= $opt{$opt} %></TD></TR>
+ <% } %>
+ </TABLE>
+ </TD>
+ </TR>
+
+<% } %>
+
+ <TR>
+ <TD COLSPAN=3><A HREF="<%= $p %>edit/part_export.cgi"><I>Add a new export</I></A></TD>
+ </TR>
+</TABLE>
+</BODY>
+</HTML>
diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi
index 250b1ff4e..c8adebcd6 100755
--- a/httemplate/browse/part_svc.cgi
+++ b/httemplate/browse/part_svc.cgi
@@ -70,31 +70,8 @@ function part_export_areyousure(href) {
foreach my $part_export ( @part_export ) {
%>
<TR>
- <TD><%= $part_export->exporttype %> to <%= $part_export->machine %> (<A HREF="<%= $p %>edit/part_export.cgi?<%= $part_export->exportnum %>">edit</A>&nbsp;|&nbsp;<A HREF="javascript:part_export_areyousure('<%= $p %>misc/delete-part_export.cgi?<%= $part_export->exportnum %>')">delete</A>)</TD>
- <TD>
- <%= itable() %>
- <% my %opt = $part_export->options;
- foreach my $opt ( keys %opt ) { %>
- <TR><TD><%= $opt %></TD><TD><%= $opt{$opt} %></TD></TR>
- <% } %>
- </TABLE>
- </TD>
+ <TD><A HREF="<%= $p %>edit/part_export.cgi?<%= $part_export->exportnum %>"><%= $part_export->exporttype %> to <%= $part_export->machine %></A></TD></TR>
<% } %>
- </TR><TR><TD COLSPAN=2><A HREF="<%= $p %>edit/part_export.cgi?new_with_svcpart=<%= $part_svc->svcpart %>"><I>Add a new export</I></A></TD></TR>
-<% if (@part_export) { %>
- <TR><TD COLSPAN=2>
- <FORM METHOD="POST" ACTION="<%= $p %>edit/part_export.cgi">
- <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $part_svc->svcpart %>">
- <SELECT NAME="clone"><OPTION></OPTION>
-<% foreach my $part_export ( @part_export ) { %>
- <OPTION VALUE="<%= $part_export->exportnum %>">
- <%= $part_export->exporttype %> to <%= $part_export->machine %>
- </OPTION>
-<% } %>
- </SELECT>
- <INPUT TYPE="submit" VALUE="clone existing export">
- </FORM></TD></TR>
-<% } %>
</TABLE></TD>
<% my($n1)='';
diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html
index a7c21c7c9..6ed96d229 100644
--- a/httemplate/docs/schema.html
+++ b/httemplate/docs/schema.html
@@ -256,10 +256,15 @@
<li>svcpart - <a href="#part_svc">Service definition</a>
<li>quantity - quantity of this service that this package includes
</ul>
+ <li><a name="export_svc" href="man/FS/export_svc.html">export_svc</a>
+ <ul>
+ <li>exportsvcnum - primary key
+ <li>svcpart - <a href="#part_svc">Service definition</a>
+ <li>exportnum - <a href="#exportnum">Export</a>
+ </ul>
<li><a name="part_export" href="man/FS/part_export.html">part_export</a> - Export to external provisioning
<ul>
<li>exportnum - primary key
- <li>svcpart - <a href="#part_svc">Service definition</a>
<li>machine - Machine name
<li>exporttype - Export type
<li>nodomain - blank or Y: usernames are exported to this service with no domain
diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html
index d1b13fe9c..841a053ed 100644
--- a/httemplate/docs/upgrade8.html
+++ b/httemplate/docs/upgrade8.html
@@ -152,9 +152,17 @@ CREATE TABLE part_bill_event (
);
CREATE INDEX part_bill_event1 ON part_bill_event ( payby );
+CREATE TABLE export_svc (
+ exportsvcnum int primary key,
+ exportnum int not null,
+ svcpart int not null
+);
+CREATE UNIQUE INDEX export_svc1 ON export_svc ( exportnum, svcpart );
+CREATE INDEX export_svc2 ON export_svc ( exportnum );
+CREATE INDEX export_svc3 ON export_svc ( svcpart );
+
CREATE TABLE part_export (
exportnum int primary key,
- svcpart int not null,
machine varchar(80) not null,
exporttype varchar(80) not null,
nodomain char(1) NULL
diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi
index 0ca964e02..f3127403e 100644
--- a/httemplate/edit/part_export.cgi
+++ b/httemplate/edit/part_export.cgi
@@ -6,34 +6,18 @@
#} 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($cgi->param('svcpart'));
- }
-} 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 } );
+ $part_export = qsearchs('part_export', { 'exportnum' => $1 } );
+} else {
+ $part_export = new FS::part_export;
}
$action ||= $part_export->exportnum ? 'Edit' : 'Add';
@@ -101,18 +85,20 @@ my %exports = (
);
-my $svcdb = $part_export->part_svc->svcdb;
+#my $svcdb = $part_export->part_svc->svcdb;
+#YUCK
+my $svcdb = 'svc_acct';
+
my %layers = map { $_ => "$_ - ". $exports{$svcdb}{$_}{desc} }
keys %{$exports{$svcdb}};
$layers{''}='';
my $widget = new HTML::Widgets::SelectLayers(
'selected_layer' => $part_export->exporttype,
- 'selected_layer' => $part_export->exporttype,
'options' => \%layers,
'form_name' => 'dummy',
'form_action' => 'process/part_export.cgi',
- 'form_text' => [qw( exportnum svcpart machine )],
+ 'form_text' => [qw( exportnum machine )],
# 'form_checkbox' => [qw()],
'html_between' => "</TD></TR></TABLE>\n",
'layer_callback' => sub {
@@ -123,7 +109,7 @@ my $widget = new HTML::Widgets::SelectLayers(
# foreach my $option ( qw(url login password groupID ) ) {
my $optinfo = $exports{$svcdb}->{$layer}{options}{$option};
my $label = $optinfo->{label};
- my $value = $part_export->option($option);
+ my $value = $cgi->param($option) || $part_export->option($option);
$html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!.
qq!<TD><INPUT TYPE="text" NAME="$option" VALUE="$value"></TD>!.
'</TR>';
@@ -160,13 +146,6 @@ my $widget = new HTML::Widgets::SelectLayers(
<%= ntable("#cccccc",2) %>
<TR>
- <TD ALIGN="right">Service</TD>
- <TD BGCOLOR="#ffffff">
- <%= $part_export->svcpart %> - <%= $part_export->part_svc->svc %>
- <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $part_export->svcpart %>">
- </TD>
-</TR>
-<TR>
<TD ALIGN="right">Export host</TD>
<TD>
<INPUT TYPE="text" NAME="machine" VALUE="<%= $part_export->machine %>">
diff --git a/httemplate/edit/process/part_export.cgi b/httemplate/edit/process/part_export.cgi
index d0c87a02a..34eb699bf 100644
--- a/httemplate/edit/process/part_export.cgi
+++ b/httemplate/edit/process/part_export.cgi
@@ -18,6 +18,7 @@ my $error;
if ( $exportnum ) {
warn $old;
warn $exportnum;
+ warn $new->machine;
$error = $new->replace($old,\%options);
} else {
$error = $new->insert(\%options);
@@ -28,7 +29,7 @@ if ( $error ) {
$cgi->param('error', $error );
print $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string );
} else {
- print $cgi->redirect(popurl(3). "browse/part_svc.cgi");
+ print $cgi->redirect(popurl(3). "browse/part_export.cgi");
}
%>
diff --git a/httemplate/index.html b/httemplate/index.html
index 99d8df956..c638aec16 100644
--- a/httemplate/index.html
+++ b/httemplate/index.html
@@ -167,6 +167,8 @@
<ul>
<LI><A HREF="browse/part_svc.cgi">View/Edit service definitions</A>
- Services are items you offer to your customers.
+ <LI><A HREF="browse/part_export.cgi">View/Edit exports</A>
+ - Provisioning services to external machines, databases and APIs.
<LI><A HREF="browse/part_pkg.cgi">View/Edit package definitions</A>
- One or more services are grouped together into a package and
given pricing information. Customers purchase packages, not
diff --git a/httemplate/misc/delete-part_export.cgi b/httemplate/misc/delete-part_export.cgi
index a5166d944..34ef06b96 100755
--- a/httemplate/misc/delete-part_export.cgi
+++ b/httemplate/misc/delete-part_export.cgi
@@ -10,6 +10,6 @@ my $part_export = qsearchs('part_export',{'exportnum'=>$exportnum});
my $error = $part_export->delete;
eidiot($error) if $error;
-print $cgi->redirect($p. "browse/part_svc.cgi");
+print $cgi->redirect($p. "browse/part_export.cgi");
%>