<?php
require_once __DIR__ . '/config.php';

$pixels_head = '';
$pixels_body_top = '';
$pixels_body_bottom = '';

try {
    $tableExists = $pdo->query("SHOW TABLES LIKE 'ad_pixels'")->rowCount() > 0;
    if ($tableExists) {
        $stmt = $pdo->query("SELECT pixel_code, position FROM ad_pixels WHERE status = 1 AND (placement = 'all' OR placement = 'home') ORDER BY sort_order ASC, id ASC");
        $pixels = $stmt->fetchAll();
        foreach ($pixels as $p) {
            $pos = $p['position'] ?? 'head';
            if ($pos == 'head') {
                $pixels_head .= $p['pixel_code'] . "\n";
            } elseif ($pos == 'body-top') {
                $pixels_body_top .= $p['pixel_code'] . "\n";
            } else {
                $pixels_body_bottom .= $p['pixel_code'] . "\n";
            }
        }
    }
} catch(PDOException $e) {}
?>
<!DOCTYPE html>
<html lang="tr" dir="ltr">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Powzzers Max Power</title>
<meta name="description" content="Powzzers Max Power">

<link rel="stylesheet" href="assets/css/app0acb0acb.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@6.1/dist/fancybox/fancybox.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com/">
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&amp;display=swap" rel="stylesheet">
<style>
* { font-family: 'Poppins', sans-serif !important; }
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
@media (min-width: 1024px) {
  .container {
    width: 50%;
  }
}
.field-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15) !important;
    background-color: #fff5f5 !important;
    animation: shake 0.4s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}
.label-error {
    background-color: #fff5f5 !important;
    border-color: #dc3545 !important;
    animation: shake 0.4s ease-in-out;
}
</style>
<?php echo $pixels_head; ?>
</head>

<body class="bg-gray-50 theme-ap7-first-tr no-webp ltr page-index no-mobile">
<?php echo $pixels_body_top; ?>
<div class="container  mx-auto shadow-xl min-h-screen bg-white relative">
<div class="bg-gray-700 relative">
<a href="#cart"><img src="assets/images/bg/1.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/2.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/3.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/4.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/5.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/6.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/7.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/8.jpg" class="w-full h-auto select-none lazyload"></a>
<a href="#cart"><img src="assets/images/bg/9.jpg" class="w-full h-auto select-none lazyload"></a>
</div>



<form action="#" method="POST" class="block px-2 py-8 bg-white" id="formOrder" novalidate>

<div class="bg-gray-900 text-white font-extrabold xs:text-2xl text-xl justify-center w-full p-4 mb-6 flex items-center rounded">
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 me-4" viewbox="0 0 20 20" fill="currentColor">
<path d="M3 1a1 1 0 000 2h1.22l.305 1.222a.997.997 0 00.01.042l1.358 5.43-.893.892C3.74 11.846 4.632 14 6.414 14H15a1 1 0 000-2H6.414l1-1H14a1 1 0 00.894-.553l3-6A1 1 0 0017 3H6.28l-.31-1.243A1 1 0 005 1H3zM16 16.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM6.5 18a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"> </path>
</svg>
Sipariş Formu
</div>

<div class="bg-gray-200 text-gray-800 font-bold xs:text-xl text-lg w-full text-center px-4 py-3 mb-4 rounded" id="cart">
Lütfen Ürün Seçiminizi Yapınız
</div>

<div class="mb-9" id="product-section">

<label class="flex items-center space-x-6 cursor-pointer p-4 mb-4 w-full bg-white rounded-xl border border-gray-200 shadow-md focus:ring-2 focus:ring-blue-600 product-label">
<input type="radio" name="product" value="0" class="form-tick appearance-none h-6 w-6 border border-gray-300 rounded-full checked:bg-blue-600 checked:border-transparent focus:outline-none">
<div class="w-24 stage:block flex-shrink-0">
<img src="assets/images/0.jpg" class="w-full h-auto lazyload select-none" alt="Max Power Performans Kapsülü 30lu 1 Kutu">
</div>
<div class="text-gray-900 font-medium flex-grow flex flex-wrap label-checked:bg-green-700">
<div class="text-lg font-semibold mb-1" style="letter-spacing: -1px;">1 Kutu Max Power 30lu Kapsül</div>
<div class="flex items-center space-x-2 text-xl w-full">
<span class="text-red-800" style="text-decoration: line-through; letter-spacing: -2px;">
<span class="price">1,999.00TL</span> 
<span class="currency"></span>
</span>
<span class="text-gray-800 font-extrabold" style="letter-spacing: -1px;">
<span class="price">1,499.00TL</span> 
</span>
</div>
<span class="rounded bg-yellow-300 text-xs font-bold text-gray-700 px-2 py-1 mt-2 flex-shrink inline-block">BAŞLANGIÇ PAKETİ</span>
<span class="rounded bg-red-300 text-xs font-bold text-gray-700 px-2 py-1 mt-2 flex-shrink inline-block">ÜCRETSİZ KARGO</span>
</div>
</label>

