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

    filename:     burnlist.php
    description:  List burns in burns database table
    inputs:       none
    outputs:      burnId
    actions:      chart, status, export, import, delete
    redirections: burnlistprocess.php

********************************************************************************
-->
<html>
    <head>
        <?php include 'head.html' ?>
        <script src = "navigation.js"></script>
        <script>
            function deleteBurn() {
               if (confirm("Confirm Delete!") == true) {
                   window.location.href = "http://www.google.com"; // THIS DOESNT WORK
               }
            }
       </script>
        <style>
            table {
                border-collapse: collapse;
            }

            table, td, th {
                border: 1px solid black;
            }
        </style>
    </head>
    <body>
        <?php include 'navigationmanageburns.html' ?>
        <h3>BURNS</h3>
        <div id="content">
            <?php
                include 'functions.php';
/*
                ... get burns 
*/
                    $burns= getBurns();
/*
                ... list burns
*/
                echo "<table>";
                    echo"<tr>";
                        echo "<th>Burn ID</th>";
                        echo "<th>Start Date Time</th>";
                        echo "<th>End Date Time</th>";
                        echo "<th>Food ID</th>";
                        echo "<th>Food</th>";
                        echo "<th>Doneness</th>";
                        echo "<th>Comments</th>";
                        echo "<th>Pit ID</th>";
                        echo "<th>Pit Manufacturer</th>";
                        echo "<th>Pit Model</th>";
                        echo "<th>Blower P</th>";
                        echo "<th>Blower I</th>";
                        echo "<th>Blower D</th>";
                        echo "<th>Vent P</th>";
                        echo "<th>Vent I</th>";
                        echo "<th>Vent D</th>";
                    echo "</tr>";
                    foreach($burns as $burn) {
                            echo "<tr>";
                                echo "<th>" . $burn['burnId'] . "</th>";
                                echo "<th>" . $burn['startDateTime'] . "</th>";
                                echo "<th>" . $burn['endDateTime'] . "</th>";
                                echo "<th>" . $burn['foodId'] . "</th>";
                                echo "<th>" . $burn['food'] . "</th>";
                                echo "<th>" . $burn['doneness'] . "</th>";
                                echo "<th>" . $burn['comments'] . "</th>";
                                echo "<th>" . $burn['pitId'] . "</th>";
                                echo "<th>" . $burn['pitManufacturer'] . "</th>";
                                echo "<th>" . $burn['pitModel'] . "</th>";
                                echo "<th>" . $burn['blowerP'] . "</th>";
                                echo "<th>" . $burn['blowerI'] . "</th>";
                                echo "<th>" . $burn['blowerD'] . "</th>";
                                echo "<th>" . $burn['ventP'] . "</th>";
                                echo "<th>" . $burn['ventI'] . "</th>";
                                echo "<th>" . $burn['ventD'] . "</th>";
                            echo "</tr>";
                   }
               echo "</table>";
                echo '<form action="burnlistprocess.php" method="post">';
                    echo 'Burn<select name="burnId">';
                        echo '<option value="0">0</option>';
                        $lastBurn = end($burns);
                        $lastBurnId = $lastBurn['burnId'];
echo $lastBurnId . "<br>";
                        foreach($burns as $burn) {
                            $burnId = $burn['burnId'];
                            if ($burnId == $lastBurnId) {
                                echo '<option value="' . $burnId . '" selected>' . $burnId . '</option>';
                             } else {
                                echo '<option value="' . $burnId . '">' . $burnId . '</option>';
                            }
                        }
                    echo "</select>";
                    echo "<br>";
                    echo '<input type="submit" name="chart" value="Chart">';
                    echo '<input type="submit" name="status" value="Status">';
                    echo '<input type="submit" name="export" value="Export">';
                    echo '<input type="submit" name="import" value="Import">';
                  echo '<input type="submit" name="delete" value="Delete">';
//                    echo '<button onclick="deleteBurn()">Delete</button>';
               echo '</form>';
            ?>
        </div>
    </body>
</html>