<commit_before><?php
    session_start();
    include_once 'dbConn.php';
    include_once 'functions.php';
    bounceToLogin();
    
    // Check for a query string that signals a message.
    $parts = explode("&", $_SERVER['QUERY_STRING']);
    $message = NULL;
    foreach ($parts as $part) {
        $cparts = explode("=", $part);
        if (count($cparts) != 2) {
            continue;
        }
        if ($cparts[0] == "update" &&
            $cparts[1] == "pw") {
            $message = "<font color=\"green\">Admin password updated!</font>";
            break;
        } else if ($cparts[0] == "update" &&
                   $cparts[1] == "as") {
            $message = "<font color=\"green\">Admin settings updated!</font>";
            break;
        } else if ($cparts[0] == "update" &&
                   $cparts[1] == "ex") {
            $message = "<font color=\"green\">De-duplication matrix updated!</font>";
            break;
        } else if ($cparts[0] == "error" &&
                   $cparts[1] == "ex") {
            $message = "<font color=\"red\">Error updating de-duplication matrix.</font> Please try again, or escalate to an administrator.";
            break;
        }
    }

    $matrixUrl = urlIfy("exclusionMatrix.html");
    $advancedUrl = urlIfy("advanced.php");
    $archiveUrl = urlIfy("archive.php");
    $resetUrl = urlIfy("staffReset.php");
    $levelingUrl = urlIfy("levelHomeLaunch.php");
    $reportUrl = urlIfy("report.php");
    $dbErr = "";
    $sessionId2Name = array();
    $blockId2Name = array();
    $groupId2Name = array();
    $edahId2Name = array();
    $chugId2Name = array();
    $bunkId2Name = array();
    
    fillId2Name(NULL, $chugId2Name, $dbErr,
                "chug_id", "chugim", "group_id",
                "groups");
    fillId2Name(NULL, $sessionId2Name, $dbErr,
                "session_id", "sessions");
    fillId2Name(NULL, $blockId2Name, $dbErr,
                "block_id", "blocks");
    fillId2Name(NULL, $groupId2Name, $dbErr,
                "group_id", "groups");
    fillId2Name(NULL, $edahId2Name, $dbErr,
                "edah_id", "edot");
    fillId2Name(NULL, $bunkId2Name, $dbErr,
                "bunk_id", "bunks");
    ?>

<?php
    echo headerText("Staff Home");
    
    $errText = genFatalErrorReport(array($dbErr), TRUE);
    if (! is_null($errText)) {
        echo $errText;
    }
    ?>

<?php
    if ($message) {
        $messageText = <<<EOM
<div class="container centered_container">
<h2>$message</h2>
</div>
EOM;
        echo $messageText;
    }
    ?>

<div class="centered_container container-fluid">
<h2>Camp Staff Control Panel</h2>
<p>To add and edit Edot, Sessions, Blocks, Groups, and Chugim, expand the relevant group below.  You may also view and edit campers according to edah.</p>
<p>Use the Leveling section to run the leveling algorithm.</p>
<p>For help, hover your mouse over an item, or press on mobile.<p>
<p>To prune obsolete items and merge duplicate camper registrations, click <a href="<?php echo $advancedUrl; ?>">here</a>. To archive your data at the end of a summer, and prepare the database for the next summer, click <a href="<?php echo $archiveUrl; ?>">here</a>.</p>

<form class="appnitro" action="<?php echo $resetUrl; ?>">
<button title="Click here to update the administrative settings, including staff password and camper code" class="btn btn-primary" type="submit" value="1">Edit Admin Settings</button>
</form>

<form class="appnitro" action="<?php echo $matrixUrl; ?>" method="post">
<button title="Click here to update the de-duplication settings" class="btn btn-primary" type="submit" value="1">De-Duplication Matrix</button>
</form>

</div>

<div class="panel-group" id="accordion">
<div class="multi_form_container">
<?php echo genPickListForm($edahId2Name, "edah", "edot"); ?>
</div>

<div class="multi_form_container">
<?php echo genPickListForm($sessionId2Name, "session", "sessions"); ?>
</div>

<div class="multi_form_container">
<?php echo genPickListForm($blockId2Name, "block", "blocks"); ?>
</div>

