[freeside-commits] freeside/httemplate/browse addr_block.cgi, 1.4.2.4, 1.4.2.5 router.cgi, 1.8.2.4, 1.8.2.5

Jeff Finucane,420,, jeff at wavetail.420.am
Fri Apr 18 09:27:46 PDT 2008


Update of /home/cvs/cvsroot/freeside/httemplate/browse
In directory wavetail.420.am:/tmp/cvs-serv19149/httemplate/browse

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	addr_block.cgi router.cgi 
Log Message:
backout browse changes until 1.7.4

Index: router.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/browse/router.cgi,v
retrieving revision 1.8.2.4
retrieving revision 1.8.2.5
diff -u -d -r1.8.2.4 -r1.8.2.5
--- router.cgi	18 Apr 2008 03:29:27 -0000	1.8.2.4
+++ router.cgi	18 Apr 2008 16:27:43 -0000	1.8.2.5
@@ -1,43 +1,76 @@
-<% include('elements/browse.html',
-                'title'           => 'Routers',
-                'menubar'         => [ @menubar ],
-                'name_singular'   => 'router',
-                'query'           => { 'table'     => 'router',
-                                       'hashref'   => {},
-                                       'extra_sql' => $extra_sql,
-                                     },
-                'count_query'     => "SELECT count(*) from router $extra_sql",
-                'header'          => [ 'Router name',
-                                       'Address block(s)',
-                                     ],
-                'fields'          => [ 'routername',
-                                       sub { join( '<BR>', map { $_->NetAddr }
-                                                               shift->addr_block
-                                                 );
-                                           },
-                                     ],
-                'links'           => [ [ "${p2}edit/router.cgi?", 'routernum' ],
-                                       '',
-                                     ],
-          )
-%>
+<% include('/elements/header.html', 'Routers') %>
+
+<% include('/elements/error.html') %>
+
+%my $hidecustomerrouters = 0;
+%my $hideurl = '';
+%if ($cgi->param('hidecustomerrouters') eq '1') {
+%  $hidecustomerrouters = 1;
+%  $cgi->param('hidecustomerrouters', 0);
+%  $hideurl = '<A HREF="' . $cgi->self_url() . '">Show customer routers</A>';
+%} else {
+%  $hidecustomerrouters = 0;
+%  $cgi->param('hidecustomerrouters', 1);
+%  $hideurl = '<A HREF="' . $cgi->self_url() . '">Hide customer routers</A>';
+%}
+
+<A HREF="<%$p2%>edit/router.cgi">Add a new router</A>&nbsp;|&nbsp;<%$hideurl%>
+
+<% include('/elements/table-grid.html') %>
+% my $bgcolor1 = '#eeeeee';
+%   my $bgcolor2 = '#ffffff';
+%   my $bgcolor = '';
+
+  <TR>
+    <TH CLASS="grid" BGCOLOR="#cccccc">Router name</TH>
+    <TH CLASS="grid" BGCOLOR="#cccccc">Address block(s)</TH>
+  </TR>
+
+% foreach my $router (sort {$a->routernum <=> $b->routernum} @router) {
+%     next if $hidecustomerrouters && $router->svcnum;
+%     my @addr_block = $router->addr_block;
+%     if (scalar(@addr_block) == 0) {
+%       push @addr_block, '&nbsp;';
+%     }
+%
+%    if ( $bgcolor eq $bgcolor1 ) {
+%      $bgcolor = $bgcolor2;
+%    } else {
+%      $bgcolor = $bgcolor1;
+%    }
+
+  <TR>
+
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <A HREF="<%$p2%>edit/router.cgi?<%$router->routernum%>"><%$router->routername%></A>
+    </TD>
+
+    <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
+      <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
+
+%       foreach my $block ( @addr_block ) { 
+
+          <TR>
+            <TD><%UNIVERSAL::isa($block, 'FS::addr_block') ? $block->NetAddr : '&nbsp;'%></TD>
+          </TR>
+%       } 
+      </TABLE>
+    </TD>
+
+  </TR>
+
+% } 
+
+</TABLE>
+
+<% include('/elements/footer.html') %>
+
 <%init>
 
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
 
+my @router = qsearch('router', {});
 my $p2 = popurl(2);
-my $extra_sql = '';
-
-my @menubar = ( 'Add a new router', "${p2}edit/router.cgi" );
-
-if ($cgi->param('hidecustomerrouters') eq '1') {
-  $extra_sql = 'WHERE svcnum > 0';
-  $cgi->param('hidecustomerrouters', 0);
-  push @menubar, 'Show customer routers', $cgi->self_url();
-} else {
-  $cgi->param('hidecustomerrouters', 1);
-  push @menubar, 'Hide customer routers', $cgi->self_url();
-}
 
 </%init>

Index: addr_block.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/browse/addr_block.cgi,v
retrieving revision 1.4.2.4
retrieving revision 1.4.2.5
diff -u -d -r1.4.2.4 -r1.4.2.5
--- addr_block.cgi	18 Apr 2008 03:29:27 -0000	1.4.2.4
+++ addr_block.cgi	18 Apr 2008 16:27:43 -0000	1.4.2.5
@@ -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;',
-                                   ],
-          )
-%>
-<%init>
+<% include('/elements/header.html', 'Address Blocks') %>
 
-die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+<% include('/elements/error.html') %>
 
-my $p2 = popurl(2);
-my $path = $p2 . "edit/process/addr_block";
+<% include('/elements/table-grid.html') %>
+% my $bgcolor1 = '#eeeeee';
+%   my $bgcolor2 = '#ffffff';
+%   my $bgcolor = '';
 
-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";
+  <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>
 
-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>
-);
+% foreach $block (sort {$a->NetAddr cmp $b->NetAddr} @addr_block) { 
+%    if ( $bgcolor eq $bgcolor1 ) {
+%      $bgcolor = $bgcolor2;
+%    } else {
+%      $bgcolor = $bgcolor1;
+%    }
 
-$html_init .= include('/elements/error.html');
+    <TR>
+      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><%$block->NetAddr%></TD>
 
-my $confirm = sub {
-  my ($verb, $num) = (shift, shift);
-  "javascript:addr_block_areyousure('$path/$verb.cgi?blocknum=$num', '$verb')";
-};
+%   if (my $router = $block->router) { 
+%
+%     if (scalar($block->svc_broadband) == 0) { 
 
-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>
-);
+        <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 { 
 
-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;
-};
+        <TD COLSPAN="2" CLASS="grid" BGCOLOR="<% $bgcolor %>">
+        <%$router->routername%>
+        </TD>
+%     } 
+%
+%   } else { 
 
-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',
-           );
-  } 
-}; 
+      <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>
 
-my $split_link = sub {
-  my $block = shift;
-  my $ref = [ '', '' ];
-  $ref = [ &{$confirm}('split', $block->blocknum), '' ]
-    unless ($block->router);
-  $ref;
-}; 
+%   }
+
+  </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";
 
 </%init>



More information about the freeside-commits mailing list