<script>
document.querySelector("#addCar").addEventListener('click', function(){
swal({
title:"Добавление машины",
html:"<font size=4>Гос-номер: </font><br/><input id=\"swal-input2\" class=\"swal2-input\">",
showCancelButton: true,
confirmButtonText: "Добавить автомобиль",
cancelButtonText: "Назад",
confirmButtonColor: "#7AC29A",
focusConfirm: false,
allowOutsideClick: false,
showLoaderOnConfirm: true,
preConfirm: function() {
return new Promise(function(resolve) {
$.ajax({
url: '<?echo "{$siteUri}requests/payConfirmation.php";?>',
type: 'POST',
data: {orderID:"<?=$repairHash?>",payType:'card',payConfirmationCode:"<?=$sql['payConfirmationCode']?>"},
dataType: 'json'
})
.done(function(response){
if(response.error == 0){
swal({title:'готово!', html:'<font size=3>готово.</font>',type:'success'});
return;
}
else {
swal({
title: "Ошибка #"+response.error,
text: response.errortext,
type: 'error',
});
return;
}
})
.fail(function(){
swal({
title: "Ошибка",
html: "<font size=3>Возникла проблема на сервере.<br/>Запрос не обработан.</font> ",
type: 'error',
});
});
});
},
});
});
</script>
<script type="text/javascript">
$( "#swal-input2" ).keyup(function() {
$( "#swal-input2" ).autocomplete({
source: "<?echo "{$siteUri}autorepair/";?>create/car-s.php",
minLength: 1,
select: function( event, ui ) {
$('#swal-input2').val(ui.item.label);
}
});
} );
</script>