diff --git a/www/organic/external/bioc/operators.php b/www/organic/external/bioc/operators.php new file mode 100644 index 0000000..10c3260 --- /dev/null +++ b/www/organic/external/bioc/operators.php @@ -0,0 +1,99 @@ + 'a1e51f85-27b5-a1e3-65f7-561569884d38', + 'DE' => '1be4d468-ba47-08f1-f048-f45869af856f', +][$_GET['country'] ?? null] ?? null; +$postalCode = $_GET['postalCode'] ?? null; +$name = $_GET['name'] ?? null; +$idNr = $_GET['idNr'] ?? null; + +if ($country === null) { + header('Status: 400'); + header('Content-Length: 0'); + exit; +} + +$data = []; + +$url = "https://www.bioc.info/search/producerSearchQuery?search[name]=" . urlencode($name) . "&search[citycode]=" . urlencode($postalCode) . "&search[operatorId]=" . urlencode($idNr) . "&search[country]=$country"; +if ($_GET['allDBs'] === 'true') { + $s = curl_init($url . implode('&sources[]=', $source_groups[0])); + curl_setopt($s, CURLOPT_RETURNTRANSFER, true); + if (($json = curl_exec($s)) === false) { + header('Status: 500'); + header('Content-Length: 0'); + exit; + } + $res = json_decode($json, true)['results']; + foreach ($res as $r) { + $data[$r['id']] = $r['row']; + } +} + +$s = curl_init($url . implode('&sources[]=', $source_groups[1])); +curl_setopt($s, CURLOPT_RETURNTRANSFER, true); +if (($json = curl_exec($s)) === false) { + header('Status: 500'); + header('Content-Length: 0'); + exit; +} +$res = json_decode($json, true)['results']; +foreach ($res as $r) { + $data[$r['id']] = $r['row']; +} + +header('Content-Type: application/json; charset=UTF-8'); + +$first = true; +echo "{\"data\":[\n"; +foreach ($data as $id => $row) { + if (!$first) echo ",\n"; + $row = explode("') + 1), 2); + echo " "; + echo jenc([ + 'id' => $id, + 'name' => substr($row[0], strrpos($row[0], '>') + 1), + 'postalCode' => substr($row[1], strrpos($row[1], '>') + 1), + 'city' => substr($row[2], strrpos($row[2], '>') + 1), + 'authorityCode' => $auth[0], + 'authorityName' => $auth[1], + ]); + $first = false; +} +echo "\n]}\n"; + diff --git a/www/organic/external/bioqs/.operators.py b/www/organic/external/bioqs/.operators.py index 8481c7e..a5ac2ad 100755 --- a/www/organic/external/bioqs/.operators.py +++ b/www/organic/external/bioqs/.operators.py @@ -69,6 +69,7 @@ def main() -> None: 'validTo': '-'.join(reversed(srow[2].split('-'))), 'type': srow[3], 'attachmentSid': srow[4], + 'url': f'https://elwig.at/organic/external/bioqs/attachments/{urllib.parse.quote(srow[0])}', }) if not first: print(',', flush=True)