From 7c4694fe3d95289fa782d1715cf03ec73f7c34cd Mon Sep 17 00:00:00 2001 From: DasunThathsara Date: Thu, 8 Feb 2024 14:41:35 +0530 Subject: [PATCH] feat: Assigning land registration verification to them selves --- app/controllers/Admin.php | 24 +- app/models/LandModel.php | 21 +- app/views/admin/requests.php | 208 +++++++++--------- app/views/parkingOwner/lands.php | 3 + app/views/superAdmin/admins.php | 119 +++++----- public/css/components/dynamicContentTable.css | 7 + 6 files changed, 232 insertions(+), 150 deletions(-) diff --git a/app/controllers/Admin.php b/app/controllers/Admin.php index d838e35a..8b989b25 100644 --- a/app/controllers/Admin.php +++ b/app/controllers/Admin.php @@ -66,4 +66,26 @@ public function unverifyLand(){ redirect('admin/viewRegistrationRequests'); } } -} \ No newline at end of file + + // Assign land verification to admin + public function assignLandVerification(){ + if ($_SERVER['REQUEST_METHOD'] == 'POST'){ + $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); + + $this->landModel->assignLandVerification($_POST['id'], $_SESSION['user_id']); + + redirect('admin/requests'); + } + } + + // Assign registration requests to admin + public function assignMySelf(){ + if ($_SERVER['REQUEST_METHOD'] == 'POST'){ + $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); + + $this->landModel->assignMySelf($_POST['id'], $_SESSION['user_id']); + + redirect('admin/viewRegistrationRequests'); + } + } +} diff --git a/app/models/LandModel.php b/app/models/LandModel.php index 62576ad5..b21bcb27 100644 --- a/app/models/LandModel.php +++ b/app/models/LandModel.php @@ -346,7 +346,7 @@ public function getLandID($name){ public function getUnVerifyLandCount(){ // Prepare statement - $this->db->query('SELECT COUNT(*) FROM land WHERE status = :status'); + $this->db->query('SELECT COUNT(*) FROM land WHERE status = :status AND admin = 0'); // Bind values $this->db->bind(':status', 0); @@ -607,4 +607,23 @@ public function getLandownerID($landID){ return $row->uid; } + + // Assign land verification to admin + public function assignMySelf($landID, $adminID): bool + { + // Prepare statement + $this->db->query('UPDATE land SET admin = :admin WHERE id = :id'); + + // Bind values + $this->db->bind(':admin', $adminID); + $this->db->bind(':id', $landID); + + // Execute + if ($this->db->execute()){ + return true; + } + else { + return false; + } + } } \ No newline at end of file diff --git a/app/views/admin/requests.php b/app/views/admin/requests.php index ca82a69a..933c9224 100644 --- a/app/views/admin/requests.php +++ b/app/views/admin/requests.php @@ -11,53 +11,124 @@
-

Requests

+

Registration Requests



- -
There are no any requests
+ +
You have no any registered vehicles
- - - - -
- + + + +
@@ -67,66 +138,5 @@ function confirmSubmit() { return confirm("Are you sure you want to delete this land?"); } - - // ------------------------------- Search Bar ------------------------------- - const userCardTemplate = document.querySelector(".data-user-template"); - const searchInput = document.querySelector(".data-search"); - - searchInput.addEventListener("input", (data) => { - const value = data.target.value.toLowerCase(); - lands.forEach(land => { - const isVisible = land.name.toLowerCase().includes(value) || land.city.toLowerCase().includes(value) || land.street.toLowerCase().includes(value); - if (land.element) { - land.element.classList.toggle("hide", !isVisible); - } - }); - }); - - let lands = []; - var backendData = ; - - lands = backendData.map(land => { - const card = userCardTemplate.content.cloneNode(true).children[0]; - console.log(card); - card.querySelector(".name").textContent = land.name; - card.querySelector(".city").textContent = land.city; - document.querySelector(".user-cards").appendChild(card); - const tileLink = card.querySelector('.tile'); - - // Set the parking view link - if (tileLink) { - tileLink.href = `viewRegistrationRequestedLand/${land.id}`; - } else { - console.error("Anchor element with class 'tile' not found in the cloned card:", card); - } - - - // Set id and name to delete the land - const deleteForm = card.querySelector('.delete-form'); - if (deleteForm) { - const idInput = deleteForm.querySelector('#id'); - - if (idInput) { - idInput.value = land.id; // Set the value dynamically - } else { - console.error("Form input with id 'name' not found in the cloned card:", card); - } - } - - - // Set values to go to the update page - const updateForm = card.querySelector('.update-form'); - if (updateForm) { - const idInput = updateForm.querySelector('#id'); - - if (idInput) { - idInput.value = land.id; - } else { - console.error("One or more form inputs not found in the cloned card:", card); - } - } - - return { id: land.id, name: land.name, city: land.city, street: land.street, element: card }; - }); diff --git a/app/views/parkingOwner/lands.php b/app/views/parkingOwner/lands.php index 381ee1ed..28e494ce 100644 --- a/app/views/parkingOwner/lands.php +++ b/app/views/parkingOwner/lands.php @@ -22,12 +22,15 @@
You have no any registered lands
+
All Lands
Available
Unavailable
+
+
diff --git a/app/views/superAdmin/admins.php b/app/views/superAdmin/admins.php index e6c8e028..7a275943 100644 --- a/app/views/superAdmin/admins.php +++ b/app/views/superAdmin/admins.php @@ -1,6 +1,6 @@ - + There are no any admins
- - - - -
- + + +
+
Name
+
Email
+
Status
+
+ +
+ +
+ +
@@ -105,6 +125,7 @@ function confirmBan() { const card = userCardTemplate.content.cloneNode(true).children[0]; console.log(card); card.querySelector(".name").textContent = admin.name; + card.querySelector(".id").textContent = admin.id; card.querySelector(".email").textContent = admin.email; document.querySelector(".user-cards").appendChild(card); const tileLink = card.querySelector('.tile'); diff --git a/public/css/components/dynamicContentTable.css b/public/css/components/dynamicContentTable.css index 15371e56..af699944 100644 --- a/public/css/components/dynamicContentTable.css +++ b/public/css/components/dynamicContentTable.css @@ -48,6 +48,7 @@ width: 85%; transition: 0.5s; height: 50px; + color: #6b6b6b; } .search-area .data-search:focus{ @@ -176,6 +177,12 @@ color: #8a8a8a; } +.user-cards .card .email{ + width: 10px; + transition: 1s, transform 1s; + background-color: yellow; +} + .user-cards .card .location{ min-width: 80px; width: 30%;