X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Faddr_block.cgi;h=9e7ef2af27d031bf70394688d0fa13c023b297bf;hp=eac7cf7b6cfbac9fc72db95099ba9fe4acae6597;hb=d2cc614910c251801564615a268c7ca3bdb2c954;hpb=d8c81a25cb29cf0ca5d7cdeb8160f79d4fbb0bc6 diff --git a/httemplate/browse/addr_block.cgi b/httemplate/browse/addr_block.cgi index eac7cf7b6..9e7ef2af2 100644 --- a/httemplate/browse/addr_block.cgi +++ b/httemplate/browse/addr_block.cgi @@ -1,80 +1,162 @@ -<% include('/elements/header.html', 'Address Blocks') %> +<& elements/browse.html, + 'title' => 'Address Blocks', + 'name' => 'address block', + 'html_init' => $html_init, + 'html_foot' => $html_foot, + 'query' => { 'table' => 'addr_block', + 'hashref' => {}, + 'extra_sql' => $extra_sql, + 'order_by' => $order_by, + }, + 'count_query' => "SELECT count(*) from addr_block $count_sql", + 'header' => [ 'Address Block', + 'Router', + 'Action(s)', + '', + '', + '', + ], + 'fields' => [ 'NetAddr', + sub { my $b = shift; + my $router = $b->router; + my $result = ''; + if ($router) { + $result .= $router->routername. ' ('. + scalar($b->svc_broadband). ' broadband, '. + scalar($b->svc_acct). ' account services)'; + } + $result; + }, + $allocate_text, + sub { shift->router ? '' : '(split)' }, + sub { '('. (shift->manual_flag ? 'allow' : 'prevent'). ' automatic ip assignment)' }, + sub { + my $block = shift; + if(!$block->router && scalar($block->svc_broadband) == 0) { + return '(delete)'; + } + ''; + }, + ], + 'sort_fields' => [], + 'links' => [ '', + '', + [ 'javascript:void(0)', '' ], + $split_link, + $autoassign_link, + sub { + my $block = shift; + if(!$block->router && scalar($block->svc_broadband) == 0) { + [ "${p}misc/delete-addr_block.html?", 'blocknum' ]; + } + }, + ], + 'link_onclicks' => [ '', + '', + $allocate_link, + '', + '', + ], + 'cell_styles' => [ '', + '', + 'border-right:none;', + 'border-left:none;', + '', + ], + 'agent_virt' => 1, + 'agent_null_right' => 'Broadband global configuration', + 'agent_pos' => 1, +&> +<%init> -<% include('/elements/error.html') %> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Broadband configuration') + || $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration'); -<%table()%> -% foreach $block (sort {$a->NetAddr cmp $b->NetAddr} @addr_block) { +my $p2 = popurl(2); +my $path = $p2 . "edit/process/addr_block"; - - <%$block->NetAddr%> -% if (my $router = $block->router) { -% if (scalar($block->svc_broadband) == 0) { +my $extra_sql = ""; - - <%$router->routername%> - - -
- - -
- -% } else { +my $count_sql = "WHERE ". $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => 'Broadband global configuration', +); - - <%$router->routername%> - -% } -% } else { +my $order_by = "ORDER BY "; +$order_by .= "inet(ip_gateway), " if driver_name =~ /^Pg/i; +$order_by .= "inet_aton(ip_gateway), " if driver_name =~ /^mysql/i; +$order_by .= "ip_netmask"; - -
- - - -
- - -
- - -
- - -% } -% } +my $confirm = sub { + my ($verb, $num) = (shift, shift); + "javascript:addr_block_areyousure('$path/$verb.cgi?blocknum=$num', '$verb')"; +}; -
- -
- Gateway/Netmask - - / - - - - -
- - +my $html_foot = qq( +
+ Gateway/Netmask: + / +); +$html_foot .= include( '/elements/select-agent.html', + 'agent_null_right' => 'Broadband global configuration', + ); +$html_foot .= qq( + +
+); -<% include('/elements/footer.html') %> +my $allocate_text = sub { my $block = shift; + my $router = $block->router; + my $result = ''; + if ($router) { + $result = '(deallocate)' + unless scalar($block->svc_broadband); + }else{ + $result .= '(allocate)' + } + $result; +}; -<%init> +my $allocate_link = sub { + my $block = shift; + if ($block->router) { + if (scalar($block->svc_broadband) == 0) { + &{$confirm}('deallocate', $block->blocknum); + } else { + ""; + } + } else { + include( '/elements/popup_link_onclick.html', + 'action' => "${p2}edit/allocate.html?blocknum=". $block->blocknum, + 'actionlabel' => 'Allocate block to router', + ); + } +}; -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +my $split_link = sub { + my $block = shift; + my $ref = [ '', '' ]; + $ref = [ &{$confirm}('split', $block->blocknum), '' ] + unless ($block->router); + $ref; +}; -my @addr_block = qsearch('addr_block', {}); -my @router = qsearch('router', {}); -my $block; -my $p2 = popurl(2); -my $path = $p2 . "edit/process/addr_block"; +my $autoassign_link = sub { + my $block = shift; + my $url = "$path/manual_flag.cgi?manual_flag="; + $url .= $block->manual_flag ? '' : 'Y'; + [ "$url;blocknum=", 'blocknum' ]; +};