<label class="flex items-center space-x-6 cursor-pointer p-4 mb-4 w-full bg-white rounded-xl border border-gray-200 shadow-md focus:ring-2 focus:ring-blue-600 product-label">
<input type="radio" name="product" value="1" class="form-tick appearance-none h-6 w-6 border border-gray-300 rounded-full checked:bg-blue-600 checked:border-transparent focus:outline-none" >
<div class="w-24 stage:block flex-shrink-0">
<img src="assets/images/1.jpg" class="w-full h-auto lazyload select-none" alt="Powzzers Max Power Krem">
</div>
<div class="text-gray-900 font-medium flex-grow flex flex-wrap label-checked:bg-green-700">
<div class="text-lg font-semibold mb-1" style="letter-spacing: -1px;">2 Kutu Max Power 30lu Kapsül</div>
<div class="flex items-center space-x-2 text-xl w-full">
<span class="text-red-800" style="text-decoration: line-through; letter-spacing: -2px;">
<span class="price">3,998.00TL</span> 
<span class="currency"></span>
</span>
<span class="text-gray-800 font-extrabold"  style="letter-spacing: -1px;">
<span class="price">2,299.00TL</span> 
<span class="currency"></span>
</span>
</div>
<span class="rounded bg-red-300 text-xs font-bold text-white-700 px-2 py-1 mt-2 flex-shrink inline-block">DENEYİM PAKETİ</span>
<span class="rounded bg-green-300 text-xs font-bold text-gray-700 px-2 py-1 mt-2 flex-shrink inline-block">ÜCRETSİZ KARGO</span>
<span class="rounded bg-yellow-300 text-xs font-bold text-gray-700 px-2 py-1 mt-2 flex-shrink inline-block" >KAYGANLAŞTIRICI JEL HEDİYE</span>
</div>
</label>

<label class="flex items-center space-x-6 cursor-pointer p-4 mb-4 w-full bg-white rounded-xl border border-gray-200 shadow-md focus:ring-2 focus:ring-blue-600 product-label">
<input type="radio" name="product" value="2" class="form-tick appearance-none h-6 w-6 border border-gray-300 rounded-full checked:bg-blue-600 checked:border-transparent focus:outline-none" checked>
<div class="w-24 stage:block flex-shrink-0">
<img src="assets/images/2.jpg" class="w-full h-auto lazyload select-none" alt="3 ADET Powzzers Max Power Göğüs Bakım Kremi 200ml">
</div>
<div class="text-gray-900 font-medium flex-grow flex flex-wrap label-checked:bg-green-700">
<div class="text-lg font-semibold mb-1" style="letter-spacing: -1px;">3 Kutu Max Power 30lu Kapsül</div>
<div class="flex items-center space-x-2 text-xl w-full">
<span class="text-red-800" style="text-decoration: line-through; letter-spacing: -1px;">
<span class="price">5,997.00TL</span> 
<span class="currency"></span>
</span>
<span class="text-gray-800 font-extrabold" style="letter-spacing: -1px;">
<span class="price">2,999.00TL</span> 
<span class="currency"></span>
</span>
</div>
<span class="rounded bg-yellow-300 text-xs font-bold text-gray-700 px-2 py-1 mt-2 flex-shrink inline-block">ÖNERİLEN PAKET</span>
<span class="rounded bg-red-300 text-xs font-bold text-gray-700 px-2 py-1 mt-2 flex-shrink inline-block">ÜCRETSİZ KARGO</span>
<span class="rounded bg-green-300 text-xs font-bold text-gray-700 px-2 py-1 mt-2 flex-shrink inline-block">GECİKTİRİCİ SPREY HEDİYE</span>
</div>
</label>
</div>
       
<div class="bg-gray-200 text-gray-800 font-bold xs:text-xl text-lg w-full text-center px-4 py-3 mb-4 rounded" id="teslimatbilgileri">
Teslimat Bilgileri
</div>

