Version 3

This commit is contained in:
Flatlogic Bot 2025-11-15 12:00:54 +00:00
parent b3895068d2
commit fd880153e8
5 changed files with 252 additions and 168 deletions

View File

@ -1,6 +1,6 @@
body.dark-mode { body.dark-mode {
background-color: #121212; background-color: #2c2c2c; /* Dark grey background */
color: #e0e0e0; color: #ffffff; /* White text */
} }
body.dark-mode .header { body.dark-mode .header {
@ -8,53 +8,47 @@ body.dark-mode .header {
border-bottom: 1px solid #333; border-bottom: 1px solid #333;
} }
body.dark-mode .card { /* Make header link white */
background-color: #1e1e1e; body.dark-mode .header a, body.dark-mode .header a:hover, body.dark-mode a.text-dark, body.dark-mode a.text-dark:hover {
border: 1px solid #333; color: #ffffff !important;
} }
body.dark-mode .modal-content {
background-color: #1e1e1e;
border: 1px solid #333;
}
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .footer { body.dark-mode .footer {
background-color: #1e1e1e; background-color: #3a3a3a; /* Lighter grey for cards */
border-top: 1px solid #333; border: 1px solid #444;
} }
body.dark-mode .table { body.dark-mode .table {
background-color: #1e1e1e; background-color: #3a3a3a; /* Lighter grey for tables */
color: #e0e0e0; color: #ffffff;
} }
body.dark-mode .table-light { body.dark-mode .table-light {
background-color: #333; background-color: #4a4a4a; /* Slightly lighter grey for table header */
color: #e0e0e0; color: #ffffff;
} }
body.dark-mode .nav-tabs .nav-link { body.dark-mode .nav-tabs .nav-link {
color: #e0e0e0; color: #ffffff;
border: 1px solid #333; border: 1px solid #444;
} }
body.dark-mode .nav-tabs .nav-link.active { body.dark-mode .nav-tabs .nav-link.active {
background-color: #333; background-color: #4a4a4a;
border-color: #333; border-color: #4a4a4a;
}
body.dark-mode .form-control {
background-color: #333;
color: #e0e0e0;
border: 1px solid #555;
} }
body.dark-mode .form-control,
body.dark-mode .form-select { body.dark-mode .form-select {
background-color: #333; background-color: #4a4a4a;
color: #e0e0e0; color: #ffffff;
border: 1px solid #555; border: 1px solid #666;
} }
/* Keep button colors for visibility */
body.dark-mode .btn-primary { body.dark-mode .btn-primary {
background-color: #0d6efd; background-color: #0d6efd;
border-color: #0d6efd; border-color: #0d6efd;
@ -71,8 +65,8 @@ body.dark-mode .btn-outline-primary:hover {
} }
body.dark-mode .btn-outline-secondary { body.dark-mode .btn-outline-secondary {
color: #6c757d; color: #8e959c;
border-color: #6c757d; border-color: #8e959c;
} }
body.dark-mode .btn-outline-secondary:hover { body.dark-mode .btn-outline-secondary:hover {
@ -91,10 +85,15 @@ body.dark-mode .btn-outline-info:hover {
} }
body.dark-mode .text-muted { body.dark-mode .text-muted {
color: #aaa !important; color: #ccc !important;
} }
body.dark-mode .badge.bg-info { body.dark-mode .badge.bg-info {
background-color: #0dcaf0 !important; background-color: #0dcaf0 !important;
color: #000 !important; color: #000 !important;
} }
/* Override for table header links */
body.dark-mode .table-light a {
color: #ffffff !important;
}

31
delete_grievance.php Normal file
View File

@ -0,0 +1,31 @@
<?php
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['grievance_id'])) {
$grievance_id = $_POST['grievance_id'];
try {
$pdo = db();
// Also delete associated updates
$stmt = $pdo->prepare("DELETE FROM grievance_updates WHERE grievance_id = ?");
$stmt->execute([$grievance_id]);
$stmt = $pdo->prepare("DELETE FROM grievances WHERE id = ?");
$stmt->execute([$grievance_id]);
header("Location: index.php");
exit();
} catch (PDOException $e) {
// Handle database errors
error_log("Database error: " . $e->getMessage());
// You might want to show an error message to the user
header("Location: index.php?error=deletion_failed");
exit();
}
} else {
// Redirect if accessed directly or without a grievance_id
header("Location: index.php");
exit();
}
?>

