<!DOCTYPE html>
<!--
********************************************************************************

    filename:     burnstatuslist.php
    description:  list burn statuses
    inputs:       burnId
    outputs:      none
    actions:      none
    redirections: none

********************************************************************************
-->
<html>
    <head>
        <style>
            table {
                border-collapse: collapse;
            }

            table, td, th {
                border: 1px solid black;
            }
        </style>
        <?php include 'head.html' ?>
        <script src = "navigation.js"></script>
    </head>
    <body>
        <?php include 'navigationmanageburns.html' ?>
        <h3>BURN</h3>
        <div id="content">
            <?php
/*
                ... connect to database
*/
                include 'functions.php';
                $conn = connectToDB();
/*
                ... get burn id
*/
                $burnId = $_GET["burnId"];
/*
                ... get statuses for burn
*/
                if ($burnId == 0) {
                    $sql = "SELECT statusId, burnId, burnState, probeId, probePosition, statusDateTime, probeTemp, targetTemp, highTemp, lowTemp, blowerSpeed, ventPosition FROM statuses";
                } else {
                    $sql = "SELECT statusId, burnId, burnState, probeId, probePosition, statusDateTime, probeTemp, targetTemp, highTemp, lowTemp, blowerSpeed, ventPosition FROM statuses WHERE burnId = $burnId";
                }
                $results = mysqli_query($conn, $sql);
                echo '<form action="currentburn.php" method="post">';
                    echo "<table>";
                    echo"<tr>";
                        echo "<th>Status ID</th>";
                        echo "<th>Burn ID</th>";
                        echo "<th>Mode</th>";
                        echo "<th>Burn State</th>";
                        echo "<th>Probe ID</th>";
                        echo "<th>Probe Position</th>";
                        echo "<th>Status Date Time</th>";
                        echo "<th>Probe Temp</th>";
                        echo "<th>Target Temp</th>";
                        echo "<th>High Temp</th>";
                        echo "<th>Low Temp</th>";
                        echo "<th>Blower Speed</th>";
                        echo "<th>Vent Position</th>";
                    echo "</tr>";        
                    if (mysqli_num_rows($results) > 0) {
                        while($row = mysqli_fetch_assoc($results)) {
                        echo"<tr>";
                           echo "<th>" . $row["statusId"] . "</th>";
                           echo "<th>" . $row["burnId"] . "</th>";
                           echo "<th>" . $row["mode"] . "</th>";
                           echo "<th>" . $row["burnState"] . "</th>";
                           echo "<th>" . $row["probeId"] . "</th>";
                           echo "<th>" . $row["probePosition"] . "</th>";
                           echo "<th>" . $row["statusDateTime"] . "</th>";
                           echo "<th>" . $row["probeTemp"] . "</th>";
                           echo "<th>" . $row["targetTemp"] . "</th>";
                           echo "<th>" . $row["highTemp"] . "</th>";
                           echo "<th>" . $row["lowTemp"] . "</th>";
                           echo "<th>" . $row["blowerSpeed"] . "</th>";
                           echo "<th>" . $row["ventPosition"] . "</th>";
                        echo '</tr>';
                        }
                     } else {            
                       echo "no status";
                    }
                echo "</table>";
            mysqli_close($conn);
?>
</div>
</body>
</html>