<label class="block mb-6">
<span class="text-gray-700 font-semibold">Adınız Soyadınız</span>
<input type="text" name="musteri_adisoyadi" id="musteri_adisoyadi" class="mt-1 block w-full rounded-md border-gray-300 shadow focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50" required="">
<div class="help-text">Lütfen ad soyad alanını eksiksiz giriniz.</div>
</label>

<label class="block mb-6">
<span class="text-gray-700 font-semibold">Cep Telefonu Numaranız</span>
<input type="tel" name="musteri_telefon" id="phone" class="mt-1 block w-full rounded-md border-gray-300 shadow focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50 mb-2" required="">
<div class="help-text">Lütfen cep telefonu numaranızı eksiksiz giriniz.</div>
</label>

<label class="block mb-6">
<span class="text-gray-700 font-semibold">İl</span>
<select id="Iller" name="musteri_il" required="" class="mt-1 block w-full rounded-md border-gray-300 shadow focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50 mb-2">
<option value="">Lütfen Bir İl Seçiniz</option>
</select>
<input type="text" name="customer_il" id="ilinput" hidden required="">
</label>

<label class="block mb-6">
<span class="text-gray-700 font-semibold">İlçe</span>
<select id="Ilceler" required="" name="musteri_ilce" disabled="disabled" class="mt-1 block w-full rounded-md border-gray-300 shadow focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50 mb-2">
<option value="">Lütfen Önce bir İl seçiniz</option>
</select>
</label>

<div class="block mb-6">
<span class="text-gray-700 font-semibold">Teslimat Adresiniz</span>
<textarea name="musteri_adres" id="musteri_adres" class="mt-1 block w-full rounded-md border-gray-300 shadow focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50" rows="3" required=""></textarea>
</div>

<div class="bg-gray-200 text-gray-800 font-bold xs:text-xl text-lg w-full text-center px-4 py-3 mb-4 mt-8 rounded">
Ödeme Seçenekleri
</div>

<div class="block mb-6" id="payment-section">
<div class="flex items-stretch space-x-6">

<label class="border border-gray-200 shadow bg-white px-4 py-3 w-1/3 rounded-lg cursor-pointer flex items-center payment-label">
<input type="radio" name="payment_type" checked value="kapidanakit" class="form-tick me-1 appearance-none h-4 w-4 border border-gray-300 rounded-full checked:bg-blue-600 checked:border-transparent focus:outline-none">
<span class="ms-2 text-gray-700 xs:text-sm font-semibold text-xs">KAPIDA NAKİT</span>
</label>

<label class="border border-gray-200 shadow bg-white px-4 py-3 w-1/3 rounded-lg cursor-pointer flex items-center payment-label">
<input type="radio" name="payment_type" value="kapidakart" class="form-tick me-1 appearance-none h-4 w-4 border border-gray-300 rounded-full checked:bg-blue-600 checked:border-transparent focus:outline-none">
<span class="ms-2 text-gray-700 xs:text-sm font-semibold text-xs">KAPIDA KART</span>
</label>

</div>
</div>

<div class="block mb-6 mt-8">
<div class="mt-2">

<button type="submit" class="flex items-center justify-center bg-green-600 hover:bg-green-700 text-white text-lg font-bold p-4 rounded shadow w-full btn-submit" data-loading-text="Lütfen bekleyin...">
<span class="btn-text">SİPARİŞİMİ TAMAMLA</span>
</button>
</div>
</div>

<div class="block mb-4 mt-2" id="agreement-section">
<label class="inline-flex items-start xs:text-sm text-xs">
<input type="checkbox" name="sales_agreement" id="sales_agreement" class="rounded border-gray-300 text-green-500 shadow-sm focus:border-blue-300 focus:ring focus:ring-offset-0 focus:ring-blue-200 focus:ring-opacity-50 mt-1" checked="">
<span class="ms-2"><a href="p/sales-agreement.html" style="font-weight:700;">Mesafeli Satış Sözleşmesi</a>ni okudum ve kabul ediyorum. Bu bilgiyi göndererek web sayfasının <a href="p/privacy-policy.html" style="font-weight:700;">Gizlilik Politikası</a>nı kabul ediyorum.</span>
</label>
</div>
</form>

<footer class="mt-8">

<div class="bg-gray-100 px-6 py-4">
<img src="assets/images/bg/cargo-firms.png" class="w-full h-auto select-none lazyload" width="863" height="140" alt="cargo-firms">
</div>

<div class="bg-gray-800 text-gray-300">

