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

    filename:    systemupdate.php
    description: list system settings (sample interval, time zone, temperature scale, mode)
    inputs:      none
    outputs:     sample interval, time zone, temperature scale, mode
    actions:     update, cancel
    redirection: systemupdateprocess.php

********************************************************************************
-->
<html>
    <head>
        <?php include 'head.html' ?>
        <script src = "navigation.js"></script>
    </head>
    <body>
        <?php include 'navigationmanagefoodspitsprobes.html' ?>
        <h3>UPDATE SYSTEM</h3>
        <div id="content">
            <?php
            include 'functions.php';
/*
            ... initialize settings
*/
            $sampleInterval = 5;
            $timeZone = -5;
            $tempScale = "F";
            $tempScales = array("F", "C");
            $mode = "Operational";
            $modes = array("Auto", "Manual");
/*
            ... Get system
*/
            $row = getSystem();
            $sampleInterval = $row[sampleInterval];
            $timeZone = $row[timeZone];
            $tempScale = $row[tempScale];
            $mode = $row[mode];
/*
            ... display form
*/
            echo '<form action="systemupdateprocess.php" method="post">';
                echo "<table>";
                echo "<tr>";
                echo "<th>Sample Interval</th>";
                echo "<th>";
                echo '<select name="sampleInterval">';
                    for($j = 0; $j <= 60; $j+=5) {
                        if ($j == 0) {
                            $i = 1;
                        } else {
                            $i= $j;
                        }
                        if ($i == $sampleInterval) {
                            echo '<option value=' . $i . ' selected>' . $i . '</option>';
                        } else {
                            echo '<option value=' . $i . '>' . $i . '</option>';
                        }
                    }
                echo '</select>';
                echo 'sec';   
                echo "</th>";
                echo "</tr>";
                echo "<tr>";
                echo "<th>Time Zone</th>";
                echo "<th>";
                echo '<select name="timeZone">';
                    for($i = -12; $i <= 12; $i++) {
                        if ($i == $timeZone) {
                            echo '<option value=' . $i . ' selected>' . $i . '</option>';
                        } else {
                            echo '<option value=' . $i . '>' . $i . '</option>';
                        }
                    }
                echo '</select>';   
                echo "</th>";
                echo "</tr>";
                echo "<tr>";
                echo "<th>Temp Scale</th>";
                echo "<th>";
                echo '<select name="tempScale">';
                foreach ($tempScales as $s) {
                    if ($s == $tempScale) {
                        echo '<option value="' . $s . '" selected>' . $s . '</option>';
                    } else {
                        echo '<option value="' . $s . '">' . $s . '</option>';
                    }
                }
                echo '</select>';
                echo "</th>";
                echo "</tr>";
                echo "<tr>";
                echo "<th>Mode</th>";
                echo "<th>";
                echo '<select name="mode">';
                foreach ($modes as $m) {
                    if ($m == $mode) {
                        echo '<option value="' . $m . '" selected>' . $m . '</option>';
                    } else {
                        echo '<option value="' . $m . '">' . $m . '</option>';
                    }
                }
                echo '</select>';
                echo "</th>";
                echo "</tr>";
                echo "</table>";
/*
                ... configure buttons
*/
                echo '<input type="submit" name="update" value="Update">';
                echo '<input type="submit" name="cancel" value="Cancel"><br>';
            echo '</form>';
        ?>
        </div>
    </body>
</html>