(feat)(in-progress): added modal for creation

This commit is contained in:
boris
2024-12-03 22:21:22 +00:00
parent 574dcbb119
commit 86f778b7ac
3 changed files with 38 additions and 9 deletions

View File

@@ -216,7 +216,6 @@ class FacilityDataSet {
// Bind other filters
for ($i = 1; $i <= 8; $i++) { // Assuming 8 other filters
$value = !empty($filterArray[$i]) ? "%" . $filterArray[$i] . "%" : "%";
print_r($i . " = " . $value . "|");
$stmt->bindValue($bindIndex++, $value, \PDO::PARAM_STR);
}
return $stmt;

View File

@@ -0,0 +1,32 @@
<button type="button" class="col btn bg-primary btn-outline-primary text-light" data-bs-toggle="modal" data-bs-target="#createModal">
<span class="bi bi-pen-fill"></span>
</button>
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="updateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateModalLabel">Add Facility</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<form class="form-inline" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ">
<input name="titlCreate" class="form-control rounded mb-2" placeholder="Title">
<input name="cateCreate" class="form-control rounded mb-2" placeholder="Category">
<input name="descCreate" class="form-control rounded mb-2" placeholder="Description">
<input name="statCreate" class="form-control rounded mb-2" placeholder="Status">
<input name="strtCreate" class="form-control rounded mb-2" placeholder="Street Name">
<input name="cntyCreate" class="form-control rounded mb-2" placeholder="County">
<input name="townCreate" class="form-control rounded mb-2" placeholder="Town">
<input name="postCreate" class="form-control rounded mb-2" placeholder="Postcode">
<input name="contCreate" class="form-control rounded mb-2" placeholder="Contributor">
</form>
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="updateButton">Add</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View File

@@ -2,8 +2,8 @@
require_once('Models/FacilityDataSet.php');
require_once("Models/Paginator.php");
// If page loads empty, set initial headers
if(!isset($_GET['page']) || !(isset($_GET['dir'])) || !(isset($_GET['sort']))) {
header("Location: ?sort=1&dir=asc&page=0");
if(empty($_GET)) {
header("Location: ?sort=1&dir=asc&category=1&term=&page=0");
exit;
}
@@ -36,9 +36,7 @@ $filterArray[$_GET['category'] ?? null] = $_GET['term'] ?? null;
$sortArray[$_GET['sort'] ?? null] = $_GET['dir'] ?? null;
$facilityDataSet = new FacilityDataSet();
if(isset($_POST['paginatorButton'])) {
var_dump($_POST);
}
if ((isset($_POST['filter']) && isset($_POST['filterCat']) && (isset($_POST['dir'])) && (isset($_POST['sort'])))) {
$filter = filter_input(INPUT_POST, 'filter', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
$filterKey = filter_input(INPUT_POST, 'filterCat', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
@@ -47,8 +45,8 @@ 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
$filterArray[$filterKey] = $filter;
$sortArray[$sortKey] = $direction;
var_dump($filterArray);
//redirect($filter, $filterArray, $direction, $sortArray, $page);
var_dump($filterArray, $filterKey);
redirect($filter, $filterArray, $direction, $sortArray, $page);
}
function redirect($filter, $filterArray, $direction, $sortArray, $page) : void {
// Set the filter and generate the new URI
@@ -72,8 +70,8 @@ function redirect($filter, $filterArray, $direction, $sortArray, $page) : void {
exit;
}
var_dump($filterArray);
$view->pageData = $facilityDataSet->fetchAll($filterArray, $sortArray);
var_dump($filterArray, $sortArray);
$view->paginator = new Paginator($rowLimit, $view->pageData);
// Initialize paginator