View File

@ -12,21 +12,29 @@
const darkModeToggle = document.getElementById('darkModeToggle'); const darkModeToggle = document.getElementById('darkModeToggle');
const body = document.body; const body = document.body;
// Check for saved dark mode preference // Function to apply dark mode based on toggle state
if (localStorage.getItem('darkMode') === 'enabled') { function applyDarkMode() {
body.classList.add('dark-mode'); if (darkModeToggle.checked) {
darkModeToggle.checked = true;
}
darkModeToggle.addEventListener('change', function () {
if (this.checked) {
body.classList.add('dark-mode'); body.classList.add('dark-mode');
localStorage.setItem('darkMode', 'enabled'); localStorage.setItem('darkMode', 'enabled');
} else { } else {
body.classList.remove('dark-mode'); body.classList.remove('dark-mode');
localStorage.setItem('darkMode', 'disabled'); localStorage.setItem('darkMode', 'disabled');
} }
}); }
// Check for saved dark mode preference and set toggle accordingly
if (localStorage.getItem('darkMode') === 'enabled') {
darkModeToggle.checked = true;
} else if (localStorage.getItem('darkMode') === 'disabled') {
darkModeToggle.checked = false;
}
// Apply dark mode on initial load
applyDarkMode();
// Listener for toggle changes
darkModeToggle.addEventListener('change', applyDarkMode);
var editGrievanceModal = document.getElementById('editGrievanceModal'); var editGrievanceModal = document.getElementById('editGrievanceModal');
if (editGrievanceModal) { if (editGrievanceModal) {
@ -61,6 +69,16 @@
} }
}); });
} }
var deleteGrievanceModal = document.getElementById('deleteGrievanceModal');
if (deleteGrievanceModal) {
deleteGrievanceModal.addEventListener('show.bs.modal', function (event) {
var button = event.relatedTarget;
var id = button.getAttribute('data-id');
var modal = this;
modal.querySelector('#delete_grievance_id').value = id;
});
}
}); });
</script> </script>
</body> </body>

View File

@ -210,11 +210,11 @@
<div class="container"> <div class="container">
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div> <div>
<h1><a href="index.php" class="text-decoration-none text-dark">TWU Local 555 BNA Ramp Grievance Tracker</a></h1> <h1><a href="index.php" class="text-decoration-none">TWU Local 555 BNA Ramp Grievance Tracker</a></h1>
<p class="lead">A simple tool to track and manage ramp grievances.</p> <p class="lead">A simple tool to track and manage ramp grievances.</p>
</div> </div>
<div class="form-check form-switch"> <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="darkModeToggle"> <input class="form-check-input" type="checkbox" id="darkModeToggle" checked>
<label class="form-check-label" for="darkModeToggle">Dark Mode</label> <label class="form-check-label" for="darkModeToggle">Dark Mode</label>
</div> </div>
</div> </div>

288
index.php
View File

