Index: trunk/cgi-bin/admin.cgi
===================================================================
--- trunk/cgi-bin/admin.cgi	(revision 646)
+++ trunk/cgi-bin/admin.cgi	(revision 647)
@@ -505,9 +505,12 @@
   $page->param(within => $within);
 
-  $sth = $ip_dbh->prepare("select cidr,custid,type,city,description from allocations where cidr <<= '$within' order by cidr");
-  $sth->execute;
+
+  $sth = $ip_dbh->prepare("SELECT id,vrf,cidr,custid,type,city,description FROM allocations".
+	" WHERE cidr <<= ? ORDER BY vrf,cidr");
+  $sth->execute($within);
   my @blocklist;
-  while (my ($cidr,$custid,$type,$city,$desc) = $sth->fetchrow_array) {
+  while (my ($id,$vrf,$cidr,$custid,$type,$city,$desc) = $sth->fetchrow_array) {
     my %row = (
+	id => $id,
 	cidr => $cidr,
 	custid => $custid,
@@ -517,6 +520,6 @@
 
 ##fixme:  don't wanna retrieve the whole type list *every time around the outer loop*
-    my $sth2 = $ip_dbh->prepare("select type,listname from alloctypes".
-	" where listorder < 500 and not (type like '_i') order by listorder");
+    my $sth2 = $ip_dbh->prepare("SELECT type,listname FROM alloctypes".
+	" WHERE listorder < 999 AND NOT (type LIKE '_i') ORDER BY listorder");
     $sth2->execute;
     my @typelist;
@@ -538,19 +541,20 @@
 # Stuff updates into DB
 sub update {
+  my $cidr = $ip_dbh->selectrow_array("SELECT cidr FROM allocations WHERE id=?", undef, ($webvar{block}) );
+
   # Relatively simple SQL transaction here.  Note that we're deliberately NOT
   # updating notes/desc here as it's available through the main interface.
-  $sth = $ip_dbh->prepare("update allocations set custid='$webvar{custid}',".
-	"city=?,type='$webvar{alloctype}' where cidr='$webvar{block}'");
-  $sth->execute($webvar{city});
-
-  $page->param(block => $webvar{block});
-  if ($sth->err) {
-    $page->param(updfailed => $sth->errstr);
-    syslog "err", "$authuser could not update block '$webvar{block}': '".$sth->errstr."'";
+  $ip_dbh->do("UPDATE allocations SET custid=?, city=?, type=? WHERE id=?", undef,
+	($webvar{custid}, $webvar{city}, $webvar{alloctype}, $webvar{block}) );
+
+  $page->param(block => $cidr);
+  if ($ip_dbh->err) {
+    $page->param(updfailed => $ip_dbh->errstr);
+    syslog "err", "$authuser could not update block '$cidr': '".$ip_dbh->errstr."'";
   } else {
-    syslog "notice", "$authuser updated $webvar{block}";
+    syslog "notice", "$authuser updated $cidr";
   }
   # need to get /24 that block is part of
-  my @bits = split /\./, $webvar{block};
+  my @bits = split /\./, $cidr;
   $bits[3] = "0/24";
   showAllocs((join ".", @bits));
@@ -562,24 +566,18 @@
 # Allow changes to ALL fields
 sub showPool {
-  my $pool = new NetAddr::IP $_[0];
-
-  $sth = $ip_dbh->prepare("select type,listname from alloctypes where type like '_i' order by listorder");
-  $sth->execute;
-  my @typelist;
-  while (my ($type,$dispname) = $sth->fetchrow_array) {
-    my %row = (
-	type => $type,
-	dispname => $dispname
-	);
-    push @typelist, \%row;
-  }
-  $page->param(typelist => \@typelist);
-
-  $sth = $ip_dbh->prepare("SELECT ip,custid,city,type,available,description,notes from poolips".
-	" WHERE pool=? ORDER BY ip");
+  my $pool = shift;
+
+  # arguably even presenting a list here is Wrong, because Pool IPs Should Alwasy Match The Pool Type, but...
+  # could also set "selected" on the "correct" type
+  my $tlist = getTypeList($ip_dbh, 'i');
+  $page->param(typelist => $tlist);
+
+  $sth = $ip_dbh->prepare("SELECT id,ip,custid,city,type,available,description,notes from poolips".
+	" WHERE parent_id=? ORDER BY ip");
   $sth->execute($pool);
   my @iplist;
-  while (my ($ip,$custid,$city,$type,$avail,$desc,$notes) = $sth->fetchrow_array) {
+  while (my ($id,$ip,$custid,$city,$type,$avail,$desc,$notes) = $sth->fetchrow_array) {
     my %row = (
+	id => $id,
 	ip => $ip,
 	custid => $custid,
Index: trunk/templates/admin/showallocs.tmpl
===================================================================
--- trunk/templates/admin/showallocs.tmpl	(revision 646)
+++ trunk/templates/admin/showallocs.tmpl	(revision 647)
@@ -6,5 +6,5 @@
 <fieldset><legend class="noshow">&nbsp;</legend>
 <input type="hidden" name="action" value="update">
-<td><TMPL_VAR NAME=cidr><input type="hidden" value="<TMPL_VAR NAME=cidr>" name=block></td>
+<td><TMPL_VAR NAME=cidr><input type="hidden" value="<TMPL_VAR NAME=id>" name=block></td>
 <td><input name="custid" value="<TMPL_VAR NAME=custid>"></td>
 <td>
