(fix): i fixed it !! filter workidge extravaganza headsplosion i just put in 3 zyns
This commit is contained in:
@@ -69,7 +69,6 @@ class FacilityDataSet {
|
|||||||
// Default to title
|
// Default to title
|
||||||
// Note: I am very sorry, i am well aware this is horrible, im running out of time
|
// Note: I am very sorry, i am well aware this is horrible, im running out of time
|
||||||
$sortBy = 1;
|
$sortBy = 1;
|
||||||
var_dump($sortArray);
|
|
||||||
switch (array_search('desc', $sortArray) ?? array_search('asc', $sortArray)) {
|
switch (array_search('desc', $sortArray) ?? array_search('asc', $sortArray)) {
|
||||||
case (0) :
|
case (0) :
|
||||||
$sortBy = 'ecoFacilityStatus.statusComment';
|
$sortBy = 'ecoFacilityStatus.statusComment';
|
||||||
@@ -217,6 +216,7 @@ class FacilityDataSet {
|
|||||||
// Bind other filters
|
// Bind other filters
|
||||||
for ($i = 1; $i <= 8; $i++) { // Assuming 8 other filters
|
for ($i = 1; $i <= 8; $i++) { // Assuming 8 other filters
|
||||||
$value = !empty($filterArray[$i]) ? "%" . $filterArray[$i] . "%" : "%";
|
$value = !empty($filterArray[$i]) ? "%" . $filterArray[$i] . "%" : "%";
|
||||||
|
print_r($i . " = " . $value . "|");
|
||||||
$stmt->bindValue($bindIndex++, $value, \PDO::PARAM_STR);
|
$stmt->bindValue($bindIndex++, $value, \PDO::PARAM_STR);
|
||||||
}
|
}
|
||||||
return $stmt;
|
return $stmt;
|
||||||
|
@@ -1,27 +1,37 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<!-- Form for Pagination -->
|
<!-- Form for Pagination -->
|
||||||
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="POST" id="paginatorButton" class="col-auto m-auto btn-group">
|
<div id="paginationButtons" class="col-auto m-auto btn-group">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$params = $_GET;
|
||||||
|
unset($params['page']); // Remove the page parameter to avoid duping
|
||||||
|
function buildUrl($page, $params): string
|
||||||
|
{
|
||||||
|
$params['page'] = $page;
|
||||||
|
return '?' . http_build_query($params);
|
||||||
|
}
|
||||||
|
?>
|
||||||
<!-- Start Button -->
|
<!-- Start Button -->
|
||||||
<a class="btn btn-outline-primary" href="?page=0" <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-double-left"></i> Start</a>
|
<a class="btn btn-outline-primary" href="<?= buildUrl(0, $params) ?>0" <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-double-left"></i> Start</a>
|
||||||
<!-- Back Button -->
|
<!-- Back Button -->
|
||||||
<a class="btn btn-outline-primary" href="?page=<?=max($view->pageNumber - 1, 0)?> " <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-left"></i> Back</a>
|
<a class="btn btn-outline-primary" href="<?= buildUrl(max($view->pageNumber - 1, 0), $params)?> " <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-left"></i> Back</a>
|
||||||
<!-- Dynamic Page Buttons -->
|
<!-- Dynamic Page Buttons -->
|
||||||
<?php
|
<?php
|
||||||
$totalPages = $view->paginator->getTotalPages();
|
$totalPages = $view->paginator->getTotalPages();
|
||||||
for ($i = $view->pageNumber - 2; $i <= $view->pageNumber + 2; $i++) {
|
for ($i = $view->pageNumber - 2; $i <= $view->pageNumber + 2; $i++) {
|
||||||
if ($i >= 0 && $i < $totalPages): ?>
|
if ($i >= 0 && $i < $totalPages): ?>
|
||||||
<input name="paginatorButton" type="submit" value='<?= $i ?>'
|
<a href="<?= buildUrl($i, $params) ?>"
|
||||||
class="btn <?= $i === $view->pageNumber ? 'btn-dark' : 'btn-outline-primary' ?>"
|
class="btn <?= $i === $view->pageNumber ? 'btn-dark' : 'btn-outline-primary' ?>"
|
||||||
<?= $i === $view->pageNumber ? 'disabled' : '' ?>>
|
<?= $i === $view->pageNumber ? 'disabled' : '' ?>>
|
||||||
<?= $i + 1 ?>
|
<?= $i + 1 ?>
|
||||||
</input>
|
</a>
|
||||||
<?php endif;
|
<?php endif;
|
||||||
} ?>
|
} ?>
|
||||||
<!-- Forward Button -->
|
<!-- Forward Button -->
|
||||||
<a class="btn btn-outline-primary" href="?page=<?=min($view->pageNumber + 1, $totalPages)?> " <?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>Forward <i class="bi bi-chevron-right"></i></a>
|
<a class="btn btn-outline-primary" href="<?=buildUrl(min($view->pageNumber + 1, $totalPages), $params)?>" <?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>Forward <i class="bi bi-chevron-right"></i></a>
|
||||||
<!-- End Button -->
|
<!-- End Button -->
|
||||||
<a class="btn btn-outline-primary" href="?page=<?= $totalPages - 1 ?>"<?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>End <i class="bi bi-chevron-double-right"></i></a>
|
<a class="btn btn-outline-primary" href="<?= buildUrl($totalPages - 1, $params) ?>"<?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>End <i class="bi bi-chevron-double-right"></i></a>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
require_once('Models/FacilityDataSet.php');
|
require_once('Models/FacilityDataSet.php');
|
||||||
require_once("Models/Paginator.php");
|
require_once("Models/Paginator.php");
|
||||||
// If page loads empty, set initial headers
|
// If page loads empty, set initial headers
|
||||||
if(!isset($_GET['page']) || !(isset($_GET['dir'])) || !(isset($_GET['sort'])) || !(isset($_GET['category']))) {
|
if(!isset($_GET['page']) || !(isset($_GET['dir'])) || !(isset($_GET['sort']))) {
|
||||||
header("Location: ?page=0&sort=1&dir=asc&category=1");
|
header("Location: ?sort=1&dir=asc&page=0");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,9 +32,14 @@ $sortArray = [
|
|||||||
|
|
||||||
$rowLimit = 5;
|
$rowLimit = 5;
|
||||||
|
|
||||||
|
$filterArray[$_GET['category'] ?? null] = $_GET['term'] ?? null;
|
||||||
|
$sortArray[$_GET['sort'] ?? null] = $_GET['dir'] ?? null;
|
||||||
|
|
||||||
$facilityDataSet = new FacilityDataSet();
|
$facilityDataSet = new FacilityDataSet();
|
||||||
|
if(isset($_POST['paginatorButton'])) {
|
||||||
var_dump($_POST);
|
var_dump($_POST);
|
||||||
if (isset($_POST['filter']) && isset($_POST['filterCat']) && (isset($_POST['dir'])) && (isset($_POST['sort'])) && (isset($_POST['paginationButton']))) {
|
}
|
||||||
|
if ((isset($_POST['filter']) && isset($_POST['filterCat']) && (isset($_POST['dir'])) && (isset($_POST['sort'])))) {
|
||||||
$filter = filter_input(INPUT_POST, 'filter', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
|
$filter = filter_input(INPUT_POST, 'filter', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
|
||||||
$filterKey = filter_input(INPUT_POST, 'filterCat', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
|
$filterKey = filter_input(INPUT_POST, 'filterCat', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
|
||||||
$direction = filter_input(INPUT_POST, 'dir', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 'asc'; // Default to 'asc'
|
$direction = filter_input(INPUT_POST, 'dir', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 'asc'; // Default to 'asc'
|
||||||
@@ -42,6 +47,10 @@ if (isset($_POST['filter']) && isset($_POST['filterCat']) && (isset($_POST['dir'
|
|||||||
$page = filter_input(INPUT_POST, 'paginationButton', FILTER_SANITIZE_NUMBER_INT) ?? 0; // Default page to 0 on new filter
|
$page = filter_input(INPUT_POST, 'paginationButton', FILTER_SANITIZE_NUMBER_INT) ?? 0; // Default page to 0 on new filter
|
||||||
$filterArray[$filterKey] = $filter;
|
$filterArray[$filterKey] = $filter;
|
||||||
$sortArray[$sortKey] = $direction;
|
$sortArray[$sortKey] = $direction;
|
||||||
|
var_dump($filterArray);
|
||||||
|
//redirect($filter, $filterArray, $direction, $sortArray, $page);
|
||||||
|
}
|
||||||
|
function redirect($filter, $filterArray, $direction, $sortArray, $page) : void {
|
||||||
// Set the filter and generate the new URI
|
// Set the filter and generate the new URI
|
||||||
//$filterSet = $facilityDataSet->setFilterUri($applyFilters, array_search($applyFilters, $filterArray));
|
//$filterSet = $facilityDataSet->setFilterUri($applyFilters, array_search($applyFilters, $filterArray));
|
||||||
$filterSet = setUri($filter, array_search($filter, $filterArray), $direction, array_search($direction, $sortArray), $page);
|
$filterSet = setUri($filter, array_search($filter, $filterArray), $direction, array_search($direction, $sortArray), $page);
|
||||||
@@ -63,11 +72,8 @@ if (isset($_POST['filter']) && isset($_POST['filterCat']) && (isset($_POST['dir'
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$filterArray[$_GET['category'] ?? null] = $_GET['term'] ?? null;
|
|
||||||
$sortArray[$_GET['sort'] ?? null] = $_GET['dir'] ?? null;
|
|
||||||
|
|
||||||
$view->pageData = $facilityDataSet->fetchAll($filterArray, $sortArray);
|
$view->pageData = $facilityDataSet->fetchAll($filterArray, $sortArray);
|
||||||
|
var_dump($filterArray, $sortArray);
|
||||||
$view->paginator = new Paginator($rowLimit, $view->pageData);
|
$view->paginator = new Paginator($rowLimit, $view->pageData);
|
||||||
|
|
||||||
// Initialize paginator
|
// Initialize paginator
|
||||||
|
Reference in New Issue
Block a user