Index: trunk/cgi-bin/IPDB.pm
===================================================================
--- trunk/cgi-bin/IPDB.pm	(revision 681)
+++ trunk/cgi-bin/IPDB.pm	(revision 682)
@@ -104,4 +104,7 @@
 # (eg, NetAddr::IP->bits - NetAddr::IP->masklen)
 our $maxrevlist = 5;  # /27
+
+# UI layout for subblocks/containers
+our $sublistlayout = 1;
 
 ##
Index: trunk/cgi-bin/MyIPDB.pm
===================================================================
--- trunk/cgi-bin/MyIPDB.pm	(revision 681)
+++ trunk/cgi-bin/MyIPDB.pm	(revision 682)
@@ -78,4 +78,10 @@
 #$IPDB::maxrevlist = 8;  # v4 /24
 
+## UI layout for showing subblocks
+# 1 lists all containers in a group, then all end-use allocations (including pools) in a group
+# 2 lists all entries in a container in CIDR order, and puts a secondary summary line under a container entry
+# Both show free blocks in a group at the bottom as previously
+# $IPDB::sublistlayout = 1;
+
 ## connectDB_My()
 # Wrapper for IPDB::connectDB
Index: trunk/cgi-bin/main.cgi
===================================================================
--- trunk/cgi-bin/main.cgi	(revision 681)
+++ trunk/cgi-bin/main.cgi	(revision 682)
@@ -87,4 +87,7 @@
   $webvar{action} = "index";	#shuts up the warnings.
 }
+
+# collect variations in layout by way of $IPDB::sublistlayout
+$webvar{action} = 'showsubs' if $webvar{action} =~ /^showsubs/;
 
 my $page;
