329 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			329 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			PHP
		
	
	
	
<?php
 | 
						|
include "zefixAPI.php";
 | 
						|
?>
 | 
						|
<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.2">
 | 
						|
    <link rel="stylesheet" href="css/bootstrap.css">
 | 
						|
    <title>Silias Zefix Suche</title>
 | 
						|
 | 
						|
    <style>
 | 
						|
        #sitzInput {
 | 
						|
            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;
 | 
						|
        }
 | 
						|
 | 
						|
        #sitzInput {outline: 3px solid #ddd;}
 | 
						|
 | 
						|
        .button-small {
 | 
						|
            font-size: 0.7rem;
 | 
						|
            padding: 0% 1%;
 | 
						|
        }
 | 
						|
 | 
						|
        .dropdown a:hover {background-color: #ddd;}
 | 
						|
 | 
						|
        .show {display: block;}
 | 
						|
 | 
						|
        .scrollWindow {
 | 
						|
            max-height: 300px; /* Adjust the value as needed */
 | 
						|
            overflow-y: auto; /* This will add a scrollbar when content exceeds max-height */
 | 
						|
            border: 1px solid #ccc; /* Optional: Add a border for visual clarity */
 | 
						|
            padding: 10px; /* Optional: Add padding for better spacing */
 | 
						|
        }
 | 
						|
    </style>
 | 
						|
</head>
 | 
						|
 | 
						|
<body>
 | 
						|
 | 
						|
<div class="wrapper">
 | 
						|
    <section>
 | 
						|
 | 
						|
 | 
						|
        <div class="container">
 | 
						|
            <h1>Silias Zefix Suche</h1>
 | 
						|
 | 
						|
 | 
						|
            <p>Diese Webseite wird gerade neu entwickelt und steht demnächst zur Verfügung.</p>
 | 
						|
 | 
						|
            <form action="submit.php" method="post">
 | 
						|
                <label for="firma">Firmenname:</label>
 | 
						|
                <p>* kann als Platzhalter verwendet werden</p>
 | 
						|
                <input type="text" id="firma" name="firma"><br><br>
 | 
						|
 | 
						|
                <label for="kanton">Kanton:</label>
 | 
						|
                    <div id="kantonauswahl" class="scrollWindow" onclick="filterFunction()">
 | 
						|
 | 
						|
                    </div><br><br>
 | 
						|
 | 
						|
                <label for="sitz">Sitz (Ort):</label><br>
 | 
						|
                <div class="dropdown">
 | 
						|
                    <div id="gemeindeDropdown" class="dropdown-content">
 | 
						|
                        <table style="width: 100%">
 | 
						|
                            <td>
 | 
						|
                                <input  type="text" placeholder="suchen (Ort)" id="sitzInput" onkeyup="filterFunction()" onchange="filterFunction()" name="sitzfilter" autocomplete="off">
 | 
						|
                            </td>
 | 
						|
                            <td>
 | 
						|
                                <button type="button" class="button-small" onclick="gefundeneGemeindenAuswählen()">Alle Ergebnise auswählen</button>
 | 
						|
                                <button type="button" class="button-small" onclick="ausgewählteGemeindenLöschen()">Auswahl löschen</button>
 | 
						|
                                <button type="button" class="button-small" onclick="alleGemeindenAnzeigen()">Alle anzeigen</button>
 | 
						|
                                <button type="button" class="button-small" onclick="nurAusgewählteGemeindenAnzeigen()">Nur ausgewählte anzeigen</button>
 | 
						|
                            </td>
 | 
						|
                        </table>
 | 
						|
 | 
						|
                        <script>
 | 
						|
 | 
						|
                            function alleGemeindenAnzeigen() {
 | 
						|
                                sitzInput.value = ""
 | 
						|
                                filterFunction()
 | 
						|
                            }
 | 
						|
 | 
						|
                            function nurAusgewählteGemeindenAnzeigen() {
 | 
						|
                                sitzInput.value = "(nur ausgewählte)"
 | 
						|
                                filterFunction()
 | 
						|
                            }
 | 
						|
 | 
						|
                            function ausgewählteGemeindenLöschen() {
 | 
						|
                                sitzauswahl.querySelectorAll('input[type="checkbox"]').forEach(function(checkbox) {
 | 
						|
                                    checkbox.checked = false;
 | 
						|
                                })
 | 
						|
                                filterFunction()
 | 
						|
                            }
 | 
						|
 | 
						|
                            function gefundeneGemeindenAuswählen() { // TODO diese Funktion aufrufen wenn keine Gemeinde ausgewählt und gesucht wird.
 | 
						|
                                sitzauswahl.querySelectorAll('input[type="checkbox"]').forEach(function(checkbox) {
 | 
						|
                                    if(checkbox.parentNode.parentNode.style.display !== "none")
 | 
						|
                                    checkbox.checked = true;
 | 
						|
                                })
 | 
						|
                                filterFunction()
 | 
						|
                            }
 | 
						|
 | 
						|
                        </script>
 | 
						|
 | 
						|
 | 
						|
                        <div id="sitzauswahl" class="scrollWindow">
 | 
						|
 | 
						|
                        </div>
 | 
						|
 | 
						|
                    </div>
 | 
						|
                </div><br><br><br><br>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
                <label for="rechtsform">Rechtsform:</label><br>
 | 
						|
                <div id = "rechtsformenauswahl" class="scrollWindow">
 | 
						|
 | 
						|
                </div>
 | 
						|
                <br><br>
 | 
						|
 | 
						|
                <input type="checkbox" id="exakteSuche" name="exakteSuche" disabled>
 | 
						|
                <label for="exakteSuche">Exakte Suche (noch in Entwicklung)</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" disabled>
 | 
						|
                <label for="inBisherigenFirmen">In bisherigen Firmen/Namen suchen (noch in Entwicklung)</label><br>
 | 
						|
 | 
						|
                <input type="checkbox" id="phonetischeSuche" name="phonetischeSuche" disabled>
 | 
						|
                <label for="phonetischeSuche">Phonetische Suche (noch in Entwicklung)</label><br><br>
 | 
						|
 | 
						|
                <label for="email">Ihre E-Mail Adresse:</label>
 | 
						|
                <p>Das aufbereiten der Daten kann lange dauern. Sie erhalten einen Download-Link per E-Mail sobald die Daten bereit sind.</p>
 | 
						|
                <input type="email" id="email" name="email" required><br><br>
 | 
						|
 | 
						|
                <input type="submit" value="Export starten">
 | 
						|
            </form>
 | 
						|
 | 
						|
            <script>
 | 
						|
 | 
						|
 | 
						|
                // Parse CSV-Daten und fülle das Dropdown-Feld
 | 
						|
 | 
						|
 | 
						|
                let communityCsvData;
 | 
						|
                let legalFormsCsvData;
 | 
						|
                <?php
 | 
						|
                    include 'gemeinden.php';
 | 
						|
                    include 'legalForms.php';
 | 
						|
                ?>
 | 
						|
 | 
						|
 | 
						|
                const legalFormslines = legalFormsCsvData.trim().split('\n');
 | 
						|
                const legalFormsheaders = legalFormslines[0].split(',');
 | 
						|
                const legalformIdIndex = legalFormsheaders.indexOf('id');
 | 
						|
                const legalformNameIndex = legalFormsheaders.indexOf('name');
 | 
						|
                for (let i = 1; i < legalFormslines.length; i++) {
 | 
						|
                    const cells = legalFormslines[i].split(',');
 | 
						|
                    const id = cells[legalformIdIndex].trim();
 | 
						|
                    const name = cells[legalformNameIndex].trim();
 | 
						|
                    const label = document.createElement('label');
 | 
						|
                    const rechtsformenauswahl = document.getElementById("rechtsformenauswahl")
 | 
						|
                    rechtsformenauswahl.appendChild(label);
 | 
						|
                    const input = document.createElement('input');
 | 
						|
                    input.type = "checkbox";
 | 
						|
                    input.name = "rechtsformen[]";
 | 
						|
                    input.value = id;
 | 
						|
                    label.textContent = " " + name;
 | 
						|
                    label.style.marginBottom = '0';
 | 
						|
                    label.prepend(input);
 | 
						|
                    rechtsformenauswahl.appendChild(document.createElement("br"))
 | 
						|
                }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
                const lines = communityCsvData.trim().split('\n');
 | 
						|
                const headers = lines[0].split(',');
 | 
						|
                const gemeindeNameIndex = headers.indexOf('Gemeindename');
 | 
						|
                const bfsIdIndex = headers.indexOf('bfsId');
 | 
						|
                const kantonIndex = headers.indexOf('Kanton');
 | 
						|
                const registryOfCommerceIdIndex = headers.indexOf('registryOfCommerceId');
 | 
						|
 | 
						|
                const sitze = [];
 | 
						|
                const kantone = []
 | 
						|
                for (let i = 1; i < lines.length; i++) {
 | 
						|
 | 
						|
                    const cells = lines[i].split(',');
 | 
						|
                    const bfsId = cells[bfsIdIndex].trim();
 | 
						|
                    const gemeindeName = cells[gemeindeNameIndex].trim();
 | 
						|
                    const kanton = cells[kantonIndex].trim();
 | 
						|
                    const registryOfCommerceId = cells[registryOfCommerceIdIndex].trim();
 | 
						|
 | 
						|
                    // Falls Kanton noch nicht vorhanden -> hinzufügen
 | 
						|
                    if (!kantone.includes(kanton)) {
 | 
						|
                        kantone.push(kanton)
 | 
						|
                        const label = document.createElement('label');
 | 
						|
                        const kantonsauswahl = document.getElementById("kantonauswahl")
 | 
						|
                        kantonsauswahl.appendChild(label);
 | 
						|
                        const input = document.createElement('input');
 | 
						|
                        input.type = "checkbox";
 | 
						|
                        input.name = "kantone[]";
 | 
						|
                        input.value = kanton;
 | 
						|
                        label.textContent = " " + kanton;
 | 
						|
                        label.style.marginBottom = '0';
 | 
						|
                        label.prepend(input);
 | 
						|
                        kantonsauswahl.appendChild(document.createElement("br"))
 | 
						|
                    }
 | 
						|
 | 
						|
                    // Sitz hinzufügen
 | 
						|
                    sitze.push(cells)
 | 
						|
                    const sitzString = gemeindeName
 | 
						|
                    const gemeindeEintrag = document.createElement("div");
 | 
						|
                    gemeindeEintrag.classList.add("gemeindeeintrag");
 | 
						|
                    const label = document.createElement('label');
 | 
						|
                    const sitzauswahl = document.getElementById("sitzauswahl")
 | 
						|
                    sitzauswahl.appendChild(gemeindeEintrag);
 | 
						|
                    gemeindeEintrag.appendChild(label);
 | 
						|
                    const input = document.createElement('input');
 | 
						|
                    input.type = "checkbox";
 | 
						|
                    input.name = "sitze[]";
 | 
						|
                    input.value = bfsId;
 | 
						|
                    label.textContent = " " + sitzString;
 | 
						|
                    label.style.marginBottom = '0';
 | 
						|
                    label.prepend(input);
 | 
						|
                    gemeindeEintrag.appendChild(document.createElement("br"))
 | 
						|
                }
 | 
						|
 | 
						|
                function filterFunction() {
 | 
						|
                    const numKantoneAusgewählt = kantoneAusgewählt()
 | 
						|
                    var input, filter, ul, li, a, i;
 | 
						|
                    input = document.getElementById("sitzInput");
 | 
						|
                    filter = input.value.toUpperCase();
 | 
						|
                    div = document.getElementById("gemeindeDropdown");
 | 
						|
                    a = div.getElementsByClassName("gemeindeeintrag");
 | 
						|
                    for (i = 0; i < a.length; i++) {
 | 
						|
                        txtValue = a[i].textContent || a[i].innerText;
 | 
						|
                        if ((txtValue.toUpperCase().indexOf(filter) > -1 && (document.querySelector('input[name="kantone[]"][value=' + sitze[i][kantonIndex] + ']').checked || numKantoneAusgewählt === 0)  ) || a[i].firstElementChild.firstElementChild.checked) {
 | 
						|
                            a[i].style.display = "";
 | 
						|
                        } else {
 | 
						|
                            a[i].style.display = "none";
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
 | 
						|
                function kantoneAusgewählt() {
 | 
						|
                    const checkboxes = document.querySelectorAll('input[name="kantone[]"]');
 | 
						|
                    let countChecked = 0;
 | 
						|
 | 
						|
                    for (var i = 0; i < checkboxes.length; i++) {
 | 
						|
                        if (checkboxes[i].checked) {
 | 
						|
                            countChecked = countChecked + 1;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    return countChecked;
 | 
						|
                }
 | 
						|
 | 
						|
 | 
						|
                const sitzInput = document.getElementById('sitzInput');
 | 
						|
                const sitzauswahl = document.getElementById('sitzauswahl');
 | 
						|
                const gemeindedropdown = document.getElementById('gemeindeDropdown');
 | 
						|
                sitzauswahl.style.display = 'block';
 | 
						|
 | 
						|
                gemeindedropdown.addEventListener('focusin', () => {
 | 
						|
                    console.log("focusin")
 | 
						|
                    sitzauswahl.style.display = 'block';
 | 
						|
                });
 | 
						|
 | 
						|
 | 
						|
            </script>
 | 
						|
 | 
						|
        </div>
 | 
						|
 | 
						|
    </section>
 | 
						|
    <div class="push"></div>
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<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>
 | 
						|
                                <a href="https://gitea.silias.ch/Silias-Public/Zefix_search">Projekt Repository</a>
 | 
						|
                        </div>
 | 
						|
                    </td>
 | 
						|
                    <td class="footer">
 | 
						|
                        <div class="col-12">
 | 
						|
                            <p><span><b>Datenquelle</b></span><br>
 | 
						|
                                Zentraler Firmenindex<br>
 | 
						|
                                Eidgenössisches Justiz- und Polizeidepartement (EJPD)<br>
 | 
						|
                                Bundesamt für Justiz (BJ)<br>
 | 
						|
                                Eidgenössisches Amt für das Handelsregister (EHRA)<br>
 | 
						|
                                Bundesrain 20<br>
 | 
						|
                                3003 Bern<br>
 | 
						|
                                <a href="https://www.zefix.admin.ch" target="_blank">www.zefix.admin.ch</a><br>
 | 
						|
                                <a href="tel:+41584624197">+41 (0) 58 462 41 97</a><br>
 | 
						|
                                <a href="zefix@bj.admin.ch">zefix@bj.admin.ch</a>
 | 
						|
                            </p>
 | 
						|
                        </div>
 | 
						|
                    </td>
 | 
						|
                </tr>
 | 
						|
            </table>
 | 
						|
 | 
						|
        </div>
 | 
						|
    </div>
 | 
						|
</footer>
 | 
						|
 | 
						|
</body>
 | 
						|
</html>
 |