cache org ids while importing datagov
[disclosr.git] / documents / agency.php
Alex Sadleir




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include('template.inc.php');
include_once('../include/common.inc.php');
$agenciesdb = $server->get_db('disclosr-agencies');
 
$idtoname = Array();
foreach ($agenciesdb->get_view("app", "byCanonicalName")->rows as $row) {
    $idtoname[$row->id] = trim($row->value->name);
}
$foidocsdb = $server->get_db('disclosr-foidocuments');
 
include_header_documents((isset($_REQUEST['id']) ? $idtoname[$_REQUEST['id']] : 'Entries by Agency'));
$endkey = (isset($_REQUEST['end_key']) ? $_REQUEST['end_key'] : '9999-99-99');
?>
    <div class="headline">Read all the information released by Australian Federal Government agencies under the FOI Act
        in one place!
    </div>
    <a style='float:right' href="rss.xml.php"><img src="img/feed-icon-14x14.png" alt="RSS Icon"/> All Agencies RSS Feed</a>
    <br>
<?php
try {
    if ($_REQUEST['id']) {
        $rows = $foidocsdb->get_view("app", "byAgencyID", $_REQUEST['id'], false, false, false)->rows;
        foreach ($rows as $row) {
            //print_r($rows);
            echo displayLogEntry($row, $idtoname);
            if (!isset($startkey))
                $startkey = $row->key;
            $endkey = $row->key;
        }
    } else {
        $rows = $foidocsdb->get_view("app", "byAgencyID?group=true", null, false, false, true)->rows;
        if ($rows) {
            foreach ($rows as $row) {
                echo '<a href="agency.php?id=' . $row->key . '">' . $idtoname[$row->key] . " (" . $row->value . " records)</a> <br>\n";
            }
        }
    }
} catch (SetteeRestClientException $e) {
    setteErrorHandler($e);
}
echo "<a class='btn btn-large btn-primary' href='?end_key=$endkey' style='float:right;'>next page <i class='icon-circle-arrow-right icon-white'></i></a>";
include_footer_documents();
?>