X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Frouter.cgi;h=3cbb8c58eb36e3fac07d189d99303e7749d5635e;hb=b71b1576c68bc40ad26592b354feace37a029f0e;hp=7e40c48a70ad233ae1ab5189eb06c0d1f79be732;hpb=58d44fbe5eb9ab32e6d87063a4a3b22ddba9a828;p=freeside.git diff --git a/httemplate/edit/process/router.cgi b/httemplate/edit/process/router.cgi index 7e40c48a7..3cbb8c58e 100644 --- a/httemplate/edit/process/router.cgi +++ b/httemplate/edit/process/router.cgi @@ -1,70 +1,20 @@ -<% - -use FS::UID qw(dbh); - -my $dbh = dbh; -local $FS::UID::AutoCommit=0; - -sub check { - my $error = shift; - if($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(3) . "edit/router.cgi?". $cgi->query_string); - $dbh->rollback; - exit; - } -} - -my $error = ''; -my $routernum = $cgi->param('routernum'); -my $routername = $cgi->param('routername'); -my $old = qsearchs('router', { routernum => $routernum }); -my @old_psr; - -my $new = new FS::router { - map { - ($_, scalar($cgi->param($_))); - } fields('router') -}; - -if($old) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $routernum = $new->routernum; -} - -check($error); - -if ($old) { - @old_psr = $old->part_svc_router; - foreach $psr (@old_psr) { - if($cgi->param('svcpart_'.$psr->svcpart) eq 'ON') { - # do nothing - } else { - $error = $psr->delete; - } - } - check($error); -} - -foreach($cgi->param) { - if($cgi->param($_) eq 'ON' and /^svcpart_(\d+)$/) { - my $svcpart = $1; - if(grep {$_->svcpart == $svcpart} @old_psr) { - # do nothing - } else { - my $new_psr = new FS::part_svc_router { svcpart => $svcpart, - routernum => $routernum }; - $error = $new_psr->insert; - } - check($error); - } -} - +<% include('elements/process.html', + 'table' => 'router', + 'viewall_dir' => 'browse', + 'viewall_ext' => 'cgi', + 'edit_ext' => 'cgi', + 'process_m2m' => { 'link_table' => 'part_svc_router', + 'target_table' => 'part_svc', + }, + 'agent_virt' => 1, + 'agent_null_right' => 'Broadband global configuration', + ) +%> +<%init> +my $curuser = $FS::CurrentUser::CurrentUser; -# Yay, everything worked! -$dbh->commit or die $dbh->errstr; -print $cgi->redirect(popurl(3). "browse/router.cgi"); +die "access denied" + unless $curuser->access_right('Broadband configuration') + || $curuser->access_right('Broadband global configuration'); -%> +