<div class="grid xs:grid-cols-2 grid-cols-1 gap-3 text-sm px-6 py-6">
<a href="p/faq.html" class="pl-4"><span class="opacity-50 mr-1 inline-block">&rsaquo;</span>Sıkça Sorulan Sorular</a>
<a href="p/privacy-policy.html" class="pl-4"><span class="opacity-50 mr-1 inline-block">&rsaquo;</span>Gizlilik Sözleşmesi</a>
<a href="p/refund-policy.html" class="pl-4"><span class="opacity-50 mr-1 inline-block">&rsaquo;</span>İade Şartları</a>
<a href="p/terms-of-use.html" class="pl-4"><span class="opacity-50 mr-1 inline-block">&rsaquo;</span>Kullanım Koşulları</a>
</div>

<div class="flex flex-wrap xs:flex-row flex-col border-t border-b border-gray-600 xs:py-0 py-6">
<div class="mb-4 xs:mb-0 px-4 xs:py-8 xs:border-r border-gray-600 w-full xs:w-1/2 text-center text-xs">
MESAİ SAATİ İÇİNDE VERİLEN SİPARİŞLER AYNI GÜN KARGOLANIR.
</div>

<div class="xs:py-8 px-4 w-full xs:w-1/2 text-center text-xs">
KAPIDA NAKİT YA DA KREDİ KARTI İLE ÖDEME YAPABİLİRSİNİZ.
</div>
</div>

<div class="py-6 px-6 text-sm italic font-semibold text-center">
Powzzers Max Power &copy; 2026
</div>
</div>
</footer>

</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.min.js"></script>
<script src="assets/ililce.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@6.1/dist/fancybox/fancybox.css" />
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@6.1/dist/fancybox/fancybox.umd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

<script>
    $(document).ready(function () {
        $('#phone').mask('0(000)000-00-00');
        
        $('#Iller').on('change', function() {
            var ilAdi = $(this).find('option:selected').text();
            $('#ilinput').val(ilAdi);
            clearError('musteri_il');
        });
        
        $('input, select, textarea').on('input change', function() {
            clearError($(this).attr('name'));
        });
    });
    
    function clearError(fieldName) {
        $('[name="' + fieldName + '"]').removeClass('field-error');
        $('.product-label').removeClass('label-error');
        $('.payment-label').removeClass('label-error');
        $('#agreement-section').find('label').removeClass('label-error');
    }
    
    function highlightErrors(fields) {
        $('.field-error').removeClass('field-error');
        $('.label-error').removeClass('label-error');
        
        if (!fields || fields.length === 0) return;
        
        var firstField = null;
        
        fields.forEach(function(field) {
            if (field === 'product') {
                $('.product-label').addClass('label-error');
                if (!firstField) firstField = '#product-section';
            } else if (field === 'payment_type') {
                $('.payment-label').addClass('label-error');
                if (!firstField) firstField = '#payment-section';
            } else if (field === 'sales_agreement') {
                $('#agreement-section').find('label').addClass('label-error');
                if (!firstField) firstField = '#agreement-section';
            } else {
                var el = $('[name="' + field + '"]');
                el.addClass('field-error');
                if (el.attr('type') === 'hidden') {
                    el = $('#Iller');
                    el.addClass('field-error');
                }
                if (!firstField && el.length) firstField = el;
            }
        });
        
        if (firstField) {
            $('html, body').animate({
                scrollTop: $(firstField).offset().top - 80
            }, 500);
        }
    }
    
    $("body").on("submit", "#formOrder", function (e) {
        e.preventDefault();
        var frm = $(this);
        var submitBtn = frm.find('.btn-submit');
        var btnOriginal = submitBtn.html();
        
        submitBtn.prop('disabled', true);
        submitBtn.html('<i class="fas fa-spinner fa-spin me-2"></i>Lütfen bekleyin...');
        
        $.ajax({
            type: 'POST',
            url: "post.php",
            data: frm.serialize(),
            error: function () {
                toastr.error("Bağlantı Hatası! Lütfen internet bağlantınızı kontrol edin.");
                submitBtn.prop('disabled', false);
                submitBtn.html(btnOriginal);
            },
            dataType: 'json',
            success: function (res) {
                submitBtn.prop('disabled', false);
                submitBtn.html(btnOriginal);
                
                if (res.status == 1) {
                    toastr.success(res.message);
                    setTimeout(function () {
                        if (res.redirect) {
                            window.location.href = res.redirect;
                        }
                    }, 1000);
                } else {
                    highlightErrors(res.fields);
                    toastr.error(res.message);
                }
            }
        });
    });
</script>
<?php echo $pixels_body_bottom; ?>
</body>
</html>
