35667-vm/index.php
Flatlogic Bot fd880153e8 Version 3
2025-11-15 12:00:54 +00:00

286 lines
20 KiB
PHP

<?php require_once 'header.php';
function get_status_class($status) {
$status_class = 'status-' . strtolower(str_replace(' ', '-', str_replace('/', '-', $status)));
return $status_class;
}
?>
<div class="container-fluid">
<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">
<a class="nav-link" href="statistics.php">Statistics</a>
</li>
</ul>
</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-body">
<h2 class="card-title"><?php echo htmlspecialchars($page); ?></h2>
<div class="table-responsive">
<table class="table table-hover">
<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>
<td colspan="8" class="text-center">No grievances found in this category.</td>
</tr>
<?php else: ?>
<?php foreach ($grievances as $grievance): ?>
<tr>
<td><?php echo htmlspecialchars($grievance['grievant_name']); ?></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>
<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>
</main>
<!-- Add Grievance Modal -->
<div class="modal fade" id="addGrievanceModal" tabindex="-1" aria-labelledby="addGrievanceModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addGrievanceModalLabel">Add New Grievance</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="index.php?page=<?php echo urlencode($page); ?>" method="post" id="addGrievanceForm">
<input type="hidden" name="add_grievance" value="1">
<input type="hidden" name="category" value="<?php echo htmlspecialchars($page); ?>">
<div class="mb-3">
<label for="grievant_name" class="form-label">Grievant Name</label>
<input type="text" class="form-control" id="grievant_name" name="grievant_name" required>
</div>
<div class="mb-3">
<label for="discipline" class="form-label">Discipline</label>
<input type="text" class="form-control" id="discipline" name="discipline" required>
</div>
<div class="mb-3">
<label for="subject" class="form-label">Subject</label>
<input type="text" class="form-control" id="subject" name="subject" required>
</div>
<div class="mb-3">
<label for="status" class="form-label">Status</label>
<select class="form-select" id="status" name="status" required>
<?php
foreach ($status_options as $option) {
echo '<option value="' . htmlspecialchars($option) . '">' . htmlspecialchars($option) . '</option>';
}
?>
</select>
</div>
<div class="mb-3">
<label for="union_representative" class="form-label">Union Representative</label>
<input type="text" class.form-control" id="union_representative" name="union_representative" required>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" form="addGrievanceForm">Save Grievance</button>
</div>
</div>
</div>
</div>
<!-- Edit Grievance Modal -->
<div class="modal fade" id="editGrievanceModal" tabindex="-1" aria-labelledby="editGrievanceModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editGrievanceModalLabel">Edit Grievance</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="index.php?page=<?php echo urlencode($page); ?>" method="post" id="editGrievanceForm">
<input type="hidden" name="edit_grievance" value="1">
<input type="hidden" name="grievance_id" id="edit_grievance_id">
<div class="mb-3">
<label for="edit_grievant_name" class="form-label">Grievant Name</label>
<input type="text" class="form-control" id="edit_grievant_name" name="grievant_name" required>
</div>
<div class="mb-3">
<label for="edit_discipline" class="form-label">Discipline</label>
<input type="text" class="form-control" id="edit_discipline" name="discipline" required>
</div>
<div class="mb-3">
<label for="edit_subject" class="form-label">Subject</label>
<input type="text" class="form-control" id="edit_subject" name="subject" required>
</div>
<div class="mb-3">
<label for="edit_status" class="form-label">Status</label>
<select class="form-select" id="edit_status" name="status" required>
<?php
foreach ($status_options as $option) {
echo '<option value="' . htmlspecialchars($option) . '">' . htmlspecialchars($option) . '</option>';
}
?>
</select>
</div>
<div class="mb-3">
<label for="edit_union_representative" class="form-label">Union Representative</label>
<input type="text" class="form-control" id="edit_union_representative" name="union_representative" required>
</div>
<div class="mb-3" id="edit_case_number_wrapper" style="display: none;">
<label for="edit_case_number" class="form-label">Case Number</label>
<input type="text" class="form-control" id="edit_case_number" name="case_number">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" form="editGrievanceForm">Save Changes</button>
</div>
</div>
</div>
</div>
<!-- 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'; ?>