Sitze und Rechtsformen aus Zefix API
This commit is contained in:
		
							parent
							
								
									3c47b7ba97
								
							
						
					
					
						commit
						bd05621843
					
				| 
						 | 
				
			
			@ -1,66 +1,70 @@
 | 
			
		|||
 | 
			
		||||
<?php
 | 
			
		||||
//include 'env_vars.php';
 | 
			
		||||
$username = getenv("username");
 | 
			
		||||
$password = getenv("password");
 | 
			
		||||
include 'zefixAPI.php';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// API endpoint
 | 
			
		||||
$apiUrl = 'https://www.zefix.admin.ch/ZefixPublicREST/apicompany/search';
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Request Types:
 | 
			
		||||
 * Count
 | 
			
		||||
 * List
 | 
			
		||||
 * Export
 | 
			
		||||
 */
 | 
			
		||||
// Request data
 | 
			
		||||
$data = array(
 | 
			
		||||
    "name" => "Silias KLG",
 | 
			
		||||
    "legalFormId" => 4,
 | 
			
		||||
    "legalFormUid" => "0107",
 | 
			
		||||
    "registryOfCommerceId" => 36,
 | 
			
		||||
    "legalSeatId" => 623,
 | 
			
		||||
    "canton" => "BE",
 | 
			
		||||
    "activeOnly" => true
 | 
			
		||||
);
 | 
			
		||||
$data = array();
 | 
			
		||||
 | 
			
		||||
// Headers
 | 
			
		||||
$headers = array(
 | 
			
		||||
    "username:".$username,
 | 
			
		||||
    "password:".$password
 | 
			
		||||
);
 | 
			
		||||
phpinfo();
 | 
			
		||||
// Initialize cURL session
 | 
			
		||||
$ch = curl_init();
 | 
			
		||||
$results = array();
 | 
			
		||||
 | 
			
		||||
// Set cURL options
 | 
			
		||||
curl_setopt($ch, CURLOPT_URL, $apiUrl);
 | 
			
		||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 | 
			
		||||
curl_setopt($ch, CURLOPT_POST, true);
 | 
			
		||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
 | 
			
		||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 | 
			
		||||
 | 
			
		||||
// Execute cURL session and get the response
 | 
			
		||||
$response = curl_exec($ch);
 | 
			
		||||
 | 
			
		||||
// Check for cURL errors
 | 
			
		||||
