<?php header('Content-type: text/html; charset=utf-8' ); ?>
<?php
// для метода POST
foreach ($_POST['data1'] as $value) {
$product[] = $value;
$product_kol[] = 1;
}
//$product_kol[] = $_POST['data2'];
//детали заказа в кодировке utf-8
$param['secret'] = "NhKf8yQKhEtB4iSBaYyBtTiRHk6ZsF66QEaN3Rk8fGA9SdAT2YfeDsZaFR2ZiSR2hSB9yQ8EhyD3A4HkNRtb8ddDY4n6G5TSHfR6YNz573TySrGs73y65AzQrKGZDnDayf7eTs9RfS938Ge6yD2n4i4eYA5kNtn8BhbhDa2HT2zStEKR7A6ZHZ5thYFYbYSE5YNtYB5EkrhGTYiQfeBS4s99aFTdnBGfhhB6Ksz2GGtrrF6AKteBKdBNKf"; //ключ api
$param['street'] = $_POST['data5']; //улица
$param['phone'] = $_POST['data4']; //телефон
$param['descr'] = $_POST['data6']; //комментарий
$param['name'] = $_POST['data3']; //имя клиента
$param['datetime'] = $_POST['data7']; //datetime
//подготовка запроса
foreach ($param as $key => $value) {
$data .= "&".$key."=".$value;
}
//содержимое заказа
foreach ($product as $key => $value){
$data .= "&product[".$key."]=".$value."";
$data .= "&product_kol[".$key."]=".$product_kol[$key]."";
if(isset($product_mod[$key])) {
$data .= "&product_mod[".$key."]=".$product_mod[$key]."";
}
}
//отправка
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://app.frontpad.ru/api/index.php?new_order");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($ch);
//результат
echo $result;
?>
$("li").each(function (i,elem){
if ( $(elem).next("ul").length > 0 || $(elem).children("ul").length > 0 ) {
$(this).addClass("parent_selector");
}
});
$("li").each(function (i,elem){
if ( $(elem).next("ul").length > 0) {
$(this).addClass("parent_selector");
}
});
$('.workspace__header div .fa-plus').on('click', function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "./index.php",
data: "action=addProject",
});
});
// Contact form
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
method: "POST",
dataType: 'json',
data: {
message : form.children('input[name="message"]').val(),
name: form.children('input[name="name"]').val(),
email: form.children('input[name="email"]').val()
},
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});