X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Faddr_block.cgi;h=ba40bfd4361f39186c187a06a371cf6b363b3d5e;hb=b21864778ad131008d94a3672820a6acbd413b60;hp=06ac556cfb89b9f6740a659cff11e7ff15b7767e;hpb=c0567c688084e89fcd11bf82348b6c418f1254ac;p=freeside.git
diff --git a/httemplate/browse/addr_block.cgi b/httemplate/browse/addr_block.cgi
index 06ac556cf..ba40bfd43 100644
--- a/httemplate/browse/addr_block.cgi
+++ b/httemplate/browse/addr_block.cgi
@@ -1,76 +1,161 @@
-<%= header('Address Blocks', menubar('Main Menu' => $p)) %>
-<%
+<& 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 $block = shift;
+ my $router = $block->router;
+ my $result = '';
+ if ($router) {
+ $result .= $router->routername. ' (';
+ $result .= scalar($block->svc_broadband). ' 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>
-use NetAddr::IP;
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Broadband configuration')
+ || $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');
-my @addr_block = qsearch('addr_block', {});
-my @router = qsearch('router', {});
-my $block;
my $p2 = popurl(2);
my $path = $p2 . "edit/process/addr_block";
-%>
+my $extra_sql = "";
-<% if ($cgi->param('error')) { %>
- Error: <%=$cgi->param('error')%>
-
-<% } %>
+my $count_sql = "WHERE ". $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null_right' => 'Broadband global configuration',
+);
-<%=table()%>
+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";
-<% foreach $block (sort {$a->NetAddr cmp $b->NetAddr} @addr_block) { %>
-