<?php
    session_start();
?>

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<!--
    Trying to demo PHP, sessions, and OCI in one example - implementing
        a state diagram version with NO "branch-back"

    Implementing dept-details VERSION 1 state diagram, at:
    https://nrs-projects.humboldt.edu/~st10/s24cs328/328lect13-1/dept-details-no-branch-back-state-diagram.pdf    
    last modified: 2024-04-17

    can run from:
    https://nrs-projects.humboldt.edu/~st10/s24cs328/328lect13-1/dept-details-1.php
-->

<head>
    <title> Department Details </title>
    <meta charset="utf-8" />

    <?php
        ini_set('display_errors', 1);
        require_once("choose_widget.php");
        require_once("build_dept_form-1.php");
        require_once("build_dept_drop_down.php");
        require_once("build_dept_radio.php");
        require_once("show_dept_details-1.php");

        require_once("hum_conn_sess.php");
        require_once("destroy_then_exit.php");
    ?>

<link href="https://nrs-projects.humboldt.edu/~st10/styles/normalize.css"
          type="text/css" rel="stylesheet" />

</head>

<body>

    <h1> Department Details </h1>

    <?php
    // I decided to use a next_state session key to help
    //     navigate through my application

    if (! array_key_exists("next_state", $_SESSION))
    {
        choose_widget();
        $_SESSION["next_state"] = "build_dept_form";
    }
    elseif ($_SESSION["next_state"] == "build_dept_form")
    {
        build_dept_form();
        $_SESSION["next_state"] = "show_dept_details";
    }    
    elseif ($_SESSION["next_state"] == "show_dept_details")
    {
        show_dept_details();
        session_destroy();
    }
 
    else  // that I hope to never reach!!
    {
        session_destroy();
        ?>
        <p> <strong> YIKES! should not have gotten here! </strong> </p>

        <p> Session concluded. </p>
        <p> <a href="<?= htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES) ?>">
            Start Over </a> </p>
        <?php            
    }
    ?>

    <footer>
    <hr />
    <p>
        Validate by pasting .xhtml copy's URL into<br />
        <a href="https://validator.w3.org/nu">
            https://validator.w3.org/nu
        </a>
        or  
        <a href="https://html5.validator.nu/">
            https://html5.validator.nu/
        </a>
    </p>
    </footer>
</body>
</html>