<?php |
<?php |
include_once ("./lib/common.inc.php"); |
include_once("./lib/common.inc.php"); |
if ($_REQUEST['category']) { |
if ($_REQUEST['category']) { |
include_header("Category"); |
|
echo "<center><h1>".$_REQUEST['category']."</h1></center>"; |
// if UNSPSC code known show, say if is a parent and offer to include children, if child link to parent |
$query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName |
$query = 'SELECT key, d."UNSPSC", "Title" AS category FROM |
FROM `contractnotice` |
(SELECT \'categoryUNSPSC\' AS key, "categoryUNSPSC"::TEXT AS "UNSPSC" FROM contractnotice WHERE category = :category |
WHERE childCN = 0 |
UNION SELECT \'parentUNSPSC\', substr( "categoryUNSPSC"::TEXT, 0, 5 )||\'0000\'::TEXT AS "parentUNSPSC" FROM contractnotice WHERE category = :category |
AND category = '" . $_REQUEST['category'] . "' |
UNION SELECT \'grandparentUNSPSC\', substr( "categoryUNSPSC"::TEXT, 0, 3 )||\'000000\'::TEXT AS "grandparentUNSPSC" |
ORDER BY value DESC"; |
FROM contractnotice WHERE category = :category ) d |
$result = mysql_query($query); |
INNER JOIN (SELECT "Title", "UNSPSC" FROM "UNSPSCcategories" ) c ON c."UNSPSC"=d."UNSPSC"::INTEGER'; |
echo "<table> <thead> |
$query = $conn->prepare($query); |
<tr> |
$query->bindParam(":category", $_REQUEST['category']); |
<th>Contract Notice Number</th> |
$query->execute(); |
<th>Contract Description</th> |
databaseError($conn->errorInfo()); |
<th>Total Contract Value</th> |
$unspsc = Array(); |
<th>Agency</th> |
foreach ($query->fetchAll() as $d) { |
<th>Contract Start Date</th> |
$unspsc[$d['key']] = $d; |
<th>Supplier</th> |
} |
</tr> |
|
</thead>"; |
|
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { |
include_header($_REQUEST['category'] . " goods and services"); |
setlocale(LC_MONETARY, 'en_US'); |
if ($unspsc['categoryUNSPSC']) { |
$value = number_format(doubleval($row['value']) , 2); |
echo "<center><h1>{$_REQUEST['category']} ({$unspsc['categoryUNSPSC']['UNSPSC']})</h1></center>"; |
echo ("<tr> |
|
<td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> |
if ($unspsc['parentUNSPSC']['UNSPSC'] != $unspsc['categoryUNSPSC']['UNSPSC']) { |
<td><b>{$row['description']}</b></a></td> |
echo "Parent Category: <a href='displayCategory.php?category={$unspsc['parentUNSPSC']['category']}'>{$unspsc['parentUNSPSC']['UNSPSC']} {$unspsc['parentUNSPSC']['category']}</a> <br/>"; |
<td>\$$value</td><td>{$row['agencyName']}</td> |
} |
<td>{$row['contractStart']}</td> |
if ($unspsc['grandparentUNSPSC']['UNSPSC'] != $unspsc['categoryUNSPSC']['UNSPSC']) { |
<td>{$row['supplierName']}</td> |
echo "Grandparent Category: <a href='displayCategory.php?category={$unspsc['grandparentUNSPSC']['category']}'>{$unspsc['grandparentUNSPSC']['UNSPSC']} {$unspsc['grandparentUNSPSC']['category']}</a></br>"; |
</tr>"); |
} |
} |
|
echo "</table>"; |
} else { |
mysql_free_result($result); |
echo "<center><h1>{$_REQUEST['category']}</h1></center>"; |
} else { |
} |
/* |
|
split by main categories |
$query = ' |
*/ |
SELECT |
include_header("Categories"); |
sum((consultancy = \'Yes\')::int) AS consultancy, |
$query = "SELECT sum(value), category |
sum(("confidentialityContract" = \'Yes\')::int) AS "confidentialityContract", |
FROM `contractnotice` |
sum(("confidentialityOutputs" = \'Yes\')::int) AS "confidentialityOutputs", |
WHERE childCN = 0 |
sum((("procurementMethod" = \'Open\' OR "procurementMethod" = \'Open tender\') AND "SONID" IS null)::int) AS open, |
GROUP BY category ORDER BY sum(value) DESC "; |
sum((("procurementMethod" = \'Open\' OR "procurementMethod" = \'Open tender\') AND "SONID" IS NOT null)::int) AS "openSON", |
$result = mysql_query($query); |
sum(("procurementMethod" = \'Prequalified tender\' OR "procurementMethod" = \'Select\')::INT) AS prequalified, |
echo "<table> <thead> |
sum(("procurementMethod" = \'Direct\' OR "procurementMethod" = \'Limited tender\')::int) AS limited, |
<tr> |
sum("value") as total_value, |
<th>Category</th> |
COUNT(*) AS total |
<th>Total Contracts Value</th> |
FROM contractnotice |
</tr> |
WHERE category = :category AND ' . " $yearQ $standardQ "; |
</thead>"; |
$query = $conn->prepare($query); |
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { |
$query->bindParam(":category", $_REQUEST['category']); |
setlocale(LC_MONETARY, 'en_US'); |
$query->execute(); |
$value = number_format(doubleval($row[0]) , 2); |
databaseError($conn->errorInfo()); |
echo ("<tr><td><A href=\"displayCategory.php?category={$row[1]}\"><b>{$row[1]}</b></a></td><td>\$$value</td></tr>"); |
|
} |
$stats = reset($query->fetchAll()); |
echo "</table>"; |
show_stats($stats); |
mysql_free_result($result); |
|
} |
|
include_footer(); |
$query = 'SELECT "CNID", description, value, "agencyName", category, "contractStart", "supplierName" |
|
FROM contractnotice |
|
WHERE ' . $yearQ . ' "childCN" IS NULL |
|
AND CATEGORY = :CATEGORY |
|
ORDER BY VALUE DESC'; |
|
$query = $conn->prepare($query); |
|
$query->bindParam(":CATEGORY", $_REQUEST['category']); |
|
$query->execute(); |
|
databaseError($conn->errorInfo()); |
|
|
|
echo "<table> <thead> |
|
<tr> |
|
<th>Contract Notice Number</th> |
|
<th>Contract Description</th> |
|
<th>Total Contract Value</th> |
|
<th>Agency</th> |
|
<th>Contract Start Date</th> |
|
<th>Supplier</th> |
|
</tr> |
|
</thead>"; |
|
foreach ($query->fetchAll() as $row) { |
|
setlocale(LC_MONETARY, 'en_US'); |
|
$value = number_format(doubleval($row['value']), 2); |
|
echo("<tr> |
|
<td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> |
|
<td><b>{$row['description']}</b></a></td> |
|
<td>\$$value</td><td>{$row['agencyName']}</td> |
|
<td>{$row['contractStart']}</td> |
|
<td>{$row['supplierName']}</td> |
|
</tr>"); |
|
} |
|
echo "</table>"; |
|
} else { |
|
/* |
|
split by main categories |
|
*/ |
|
include_header("Categories"); |
|
$query = 'SELECT sum(value), category |
|
FROM contractnotice |
|
WHERE ' . $yearQ . ' "childCN" IS NULL |
|
GROUP BY CATEGORY ORDER BY sum(VALUE) DESC '; |
|
$query = $conn->prepare($query); |
|
$query->execute(); |
|
databaseError($conn->errorInfo()); |
|
echo "<table> <thead> |
|
<tr> |
|
<th>Category</th> |
|
<th>Total Contracts Value</th> |
|
</tr> |
|
</thead>"; |
|
foreach ($query->fetchAll() as $row) { |
|
setlocale(LC_MONETARY, 'en_US'); |
|
$value = number_format(doubleval($row[0]), 2); |
|
echo("<tr><td><A href=\"displayCategory.php?category={$row[1]}\"><b>{$row[1]}</b></a></td><td>\$$value</td></tr>"); |
|
} |
|
echo "</table>"; |
|
} |
|
include_footer(); |
?> |
?> |
|
|