Record listing and individual viewing
Record listing and individual viewing


Former-commit-id: 675f84aad86a2d79ee305608962c396c6a349ce8

--- a/common.inc.php
+++ b/common.inc.php
@@ -9,7 +9,7 @@
     $obj->views->getActive->map = 'function(doc) { if (doc.status == "active") {  emit(doc._id, doc); } };';
     $obj->views->getSuspended->map = 'function(doc) { if (doc.status == "suspended") {  emit(doc._id, doc); } };';
     $obj->views->getScrapeRequired->map = "function(doc) {   emit(doc.abn, doc); };";
-
+$obv->views->showNamesABNs->map = "function(doc) {   emit(doc._id, {name: doc.name, abn: doc.abn}); };";
     // allow safe updates (even if slightly slower due to extra: rev-detection check).
     return $db->save($obj, true);
 }

--- a/getAgency.php
+++ b/getAgency.php
@@ -3,23 +3,33 @@
 include_once('common.inc.php');
 include_header();
 $db = $server->get_db('disclosr-agencies');
-//get an agency record as json/html, search by name/abn/id
+if (isset($_REQUEST['id'])) {
+    //get an agency record as json/html, search by name/abn/id
 // by name = startkey="Ham"&endkey="Ham\ufff0"
 // edit?
-$rows = $db->get_view("app","byABN")->rows;
-//print_r($rows);
-foreach ($rows as $row) {
-
-    echo "<table>";
-    echo '<tr> <td colspan="2"><h3>' . $row->value->name . "</h3></td></tr>";
+    
+   $row = $db->get($_REQUEST['id']);
+   //print_r($row);
+    echo '<table width="100%">';
+    echo '<tr> <td colspan="2"><h3>' . $row->name . "</h3></td></tr>";
     echo "<tr><th>Field Name</th><th>Field Value</th></tr>";
-foreach ($row->value as $key => $value) {
-            if (is_a($value, 'stdClass')) {
-            		echo "<tr><td>$key</td><td>".var_dump($value,true)."</td></tr>";
-            } else echo "<tr><td>$key</td><td>$value</td></tr>";
-	} // also show documents/URLs available
+    foreach ($row as $key => $value) {
+        if (is_a($value, 'stdClass')) {
+            echo "<tr><td>$key</td><td>" . var_dump($value, true) . "</td></tr>";
+        } else
+            echo "<tr><td>$key</td><td>$value</td></tr>";
+    }
 
     echo "</table>";
+} else {
+
+    $rows = $db->get_view("app", "showNamesABNs")->rows;
+//print_r($rows);
+    foreach ($rows as $row) {
+        //   print_r($row);
+        echo '<li><a href="getAgency.php?id=' . $row->key . '">' .
+                (isset($row->value->name) && $row->value->name != "" ? $row->value->name : "NO NAME " . $row->value->abn) 
+                . '</a></li>';
+    }
 }
-
 include_footer();