i finally committed i guess

Signed-off-by: boris <boris@borishub.co.uk>
This commit is contained in:
boris
2025-03-15 01:59:16 +00:00
parent 8de2b7f29e
commit 709596eea2
113 changed files with 25075 additions and 54344 deletions

111
Views/template/pagination.phtml Normal file → Executable file
View File

@@ -1,37 +1,78 @@
<div>
<div class="row mb-2">
<!-- Form for Pagination -->
<div id="paginationButtons" class="col-auto m-auto btn-group">
<?php
$param = $_GET;
unset($param['page']); // Remove the page parameter to avoid duping
function buildUrl($page, $param): string
{
$param['page'] = $page;
return '?' . http_build_query($param);
}
?>
<!-- Start Button -->
<a class="btn btn-outline-primary" href="<?= buildUrl(0, $param) ?>0" <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-double-left"></i> Start</a>
<!-- Back Button -->
<a class="btn btn-outline-primary" href="<?= buildUrl(max($view->pageNumber - 1, 0), $param)?> " <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-left"></i> Back</a>
<!-- Dynamic Page Buttons -->
<?php
$totalPages = $view->paginator->getTotalPages();
for ($i = $view->pageNumber - 2; $i <= $view->pageNumber + 2; $i++) {
if ($i >= 0 && $i < $totalPages): ?>
<a href="<?= buildUrl($i, $param) ?>"
class="btn <?= $i === $view->pageNumber ? 'btn-dark' : 'btn-outline-primary' ?>"
<?= $i === $view->pageNumber ? 'disabled' : '' ?>>
<?= $i + 1 ?>
</a>
<?php endif;
} ?>
<!-- Forward Button -->
<a class="btn btn-outline-primary" href="<?=buildUrl(min($view->pageNumber + 1, $totalPages), $param)?>" <?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>Forward <i class="bi bi-chevron-right"></i></a>
<!-- End Button -->
<a class="btn btn-outline-primary" href="<?= buildUrl($totalPages - 1, $param) ?>"<?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>End <i class="bi bi-chevron-double-right"></i></a>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between align-items-center gap-2">
<div class="text-muted small">
<span id="paginationInfo" class="d-flex align-items-center">
<i class="bi bi-info-circle me-2 text-success"></i>
<span>Showing facilities</span>
</span>
</div>
<!-- Pagination controls -->
<nav aria-label="Facility table pagination">
<ul class="pagination pagination-sm mb-0" id="paginationControls">
<!-- First page button -->
<li class="page-item">
<a class="page-link border-0 text-success" href="#" aria-label="First" id="firstPage">
<i class="bi bi-chevron-double-left"></i>
</a>
</li>
<!-- Previous page button -->
<li class="page-item">
<a class="page-link border-0 text-success" href="#" aria-label="Previous" id="prevPage">
<i class="bi bi-chevron-left"></i>
</a>
</li>
<!-- Dynamic page numbers will be inserted here as list items -->
<!-- Next page button -->
<li class="page-item">
<a class="page-link border-0 text-success" href="#" aria-label="Next" id="nextPage">
<i class="bi bi-chevron-right"></i>
</a>
</li>
<!-- Last page button -->
<li class="page-item">
<a class="page-link border-0 text-success" href="#" aria-label="Last" id="lastPage">
<i class="bi bi-chevron-double-right"></i>
</a>
</li>
</ul>
</nav>
<!-- Items per page selector -->
<div class="d-flex align-items-center">
<label for="itemsPerPage" class="form-label text-muted small mb-0 me-2">Items per page:</label>
<select class="form-select form-select-sm" id="itemsPerPage" style="width: 70px;">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Set up items per page selector
const itemsPerPageSelect = document.getElementById('itemsPerPage');
if (itemsPerPageSelect) {
itemsPerPageSelect.addEventListener('change', function() {
// Update items per page in the pagination system
if (typeof itemsPerPage !== 'undefined') {
itemsPerPage = parseInt(this.value);
currentPage = 1; // Reset to first page
// Recalculate total pages
if (typeof filteredData !== 'undefined' && typeof totalPages !== 'undefined') {
totalPages = Math.ceil(filteredData.length / itemsPerPage);
// Update table with new pagination
if (typeof updateTableWithPagination === 'function') {
updateTableWithPagination();
}
}
}
});
}
});
</script>