@@ -244,4 +247,33 @@
 # Display blocks immediately within a given parent
 sub showSubs {
+  # Which layout?
+  if ($IPDB::sublistlayout == 2) {
+
+    # 2-part layout;  mixed containers and end-use allocations and free blocks.
+    # Containers have a second line for the subblock metadata.
+    # We need to load an alternate template for this case.
+    $page = HTML::Template->new(filename => "showsubs2.tmpl", loop_context_vars => 1, global_vars => 1);
+
+    $page->param(maydel => ($IPDBacl{$authuser} =~ /d/));
+
+    my $sublist = listSubs($ip_dbh, parent => $webvar{parent});
+    $page->param(sublist => $sublist);
+
+  } else {
+
+    # Default 3-part layout;  containers, end-use allocations, and free blocks
+
+    my $contlist = listContainers($ip_dbh, parent => $webvar{parent});
+    $page->param(contlist => $contlist);
+
+    my $alloclist = listAllocations($ip_dbh, parent => $webvar{parent});
+    $page->param(alloclist => $alloclist);
+
+    # only show "delete" button if we have no container or usage allocations
+    $page->param(maydel => ($IPDBacl{$authuser} =~ /d/) && !(@$contlist || @$alloclist));
+
+  }
+
+  # Common elements
   my $pinfo = getBlockData($ip_dbh, $webvar{parent});
 
@@ -249,8 +281,4 @@
   $page->param(block => $pinfo->{block});
   $page->param(mayadd => ($IPDBacl{$authuser} =~ /a/));
-  $page->param(maydel => ($IPDBacl{$authuser} =~ /d/));
-
-  my $sublist = listSubs($ip_dbh, parent => $webvar{parent});
-  $page->param(sublist => $sublist);
 
   my $flist = listFree($ip_dbh, parent => $webvar{parent});
Index: trunk/templates/showsubs.tmpl
===================================================================
--- trunk/templates/showsubs.tmpl	(revision 681)
+++ trunk/templates/showsubs.tmpl	(revision 682)
@@ -1,12 +1,46 @@
 <div class="tbltitle">Subnets in <TMPL_VAR NAME=block></div>
-<br>
 <TMPL_VAR NAME=addperm>
 
-<TMPL_IF sublist>
+<TMPL_IF contlist>
+<br>
+<hr class="w30">
+<div class="tbltitle">Containers</div>
+<br>
+<table class="center" width="98%" cellspacing="0">
+<tr>
+<td class="heading">Container block</td>
+<td class="heading">Location</td>
+<td class="heading">Type</td>
+<td class="heading">Description/Name</td>
+<td class="heading">Allocations</td>
+<td class="heading">Free blocks</td>
+<td class="heading">Largest free block</td>
+</tr>
+
+<TMPL_LOOP NAME=contlist>
+<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
+<td><a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=showsubs&amp;parent=<TMPL_VAR NAME=id>"><TMPL_VAR NAME=block></a></td>
+<td><TMPL_VAR NAME=city></td>
+<td><TMPL_VAR NAME=type></td>
+<td><TMPL_VAR NAME=desc></td>
+<td><TMPL_VAR NAME=suballocs></td>
+<td><TMPL_VAR NAME=subfree></td>
+<td><TMPL_VAR ESCAPE=HTML NAME=lfree></td>
+</TMPL_LOOP>
+</table>
+<TMPL_ELSE>
+<hr class="w30">
+<div class="tbltitle">No container blocks in <TMPL_VAR NAME=block></div>
+</TMPL_IF>
+
+<TMPL_IF alloclist>
+<br>
+<hr class="w30">
+<div class="tbltitle">Usage allocations</div>
+<br>
 <table width="98%" cellspacing="0" class="center">
-
 <tr>
-<td class="heading">Netblock</td>
-<td class="heading">City</td>
+<td class="heading">CIDR allocation</td>
+<td class="heading">Location</td>
 <td class="heading">Type</td>
 <td class="heading">CustID</td>
@@ -15,32 +49,25 @@
 </tr>
 
-<TMPL_LOOP NAME=sublist>
+<TMPL_LOOP NAME=alloclist>
 <tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
 <td>
-<TMPL_IF hassubs>
-<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=showsubs&amp;parent=<TMPL_VAR NAME=id>"><TMPL_VAR NAME=block></a>
-<TMPL_ELSE>
 <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;id=<TMPL_VAR NAME=id>&amp;basetype=b"><TMPL_VAR NAME=block></a>
 <TMPL_IF listpool> &nbsp; <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=listpool&amp;pool=<TMPL_VAR NAME=id>">List IPs</a></TMPL_IF>
-</TMPL_IF>
 </td>
 <td><TMPL_VAR NAME=city></td>
 <td><TMPL_VAR NAME=type></td>
-<td><a href="<TMPL_VAR NAME=webpath>/cgi-bin/search.cgi?stype=q&amp;input=<TMPL_VAR NAME=custid>"><TMPL_VAR NAME=custid></a></td>
+<td><TMPL_VAR NAME=custid></td>
 <td><TMPL_VAR NAME=swip><TMPL_IF partswip><small>*</small></TMPL_IF></td>
 <td><TMPL_VAR NAME=desc></td>
 </tr>
-<TMPL_IF hassubs>
-<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
-<td colspan=4>
-Containers: <TMPL_VAR NAME=subcontainers>, Allocations: <TMPL_VAR NAME=suballocs>, Free: <TMPL_VAR NAME=subfree>, Largest free: <TMPL_VAR ESCAPE=HTML NAME=lfree>
-</td><td colspan=2></td></tr>
-</TMPL_IF>
 </TMPL_LOOP>
 </table>
 <TMPL_ELSE>
 <hr class="w30">
-<div class="tbltitle">No allocations in <TMPL_VAR NAME=block>
+<div class="tbltitle">No usage allocations in <TMPL_VAR NAME=block></div>
+</TMPL_IF>
+
 <TMPL_IF maydel>
+<div class="tbltitle">
 <br>
 <form action="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi" method=POST>
@@ -52,5 +79,4 @@
 </fieldset>
 </form>
-</TMPL_IF>
 </div>
 </TMPL_IF>
Index: trunk/templates/showsubs2.tmpl
===================================================================
--- trunk/templates/showsubs2.tmpl	(revision 682)
+++ trunk/templates/showsubs2.tmpl	(revision 682)
@@ -0,0 +1,91 @@
+<div class="tbltitle">Subnets in <TMPL_VAR NAME=block></div>
+<br>
+<TMPL_VAR NAME=addperm>
+
+<TMPL_IF sublist>
+<table width="98%" cellspacing="0" class="center">
+
+<tr>
+<td class="heading">Netblock</td>
+<td class="heading">City</td>
+<td class="heading">Type</td>
+<td class="heading">CustID</td>
+<td class="heading">SWIPed?</td>
+<td class="heading">Description/Name</td>
+</tr>
+
+<TMPL_LOOP NAME=sublist>
+<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
+<td>
+<TMPL_IF subblock>Sub </TMPL_IF>
+<TMPL_IF hassubs>
+<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=showsubs&amp;parent=<TMPL_VAR NAME=id>"><TMPL_VAR NAME=block></a>
+<TMPL_ELSE>
+<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;id=<TMPL_VAR NAME=id>&amp;basetype=b"><TMPL_VAR NAME=block></a>
+<TMPL_IF listpool> &nbsp; <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=listpool&amp;pool=<TMPL_VAR NAME=id>">List IPs</a></TMPL_IF>
+</TMPL_IF>
+</td>
+<td><TMPL_VAR NAME=city></td>
+<td><TMPL_VAR NAME=type></td>
+<td><a href="<TMPL_VAR NAME=webpath>/cgi-bin/search.cgi?stype=q&amp;input=<TMPL_VAR NAME=custid>"><TMPL_VAR NAME=custid></a></td>
+<td><TMPL_VAR NAME=swip><TMPL_IF partswip><small>*</small></TMPL_IF></td>
+<td><TMPL_VAR NAME=desc></td>
+</tr>
+<TMPL_IF hassubs>
+<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
+<td colspan=4>
+Containers: <TMPL_VAR NAME=subcontainers>, Allocations: <TMPL_VAR NAME=suballocs>, Free: <TMPL_VAR NAME=subfree>, Largest free: <TMPL_VAR ESCAPE=HTML NAME=lfree>
+</td><td colspan=2></td></tr>
+</TMPL_IF>
+</TMPL_LOOP>
+</table>
+<TMPL_ELSE>
+<hr class="w30">
+<div class="tbltitle">No allocations in <TMPL_VAR NAME=block>
+<TMPL_IF maydel>
+<br>
+<form action="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi" method=POST>
+<fieldset><legend class="noshow">&nbsp;</legend>
+<input type=hidden name=action value="delete">
+<input type=hidden name=block value="<TMPL_VAR NAME=del_id>">
+<input type=hidden name=basetype value="b">
+<input type=submit value=" Remove this block ">
+</fieldset>
+</form>
+</TMPL_IF>
+</div>
+</TMPL_IF>
+
+<br>
+<hr class="w60">
+
+<div class="tbltitle">Free blocks within <TMPL_VAR NAME=block></div>
+
+<TMPL_IF freelist>
+<table width="98%" cellspacing="0" class="center">
+<tr>
+<td class="heading">CIDR block</td>
+<td class="heading">Range</td>
+</tr>
+
+<TMPL_LOOP name=freelist>
+<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
+<TMPL_IF newvrf><td colspan=2>vrf: <TMPL_VAR NAME=newvrf></td>
+<TMPL_ELSE>
+<td>
+<TMPL_IF mayadd>
+<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=assign&amp;block=<TMPL_VAR NAME=fblock>&amp;fbid=<TMPL_VAR NAME=fbid>&amp;parent=<TMPL_VAR NAME=fbparent>"><TMPL_VAR NAME=fblock></a>
+<TMPL_ELSE>
+<TMPL_VAR NAME=fblock>
+</TMPL_IF>
+</td>
+<td><TMPL_VAR NAME=frange></td>
+</TMPL_IF>
+</tr>
+</TMPL_LOOP>
+</table>
+<TMPL_ELSE>
+<br>
+<hr class="w30">
+<div class="tbltitle">No unassigned blocks in <TMPL_VAR NAME=block></div>
+</TMPL_IF>
