From bd05621843350ce14df9cafa881df34a4812b01e Mon Sep 17 00:00:00 2001 From: schrom01 Date: Mon, 21 Aug 2023 20:37:59 +0200 Subject: [PATCH] Sitze und Rechtsformen aus Zefix API --- api/index.php | 92 +++++++++++++++-------------- api/zefixAPI.php | 147 +++++++++++++++++++++++++++++++++++++++++++++++ gemeinden.php | 2 +- index.php | 92 +++++++++++++++-------------- legalForms.php | 4 ++ 5 files changed, 249 insertions(+), 88 deletions(-) create mode 100644 api/zefixAPI.php create mode 100644 legalForms.php diff --git a/api/index.php b/api/index.php index 87d26f3..ae3c2d2 100644 --- a/api/index.php +++ b/api/index.php @@ -1,66 +1,70 @@ - "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; + ?> \ No newline at end of file diff --git a/api/zefixAPI.php b/api/zefixAPI.php new file mode 100644 index 0000000..89a80e8 --- /dev/null +++ b/api/zefixAPI.php @@ -0,0 +1,147 @@ + \ No newline at end of file diff --git a/gemeinden.php b/gemeinden.php index e56be0d..ec42b5d 100644 --- a/gemeinden.php +++ b/gemeinden.php @@ -1,4 +1,4 @@ diff --git a/index.php b/index.php index 5f2fd33..d96a710 100644 --- a/index.php +++ b/index.php @@ -51,21 +51,21 @@

Diese Webseite wird gerade neu entwickelt und steht demnächst zur Verfügung.

- +

* kann als Platzhalter verwendet werden

-

+



-
+