<div class="multi_form_container"><commit_msg>Make fix button more prominent<commit_after><?php
    session_start();
    include_once 'dbConn.php';
    include_once 'functions.php';
    bounceToLogin();
    
    // Check for a query string that signals a message.
    $parts = explode("&", $_SERVER['QUERY_STRING']);
    $message = NULL;
    foreach ($parts as $part) {
        $cparts = explode("=", $part);
        if (count($cparts) != 2) {
            continue;
        }
        if ($cparts[0] == "update" &&
            $cparts[1] == "pw") {
            $message = "<font color=\"green\">Admin password updated!</font>";
            break;
        } else if ($cparts[0] == "update" &&
                   $cparts[1] == "as") {
            $message = "<font color=\"green\">Admin settings updated!</font>";
            break;
        } else if ($cparts[0] == "update" &&
                   $cparts[1] == "ex") {
            $message = "<font color=\"green\">De-duplication matrix updated!</font>";
            break;
        } else if ($cparts[0] == "error" &&
                   $cparts[1] == "ex") {
            $message = "<font color=\"red\">Error updating de-duplication matrix.</font> Please try again, or escalate to an administrator.";
            break;
        }
    }

    $matrixUrl = urlIfy("exclusionMatrix.html");
    $advancedUrl = urlIfy("advanced.php");
    $archiveUrl = urlIfy("archive.php");
    $resetUrl = urlIfy("staffReset.php");
    $levelingUrl = urlIfy("levelHomeLaunch.php");
    $reportUrl = urlIfy("report.php");
    $dbErr = "";
    $sessionId2Name = array();
    $blockId2Name = array();
    $groupId2Name = array();
    $edahId2Name = array();
    $chugId2Name = array();
    $bunkId2Name = array();
    
    fillId2Name(NULL, $chugId2Name, $dbErr,
                "chug_id", "chugim", "group_id",
                "groups");
    fillId2Name(NULL, $sessionId2Name, $dbErr,
                "session_id", "sessions");
    fillId2Name(NULL, $blockId2Name, $dbErr,
                "block_id", "blocks");
    fillId2Name(NULL, $groupId2Name, $dbErr,
                "group_id", "groups");
    fillId2Name(NULL, $edahId2Name, $dbErr,
                "edah_id", "edot");
    fillId2Name(NULL, $bunkId2Name, $dbErr,
                "bunk_id", "bunks");
    ?>

<?php
    echo headerText("Staff Home");
    
    $errText = genFatalErrorReport(array($dbErr), TRUE);
    if (! is_null($errText)) {
        echo $errText;
    }
    ?>

<?php
    if ($message) {
        $messageText = <<<EOM
<div class="container centered_container">
<h2>$message</h2>
</div>
EOM;
        echo $messageText;
    }
    ?>

<div class="centered_container container-fluid">
<h2>Camp Staff Control Panel</h2>
<p>To add and edit Edot, Sessions, Blocks, Groups, and Chugim, expand the relevant group below.  You may also view and edit campers according to edah.</p>
<p>Use the Leveling section to run the leveling algorithm.</p>
<p>For help, hover your mouse over an item, or press on mobile.<p>
<p>To archive your data at the end of a summer, and prepare the database for the next summer, click <a href="<?php echo $archiveUrl; ?>">here</a>.</p>

<form class="appnitro" action="<?php echo $resetUrl; ?>">
<button title="Click here to update the administrative settings, including staff password and camper code" class="btn btn-primary" type="submit" value="1">Edit Admin Settings</button>
</form>

<form class="appnitro" action="<?php echo $matrixUrl; ?>" method="post">
<button title="Click here to update the de-duplication settings" class="btn btn-primary" type="submit" value="1">De-Duplication Matrix</button>
</form>

<form class="appnitro" action="<?php echo $advancedUrl; ?>" method="post">
<button title="Click here to prune illegal or obsolete assignments" class="btn btn-primary" type="submit" value="1">Fix Illegal And Duplicate</button>
</form>

</div>

<div class="panel-group" id="accordion">
<div class="multi_form_container">
<?php echo genPickListForm($edahId2Name, "edah", "edot"); ?>
</div>

<div class="multi_form_container">
<?php echo genPickListForm($sessionId2Name, "session", "sessions"); ?>
</div>

<div class="multi_form_container">
<?php echo genPickListForm($blockId2Name, "block", "blocks"); ?>
</div>

<div class="multi_form_container">
{'fraction_non_alphanumeric': 0.165625, 'fraction_numerical': 0.008774038461538462, 'mean_word_length': 3.1071076011846004, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6304606', 'n_tokens_mistral': 2684, 'n_tokens_neox': 2639, 'n_words': 685}