2023-08-17 19:08:24 +02:00
|
|
|
<?php
|
2023-08-21 20:37:59 +02:00
|
|
|
include 'zefixAPI.php';
|
2023-08-21 17:08:15 +02:00
|
|
|
|
2023-09-25 12:43:51 +02:00
|
|
|
$taskDir = 'tasks';
|
2023-09-25 11:55:08 +02:00
|
|
|
|
2023-08-21 20:37:59 +02:00
|
|
|
/*
|
|
|
|
* Request Types:
|
|
|
|
* Count
|
|
|
|
* List
|
|
|
|
* Export
|
|
|
|
*/
|
2023-08-17 21:38:35 +02:00
|
|
|
// Request data
|
2023-08-21 20:37:59 +02:00
|
|
|
$data = array();
|
|
|
|
|
|
|
|
$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["activeOnly"] = false;
|
|
|
|
} else {
|
|
|
|
$data["activeOnly"] = true;
|
2023-08-17 21:38:35 +02:00
|
|
|
}
|
|
|
|
|
2023-08-21 20:37:59 +02:00
|
|
|
$rechtsformen = array();
|
|
|
|
if (isset($_POST['rechtsform']) && is_array($_POST['rechtsform']) && count($_POST['rechtsform']) > 0) {
|
|
|
|
$rechtsformen = $_POST['rechtsform'];
|
|
|
|
} else {
|
2023-09-25 11:13:53 +02:00
|
|
|
$legalFormArray = json_decode(sendAPILegalFormRequest($username, $password), true);
|
|
|
|
foreach ($legalFormArray as $rechtsform) {
|
|
|
|
$rechtsformen[] = $rechtsform["id"];
|
|
|
|
}
|
2023-08-21 20:37:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$sitze = array();
|
|
|
|
if (isset($_POST['sitze']) && is_array($_POST['sitze']) && count($_POST['sitze']) > 0) {
|
|
|
|
$sitze = $_POST['sitze'];
|
|
|
|
} else {
|
2023-09-25 11:13:53 +02:00
|
|
|
$communityArray = json_decode(sendAPICommunityRequest($username, $password), true);
|
|
|
|
foreach ($communityArray as $community) {
|
|
|
|
$sitze[] = $community["bfsId"];
|
|
|
|
}
|
2023-08-21 20:37:59 +02:00
|
|
|
}
|
2023-09-25 12:33:12 +02:00
|
|
|
|
|
|
|
$requests_to_do = Array();
|
2023-08-21 20:37:59 +02:00
|
|
|
// Loop through the selected values
|
|
|
|
foreach ($rechtsformen as $rechtsform) {
|
|
|
|
$data["legalFormId"] = $rechtsform;
|
2023-08-17 21:38:35 +02:00
|
|
|
|
2023-08-21 20:37:59 +02:00
|
|
|
// Loop through the selected values
|
|
|
|
foreach ($sitze as $sitz) {
|
|
|
|
$data["legalSeatId"] = $sitz;
|
2023-09-25 11:55:08 +02:00
|
|
|
//$response = sendAPICompanySearchRequest($username, $password, $data);
|
2023-09-25 12:33:12 +02:00
|
|
|
$requests_to_do[] = $data;
|
2023-08-21 20:37:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-09-25 12:33:12 +02:00
|
|
|
$taskdata = Array();
|
|
|
|
$taskdata['requests'] = $requests_to_do;
|
2023-09-25 14:29:53 +02:00
|
|
|
$taskdata['email'] = $_POST['email'];
|
2023-09-25 12:33:12 +02:00
|
|
|
$taskString = json_encode($taskdata);
|
2023-09-25 12:43:51 +02:00
|
|
|
if(!is_dir($taskDir)){
|
|
|
|
mkdir($taskDir, 0755, true);
|
|
|
|
}
|
|
|
|
$taskfilename = $taskDir.'/'.time().'-'.bin2hex(random_bytes(4)).'.txt';
|
2023-09-25 11:55:08 +02:00
|
|
|
$taskfile = fopen($taskfilename, 'w');
|
|
|
|
if($taskfile){
|
|
|
|
fwrite($taskfile, $taskString);
|
|
|
|
fclose($taskfile);
|
2023-09-25 13:49:34 +02:00
|
|
|
echo "Task written to file";
|
2023-09-25 11:55:08 +02:00
|
|
|
} else {
|
2023-09-25 12:43:51 +02:00
|
|
|
echo "Task not written to file";
|
2023-09-25 11:55:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//$constructed_response = $response;
|
2023-08-17 21:38:35 +02:00
|
|
|
|
|
|
|
// Send the response back to the client
|
2023-08-21 20:37:59 +02:00
|
|
|
//header('Content-Type: application/json');
|
|
|
|
//echo $constructed_response;
|
|
|
|
|
2023-08-21 21:16:49 +02:00
|
|
|
|
2023-08-17 19:08:24 +02:00
|
|
|
?>
|