diff --git a/app/views/listtempatwisata.php b/app/views/listtempatwisata.php index 9287de17c5486597dd35141b140d236cea9c21e5..77c36ca5af310056096ed7b5ec044ea49e377823 100644 --- a/app/views/listtempatwisata.php +++ b/app/views/listtempatwisata.php @@ -11,7 +11,6 @@ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="stylesheet" href="../../public/css/listplace.css"> <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&family=Open+Sans&family=Poppins:wght@300&family=Roboto&display=swap" rel="stylesheet"> - <!-- <script src="../../public/js/infowisataconf.js"></script> --> <title>Travelution</title> </head> <body> @@ -20,7 +19,6 @@ <h1>Cari Akomodasi:</h1> <div class="search"> <input type="text" placeholder="Search" id="search" name="search"> - <!-- <label for="search">Search</label> --> </div> <div class="sortfill"> <div class="sorted"> @@ -36,11 +34,10 @@ <h1>Filter Tipe:</h1> <div class="filter-type"> <button id="toggle-dropdown1" class="dropdown-button" onclick="getCategory(event)">Pilih Tipe Tempat</button> - <div class="dropdown-select" id="type-dropdown"> + <div id="category-dropdown" class="dropdown-select" > <script src="../../public/js/getCategory.js"></script> </div> </div> - <script src="../../public/js/placeselection.js"></script> </div> <div class="filter2"> <h1>Filter Daerah:</h1> @@ -50,7 +47,6 @@ <script src="../../public/js/getLocation.js"></script> </div> </div> - <script src="../../public/js/placeselection.js"></script> </div> <button type="submit" class="buttonfilter" id="buttonfilter" >Apply Filter</button> <script src="../../public/js/httprequest.js"></script> @@ -63,7 +59,6 @@ <div class="listdestination" id="destinationContainer"> </div> - <script src="../../public/js/placeselection.js"></script> <div class="pagination-page"> <ul id="pagination-list"> <a href="#">«</a> diff --git a/app/views/piliheditwisata.php b/app/views/piliheditwisata.php index 7eae9ef753bb3ee9b93919dc8e7c50b505c55f1a..74cab857f421bb0789586dce61c9925d2affbbb2 100644 --- a/app/views/piliheditwisata.php +++ b/app/views/piliheditwisata.php @@ -35,7 +35,7 @@ <h1>Filter Tipe:</h1> <div class="filter-type"> <button id="toggle-dropdown1" class="dropdown-button" onclick="getCategory(event)">Pilih Tipe Tempat</button> - <div class="dropdown-select" id="type-dropdown"> + <div class="dropdown-select" id="category-dropdown"> <script src="../../public/js/getCategory.js"></script> </div> </div> diff --git a/public/js/editplaceselection.js b/public/js/editplaceselection.js index 24598eaf1f987de458b0c8f928fde29a867c76a0..86522c494867a27f4addf568c4401aa70834a76a 100644 --- a/public/js/editplaceselection.js +++ b/public/js/editplaceselection.js @@ -2,7 +2,7 @@ document.addEventListener("DOMContentLoaded" , async () => { const searchInput = document.getElementById("search"); const sortedSelect = document.getElementById("sorted"); const toggleButton1 = document.getElementById("toggle-dropdown1"); - const dropdown1 = document.getElementById("type-dropdown"); + const dropdown1 = document.getElementById("category-dropdown"); const toggleButton2 = document.getElementById("toggle-dropdown2"); const dropdown2 = document.getElementById("location-dropdown"); const filterButton = document.getElementById("buttonfilter"); @@ -13,7 +13,7 @@ document.addEventListener("DOMContentLoaded" , async () => { e.preventDefault(); function getTypeFilter() { - const checkboxes = document.querySelectorAll('#type-dropdown input[type="checkbox"]:checked'); + const checkboxes = document.querySelectorAll('#category-dropdown input[type="checkbox"]:checked'); const selectedValues = Array.from(checkboxes).map(checkbox => checkbox.value); return selectedValues; } diff --git a/public/js/getCategory.js b/public/js/getCategory.js index 7b0638bec349cf9adceb8be096bfc8ce7b59ab9c..67019d573b4b43e3c5895892a5ff804579bb3624 100644 --- a/public/js/getCategory.js +++ b/public/js/getCategory.js @@ -1,21 +1,20 @@ const getCategory = async (e) => { e.preventDefault(); - const formData = new FormData(); - const lib = new Lib(); - const res = await lib.get('/api/get-places-category', formData); + const res = await lib.get('/api/get-places-category'); const jsonRes = JSON.parse(res); - // console.log(jsonRes["message"]) - - var catDropDown = document.getElementById("type-dropdown"); + + var catDropDown = document.getElementById("category-dropdown"); if(catDropDown.firstChild != null) + { while (catDropDown.firstChild) { catDropDown.removeChild(catDropDown.firstChild); } + } + (jsonRes["message"]).forEach(cat => { - jsonRes["message"].forEach(cat => { const label = document.createElement('label'); const input = document.createElement('input'); @@ -26,9 +25,10 @@ const getCategory = async (e) => { label.textContent = cat["PlaceType"]; label.style.display = 'flex'; - label.style.alignItems = 'center'; // Vertically center align the checkbox and text - input.style.order = '-1'; // Move the checkbox to the left + label.style.alignItems = 'center'; + input.style.order = '-1'; label.appendChild(input); - catDropDown.appendChild(label); + catDropDown.appendChild(label); }); + } \ No newline at end of file diff --git a/public/js/placeselection.js b/public/js/placeselection.js index 92b64f527994e993a9dae14d5ba5ed3640586986..bacaedfb12acd21960172b458973d437872afd73 100644 --- a/public/js/placeselection.js +++ b/public/js/placeselection.js @@ -2,7 +2,7 @@ document.addEventListener("DOMContentLoaded" , async () => { const searchInput = document.getElementById("search"); const sortedSelect = document.getElementById("sorted"); const toggleButton1 = document.getElementById("toggle-dropdown1"); - const dropdown1 = document.getElementById("type-dropdown"); + const dropdown1 = document.getElementById("category-dropdown"); const toggleButton2 = document.getElementById("toggle-dropdown2"); const dropdown2 = document.getElementById("location-dropdown"); const filterButton = document.getElementById("buttonfilter"); @@ -13,7 +13,7 @@ document.addEventListener("DOMContentLoaded" , async () => { e.preventDefault(); function getTypeFilter() { - const checkboxes = document.querySelectorAll('#type-dropdown input[type="checkbox"]:checked'); + const checkboxes = document.querySelectorAll('#category-dropdown input[type="checkbox"]:checked'); const selectedValues = Array.from(checkboxes).map(checkbox => checkbox.value); return selectedValues; } @@ -108,6 +108,7 @@ document.addEventListener("DOMContentLoaded" , async () => { toggleButton1.addEventListener("click", function () { dropdown1.style.display = dropdown1.style.display === "block" ? "none" : "block"; + console.log(dropdown1.style.display); }); toggleButton2.addEventListener("click", function () { diff --git a/src/getCategoryServerSide.php b/src/getCategoryServerSide.php index cb679427c4350dbb9791f01e959f0f3a468f0788..9a35f610ff5a7d3b72e658ae7c51f070a21c0bb1 100644 --- a/src/getCategoryServerSide.php +++ b/src/getCategoryServerSide.php @@ -3,21 +3,27 @@ include_once 'pdo.php'; if ($_SERVER["REQUEST_METHOD"] == "GET") { - $params = array(); - - $sql = "SELECT DISTINCT PlaceType from Place"; - - $stmt = executeSQL($sql, $params); - - $res = array(); - while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) + try { - array_push($res, $record); - } - $data = ['message' => $res]; + $params = array(); + + $sql = "SELECT DISTINCT PlaceType from Place"; + + $stmt = executeSQL($sql, $params); + + $res = array(); + while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) + { + array_push($res, $record); + } + $data = ['message' => $res]; - echo json_encode($data); - exit; + echo json_encode($data); + exit; + } catch (PDOException $e) { + $res = ['message' => $e]; + echo json_encode($res); + } } ?> \ No newline at end of file diff --git a/src/getLocationServerSide.php b/src/getLocationServerSide.php index 52158d0e6844d9258911dcbef28ec4725ac2c620..4d3f658b1a9fca6f03b435727dc0470704140e15 100644 --- a/src/getLocationServerSide.php +++ b/src/getLocationServerSide.php @@ -3,21 +3,27 @@ include_once 'pdo.php'; if ($_SERVER["REQUEST_METHOD"] == "GET") { - $params = array(); - - $sql = "SELECT DISTINCT PlaceLocation from Place"; - - $stmt = executeSQL($sql, $params); - - $res = array(); - while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) + try { - array_push($res, $record); - } - $data = ['message' => $res]; + $params = array(); + + $sql = "SELECT DISTINCT PlaceLocation from Place"; + + $stmt = executeSQL($sql, $params); + + $res = array(); + while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) + { + array_push($res, $record); + } + $data = ['message' => $res]; - echo json_encode($data); - exit; + echo json_encode($data); + exit; + } catch (PDOException $e) { + $res = ['message' => $e]; + echo json_encode($res); + } } ?> \ No newline at end of file diff --git a/src/getPlaceCountServerSide.php b/src/getPlaceCountServerSide.php index a7ac9151c41cd5ee8736853e37de9e39e04e26e5..9646f4ecda61c30e843aa42488e952370b3fe02d 100644 --- a/src/getPlaceCountServerSide.php +++ b/src/getPlaceCountServerSide.php @@ -3,21 +3,26 @@ include_once 'pdo.php'; if ($_SERVER["REQUEST_METHOD"] == "GET") { - - $sql = "SELECT COUNT(PlaceID) as placeCount from Place"; - $params = array(); - - $stmt = executeSQL($sql, $params); - - $res = array(); - while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) + try { - array_push($res, $record); - } - $data = ['message' => $res]; + $sql = "SELECT COUNT(PlaceID) as placeCount from Place"; + $params = array(); + + $stmt = executeSQL($sql, $params); + + $res = array(); + while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) + { + array_push($res, $record); + } + $data = ['message' => $res]; - echo json_encode($data); - exit; + echo json_encode($data); + exit; + } catch (PDOException $e) { + $res = ['message' => $e]; + echo json_encode($res); + } } ?> \ No newline at end of file diff --git a/src/getPlaceInfo.php b/src/getPlaceInfo.php index a01e57a1daf96b471ef5588e4828cfd56c20ba4e..72cc653acd2068fce1c61c478f589cc91a4db922 100644 --- a/src/getPlaceInfo.php +++ b/src/getPlaceInfo.php @@ -3,21 +3,25 @@ include_once 'pdo.php'; if ($_SERVER["REQUEST_METHOD"] == "POST") { + try { + $sql = "SELECT * from Place WHERE PlaceID = :placeid"; + $params = array(':placeid' => $_POST["PlaceID"]); + + $stmt = executeSQL($sql, $params); + + $res = array(); + while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) + { + array_push($res, $record); + } + $data = ['message' => $res]; - $sql = "SELECT * from Place WHERE PlaceID = :placeid"; - $params = array(':placeid' => $_POST["PlaceID"]); - - $stmt = executeSQL($sql, $params); - - $res = array(); - while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) - { - array_push($res, $record); - } - $data = ['message' => $res]; - - echo json_encode($data); - exit; + echo json_encode($data); + exit; + } catch (PDOException $e) { + $res = ['message' => $e]; + echo json_encode($res); + } } ?> \ No newline at end of file