diff --git a/ShowActs/show-to-Docu b/ShowActs/show-to-Docu new file mode 100644 index 0000000..ecb89e4 --- /dev/null +++ b/ShowActs/show-to-Docu @@ -0,0 +1,123 @@ + trim($_POST['act_name'] ?? ''), + "person_count" => intval($_POST['person_count'] ?? 1), + "duration" => intval($_POST['duration'] ?? 0), + "description" => trim($_POST['description'] ?? ''), + "tech_needs" => trim($_POST['tech_needs'] ?? ''), + "contact_name" => trim($_POST['contact_name'] ?? ''), + "email" => filter_var(trim($_POST['email'] ?? ''), FILTER_VALIDATE_EMAIL), + "total_price" => trim($_POST['total_price'] ?? ''), + "terms_accepted" => isset($_POST['terms']) ? true : false +]; + +if (empty($api_key) || $api_key === 'DEIN_DOCUSEAL_API_KEY') { + die("Konfigurationsfehler: API-Key wurde nicht hinterlegt."); +} +if (!$data['email'] || empty($data['act_name']) || empty($data['contact_name'])) { + die("Validierungsfehler: Bitte fülle alle Pflichtfelder korrekt aus."); +} +if (!$data['terms_accepted']) { + die("Validierungsfehler: Die Teilnahmebedingungen müssen akzeptiert werden."); +} + +$payload = [ + "template_id" => $template_id, + "send_email" => false, + "submitters" => [ + [ + "email" => $data['email'], + "name" => $data['contact_name'], + "fields" => [ + [ + "name" => "act_name", + "default_value" => $data['act_name'] + ], + [ + "name" => "ansprechpartner", + "default_value" => $data['contact_name'] + ], + [ + "name" => "email", + "default_value" => $data['email'] + ], + [ + "name" => "anzahl_personen", + "default_value" => (string)$data['person_count'] + ], + [ + "name" => "dauer_minuten", + "default_value" => (string)$data['duration'] + ], + [ + "name" => "beschreibung", + "default_value" => $data['description'] + ], + [ + "name" => "technik", + "default_value" => $data['tech_needs'] + ], + [ + "name" => "gesamtbetrag", + "default_value" => $data['total_price'] + ], + [ + "name" => "teilnahmebedingungen", + "default_value" => true + ] + ] + ] + ] +]; + +$ch = curl_init($api_url); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_POST, true); +curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); +curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); +curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'X-Auth-Token: ' . $api_key, + 'Content-Type: application/json' +]); +$response = curl_exec($ch); +$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); +$curl_error = curl_error($ch); +if ($http_code === 200 || $http_code === 201) { + $responseData = json_decode($response, true); + $submitter = $responseData[0] ?? []; + $signing_url = $submitter['url'] ?? null; + if (!$signing_url && !empty($submitter['slug'])) { + $signing_url = "URL EINFÜGEN" . $submitter['slug']; + } + if ($signing_url) { + header("Location: " . $signing_url); + exit; + } else { + echo "
" . htmlspecialchars($response) . ""; + exit; + } + +} else { + echo "
HTTP-Code: " . htmlspecialchars($http_code) . "
"; + echo "API-Antwort von DocuSeal: " . htmlspecialchars($response) . "
"; + echo "Interner cURL-Fehler: " . htmlspecialchars($curl_error) . "
"; + exit; +} \ No newline at end of file