summaryrefslogtreecommitdiff
path: root/httemplate/browse/addr_block.cgi
diff options
context:
space:
mode:
authorjeff <jeff>2008-04-18 16:27:44 +0000
committerjeff <jeff>2008-04-18 16:27:44 +0000
commitccb98cbde1747707e3ea8a4c1c8b75d737f1e653 (patch)
tree06435d42e2a0a46417b9855b7b9e7b4319d4f698 /httemplate/browse/addr_block.cgi
parentd1d39ca153781e8c6f2640f9a694b2631bec3550 (diff)
backout browse changes until 1.7.4
Diffstat (limited to 'httemplate/browse/addr_block.cgi')
-rw-r--r--httemplate/browse/addr_block.cgi194
1 files changed, 82 insertions, 112 deletions
diff --git a/httemplate/browse/addr_block.cgi b/httemplate/browse/addr_block.cgi
index d597ee17e..7a9351918 100644
--- a/httemplate/browse/addr_block.cgi
+++ b/httemplate/browse/addr_block.cgi
@@ -1,121 +1,91 @@
-<% include('elements/browse.html',
- 'title' => 'Address Blocks',
- 'name' => 'address block',
- 'html_init' => $html_init,
- 'html_form' => $html_form,
- 'query' => { 'table' => 'addr_block',
- 'hashref' => {},
- 'extra_sql' => $extra_sql,
- 'order_by' => $order_by,
- },
- 'count_query' => "SELECT count(*) from addr_block $extra_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 ? '' : '<FONT SIZE="-2">(split)</FONT>' },
- ],
- 'links' => [ '',
- '',
- [ 'javascript:void(0)', '' ],
- $split_link,
- ],
- 'link_onclicks' => [ '',
- '',
- $allocate_link,
- '',
- ],
- 'cell_styles' => [ '',
- '',
- 'border-right:none;',
- 'border-left:none;',
- ],
- )
-%>
+<% include('/elements/header.html', 'Address Blocks') %>
+
+<% include('/elements/error.html') %>
+
+<% include('/elements/table-grid.html') %>
+% my $bgcolor1 = '#eeeeee';
+% my $bgcolor2 = '#ffffff';
+% my $bgcolor = '';
+
+ <TR>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Address block(s)</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Router</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Action(s)</TH>
+ </TR>
+
+% foreach $block (sort {$a->NetAddr cmp $b->NetAddr} @addr_block) {
+% if ( $bgcolor eq $bgcolor1 ) {
+% $bgcolor = $bgcolor2;
+% } else {
+% $bgcolor = $bgcolor1;
+% }
+
+ <TR>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><%$block->NetAddr%></TD>
+
+% if (my $router = $block->router) {
+%
+% if (scalar($block->svc_broadband) == 0) {
+
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <%$router->routername%>
+ </TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <FORM ACTION="<%$path%>/deallocate.cgi" METHOD="POST">
+ <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$block->blocknum%>">
+ <INPUT TYPE="submit" NAME="submit" VALUE="Deallocate">
+ </FORM>
+ </TD>
+% } else {
+
+ <TD COLSPAN="2" CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <%$router->routername%>
+ </TD>
+% }
+%
+% } else {
+
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <FORM ACTION="<%$path%>/allocate.cgi" METHOD="POST">
+ <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$block->blocknum%>">
+ <SELECT NAME="routernum" SIZE="1">
+% foreach (@router) {
+ <OPTION VALUE="<%$_->routernum %>"><%$_->routername%></OPTION>
+% }
+ </SELECT>
+ <INPUT TYPE="submit" NAME="submit" VALUE="Allocate">
+ </FORM>
+ </TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <FORM ACTION="<%$path%>/split.cgi" METHOD="POST">
+ <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$block->blocknum%>">
+ <INPUT TYPE="submit" NAME="submit" VALUE="Split">
+ </FORM>
+ </TD>
+
+% }
+
+ </TR>
+% }
+
+</TABLE>
+
+<BR><BR>
+<FORM ACTION="<%$path%>/add.cgi" METHOD="POST">
+Gateway/Netmask:
+<INPUT TYPE="text" NAME="ip_gateway" SIZE="15">/<INPUT TYPE="text" NAME="ip_netmask" SIZE="2">
+<INPUT TYPE="submit" NAME="submit" VALUE="Add">
+
+<% include('/elements/footer.html') %>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('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 = " ";
-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 $html_init = qq(
-<SCRIPT>
- function addr_block_areyousure(href, word) {
- if(confirm("Are you sure you want to "+word+" this address block?") == true)
- window.location.href = href;
- }
-</SCRIPT>
-);
-
-$html_init .= include('/elements/error.html');
-
-my $confirm = sub {
- my ($verb, $num) = (shift, shift);
- "javascript:addr_block_areyousure('$path/$verb.cgi?blocknum=$num', '$verb')";
-};
-
-my $html_form = qq(
- <FORM ACTION="$path/add.cgi" METHOD="POST">
- Gateway/Netmask:
- <INPUT TYPE="text" NAME="ip_gateway" SIZE="15">/<INPUT TYPE="text" NAME="ip_netmask" SIZE="2">
- <INPUT TYPE="submit" NAME="submit" VALUE="Add">
- </FORM>
-);
-
-my $allocate_text = sub { my $block = shift;
- my $router = $block->router;
- my $result = '';
- if ($router) {
- $result = '<FONT SIZE="-2">(deallocate)</FONT>'
- unless scalar($block->svc_broadband);
- }else{
- $result .= '<FONT SIZE="-2">(allocate)</FONT>'
- }
- $result;
-};
-
-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',
- );
- }
-};
-
-my $split_link = sub {
- my $block = shift;
- my $ref = [ '', '' ];
- $ref = [ &{$confirm}('split', $block->blocknum), '' ]
- unless ($block->router);
- $ref;
-};
-
</%init>