if (curl_errno($ch)) {
 | 
			
		||||
    echo 'Curl error: ' . curl_error($ch);
 | 
			
		||||
// Wenn Firmenname vorhanden
 | 
			
		||||
if(isset($_POST['firma']) && !empty($_POST['firma'])) {
 | 
			
		||||
    $data["name"] = $_POST['firma'];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Close cURL session
 | 
			
		||||
curl_close($ch);
 | 
			
		||||
// Wenn gelöschte auch gesucht werden sollen
 | 
			
		||||
if(isset($_POST['geloeschteRechtseinheiten'])) {
 | 
			
		||||
    $data["activeOnly"] = false;
 | 
			
		||||
} else {
 | 
			
		||||
    $data["activeOnly"] = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Output the API response
 | 
			
		||||
echo $response;
 | 
			
		||||
$rechtsformen = array();
 | 
			
		||||
if (isset($_POST['rechtsform']) && is_array($_POST['rechtsform']) && count($_POST['rechtsform']) > 0) {
 | 
			
		||||
    $rechtsformen = $_POST['rechtsform'];
 | 
			
		||||
} else {
 | 
			
		||||
    $rechtsformen = array(); //TODO alle Rechtsformen hinzufügen
 | 
			
		||||
    $rechtsformen[] = 2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$sitze = array();
 | 
			
		||||
if (isset($_POST['sitze']) && is_array($_POST['sitze']) && count($_POST['sitze']) > 0) {
 | 
			
		||||
    $sitze = $_POST['sitze'];
 | 
			
		||||
} else {
 | 
			
		||||
    $sitze = array(); //TODO alle Sitze hinzufügen
 | 
			
		||||
    $sitze[] = 27;
 | 
			
		||||
}
 | 
			
		||||
// Loop through the selected values
 | 
			
		||||
    foreach ($rechtsformen as $rechtsform) {
 | 
			
		||||
        $data["legalFormId"] = $rechtsform;
 | 
			
		||||
 | 
			
		||||
            // Loop through the selected values
 | 
			
		||||
            foreach ($sitze as $sitz) {
 | 
			
		||||
                $data["legalSeatId"] = $sitz;
 | 
			
		||||
                $response = sendAPICompanySearchRequest($username, $password, $data);
 | 
			
		||||
 | 
			
		||||
                echo $response;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
// Close cURL
 | 
			
		||||
curl_close($ch);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
// Process the Zefix response and construct your own response
 | 
			
		||||
// ...
 | 
			
		||||
$constructed_response = $response;
 | 
			
		||||
 | 
			
		||||
// Send the response back to the client
 | 
			
		||||
header('Content-Type: application/json');
 | 
			
		||||
echo $constructed_response;
 | 
			
		||||
//header('Content-Type: application/json');
 | 
			
		||||
//echo $constructed_response;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,147 @@
 | 
			
		|||
<?php
 | 
			
		||||
include 'env_vars.php';
 | 
			
		||||
$username = getenv("username");
 | 
			
		||||
$password = getenv("password");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @param string $
 | 
			
		||||
 * @param string $
 | 
			
		||||
 * @param array $data
 | 
			
		||||
 * @return bool|string
 | 
			
		||||
 */
 | 
			
		||||
function sendAPICompanySearchRequest(string $username, string $password, array $data): string|bool
 | 
			
		||||
{
 | 
			
		||||
// API endpoint
 | 
			
		||||
$apiUrl = 'https://www.zefix.admin.ch/ZefixPublicREST/api/v1/company/search';
 | 
			
		||||
 | 
			
		||||
// Headers
 | 
			
		||||
$headers = array(
 | 
			
		||||
"accept: application/json",
 | 
			
		||||
"Content-Type: application/json"
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
// Initialize cURL session
 | 
			
		||||
$ch = curl_init();
 | 
			
		||||
 | 
			
		||||
// Set cURL options
 | 
			
		||||
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
 | 
			
		||||
curl_setopt($ch, CURLOPT_URL, $apiUrl);
 | 
			
		||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 | 
			
		||||
curl_setopt($ch, CURLOPT_POST, true);
 | 
			
		||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
 | 
			
		||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 | 
			
		||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL verification
 | 
			
		||||
 | 
			
		||||
// Execute cURL session and get the response
 | 
			
		||||
$response = curl_exec($ch);
 | 
			
		||||
// Check for cURL errors
 | 
			
		||||
if (curl_errno($ch)) {
 | 
			
		||||
echo 'Curl error: ' . curl_error($ch);
 | 
			
		||||
}
 | 
			
		||||
// Close cURL session
 | 
			
		||||
curl_close($ch);
 | 
			
		||||
 | 
			
		||||
// Close cURL
 | 
			
		||||
curl_close($ch);
 | 
			
		||||
    return $response;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function sendAPICommunityRequest(string $username, string $password): string|bool
 | 
			
		||||
{
 | 
			
		||||
// API endpoint
 | 
			
		||||
    $apiUrl = 'https://www.zefix.admin.ch/ZefixPublicREST/api/v1/community';
 | 
			
		||||
 | 
			
		||||
// Headers
 | 
			
		||||
    $headers = array(
 | 
			
		||||
        "accept: application/json",
 | 
			
		||||
        "Content-Type: application/json"
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
// Initialize cURL session
 | 
			
		||||
    $ch = curl_init();
 | 
			
		||||
 | 
			
		||||
// Set cURL options
 | 
			
		||||
    curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_POST, false);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL verification
 | 
			
		||||
 | 
			
		||||
// Execute cURL session and get the response
 | 
			
		||||
    $response = curl_exec($ch);
 | 
			
		||||
// Check for cURL errors
 | 
			
		||||
    if (curl_errno($ch)) {
 | 
			
		||||
        echo 'Curl error: ' . curl_error($ch);
 | 
			
		||||
    }
 | 
			
		||||
// Close cURL session
 | 
			
		||||
    curl_close($ch);
 | 
			
		||||
 | 
			
		||||
// Close cURL
 | 
			
		||||
    curl_close($ch);
 | 
			
		||||
    return $response;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function communityCSV(string $username, string $password): string {
 | 
			
		||||
    $response = sendAPICommunityRequest($username, $password);
 | 
			
		||||
    $communityArray = json_decode($response, true);
 | 
			
		||||
    $csvOutput = 'bfsId,Kanton,Gemeindename,registryOfCommerceId\n';
 | 
			
		||||
    // Create CSV rows
 | 
			
		||||
 | 
			
		||||
    foreach ($communityArray as $item) {
 | 
			
		||||
       $csvOutput .= implode(',', $item) . "\n";
 | 
			
		||||
    }
 | 
			
		||||
    return $csvOutput;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function sendAPILegalFormRequest(string $username, string $password): string|bool
 | 
			
		||||
{
 | 
			
		||||
// API endpoint
 | 
			
		||||
    $apiUrl = 'https://www.zefix.admin.ch/ZefixPublicREST/api/v1/legalForm';
 | 
			
		||||
 | 
			
		||||
// Headers
 | 
			
		||||
    $headers = array(
 | 
			
		||||
        "accept: application/json",
 | 
			
		||||
        "Content-Type: application/json"
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
// Initialize cURL session
 | 
			
		||||
    $ch = curl_init();
 | 
			
		||||
 | 
			
		||||
// Set cURL options
 | 
			
		||||
    curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_POST, false);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 | 
			
		||||
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL verification
 | 
			
		||||
 | 
			
		||||
// Execute cURL session and get the response
 | 
			
		||||
    $response = curl_exec($ch);
 | 
			
		||||
// Check for cURL errors
 | 
			
		||||
    if (curl_errno($ch)) {
 | 
			
		||||
        echo 'Curl error: ' . curl_error($ch);
 | 
			
		||||
    }
 | 
			
		||||
// Close cURL session
 | 
			
		||||
    curl_close($ch);
 | 
			
		||||
 | 
			
		||||
// Close cURL
 | 
			
		||||
    curl_close($ch);
 | 
			
		||||
    return $response;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function legalFormCSV(string $username, string $password): string {
 | 
			
		||||
    $response = sendAPILegalFormRequest($username, $password);
 | 
			
		||||
    $legalformArray = json_decode($response, true);
 | 
			
		||||
    $csvOutput = 'id,name\n';
 | 
			
		||||
    // Create CSV rows
 | 
			
		||||
 | 
			
		||||
    foreach ($legalformArray as $item) {
 | 
			
		||||
        $csvOutput .= $item["id"].",".$item["name"]["de"] . "\n";
 | 
			
		||||
    }
 | 
			
		||||
    return $csvOutput;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
 | 
			
		||||
<?php
 | 
			
		||||
echo "csvData = `". file_get_contents('gemeinden.csv') ."`;";
 | 
			
		||||
echo "communityCsvData = `". communityCSV($username, $password) ."`;";
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										92
									
								
								index.php
								
								
								
								
							
							
						
						
									
										92
									
								
								index.php
								
								
								
								
							| 
						 | 
				
			
			@ -51,21 +51,21 @@
 | 
			
		|||
            <p>Diese Webseite wird gerade neu entwickelt und steht demnächst zur Verfügung.</p>
 | 
			
		||||
 | 
			
		||||
            <form action="submit.php" method="post">
 | 
			
		||||
                <label for="firmenname">Firmenname:</label>
 | 
			
		||||
                <label for="firma">Firmenname:</label>
 | 
			
		||||
                <p>* kann als Platzhalter verwendet werden</p>
 | 
			
		||||
                <input type="text" id="firmenname" name="firmenname"><br><br>
 | 
			
		||||
                <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 (Postleitzahl / Ort):</label><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 (PLZ oder Ort)" id="sitzInput" onkeyup="filterFunction()" onchange="filterFunction()" name="sitzfilter" autocomplete="off">
 | 
			
		||||
                                <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>
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +94,7 @@
 | 
			
		|||
                                filterFunction()
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
                            function gefundeneGemeindenAuswählen() {
 | 
			
		||||
                            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;
 | 
			
		||||
| 
						 | 
				
			
			@ -112,41 +112,25 @@
 | 
			
		|||
                    </div>
 | 
			
		||||
                </div><br><br><br><br>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                <label for="rechtsform">Rechtsform:</label><br>
 | 
			
		||||
                <div class="scrollWindow">
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Einzelunternehmen"> Einzelunternehmen</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Kollektivgesellschaft"> Kollektivgesellschaft</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Aktiengesellschaft"> Aktiengesellschaft</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Gesellschaft mit beschränkter Haftung"> Gesellschaft mit beschränkter Haftung</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Genossenschaft"> Genossenschaft</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Verein"> Verein</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Stiftung"> Stiftung</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Institut des öffentlichen Rechts"> Institut des öffentlichen Rechts</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Zweigniederlassung"> Zweigniederlassung</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Kommanditgesellschaft"> Kommanditgesellschaft</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Zweigniederlassung einer ausl. Gesellschaft"> Zweigniederlassung einer ausl. Gesellschaft</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Kommanditaktiengesellschaft"> Kommanditaktiengesellschaft</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Besondere Rechtsform"> Besondere Rechtsform</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Gemeinderschaft"> Gemeinderschaft</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Investmentgesellschaft mit festem Kapital"> Investmentgesellschaft mit festem Kapital</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Investmentgesellschaft mit variablem Kapital"> Investmentgesellschaft mit variablem Kapital</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Kommanditgesellschaft für kollektive Kapitalanlagen"> Kommanditgesellschaft für kollektive Kapitalanlagen</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="Nichtkaufmännische Prokura"> Nichtkaufmännische Prokura</label><br>
 | 
			
		||||
                <label><input type="checkbox" name="rechtsform[]" value="(unbekannt)"> (unbekannt)</label><br>
 | 
			
		||||
                <div id = "rechtsformenauswahl" class="scrollWindow">
 | 
			
		||||
 | 
			
		||||
                </div>
 | 
			
		||||
                <br><br>
 | 
			
		||||
 | 
			
		||||
                <input type="checkbox" id="exakteSuche" name="exakteSuche">
 | 
			
		||||
                <label for="exakteSuche">Exakte Suche</label><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">
 | 
			
		||||
                <label for="inBisherigenFirmen">In bisherigen Firmen/Namen 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">
 | 
			
		||||
                <label for="phonetischeSuche">Phonetische Suche</label><br><br>
 | 
			
		||||
                <input type="checkbox" id="phonetischeSuche" name="phonetischeSuche" disabled>
 | 
			
		||||
                <label for="phonetischeSuche">Phonetische Suche (noch in Entwicklung)</label><br><br>
 | 
			
		||||
 | 
			
		||||
                <input type="submit" value="Suchergebnisse exportieren">
 | 
			
		||||
            </form>
 | 
			
		||||
| 
						 | 
				
			
			@ -154,36 +138,58 @@
 | 
			
		|||
            <script>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                // Parse CSV-Daten und fülle das Dropdown-Feld
 | 
			
		||||
 | 
			
		||||
                let csvData;
 | 
			
		||||
 | 
			
		||||
                let communityCsvData;
 | 
			
		||||
                let legalFormsCsvData;
 | 
			
		||||
                <?php
 | 
			
		||||
                    include 'api/zefixAPI.php';
 | 
			
		||||
                    include 'gemeinden.php';
 | 
			
		||||
                    include 'legalForms.php';
 | 
			
		||||
                ?>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                csvData = csvData.slice(1);
 | 
			
		||||
                // csvData = "PLZ,ORTBEZ,KANTON
 | 
			
		||||
                // 1000,Lausanne  Dépôt,VD
 | 
			
		||||
                // 1001,Lausanne,VD
 | 
			
		||||
                // 1002,Lausanne,VD"
 | 
			
		||||
                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 = csvData.trim().split('\n');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                const lines = communityCsvData.trim().split('\n');
 | 
			
		||||
                const headers = lines[0].split(',');
 | 
			
		||||
                const gemeindeNameIndex = headers.indexOf('Gemeindename');
 | 
			
		||||
                const plzIndex = headers.indexOf('PLZ');
 | 
			
		||||
                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 plz = cells[plzIndex].trim();
 | 
			
		||||
                    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)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -203,7 +209,7 @@
 | 
			
		|||
 | 
			
		||||
                    // Sitz hinzufügen
 | 
			
		||||
                    sitze.push(cells)
 | 
			
		||||
                    const sitzString = plz + " " + gemeindeName
 | 
			
		||||
                    const sitzString = gemeindeName
 | 
			
		||||
                    const gemeindeEintrag = document.createElement("div");
 | 
			
		||||
                    gemeindeEintrag.classList.add("gemeindeeintrag");
 | 
			
		||||
                    const label = document.createElement('label');
 | 
			
		||||
| 
						 | 
				
			
			@ -213,7 +219,7 @@
 | 
			
		|||
                    const input = document.createElement('input');
 | 
			
		||||
                    input.type = "checkbox";
 | 
			
		||||
                    input.name = "sitze[]";
 | 
			
		||||
                    input.value = plz;
 | 
			
		||||
                    input.value = bfsId;
 | 
			
		||||
                    label.textContent = " " + sitzString;
 | 
			
		||||
                    label.style.marginBottom = '0';
 | 
			
		||||
                    label.prepend(input);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
 | 
			
		||||
<?php
 | 
			
		||||
    echo "legalFormsCsvData = `". legalFormCSV($username, $password) ."`;";
 | 
			
		||||
?>
 | 
			
		||||
		Loading…
	
		Reference in New Issue