91 lines
2.4 KiB
PHP
91 lines
2.4 KiB
PHP
<?php
|
|
include 'zefixAPI.php';
|
|
|
|
$taskDir = 'tasks';
|
|
|
|
/*
|
|
* Request Types:
|
|
* Count
|
|
* List
|
|
* Export
|
|
*/
|
|
// Request data
|
|
$data = array();
|
|
$data["maxEntries"] = 50;
|
|
$data["offset"] = 0;
|
|
$data["languageKey"] = "de";
|
|
$results = array();
|
|
|
|
// Wenn Firmenname vorhanden
|
|
if(isset($_POST['firma']) && !empty($_POST['firma'])) {
|
|
$data["name"] = $_POST['firma'];
|
|
}
|
|
|
|
// Wenn gelöschte auch gesucht werden sollen
|
|
if(isset($_POST['geloeschteRechtseinheiten'])) {
|
|
$data["deletedFirms"] = true;
|
|
} else {
|
|
$data["deletedFirms"] = false;
|
|
}
|
|
|
|
//TODO get from Frontend
|
|
$data["searchType"] = "exact";
|
|
|
|
$rechtsformen = array();
|
|
if (isset($_POST['rechtsformen']) && is_array($_POST['rechtsformen']) && count($_POST['rechtsformen']) > 0) {
|
|
$rechtsformen = $_POST['rechtsformen'];
|
|
} else {
|
|
$legalFormArray = json_decode(sendAPILegalFormRequest($username, $password), true);
|
|
foreach ($legalFormArray as $rechtsform) {
|
|
$rechtsformen[] = $rechtsform["id"];
|
|
}
|
|
}
|
|
|
|
$sitze = array();
|
|
if (isset($_POST['sitze']) && is_array($_POST['sitze']) && count($_POST['sitze']) > 0) {
|
|
$sitze = $_POST['sitze'];
|
|
} else {
|
|
$communityArray = json_decode(sendAPICommunityRequest($username, $password), true);
|
|
foreach ($communityArray as $community) {
|
|
$sitze[] = $community["bfsId"];
|
|
}
|
|
}
|
|
|
|
$requests_to_do = Array();
|
|
// Loop through the selected values
|
|
foreach ($rechtsformen as $rechtsform) {
|
|
$data["legalForms"] = Array(intval($rechtsform));
|
|
|
|
// Loop through the selected values
|
|
foreach ($sitze as $sitz) {
|
|
$data["legalSeats"] = Array(intval($sitz));
|
|
$requests_to_do[] = $data;
|
|
}
|
|
|
|
}
|
|
$taskdata = Array();
|
|
$taskdata['requests'] = $requests_to_do;
|
|
$taskdata['email'] = $_POST['email'];
|
|
$taskString = json_encode($taskdata);
|
|
if(!is_dir($taskDir)){
|
|
mkdir($taskDir, 0755, true);
|
|
}
|
|
$taskfilename = $taskDir.'/'.time().'-'.bin2hex(random_bytes(4)).'.json';
|
|
$taskfile = fopen($taskfilename, 'w');
|
|
if($taskfile){
|
|
fwrite($taskfile, $taskString);
|
|
fclose($taskfile);
|
|
echo "Wir haben Ihren Auftrag erhalten. Sie erhalten von uns eine E-Mail, sobald die Daten zum Download bereit sind. Dies kann je nach Datenmenge lange dauern.";
|
|
echo '<br><a href="index.php">Zurück zur Startseite</a>';
|
|
} else {
|
|
echo "Ein Fehler ist aufgetreten.";
|
|
}
|
|
|
|
//$constructed_response = $response;
|
|
|
|
// Send the response back to the client
|
|
//header('Content-Type: application/json');
|
|
//echo $constructed_response;
|
|
|
|
|
|
?>
|