Zefix_search/index.php

254 lines
9.0 KiB
PHP
Raw Normal View History

2023-08-16 18:26:11 +02:00
<html lang="de">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/custom.css?v=1.1">
<link rel="stylesheet" href="css/bootstrap.css">
<title>Silias Zefix Suche</title>
2023-08-16 17:23:44 +02:00
2023-08-16 21:15:28 +02:00
<style>
#myInput {
box-sizing: border-box;
background-position: 14px 12px;
background-repeat: no-repeat;
font-size: 16px;
padding: 14px 20px 12px 45px;
border: none;
border-bottom: 1px solid #ddd;
}
#myInput:focus {outline: 3px solid #ddd;}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
position: absolute;
background-color: #f6f6f6;
min-width: 230px;
overflow: auto;
border: 1px solid #ddd;
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown a:hover {background-color: #ddd;}
.show {display: block;}
</style>
2023-08-16 18:26:11 +02:00
</head>
<body>
2023-08-16 17:36:41 +02:00
2023-08-16 18:27:32 +02:00
<div class="wrapper">
<section>
<div class="container">
2023-08-16 18:28:03 +02:00
<h1>Silias Zefix Suche</h1>
2023-08-16 18:21:11 +02:00
2023-08-16 18:27:32 +02:00
<p>Diese Webseite wird gerade neu entwickelt und steht demnächst zur Verfügung.</p>
</div>
2023-08-16 21:15:28 +02:00
<div class="container">
<form action="submit.php" method="post">
<label for="firmenname">Firmenname:</label>
<input type="text" id="firmenname" name="firmenname" required><br><br>
<label for="kanton">Kanton:</label>
<select id="kanton" name="kanton">
<!-- Hier kannst du die Optionen für die Kantone einfügen -->
</select><br><br>
<label for="sitz">Sitz (Postleitzahl / Gemeinde):</label>
<div class="dropdown">
<div id="myDropdown" class="dropdown-content">
<input type="text" placeholder="Postleitzahl / Ort" id="myInput" onkeyup="filterFunction()" name="sitz">
<div id="results">
</div>
</div>
</div><br><br>
<label for="rechtsform">Rechtsform:</label>
<select id="rechtsform" name="rechtsform">
<!-- Hier kannst du die Optionen für die Rechtsformen einfügen -->
</select><br><br>
<input type="checkbox" id="exakteSuche" name="exakteSuche">
<label for="exakteSuche">Exakte Suche</label><br>
<input type="checkbox" id="geloeschteRechtseinheiten" name="geloeschteRechtseinheiten">
<label for="geloeschteRechtseinheiten">Gelöschte Rechtseinheiten suchen</label><br>
<input type="checkbox" id="inBisherigenFirmen" name="inBisherigenFirmen">
<label for="inBisherigenFirmen">In bisherigen Firmen/Namen suchen</label><br>
<input type="checkbox" id="phonetischeSuche" name="phonetischeSuche">
<label for="phonetischeSuche">Phonetische Suche</label><br><br>
<input type="submit" value="Formular absenden">
</form>
<script>
const kantonDropdown = document.getElementById('kanton');
const sitzInput = document.getElementById('sitz');
// Parse CSV-Daten und fülle das Dropdown-Feld
let csvData;
<?php
include 'gemeinden.php';
?>
csvData = csvData.slice(1);
// csvData = "PLZ,ORTBEZ,KANTON
// 1000,Lausanne Dépôt,VD
// 1001,Lausanne,VD
// 1002,Lausanne,VD"
const lines = csvData.trim().split('\n');
const headers = lines[0].split(',');
const gemeindeNameIndex = headers.indexOf('Gemeindename');
const plzIndex = headers.indexOf('PLZ');
const kantonIndex = headers.indexOf('Kanton');
const sitze = [];
for (let i = 1; i < lines.length; i++) {
const cells = lines[i].split(',');
const plz = cells[plzIndex].trim();
const gemeindeName = cells[gemeindeNameIndex].trim();
const kanton = cells[kantonIndex].trim();
// Falls Kanton noch nicht vorhanden -> hinzufügen
if (!kantonDropdown.querySelector(`[value="${kanton}"]`)) {
const option = document.createElement('option');
option.value = kanton;
option.textContent = kanton;
kantonDropdown.appendChild(option);
}
// Sitz hinzufügen
const sitzString = plz + " " + gemeindeName
sitze.push(sitzString)
const anchorElement = document.createElement('a');
anchorElement.textContent = sitzString
anchorElement.href="#"
anchorElement.classList.add("result")
anchorElement.addEventListener('click', function(event) {
const index = i - 1; // Make sure 'i' is defined before using it here
chooseResult(index.toString());
});
document.getElementById("results").appendChild(anchorElement)
}
function filterFunction() {
var input, filter, ul, li, a, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
div = document.getElementById("myDropdown");
a = div.getElementsByTagName("a");
for (i = 0; i < a.length; i++) {
txtValue = a[i].textContent || a[i].innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
a[i].style.display = "";
} else {
a[i].style.display = "none";
}
}
}
function chooseResult(index) {
document.getElementById("myInput").value = sitze[index]
console.log("Choosen" + index)
}
const myInput = document.getElementById('myInput');
const results = document.getElementById('results');
results.style.display = 'none';
myInput.addEventListener('focus', () => {
results.style.display = 'block';
});
myInput.addEventListener('blur', () => {
setTimeout(() => {
results.style.display = 'none';
}, 100); // 1000 milliseconds = 1 second
});
</script>
</div>
2023-08-16 18:27:32 +02:00
</section>
</div>
2023-08-16 21:15:28 +02:00
2023-08-16 17:36:41 +02:00
<?php
2023-08-16 18:02:00 +02:00
include 'env_vars.php';
2023-08-16 18:21:11 +02:00
//echo "My API Key is:" . $_ENV["APIKEY"];
//echo "Getenv:" . getenv('APIKEY');
2023-08-16 17:36:41 +02:00
2023-08-16 18:19:50 +02:00
?>
2023-08-16 18:26:11 +02:00
2023-08-16 18:19:50 +02:00
<footer class="text-center">
<div class="container footer">
<div class="row">
<table>
<tr>
<td class="footer">
<div class="col-12">
<p><span><b>Impressum</b></span><br>
Silias KLG<br>
Toggenburgstrasse 31<br>
8245 Feuerthalen<br>
<a href="https://www.silias.ch" target="_blank">www.silias.ch</a><br>
<a href="mailto:info@silias.ch">info@silias.ch</a><br>
2023-08-16 18:21:47 +02:00
<a href="https://gitea.silias.ch/Silias-Public/Zefix_search">Projekt Repository</a>
2023-08-16 18:19:50 +02:00
</div>
</td>
<td class="footer">
<div class="col-12">
<p><span><b>Datenquelle</b></span><br>
2023-08-16 18:26:11 +02:00
Zentraler Firmenindex<br>
2023-08-16 18:19:50 +02:00
Eidgenössisches Justiz- und Polizeidepartement (EJPD)<br>
Bundesamt für Justiz (BJ)<br>
2023-08-16 18:42:20 +02:00
Eidgenössisches Amt für das Handelsregister (EHRA)<br>
Bundesrain 20<br>
3003 Bern<br>
2023-08-16 18:19:50 +02:00
<a href="https://www.zefix.admin.ch" target="_blank">www.zefix.admin.ch</a><br>
2023-08-16 18:43:20 +02:00
<a href="tel:+41584624197">+41 (0) 58 462 41 97</a><br>
2023-08-16 18:42:20 +02:00
<a href="zefix@bj.admin.ch">zefix@bj.admin.ch</a>
2023-08-16 18:19:50 +02:00
</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</footer>
2023-08-16 18:26:11 +02:00
</body>
2023-08-16 18:19:50 +02:00
</html>