@ -7,144 +7,158 @@ function get_status_class($status) {
?> ?>
<ul class="nav nav-tabs mb-3"> <div class="container-fluid">
<?php foreach ($categories as $category): ?> <div class="row">
<div class="col-md-3">
<ul class="nav nav-pills flex-column">
<?php foreach ($categories as $category): ?>
<li class="nav-item">
<a class="nav-link <?php echo $page === $category ? 'active' : ''; ?>" href="index.php?page=<?php echo urlencode($category); ?>"><?php echo htmlspecialchars($category); ?></a>
</li>
<?php endforeach; ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link <?php echo $page === $category ? 'active' : ''; ?>" href="index.php?page=<?php echo urlencode($category); ?>"><?php echo htmlspecialchars($category); ?></a> <a class="nav-link" href="statistics.php">Statistics</a>
</li> </li>
<?php endforeach; ?> </ul>
<li class="nav-item">
<a class="nav-link" href="statistics.php">Statistics</a>
</li>
</ul>
<div class="d-flex justify-content-end mb-3">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addGrievanceModal">
<i class="bi bi-plus-circle"></i> Add Grievance
</button>
</div> </div>
<div class="col-md-9">
<div class="d-flex justify-content-end mb-3">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addGrievanceModal">
<i class="bi bi-plus-circle"></i> Add Grievance
</button>
</div>
<div class="card shadow-sm"> <div class="card shadow-sm">
<div class="card-body"> <div class="card-body">
<h2 class="card-title"><?php echo htmlspecialchars($page); ?></h2> <h2 class="card-title"><?php echo htmlspecialchars($page); ?></h2>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover"> <table class="table table-hover">
<thead class="table-light"> <thead class="table-light">
<tr>
<th>Grievant Name</th>
<th>Discipline</th>
<th>Subject</th>
<?php if ($page === 'FWD to Office' || $page === 'Terminations'): ?>
<th>Case Number</th>
<?php endif; ?>
<?php if ($page === 'Local Grievances'): ?>
<th><a href="index.php?page=<?php echo urlencode($page); ?>&sort=timeframes&order=<?php echo ($sort_column === 'timeframes' && $sort_order === 'asc') ? 'desc' : 'asc'; ?>">Timeframes</a></th>
<?php endif; ?>
<th><a href="index.php?page=<?php echo urlencode($page); ?>&sort=status&order=<?php echo ($sort_column === 'status' && $sort_order === 'asc') ? 'desc' : 'asc'; ?>">Status</a></th>
<th><a href="index.php?page=<?php echo urlencode($page); ?>&sort=last_updated&order=<?php echo ($sort_column === 'last_updated' && $sort_order === 'asc') ? 'desc' : 'asc'; ?>">Last Updated</a></th>
<th>Union Representative</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($grievances)): ?>
<tr> <tr>
<td colspan="8" class="text-center">No grievances found in this category.</td> <th>Grievant Name</th>
<th>Discipline</th>
<th>Subject</th>
<?php if ($page === 'FWD to Office' || $page === 'Terminations'): ?>
<th>Case Number</th>
<?php endif; ?>
<?php if ($page === 'Local Grievances'): ?>
<th><a href="index.php?page=<?php echo urlencode($page); ?>&sort=timeframes&order=<?php echo ($sort_column === 'timeframes' && $sort_order === 'asc') ? 'desc' : 'asc'; ?>">Timeframes</a></th>
<?php endif; ?>
<th><a href="index.php?page=<?php echo urlencode($page); ?>&sort=status&order=<?php echo ($sort_column === 'status' && $sort_order === 'asc') ? 'desc' : 'asc'; ?>">Status</a></th>
<th><a href="index.php?page=<?php echo urlencode($page); ?>&sort=last_updated&order=<?php echo ($sort_column === 'last_updated' && $sort_order === 'asc') ? 'desc' : 'asc'; ?>">Last Updated</a></th>
<th>Union Representative</th>
<th>Actions</th>
</tr> </tr>
<?php else: ?> </thead>
<?php foreach ($grievances as $grievance): ?> <tbody>
<?php if (empty($grievances)): ?>
<tr> <tr>
<td><?php echo htmlspecialchars($grievance['grievant_name']); ?></td> <td colspan="8" class="text-center">No grievances found in this category.</td>
<td><?php echo htmlspecialchars($grievance['discipline']); ?></td>
<td><?php echo htmlspecialchars($grievance['subject']); ?></td>
<?php if ($page === 'FWD to Office' || $page === 'Terminations'): ?>
<td><?php echo htmlspecialchars($grievance['case_number'] ?? ''); ?></td>
<?php endif; ?>
<?php if ($page === 'Local Grievances'): ?>
<td><input type="date" class="form-control"></td>
<?php endif; ?>
<td><span class="badge <?php echo get_status_class(htmlspecialchars($grievance['status'])); ?>"><?php echo htmlspecialchars($grievance['status']); ?></span></td>
<td><?php echo date("m/d/Y h:i A", strtotime($grievance['last_updated'])); ?></td>
<td><?php echo htmlspecialchars($grievance['union_representative']); ?></td>
<td class="d-flex gap-2">
<form action="index.php?page=<?php echo urlencode($page); ?>" method="post" class="d-flex">
<input type="hidden" name="move_grievance" value="1">
<input type="hidden" name="grievance_id" value="<?php echo $grievance['id']; ?>">
<select name="new_category" class="form-select form-select-sm me-2">
<option selected disabled>Move to...</option>
<?php
foreach ($categories as $category) {
if ($category !== $grievance['category']) {
echo '<option value="' . htmlspecialchars($category) . '">' . htmlspecialchars($category) . '</option>';
}
}
?>
</select>
<button type="submit" class="btn btn-sm btn-outline-secondary">Move</button>
</form>
<button type="button" class="btn btn-sm btn-outline-primary edit-btn"
data-bs-toggle="modal"
data-bs-target="#editGrievanceModal"
data-id="<?php echo $grievance['id']; ?>"
data-grievant-name="<?php echo htmlspecialchars($grievance['grievant_name']); ?>"
data-discipline="<?php echo htmlspecialchars($grievance['discipline']); ?>"
data-subject="<?php echo htmlspecialchars($grievance['subject']); ?>"
data-status="<?php echo htmlspecialchars($grievance['status']); ?>"
data-union-representative="<?php echo htmlspecialchars($grievance['union_representative']); ?>"
data-category="<?php echo htmlspecialchars($grievance['category']); ?>"
data-case-number="<?php echo htmlspecialchars($grievance['case_number'] ?? ''); ?>">
Edit
</button>
<button type="button" class="btn btn-sm btn-outline-info view-updates-btn" data-bs-toggle="collapse" data-bs-target="#updates-<?php echo $grievance['id']; ?>">
<i class="bi bi-chat-dots"></i> View Updates
</button>
</td>
</tr> </tr>
<tr class="collapse" id="updates-<?php echo $grievance['id']; ?>"> <?php else: ?>
<td colspan="8"> <?php foreach ($grievances as $grievance): ?>
<div class="updates-container p-3"> <tr>
<h5>Updates</h5> <td><?php echo htmlspecialchars($grievance['grievant_name']); ?></td>
<?php <td><?php echo htmlspecialchars($grievance['discipline']); ?></td>
$update_stmt = $pdo->prepare("SELECT * FROM grievance_updates WHERE grievance_id = ? ORDER BY created_at DESC"); <td><?php echo htmlspecialchars($grievance['subject']); ?></td>
$update_stmt->execute([$grievance['id']]); <?php if ($page === 'FWD to Office' || $page === 'Terminations'): ?>
$updates = $update_stmt->fetchAll(PDO::FETCH_ASSOC); <td><?php echo htmlspecialchars($grievance['case_number'] ?? ''); ?></td>
?> <?php endif; ?>
<?php if (empty($updates)): ?> <?php if ($page === 'Local Grievances'): ?>
<p>No updates for this grievance yet.</p> <td><input type="date" class="form-control"></td>
<?php else: ?> <?php endif; ?>
<ul class="list-group mb-3"> <td><span class="badge <?php echo get_status_class(htmlspecialchars($grievance['status'])); ?>"><?php echo htmlspecialchars($grievance['status']); ?></span></td>
<?php foreach ($updates as $update): ?> <td><?php echo date("m/d/Y h:i A", strtotime($grievance['last_updated'])); ?></td>
<li class="list-group-item"> <td><?php echo htmlspecialchars($grievance['union_representative']); ?></td>
<p class="mb-1"><?php echo htmlspecialchars($update['update_text']); ?></p> <td class="d-flex gap-2">
<small class="text-muted">By <?php echo htmlspecialchars($update['representative_name']); ?> on <?php echo date("m/d/Y h:i A", strtotime($update['created_at'])); ?></small> <form action="index.php?page=<?php echo urlencode($page); ?>" method="post" class="d-flex">
</li> <input type="hidden" name="move_grievance" value="1">
<?php endforeach; ?>
</ul>
<?php endif; ?>
<form action="index.php?page=<?php echo urlencode($page); ?>" method="post">
<input type="hidden" name="add_grievance_update" value="1">
<input type="hidden" name="grievance_id" value="<?php echo $grievance['id']; ?>"> <input type="hidden" name="grievance_id" value="<?php echo $grievance['id']; ?>">
<div class="mb-3"> <select name="new_category" class="form-select form-select-sm me-2">
<label for="update_text_<?php echo $grievance['id']; ?>" class="form-label">Add Update</label> <option selected disabled>Move to...</option>
<textarea class="form-control" id="update_text_<?php echo $grievance['id']; ?>" name="update_text" rows="3" required></textarea> <?php
</div> foreach ($categories as $category) {
<div class="mb-3"> if ($category !== $grievance['category']) {
<label for="representative_name_<?php echo $grievance['id']; ?>" class="form-label">Your Name (Union Representative)</label> echo '<option value="' . htmlspecialchars($category) . '">' . htmlspecialchars($category) . '</option>';
<input type="text" class="form-control" id="representative_name_<?php echo $grievance['id']; ?>" name="representative_name" required> }
</div> }
<button type="submit" class="btn btn-primary">Submit Update</button> ?>
</select>
<button type="submit" class="btn btn-sm btn-outline-secondary">Move</button>
</form> </form>
</div> <button type="button" class="btn btn-sm btn-outline-primary edit-btn"
</td> data-bs-toggle="modal"
</tr> data-bs-target="#editGrievanceModal"
<?php endforeach; ?> data-id="<?php echo $grievance['id']; ?>"
<?php endif; ?> data-grievant-name="<?php echo htmlspecialchars($grievance['grievant_name']); ?>"
</tbody> data-discipline="<?php echo htmlspecialchars($grievance['discipline']); ?>"
</table> data-subject="<?php echo htmlspecialchars($grievance['subject']); ?>"
data-status="<?php echo htmlspecialchars($grievance['status']); ?>"
data-union-representative="<?php echo htmlspecialchars($grievance['union_representative']); ?>"
data-category="<?php echo htmlspecialchars($grievance['category']); ?>"
data-case-number="<?php echo htmlspecialchars($grievance['case_number'] ?? ''); ?>">
Edit
</button>
<button type="button" class="btn btn-sm btn-outline-info view-updates-btn" data-bs-toggle="collapse" data-bs-target="#updates-<?php echo $grievance['id']; ?>">
<i class="bi bi-chat-dots"></i> View Updates
</button>
<button type="button" class="btn btn-sm btn-outline-danger delete-btn"
data-bs-toggle="modal"
data-bs-target="#deleteGrievanceModal"
data-id="<?php echo $grievance['id']; ?>">
Delete
</button>
</td>
</tr>
<tr class="collapse" id="updates-<?php echo $grievance['id']; ?>">
<td colspan="8">
<div class="updates-container p-3">
<h5>Updates</h5>
<?php
$update_stmt = $pdo->prepare("SELECT * FROM grievance_updates WHERE grievance_id = ? ORDER BY created_at DESC");
$update_stmt->execute([$grievance['id']]);
$updates = $update_stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<?php if (empty($updates)): ?>
<p>No updates for this grievance yet.</p>
<?php else: ?>
<ul class="list-group mb-3">
<?php foreach ($updates as $update): ?>
<li class="list-group-item">
<p class="mb-1"><?php echo htmlspecialchars($update['update_text']); ?></p>
<small class="text-muted">By <?php echo htmlspecialchars($update['representative_name']); ?> on <?php echo date("m/d/Y h:i A", strtotime($update['created_at'])); ?></small>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<form action="index.php?page=<?php echo urlencode($page); ?>" method="post">
<input type="hidden" name="add_grievance_update" value="1">
<input type="hidden" name="grievance_id" value="<?php echo $grievance['id']; ?>">
<div class="mb-3">
<label for="update_text_<?php echo $grievance['id']; ?>" class="form-label">Add Update</label>
<textarea class="form-control" id="update_text_<?php echo $grievance['id']; ?>" name="update_text" rows="3" required></textarea>
</div>
<div class="mb-3">
<label for="representative_name_<?php echo $grievance['id']; ?>" class="form-label">Your Name (Union Representative)</label>
<input type="text" class="form-control" id="representative_name_<?php echo $grievance['id']; ?>" name="representative_name" required>
</div>
<button type="submit" class="btn btn-primary">Submit Update</button>
</form>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</main> </main>
<!-- Add Grievance Modal --> <!-- Add Grievance Modal -->
@ -247,4 +261,26 @@ function get_status_class($status) {
</div> </div>
</div> </div>
<?php require_once 'footer.php'; ?> <!-- Delete Grievance Modal -->
<div class="modal fade" id="deleteGrievanceModal" tabindex="-1" aria-labelledby="deleteGrievanceModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteGrievanceModalLabel">Delete Grievance</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this grievance?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<form action="delete_grievance.php" method="post" id="deleteGrievanceForm">
<input type="hidden" name="grievance_id" id="delete_grievance_id">
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</div>
</div>
</div>
</div>
<?php require_once 'footer.php'; ?>