@@ -21,11 +21,17 @@ require('template/header.phtml')
|
||||
<div class="card-header bg-light py-3">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex align-items-center">
|
||||
<h5 class="mb-0 fw-bold text-primary">
|
||||
<i class="bi bi-geo-alt-fill me-2 text-success"></i>Facilities
|
||||
</h5>
|
||||
<!-- Badge showing the number of facilities -->
|
||||
<span class="badge bg-success rounded-pill ms-2" id="facilityCount"></span>
|
||||
<!-- Search and filter controls -->
|
||||
<div class="d-flex flex-column flex-lg-row search-controls mx-auto">
|
||||
<form class="d-flex flex-column flex-lg-row gap-2 w-100" role="search" action="" method="POST">
|
||||
<div class="input-group flex-grow-1">
|
||||
<span class="input-group-text bg-light border-end-0">
|
||||
<i class="bi bi-search text-success"></i>
|
||||
</span>
|
||||
<input class="form-control border-start-0" id="searchInput" type="search" name="filter" placeholder="Search..." aria-label="Search">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Admin-only buttons -->
|
||||
<div id="adminButtons" style="display: none;">
|
||||
@@ -99,33 +105,6 @@ require('template/header.phtml')
|
||||
regularUserView.style.display = isAdmin ? 'none' : 'block';
|
||||
}
|
||||
|
||||
// Update table headers based on user role :DDD (it just shows the ID column for admins...)
|
||||
if (tableHeaderRow) {
|
||||
if (isAdmin) {
|
||||
// Admin view - show all columns and bigger management actions
|
||||
tableHeaderRow.innerHTML = `
|
||||
<th class="fw-semibold" style="width: 40px;">ID</th>
|
||||
<th class="fw-semibold" style="width: 15%;">Title</th>
|
||||
<th class="fw-semibold text-center" style="width: 10%;">Category</th>
|
||||
<th class="fw-semibold" style="width: 25%;">Description</th>
|
||||
<th class="fw-semibold" style="width: 20%;">Address</th>
|
||||
<th class="fw-semibold text-center" style="width: 12%;">Coordinates</th>
|
||||
<th class="fw-semibold text-center" style="width: 8%;">Contributor</th>
|
||||
<th class="fw-semibold text-center" style="width: 10%;">Actions</th>
|
||||
`;
|
||||
} else {
|
||||
// Regular user view - hide ID column and make management actions smaller
|
||||
tableHeaderRow.innerHTML = `
|
||||
<th class="fw-semibold" style="width: 17%;">Title</th>
|
||||
<th class="fw-semibold text-center" style="width: 11%;">Category</th>
|
||||
<th class="fw-semibold" style="width: 27%;">Description</th>
|
||||
<th class="fw-semibold" style="width: 20%;">Address</th>
|
||||
<th class="fw-semibold text-center" style="width: 12%;">Coordinates</th>
|
||||
<th class="fw-semibold text-center" style="width: 8%;">Contributor</th>
|
||||
<th class="fw-semibold text-center" style="width: 5%;">Actions</th>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update UI when the page loads
|
||||
@@ -139,28 +118,4 @@ require('template/header.phtml')
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Script to update the facility count badge -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Update facility count badge based on data in sessionStorage
|
||||
const updateFacilityCount = () => {
|
||||
const facilityData = JSON.parse(sessionStorage.getItem('facilityData') || '[]');
|
||||
const countBadge = document.getElementById('facilityCount');
|
||||
if (countBadge) {
|
||||
countBadge.textContent = `${facilityData.length} facilities`;
|
||||
}
|
||||
};
|
||||
|
||||
// Initial count update when the page loads
|
||||
updateFacilityCount();
|
||||
|
||||
// Listen for changes in facility data to update the count
|
||||
window.addEventListener('storage', function(e) {
|
||||
if (e.key === 'facilityData') {
|
||||
updateFacilityCount();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php require('template/footer.phtml');?>
|
Reference in New Issue
Block a user