Data update
[contractdashboard.git] / displayContract.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
 
include_once("./lib/common.inc.php");
$query = 'SELECT *
FROM contractnotice
WHERE  "CNID" = :CNID LIMIT 1';
 
$query = $conn->prepare($query);
$query->bindParam(":CNID", $_REQUEST['CNID']);
$query->execute();
$contractResult = $query->fetch(PDO::FETCH_ASSOC);
if (!$contractResult) {
  header("Status: 404 Not Found");
    header("HTTP/1.0 404 Not Found");
include_header("Contract Not Found");
 echo "<center><h1>No Contract Notice with that ID found</h1></center>";
databaseError($conn->errorInfo());
} else {
$description = ucsmart($contractResult["description"]);
include_header($description);
 echo '<center><h1>'.$description.'</h1></center>
     <div about="http://contracts.disclosurelo.gs/displayContract.php?CNID='.$contractResult["CNID"].'" typeof="pc:Contract">';
databaseError($conn->errorInfo());
    setlocale(LC_MONETARY, 'en_US');
    foreach (array_filter($contractResult) as $key => $value) {
        echo "<b>$key</b>&nbsp;";
        switch ($key) {
            case "supplierABN":
            break;
            case "supplierName":
                echo '
                    <a href="displaySupplier.php?supplier=' . $contractResult['supplierABN'] . '-' . urlencode($contractResult['supplierName']) . '">
                        <span rel="pc:contractingAuthority" typeof="gr:BusinessEntity">
                        <span property="gr:legalName">' 
                    . $contractResult['supplierName'] . 
                    '</span>'.
                    (isset($contractResult['supplierABN']) && $contractResult['supplierABN'] != '' ? ' (ABN: <span property="br:officialNumber" lang="">'.$contractResult['supplierABN'].'</span>)' : '')
                        .'</span></a>';
                break;
            case "CNID":
                echo '<span property="pc:referenceNumber" lang="">'.$value.'</span>';
                break;
            case "categoryUNSPSC":
                break;
            case "category":
                echo '<span rel="pc:mainObject" resource="[unspsc:'.$contractResult["categoryUNSPSC"].']">'.$value.'</span>';
                break;
            case "SONID":
                echo '<a href="displaySON.php?SONID=' . urlencode($value) . '">' . $value . "</a>";
                break;
            case "agencyName":
                echo '<a href="displayAgency.php?agency=' . urlencode($value) . '">' . $value . "</a>";
                break;
            case "contractStart":
                echo '<span property="pc:startDate" content="'.$value.'" datatype="xsd:date">'.$value.'</span>';
                break;
            case "contractEnd":
                echo '<span property="pc:endDate" content="'.$value.'" datatype="xsd:date">'.$value.'</span>';
                break;
            case "value":
                echo '<span rel="pc:agreedPrice" typeof="gr:PriceSpecification">
                     <span property="gr:hasCurrency" content="AUD" lang="">$ </span>
                     <span property="gr:hasCurrencyValue" content="'.doubleval($value).'" datatype="xsd:float">' . number_format(doubleval($value), 2)
                    .'</span></span>';
                break;
            case "description":
                echo '<span property="dcterms:title">'.$value.'</span>';
                break;
            default:
                echo str_replace("  ", "<br>", ucsmart($value));
        }
        echo "<br>\n";
    }
echo '<br><a href="https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN' . $_REQUEST['CNID'] . '"> View original record @ tenders.gov.au</a><br>
    
</div>';
 
/*$query = $solr_client->createMoreLikeThis();
 
$query->setQuery('id:'.$_REQUEST['CNID']);
$query->setMltFields('description');
$query->setMinimumDocumentFrequency(1);
$query->setMinimumTermFrequency(1);
$query->setInterestingTerms('description');
$query->setMatchInclude(true);
 
// this executes the query and returns the result
$resultset = $solr_client->select($query);
 
// display the total number of documents found by solr
echo 'Found '.$resultset->getNumFound(). ' similar results: <table>';
 
 
foreach ($resultset as $row) {
setlocale(LC_MONETARY, 'en_US');
        $value = number_format(doubleval($row['value'][0]), 2);
        echo ("<tr>
    <td><a href=\"displayContract.php?CNID={$row['id']}\">{$row['id']}</a></td>
    <td><b>{$row['description'][0]}</b></a></td>
    <td>\$$value</td><td>{$row['agencyName'][0]}</td>
    <td>{$row['contractStart'][0]}</td>
    <td>{$row['supplierName'][0]}</td>
    </tr>");
}
echo "</table>";*/
 
 
$query = 'SELECT * FROM heuristic_results where "CNID" = :CNID';
$query = $conn->prepare($query);
$agencyName = $input . '%';
$query->bindParam(":CNID", $_REQUEST['CNID']);
$query->execute();
databaseError($conn->errorInfo());
foreach ($query->fetchAll() as $r) {
    echo "<b>{$r['heuristic_name']}</b>: {$r['heuristic_value']} (raw value: {$r['raw_value']}, mean: {$r['mean']}, stddev: {$r['stddev']})<br>";
}
}
include_footer();
?>