6 local $FS::UID::AutoCommit=0;
11 $cgi->param('error', $error);
12 print $cgi->redirect(popurl(3) . "edit/router.cgi?". $cgi->query_string);
19 my $routernum = $cgi->param('routernum');
20 my $routername = $cgi->param('routername');
21 my $old = qsearchs('router', { routernum => $routernum });
24 my $new = new FS::router {
26 ($_, scalar($cgi->param($_)));
31 $error = $new->replace($old);
33 $error = $new->insert;
34 $routernum = $new->routernum;
40 @old_psr = $old->part_svc_router;
41 foreach $psr (@old_psr) {
42 if($cgi->param('svcpart_'.$psr->svcpart) eq 'ON') {
45 $error = $psr->delete;
51 foreach($cgi->param) {
52 if($cgi->param($_) eq 'ON' and /^svcpart_(\d+)$/) {
54 if(grep {$_->svcpart == $svcpart} @old_psr) {
57 my $new_psr = new FS::part_svc_router { svcpart => $svcpart,
58 routernum => $routernum };
59 $error = $new_psr->insert;
66 # Yay, everything worked!
67 $dbh->commit or die $dbh->errstr;
68 print $cgi->redirect(popurl(3). "browse/router.cgi");