Save
This commit is contained in:
222
templates_user/pages-contact-form.php
Normal file
222
templates_user/pages-contact-form.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
if (\S::get('action') == 'pages_form_send') {
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$recaptchaSecret = '6Le9GhEqAAAAAKUCOPR9QGXs4G81OGZ2CxUOu7rW';
|
||||
$recaptchaResponse = $_POST['g-recaptcha-response'];
|
||||
|
||||
// Verify reCAPTCHA
|
||||
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$recaptchaSecret}&response={$recaptchaResponse}");
|
||||
$responseKeys = json_decode($response, true);
|
||||
|
||||
if ($responseKeys["success"]) {
|
||||
$hubspot_url = "https://api.hsforms.com/submissions/v3/integration/submit/7094950/21a84368-93fb-4a22-a35c-d7143f9dc3d3";
|
||||
$hubspotutk = isset($_COOKIE['hubspotutk']) ? $_COOKIE['hubspotutk'] : null;
|
||||
|
||||
$postData = [
|
||||
'fields' => [
|
||||
[
|
||||
'name' => 'liczba_transakcji_miesiecznie',
|
||||
'value' => $_POST['monthly_transactions']
|
||||
],
|
||||
[
|
||||
'name' => 'liczba_sklepow_stacjonarnych',
|
||||
'value' => $_POST['stationary_stores']
|
||||
],
|
||||
[
|
||||
'name' => 'liczba_sklepow_lub_wersji_jezykowych',
|
||||
'value' => $_POST['language_versions']
|
||||
],
|
||||
[
|
||||
'name' => 'email',
|
||||
'value' => $_POST['email'],
|
||||
],
|
||||
[
|
||||
'name' => 'phone',
|
||||
'value' => $_POST['phone'],
|
||||
]
|
||||
],
|
||||
'context' => [
|
||||
'hutk' => $hubspotutk,
|
||||
'pageUri' => 'https://zaufane.pl/',
|
||||
'pageName' => 'zaufane.pl'
|
||||
],
|
||||
'legalConsentOptions' => [
|
||||
'consent' => [
|
||||
'content' => 'By submitting this form, you agree that we may use the data you provide to contact you with information related to your request/submission and the relevant LinkedIn product. If you are a LinkedIn member, you can control the messages you receive from LinkedIn in your settings. If you are a guest, you can unsubscribe from LinkedIn marketing emails at any time by clicking the unsubscribe link in the email. To learn more, see LinkedIn\'s Privacy Policy.',
|
||||
'consentToProcess' => true,
|
||||
'text' => 'I agree to the processing of my personal data by LinkedIn.',
|
||||
'communications' => [
|
||||
[
|
||||
'value' => true,
|
||||
'subscriptionTypeId' => 8383894,
|
||||
'text' => 'I agree to receive marketing communications from LinkedIn.'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$jsonData = json_encode($postData);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init($hubspot_url);
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Check for errors
|
||||
if ($response === false) {
|
||||
$error = curl_error($ch);
|
||||
echo "cURL Error: $error";
|
||||
} else {
|
||||
// Decode response
|
||||
$responseData = json_decode($response, true);
|
||||
if (isset($responseData['inlineMessage'])) {
|
||||
echo "<div id='custom-form-response'><p>" . $responseData['inlineMessage'] . '</p></div>';
|
||||
} else {
|
||||
echo "<div id='custom-form-response'><p>" . $response . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Close cURL session
|
||||
curl_close($ch);
|
||||
?>
|
||||
<script class="footer">
|
||||
$(document).ready(function() {
|
||||
$('#custom-form-2').remove()
|
||||
})
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
// echo 'Please complete the CAPTCHA';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="custom-form-2">
|
||||
<input type="hidden" name="action" value="pages_form_send">
|
||||
|
||||
<div class="f-row">
|
||||
<p><strong>Średnia liczba transakcji miesięcznie:</strong></p>
|
||||
<span class="min">0</span>
|
||||
<span class="max">10000+</span>
|
||||
<input type="range" value="0" min="0" max="10000" step="50" name="monthly_transactions" id="">
|
||||
<output class="range-output">0</output>
|
||||
</div>
|
||||
<div class="f-row">
|
||||
<p><strong>Liczba sklepów lub wersji językowych:</strong></p>
|
||||
<span class="min">0</span>
|
||||
<span class="max">50</span>
|
||||
<input type="range" value="0" min="0" max="50" step="1" name="language_versions" id="">
|
||||
<output class="range-output">0</output>
|
||||
</div>
|
||||
<div class="f-row">
|
||||
<p><strong>Liczba sklepów stacjonarnych:</strong></p>
|
||||
<span class="min">0</span>
|
||||
<span class="max">100+</span>
|
||||
<input type="range" value="0" min="0" max="100" step="1" name="stationary_stores" id="">
|
||||
<output class="range-output">0</output>
|
||||
</div>
|
||||
<div class="f-row">
|
||||
<p><strong class="mb-3">Podaj email, aby otrzymać wycenę:</strong></p>
|
||||
|
||||
<div class="tile">
|
||||
<input type="email" name="email" id="form-email" placeholder="" required>
|
||||
<label for="form-email">Email*</label>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<input type="text" name="phone" id="form-phone" placeholder="" required>
|
||||
<label for="form-phone">Numer telefonu*</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="checkbox-row">
|
||||
<input type="checkbox" name="" id="checkbox-1" required>
|
||||
<label for="checkbox-1">*Wyrażam zgodę na otrzymywanie innych powiadomień od firmy ... <a href="#" id="info-for-checkbox-1">Więcej</a></label>
|
||||
</div>
|
||||
<div class="checkbox-row">
|
||||
<input type="checkbox" name="" id="checkbox-2" required>
|
||||
<label for="checkbox-2">*Wyrażam zgodę na przechowywanie i przetwarzanie moich danych ... <a href="#" id="info-for-checkbox-2">Więcej</a></label>
|
||||
</div>
|
||||
|
||||
<div class="g-recaptcha" data-sitekey="6Le9GhEqAAAAAASXQqtDHPWmC1qJyLocYLZD2KAR"></div>
|
||||
<button type="submit" class="btn1">Otrzymaj wycenę</button>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.checkbox-rows{
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 100%;
|
||||
max: 500px;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
padding: 40px;
|
||||
border-radius: 24px;
|
||||
border: 1px solid yellow;
|
||||
background: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script class="footer">
|
||||
$(document).ready(function() {
|
||||
$('body').on('click', '#info-for-checkbox-1', function (e) {
|
||||
e.preventDefault()
|
||||
$.alert({
|
||||
title: '',
|
||||
content: 'Wyrażam zgodę na otrzymywanie innych powiadomień od firmy Zaufane.pl. Aby zapewnić Państwu żądane treści, musimy przechowywać i przetwarzać Państwa dane osobowe. Jeśli wyrażają Państwo zgodę na przechowywanie Państwa danych osobowych w tym celu, prosimy zaznaczyć poniższe pole wyboru.',
|
||||
});
|
||||
})
|
||||
|
||||
$('body').on('click', '#info-for-checkbox-2', function (e) {
|
||||
e.preventDefault()
|
||||
$.alert({
|
||||
title: '',
|
||||
content: 'Wyrażam zgodę na przechowywanie i przetwarzanie moich danych osobowych przez firmę Zaufane.pl.* W każdej chwili mogą Państwo zrezygnować z tych komunikatów. Aby uzyskać więcej informacji na temat sposobu rezygnacji z subskrypcji, naszych zasad ochrony prywatności oraz tego, w jaki sposób zobowiązujemy się do ochrony i poszanowania prywatności, należy zapoznać się z naszą Polityką Prywatności.',
|
||||
});
|
||||
})
|
||||
|
||||
$('input[type="range"]').on('input', function() {
|
||||
var value = $(this).val();
|
||||
$(this).next('.range-output').text(value);
|
||||
});
|
||||
|
||||
|
||||
$(".f-row").each(function() {
|
||||
const range = $(this).find("input");
|
||||
const bubble = $(this).find(".range-output");
|
||||
|
||||
range.on("input", function() {
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
|
||||
function setBubble(range, bubble) {
|
||||
const val = range.val();
|
||||
const min = range.attr("min") ? range.attr("min") : 0;
|
||||
const max = range.attr("max") ? range.attr("max") : 100;
|
||||
const newVal = Number(((val - min) * 100) / (max - min));
|
||||
bubble.html(`${val}`);
|
||||
|
||||
bubble.css("left", `calc(${newVal}% + (${8 - newVal * 0.15}px))`);
|
||||
}
|
||||
|
||||
$('input[type="range"]').on('input', function() {
|
||||
var tempSliderValue = Number($(this).val());
|
||||
$(this).next('.range-output').text(tempSliderValue);
|
||||
|
||||
var progress = ((tempSliderValue / $(this).attr("max"))) * 100;
|
||||
$(this).css("background", `linear-gradient(to right, #ffbf0b ${progress}%, #ccc ${progress}%)`);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user