summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/svc_broadband.cgi
diff options
context:
space:
mode:
authorkhoff <khoff>2003-02-05 23:17:17 +0000
committerkhoff <khoff>2003-02-05 23:17:17 +0000
commit0354f39ed0e74fd2eae1d9da13906625b4f56591 (patch)
tree730b2ac862f4c47c661d91a91ccb8167a4a0ee8f /httemplate/edit/process/svc_broadband.cgi
parentc89aa83639038cc1946fec07a2dda252f64e5144 (diff)
svc_broadband rewrite
Diffstat (limited to 'httemplate/edit/process/svc_broadband.cgi')
-rw-r--r--httemplate/edit/process/svc_broadband.cgi54
1 files changed, 44 insertions, 10 deletions
diff --git a/httemplate/edit/process/svc_broadband.cgi b/httemplate/edit/process/svc_broadband.cgi
index fd7ba20d5..ab8b9f9d8 100644
--- a/httemplate/edit/process/svc_broadband.cgi
+++ b/httemplate/edit/process/svc_broadband.cgi
@@ -1,12 +1,19 @@
<%
+# If it's stupid but it works, it's not stupid.
+# -- U.S. Army
+
+local $FS::UID::AutoCommit = 0;
+my $dbh = FS::UID::dbh;
+
$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
my $svcnum = $1;
-my $old;
+my $old; my @old_sbf;
if ( $svcnum ) {
$old = qsearchs('svc_broadband', { 'svcnum' => $svcnum } )
or die "fatal: can't find broadband service (svcnum $svcnum)!";
+ @old_sbf = $old->sb_field;
} else {
$old = '';
}
@@ -17,14 +24,6 @@ my $new = new FS::svc_broadband ( {
} ( fields('svc_broadband'), qw( pkgnum svcpart ) )
} );
-unless ( $new->ip_addr ) {
- $new->ip_addr(join('.', (map $cgi->param('ip_addr_'.$_), (a..d))));
-}
-
-unless ( $new->mac_addr) {
- $new->mac_addr(join(':', (map $cgi->param('mac_addr_'.$_), (a..f))));
-}
-
my $error;
if ( $svcnum ) {
$error = $new->replace($old);
@@ -33,12 +32,47 @@ if ( $svcnum ) {
$svcnum = $new->svcnum;
}
+unless ($error) {
+ my $sb_field;
+
+ foreach ($cgi->param) {
+ #warn "\$cgi->param $_: " . $cgi->param($_);
+ if(/^sbf_(\d+)/) {
+ my $part = $1;
+ #warn "\$part $part";
+ $sb_field = new FS::sb_field
+ { svcnum => $svcnum,
+ value => $cgi->param($_),
+ sbfieldpart => $part };
+ if (my @x = grep { $_->sbfieldpart eq $part } @old_sbf) {
+ #if (my $old_sb_field = (grep { $_->sbfieldpart eq $part} @old_Sbf)[0]) {
+ #warn "array: " . scalar(@x);
+ if (length($sb_field->value) && ($sb_field->value ne $x[0]->value)) {
+ #warn "replacing " . $x[0]->value . " with " . $sb_field->value;
+ $error = $sb_field->replace($x[0]);
+ #$error = $sb_field->replace($old_sb_field);
+ } elsif (length($sb_field->value) == 0) {
+ #warn "delete";
+ $error = $x[0]->delete;
+ }
+ } else {
+ if (length($sb_field->value) > 0) {
+ #warn "insert";
+ $error = $sb_field->insert;
+ }
+ # else do nothing
+ }
+ }
+ }
+}
+
if ( $error ) {
$cgi->param('error', $error);
$cgi->param('ip_addr', $new->ip_addr);
- $cgi->param('mac_addr', $new->mac_addr);
+ $dbh->rollback;
print $cgi->redirect(popurl(2). "svc_broadband.cgi?". $cgi->query_string );
} else {
+ $dbh->commit or die $dbh->errstr;
print $cgi->redirect(popurl(3). "view/svc_broadband.cgi?" . $svcnum );
}