<?php
/*
********************************************************************************

    filename:     currentburnprocess.php
    description:  
    inputs:       chart, read, preheat, cook, done, adjust, burnDetail, probeDetail, autoMode, manualMode, blowerSpeed, ventPosition
    outputs:      action (read, preheat, cook, done, adjust)
    actions:      none
    redirections: currentburn.php

********************************************************************************
*/
/*
            ... connect to database
*/
            include 'functions.php';
            $conn = connectToDB();

    if ($_POST["adjustDamping"]) {
        $blowerSpeed = $_POST["blowerSpeed"];
        $ventPosition = $_POST["ventPosition"];
        $sql = "UPDATE currentburn SET blowerSpeed=$blowerSpeed, ventPosition=$ventPosition WHERE currentBurnId=1";
        if (!mysqli_query($conn, $sql)) {
            error_log("Error updating table: " . mysqli_error($conn));
        }
        header('Location: currentburn.php');
        exit();
    } elseif ($_POST["manualMode"]) {
        setManualMode();
        header('Location: currentburn.php');
        exit();
    } elseif ($_POST["autoMode"]) {
        setAutoMode();
        header('Location: currentburn.php');
        exit();
    } elseif ($_POST["chart"]) {
        $burnId = $_GET["burnId"];
        header('Location: burnchart.php?burnId=' . $burnId, false);
        exit();
    } elseif ($_POST["read"]) {
        header('Location: currentburn.php?action=read'); 
        exit();
    } elseif ($_POST["preheat"]) {
        header('Location: currentburn.php?action=preheat'); 
        exit();
    } elseif ($_POST["cook"]) {
        header('Location: currentburn.php?action=cook'); 
        exit();
    } elseif ($_POST["check"]) {
        header('Location: currentburn.php?action=check'); 
        exit();
    } elseif ($_POST["done"]) {
        header('Location: currentburn.php?action=done'); 
        exit();
    } elseif ($_POST["adjustTemps"]) {
        header('Location: currentburnadjust.php?action=adjustTemps'); 
        exit();
    } elseif ($_POST["burndetail"]) {
        header('Location: currentburnlist.php'); 
        exit();
    } elseif ($_POST["probedetail"]) {
        header('Location: currentprobelist.php'); 
        exit();
    } else {
        header('Location: currentburn.php');
        exit();
    }    
?>