Files
controls-web/overviews/select.php
2026-02-17 12:44:37 -06:00

224 lines
6.6 KiB
PHP

<?php
// filepath: v:\controls\overviews\select.php
// Start session first
session_start();
// Initialize variables with defaults
$check_General = "";
$check_Mills = "";
$check_Levels = "";
// Handle form submission and update session
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$_SESSION['General'] = isset($_POST['General']) ? 1 : 0;
$_SESSION['Mills'] = isset($_POST['Mills']) ? 1 : 0;
$_SESSION['Levels'] = isset($_POST['Levels']) ? 1 : 0;
}
// Set checkbox states (check if enabled, not disabled)
if (isset($_SESSION['General']) && $_SESSION['General'] == 1) {
$check_General = "checked";
}
if (isset($_SESSION['Mills']) && $_SESSION['Mills'] == 1) {
$check_Mills = "checked";
}
if (isset($_SESSION['Levels']) && $_SESSION['Levels'] == 1) {
$check_Levels = "checked";
}
// Fallback to POST if session not set (for initial page load)
if (!isset($_SESSION['General'])) {
if (isset($_POST['General']) && intval($_POST['General']) == 1) {
$check_General = "checked";
}
if (isset($_POST['Mills']) && intval($_POST['Mills']) == 1) {
$check_Mills = "checked";
}
if (isset($_POST['Levels']) && intval($_POST['Levels']) == 1) {
$check_Levels = "checked";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>System Overview</title>
<style>
.control-panel {
background: #f8f9fa;
padding: 1rem;
border-radius: 8px;
margin-bottom: 1rem;
border: 1px solid #dee2e6;
}
.control-panel h3 {
margin-top: 0;
color: #495057;
}
.checkbox-group {
display: flex;
gap: 2rem;
flex-wrap: wrap;
}
.checkbox-item {
display: flex;
align-items: center;
gap: 0.5rem;
}
.checkbox-item input[type="checkbox"] {
width: 1.25rem;
height: 1.25rem;
accent-color: #007bff;
}
.checkbox-item label {
font-weight: 500;
cursor: pointer;
user-select: none;
}
.content-section {
margin-bottom: 2rem;
}
.disabled-message {
background: #fff3cd;
border: 1px solid #ffeaa7;
color: #856404;
padding: 1rem;
border-radius: 6px;
font-style: italic;
}
@media (max-width: 768px) {
.checkbox-group {
flex-direction: column;
gap: 1rem;
}
}
</style>
</head>
<body>
<div class="control-panel">
<h3>System Overview Controls</h3>
<form id="overview-controls" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<div class="checkbox-group">
<div class="checkbox-item">
<input type="checkbox"
id="general"
name="General"
value="1"
onchange="this.form.submit()"
<?php echo $check_General; ?>>
<label for="general">General Systems</label>
</div>
<div class="checkbox-item">
<input type="checkbox"
id="mills"
name="Mills"
value="1"
onchange="this.form.submit()"
<?php echo $check_Mills; ?>>
<label for="mills">Mills & Boilers</label>
</div>
<div class="checkbox-item">
<input type="checkbox"
id="levels"
name="Levels"
value="1"
onchange="this.form.submit()"
<?php echo $check_Levels; ?>>
<label for="levels">Tank Levels</label>
</div>
</div>
<input type="hidden" name="Submit" value="1">
</form>
</div>
<?php
// Include header after form
include("data/header.php");
?>
<div class="content-sections">
<!-- General Systems Section -->
<div class="content-section">
<?php
if (isset($_SESSION['General']) && $_SESSION['General'] == 1) {
// ENABLED - Show content
include 'general.php';
} elseif (isset($_POST['General']) && intval($_POST['General']) == 1) {
// Handle initial POST
include 'general.php';
} else {
// DISABLED - Show message
echo '<div class="disabled-message">General Systems - Disabled</div>';
}
?>
</div>
<!-- Mills Section -->
<div class="content-section">
<?php
if (isset($_SESSION['Mills']) && $_SESSION['Mills'] == 1) {
// ENABLED - Show content
if (file_exists('data/boilers.php')) {
include 'data/boilers.php';
} else {
echo '<div class="disabled-message">Mills & Boilers - File not found</div>';
}
} elseif (isset($_POST['Mills']) && intval($_POST['Mills']) == 1) {
// Handle initial POST
if (file_exists('data/boilers.php')) {
include 'data/boilers.php';
}
} else {
// DISABLED - Show message
echo '<div class="disabled-message">Mills & Boilers - Disabled</div>';
}
?>
</div>
<!-- Tank Levels Section -->
<div class="content-section">
<?php
if (isset($_SESSION['Levels']) && $_SESSION['Levels'] == 1) {
// ENABLED - Show content
if (file_exists('tanklevels.php')) {
include 'tanklevels.php';
} else {
echo '<div class="disabled-message">Tank Levels - File not found</div>';
}
} elseif (isset($_POST['Levels']) && intval($_POST['Levels']) == 1) {
// Handle initial POST
if (file_exists('tanklevels.php')) {
include 'tanklevels.php';
}
} else {
// DISABLED - Show message
echo '<div class="disabled-message">Tank Levels - Disabled</div>';
}
?>
</div>
</div>
<?php if (isset($_SESSION['picturenum'])): ?>
<div style="margin-top: 2rem; padding: 1rem; background: #e9ecef; border-radius: 6px;">
<strong>Picture Number: <?php echo htmlspecialchars($_SESSION['picturenum']); ?></strong>
</div>
<?php endif; ?>
</body>
</html>