<?php
include("config.php");
$acnabn = filter_input(INPUT_GET,'acnabn', FILTER_SANITIZE_STRING);
$service_name = filter_input(INPUT_GET,'service_name', FILTER_SANITIZE_STRING);
$sth =  $db->prepare("Select * from dcaas_services where acnabn = :acnabn and service_name = :service_name");
$sth->bindValue(':acnabn',$acnabn);
$sth->bindValue(':service_name',$service_name);
$sth->execute();
$data = $sth->fetchAll(PDO::FETCH_ASSOC);
if (count($data) == 0) {
    header('HTTP/1.0 404 Not Found');
    includeHeader('Not Found');
    echo "not found";
} else {

    $service = $data[0];
    includeHeader($service['service_name']);
    ?>
    <div itemscope itemtype="http://schema.org/Product">
    <h1 itemprop="name"><?= $service['service_name'] ?></h1>

    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <div itemprop="seller" itemscope itemtype="http://schema.org/Organization">
            <h2>(<span itemprop="name"><?= $service['trading_or_business_name'] ?></span>)</h2>
            <small><a
                    href="https://www.tenders.gov.au/?event=public.advancedsearch.CNSONRedirect&type=cnEvent&atmType=archived%2Cclosed%2Cpublished%2Cproposed&agencyUUID=&agencyStatus=0&portfolioUUID=&keyword=&KeywordTypeSearch=AllWord&CNID=&dateType=Publish+Date&dateStart=&dateEnd=&supplierName=&supplierABN=<?= $service['acnabn'] ?>&valueFrom=&valueTo=&ATMID=&AgencyRefId=&consultancy=&submit=Search">
                    View Australian Government contracts with this supplier on AusTender</a></small>
            <br/>
        </div>
    </div>
    <br/>
    <i><span itemprop="description"><?= $service['service_description'] ?></span></i><br/>
    <table>
    <?php
    foreach ($service as $key => $value) {
        if (trim($value) != "" && !in_array($key, Array('trading_or_business_name' , 'acnabn' , 'service_name' ,'service_description', 'id'))) {

                echo "<tr><td>".ucwords(str_replace("_", " ", $key)) . "</td><td>$value</td></tr>\n";


        }

    }
    echo "</table>";

}
includeFooter();

