Index: /trunk/cgi-bin/ipdb-2.7-3.0.sql
===================================================================
--- /trunk/cgi-bin/ipdb-2.7-3.0.sql	(revision 669)
+++ /trunk/cgi-bin/ipdb-2.7-3.0.sql	(revision 670)
@@ -32,4 +32,18 @@
 -- probably need some more indexes
 
+-- Need some additional fields to support search output.  Might arguably
+-- move pool IPs into the allocations table;  we'll see.
+DROP VIEW searchme;
+CREATE VIEW "searchme" AS
+    SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, 
+      allocations.description, allocations.notes, allocations.circuitid, allocations.id,
+      allocations.parent_id, 'n' AS available
+    FROM allocations
+  UNION
+    SELECT poolips.ip, poolips.custid, poolips.type, poolips.city,
+      poolips.description, poolips.notes, poolips.circuitid, poolips.id,
+      poolips.parent_id, poolips.available
+    FROM poolips;
+
 -- Relabel a few types to match the new structure
 UPDATE alloctypes SET listname='Routing aggregation', dispname='Routing aggregation' WHERE type='rm';
Index: /trunk/cgi-bin/search.cgi
===================================================================
--- /trunk/cgi-bin/search.cgi	(revision 669)
+++ /trunk/cgi-bin/search.cgi	(revision 670)
@@ -78,5 +78,6 @@
   $page = HTML::Template->new(filename => "search/compsearch.tmpl");
 } else {
-  $page = HTML::Template->new(filename => "search/sresults.tmpl");
+  $page = HTML::Template->new(filename => "search/sresults.tmpl", global_vars => 1);
+  $page->param(webpath => $IPDB::webpath);
 }
 
@@ -84,5 +85,10 @@
 $header->param(version => $IPDB::VERSION);
 $header->param(addperm => $IPDBacl{$authuser} =~ /a/);
+$header->param(webpath => $IPDB::webpath);
 print "Content-type: text/html\n\n", $header->output;
+
+# Columns actually returned.  Slightly better than hardcoding it
+# in each (sub)select
+my $cols = "cidr,custid,type,city,description,id,parent_id,available";
 
 # Handle the DB error first
@@ -141,8 +147,4 @@
 # Iff something has NOT been entered, we still include it but in
 # such a way that it does not actually filter anything out.
-
-  # Columns actually returned.  Slightly better than hardcoding it
-  # in each (sub)select
-  my $cols = "cidr,custid,type,city,description";
 
   # hack fix for undefined variables
@@ -248,5 +250,5 @@
   # Node search.
 
-  my $sql = "SELECT cidr,custid,type,city,description FROM searchme".
+  my $sql = "SELECT $cols FROM searchme".
 	" WHERE cidr IN (SELECT block FROM noderef WHERE node_id=$webvar{node})";
 
@@ -345,6 +347,4 @@
 # 5) Invalid data which might be interpretable as an IP or something, but
 #    which probably shouldn't be for reasons of sanity.
-
-  my $cols = "cidr,custid,type,city,description";
 
   if ($category eq 'all') {
@@ -469,14 +469,18 @@
   my $count = 0;
   my @sresults;
-  while (my ($block, $custid, $type, $city, $desc) = $sth->fetchrow_array) {
+  while (my ($block, $custid, $type, $city, $desc, $id, $parent, $avail) = $sth->fetchrow_array) {
     my %row = (
 	rowclass => $count++ % 2,
 	issub => ($type =~ /^.r$/ ? 1 : 0),
+	ispool => ($type =~ /^.[pd]$/ ? 1 : 0),
+	basetype => ($type =~ /^.i/ ? 'i' : 'b'),
+	freeip => ($avail eq 'y'),
+	parent => $parent,
 	block => $block,
-	ispool => ($type =~ /^.[pd]$/ ? 1 : 0),
 	custid => $custid,
 	disptype => $disp_alloctypes{$type},
 	city => $city,
-	desc => $desc
+	desc => $desc,
+	id => $id,
 	);
     push @sresults, \%row;
Index: /trunk/templates/search/sresults.tmpl
===================================================================
--- /trunk/templates/search/sresults.tmpl	(revision 669)
+++ /trunk/templates/search/sresults.tmpl	(revision 670)
@@ -17,5 +17,11 @@
 <TMPL_LOOP NAME=sresults>
 <tr class="row<TMPL_VAR NAME=rowclass>">
-<td><TMPL_IF issub>Sub </TMPL_IF><a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;block=<TMPL_VAR NAME=block>"><TMPL_VAR NAME=block></a><TMPL_IF ispool>&nbsp; <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=listpool&amp;pool=<TMPL_VAR NAME=block>">List IPs</a></TMPL_IF></td>
+<td><TMPL_IF issub>Sub </TMPL_IF>
+<TMPL_IF freeip>
+<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=assign&amp;block=<TMPL_VAR NAME=id>&amp;parent=<TMPL_VAR NAME=parent>&amp;fbtype=i"><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=<TMPL_VAR NAME=basetype>"><TMPL_VAR NAME=block></a><TMPL_IF ispool>&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=custid></td>
 <td><TMPL_VAR NAME=disptype></td>
