    <main>
<?php if(@$_GET["sil"]!=Null){
	unset($_SESSION["sepet"][$_GET["sil"]]);
	header("Location: ".settings("sepet_url"));
	exit;
}
unset($_SESSION["sepetindirim"]);
?>
<?php if(!isset($_SESSION["user"]) && $uyelikmodul["durum"]=="1"){ ?>
        <section id="alert__top">
            <div class="container">
                <div class="alert__container">
                    <div class="icon">
                        <i class="ri-alarm-warning-line"></i>
                    </div>
                    <div class="text">
                        Giriş yapmadığınız için işleme devam edemiyorsunuz. Üye girişi yapmak için lütfen
                        <a href="<?=$site;?>panel/login">buraya tıklayınız.</a>
                    </div>
                </div>
            </div>
        </section>
<?php }  elseif( $uyelikmodul["durum"]=="1"){ if($puser["ad"]==Null || $puser["soyad"]==Null || $puser["telefon"]==Null || $puser["ulke"]==Null || $puser["sehir"]==Null || $puser["ilce"]==Null || $puser["adres"]==Null) { ?>
        <section id="alert__top">
            <div class="container">
                <div class="alert__container">
                    <div class="icon">
                        <i class="ri-alarm-warning-line"></i>
                    </div>
                    <div class="text">
                        Üyelik bilgilerinizi tanımlamadınığınız için işleme devam edemiyorsunuz. Bilgilerinizi tanımlamak için lütfen
                        <a href="<?=$site;?>panel/index">buraya tıklayınız.</a>
                    </div>
                </div>
            </div>
        </section>
<?php } } ?>
    <!-- Order Form Start -->
    <section id="basket">
            <form action="" method="post" id="formposta">
			<input type="hidden" name="formupdate" value="2">
                <div class="container">
                    <div class="basket__container clear row">
                        <div class="col-xl-9 col-lg-8 col-md-12 form-left">
						
						
						<div class="basket__detail">
                            <div class="detail__top">
                                <span><i class="ri-shopping-cart-line"></i> Sepetim</span>
                                <h6>Sepetinizde toplam <strong><?php if(isset($_SESSION["sepet"])){ $add= count($_SESSION["sepet"]); } else{ $add= "0";} echo $add; ?> ürün</strong> mevcut.</h6>
                            </div>
                            <div class="detail__content <?php if(isset($_SESSION["sepet"]) && $add!="0"){  } else{ echo "clear";} ?>">
                                <div class="cart-details-main-block" <?php if(isset($_SESSION["sepet"]) && $add!="0"){ ?>id="dynamic-cart"<?php } ?>>
                                    <div class="cart-product cart-product-title d-flex flex-wrap d-none d-lg-flex align-items-center">
                                        <div class="product-block">
                                            <h3>Ürün / Hizmet</h3>
                                        </div>
                                        <div class="price-block">
                                            <h3>Adet</h3>
                                        </div>
                                        <div class="quantity-block">
                                            <h3 class="text-center">Tutar </h3>
                                        </div>
                                        <div class="total-block">
                                            <h3> </h3>
                                        </div>
                                    </div>
									<?php if(isset($_SESSION["sepet"]) && $add!="0"){ 
									$fiyat="0";
									$total="0";
									$indirimlifiyat="0";
									$kdv="0";
									
									foreach($_SESSION["sepet"] as $deg => $val){
								
										$adet=$val["adet"];
										$product=$val["product"];
	$data_query = $db->prepare("SELECT * FROM urun WHERE id=?");
    $data_query->execute(array($product));
    $data = $data_query->fetch(PDO::FETCH_ASSOC);
	
	
	
	$data["fiyat"]=$data["fiyat"]*$adet;
	$say=0;
	$inputops=array();
	$adx=array();
	while(isset($val["opsiyon"][$say])){
		$opt=$val["opsiyon"][$say];
		$opt=opsiyon($opt);
		if($opt["id"]!=Null && $opt["urun"]==$product){
			$opfiyat=$opt["fiyat"]*$adet;
			$data["fiyat"]=$data["fiyat"]+$opfiyat;
			$inputops[]=$_POST["opsiyon"][$say];
			$adx[]=$opt["ad"].": ".$opt["secenek"]." (+".$opfiyat."₺)";
		}
		$say++;
	}
	
	if($data["kargo_ucret"]!=Null){ 
	$data["fiyat"]=$data["fiyat"]+$data["kargo_ucret"];
	}
	
	if($data["fiyat_indirim"]!=Null){ 
	$data["fiyat_indirim"]=$data["fiyat_indirim"]*$adet;
	$say=0;
	while(isset($val["opsiyon"][$say])){
		$opt=$val["opsiyon"][$say];
		$opt=opsiyon($opt);
		if($opt["id"]!=Null && $opt["urun"]==$product){
			$opfiyat=$opt["fiyat"]*$adet;
			$data["fiyat_indirim"]=$data["fiyat_indirim"]+$opfiyat;
		}
		$say++;
	}
	// $indirimlifiyat=$data["fiyat_indirim"];
	if($data["kargo_ucret"]!=Null){ 
	$data["fiyat_indirim"]=$data["fiyat_indirim"]+$data["kargo_ucret"];
	}
	
	
	}
	
                            if($data["fiyat_indirim"]!=Null){
								$indirimlifiyat=$indirimlifiyat+$data["fiyat_indirim"];
								$total=$total+$data["fiyat_indirim"];
								$yaz=$data["fiyat_indirim"];
							}
							else{
								$total=$total+$data["fiyat"];
								$yaz=$data["fiyat"];
							}
	if(json_decode(settings("kdv"))->durum=="1"){ 
							$kdv=$kdv+$kdv2;
	}
								$fiyat=$fiyat+$data["fiyat"];
							
										?>
										
                                    <div class="product-cart-all-acrd-items">
                                        <div class="cart-product cart-product-body d-flex flex-wrap cart-item  overflow-hidden position-relative">
                                            <div class="product-block">
                                                <div class="d-flex align-items-center">
                                                    <div class="product__image">
                                                        <img src="<?=$site;?>upload/urun/<?=$data["resim"];?>" style="width:75px;" alt="">
                                                    </div>
                                                    <a href="#">
                                                       <?=$data["ad"];?>
                                                    <?php if($say!="0"){ ?>
													<p style="font-size:10px;"><?=implode(",",$adx);?></p><?php } ?></a>
                                                </div>
                                            </div>
                                            <div class="price-block d-flex align-items-center">
                                                <div class="quantity-block d-flex align-items-center">
                                                    <div class="input--amount-control d-flex ">
                                                        <button type="button" onclick="fiyatgunc('-','<?=$yaz;?>','<?=$data["id"];?>')" class="amount-dec-btn focus-reset">
                                                            -
                                                        </button>
                                                        <span class="position-relative">
                                                    <input type="number" onchange="fiyatgunc('+','<?=$yaz;?>','<?=$data["id"];?>')" min="1" <?php if($data["urun_stok"]!=Null){ ?>max="<?=$data["urun_stok"];?>"<?php } ?> name="adet[<?=$deg;?>]" class="form-control text-center" id="adetid<?=$data["id"];?>" value="<?=$adet;?>">
                                                  </span>
                                                        <button type="button" onclick="fiyatgunc('+','<?=$yaz;?>','<?=$data["id"];?>')" class="amount-inc-btn focus-reset">+</button>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="quantity-block d-flex align-items-center justify-content-center">
                                                <h4 class="mb-0" id="urunfiyat<?=$data["id"];?>"><?=$yaz;?> TL</h4>
                                            </div>
                                            <div class="total-block d-flex align-items-center">
                                                <div class="d-flex align-items-center justify-content-between w-100">
                                                    <a href="?sil=<?=$deg;?>" class="cross-btn-positioning"><i class="ri-delete-bin-5-line sepet"></i></a>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
										
										<?php
									}
									
									} 
									else{ ?>
									
									             <div class="product-cart-all-acrd-items">
                                        <div class="cart-product cart-product-body d-flex flex-wrap cart-item  overflow-hidden position-relative">
                                            <i class="ri-shopping-basket-2-line"></i>
                                            <p>Sepetinizde hiç ürün bulunmuyor.</p>
                                            <p class="second">Kaliteli hizmete erişmek için hemen sepetinize ürün ekleyin.</p>
                                        </div>
                                    </div>
									<?php } ?>
                       
                                </div>
                            </div>
                        </div>
						
						<div class="continue-shop-btn">
                            <a href="<?=$site;?>" class="btn focus-reset"><i class="ri-arrow-left-line"></i>Alışverişe Devam Et</a>
                        </div>
						
                      
                        </div>
                        <div class="col-xl-3 col-lg-4 col-md-12 order-info">
                    
                            <div class="order-info-inner">
                                <div class="inner-top">
                                    <span> <i class="ri-window-line"></i> Ücret Bilgisi</span>
                                    <p>İşlemlerinizin ücret detayı</p>
                                </div><?php if(isset($_SESSION["sepet"]) && $add!="0"){  ?>
                                <div class="inner-middle" style="padding-bottom:0px !important;" id="fiyatups">
                                    <ul>
		
                                        <?php if($indirimlifiyat!="0"){ ?>
                                            <li class="order-price">
                                                <span class="txt"><i class="ri-check-line"></i>Normal Fiyatı:</span>
                                                <span class="order-old-price ms-auto">
                                                    <del><?php echo $fiyat;?><strong>₺</strong></del>
                                                </span>
                                            </li>
                                            <li class="order-price">
                                                <span class="txt"><i class="ri-check-line"></i> İndirimli Fiyatı:</span>
                                                <span class="order-new-price ms-auto">
                                                <?php echo $total;?><strong>₺</strong>
                                                </span>
                                            </li>
                                        <?php } else{ ?>
                                            <li class="order-price">
                                                <span class="txt"><i class="ri-check-line"></i>Normal Fiyatı:</span>
                                                <span class="order-new-price ms-auto">
                                                   <?php echo $fiyat;?><strong>₺</strong>
                                                </span>
                                            </li>
                                        <?php } ?>
					
                                        <?php if(json_decode(settings("kdv"))->durum=="1"){
	$kdv=yuzdeHesaplama($total,json_decode(settings("kdv"))->yuzde); 
$total=$total+$kdv;	?>
                                            <li class="order-price">
                                                <span class="txt"> <i class="ri-check-line"></i> Kdv Tutarı:</span>
                                                <span class="order-new-price ms-auto">
                                                    <?php echo $kdv;?><strong>₺</strong>
                                                </span>
                                            </li>
                                        <?php } ?>
                                        <li class="order-price" id="komisyonli" style="display:none;">
                                            <span class="txt"><i class="ri-check-line"></i>Ödeme Komisyonu:</span>
                                            <span class="order-new-price ms-auto" id="komisyonode">
                                                0<strong>₺</strong>
                                            </span>
                                            </li>
                                        <li class="order-price">
                                            <span class="txt"><i class="ri-check-line"></i> Genel Toplam:</span>
                                            <span class="order-new-price ms-auto" id='komisyongenel'>
<div id="ntutar" style="display:none;"><?php
echo $total; ?></div>
                                            <?php 
                                            echo $total;?><strong>₺</strong>
                                         
                                            </span>
                                        </li>
                                    </ul>	 <?php 
$indirimkod=moduller("indirimkod");
if($indirimkod["durum"]=="1"){ ?>
        <div class="form-group mt-3" style="border-top: 1px solid var(--line);padding-top: 10px;">
                                            <label class="c-label" style="font-size: 15px;color: #111111;font-weight: 500;margin-bottom:10px;">İndirim Kodu (opsiyonel)</label>
                                            <input type="text" class="form-control" style="border-radius: 16px;border: 1px solid #dfecf5;" name="indirim" id="indirimcoe" onchange="indirimcheck(this.value)">
                                        </div>
                                        <div id="indirimdurum">
<div id="indx" style="display:none;">0</div>
</div><?php } ?>
                                </div> <?php if(!isset($_SESSION["user"]) && $uyelikmodul["durum"]=="1"){ ?>
                                <div class="inner-bottom" style="opacity:0.2;">
                                    <button type="submit" disabled>
                                        Şimdi Satın Al
                                    </button>
                                </div>
								<?php } else{
if($puser["ad"]==Null && $uyelikmodul["durum"]=="1" || $puser["soyad"]==Null && $uyelikmodul["durum"]=="1" || $puser["telefon"]==Null && $uyelikmodul["durum"]=="1" || $puser["ulke"]==Null && $uyelikmodul["durum"]=="1" || $puser["sehir"]==Null  && $uyelikmodul["durum"]=="1" || $puser["ilce"]==Null && $uyelikmodul["durum"]=="1" || $puser["adres"]==Null && $uyelikmodul["durum"]=="1") {  ?>
                                <div class="inner-bottom" style="opacity:0.2;">
                                    <button type="submit" disabled>
                                        Şimdi Satın Al
                                    </button>
                                </div>
								<?php
} else{
									?>
                                <div class="inner-bottom" style="opacity:1;">
                                    <button type="submit" name="al" value="1">
                                        Şimdi Satın Al
                                    </button>
                                </div>
								<?php }} ?>
								<?php } else{ ?>
                                <div class="inner-bottom" style="opacity:0.2;">
                                    <button type="submit" disabled>
                                        Şimdi Satın Al
                                    </button>
                                </div>
								
								<?php } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
    </section>
    <!-- Order Form End -->
    <script>
        var odemefiyat = <?php
echo $total; ?>;
        function yontem(deger) {
                $.post("<?=$site.settings("sepet_url");?>", {
                    'odemetutar': odemefiyat,
                    'odemesaglayici': deger,
                }, function(donenVeri) {
                    if (donenVeri == "0") {
                        document.getElementById("komisyonli").style.display = "none";
                        $("#komisyongenel").html('<div id="ntutar" style="display:none;">'+odemefiyat+'</div>'+odemefiyat + "<strong>₺</strong>");
                        <?php if($indirimkod["durum"]=="1"){ ?>
                        var tutar=$("#ntutar").html();
                        var intutar=$("#indx").html();
var hesap=tutar-intutar;
                        $("#komisyongenel").html('<div id="ntutar" style="display:none;">'+odemefiyat+'</div>'+hesap + "<strong>₺</strong>");
<?php } ?>
                    } else {
                        document.getElementById("komisyonli").style.display = "flex";
                        $("#komisyonode").html(donenVeri + "<strong>₺</strong>");
                        var fiyat = Number(odemefiyat) + Number(donenVeri);
                        fiyat = fiyat.toFixed(2);
                        $("#komisyongenel").html('<div id="ntutar" style="display:none;">'+fiyat+'</div>'+fiyat + "<strong>₺</strong>");
                        <?php if($indirimkod["durum"]=="1"){ ?>
                        var tutar=$("#ntutar").html();
                        var intutar=$("#indx").html();
var hesap=tutar-intutar;
                        $("#komisyongenel").html('<div id="ntutar" style="display:none;">'+fiyat+'</div>'+hesap + "<strong>₺</strong>");
<?php } ?>
                    }
                });
        }
    </script>
<script>
function indirimcheck(val){
	               $.post("<?=$site.settings("sepet_url");?>", {
                    'indirimkodcheck': val
                }, function(donenVeri) {
                    if (donenVeri == "-") {
                        $("#indirimdurum").html('<div id="indx" style="display:none;">0</div><div class="alert alert-danger">Hatalı indirim kodu girildi.</div>');
                        <?php if($indirimkod["durum"]=="1"){ ?>
                        var tutar=$("#ntutar").html();
                        var intutar=$("#indx").html();
var hesap=tutar-intutar;
                        $("#komisyongenel").html('<div id="ntutar" style="display:none;">'+tutar+'</div>'+hesap + "<strong>₺</strong>");
<?php } ?>
                    } else {
                        $("#indirimdurum").html('<div id="indx" style="display:none;">'+donenVeri+'</div><div class="alert alert-success">'+donenVeri+'₺ değerinde indirim kodu girildi.</div>');
        <?php if($indirimkod["durum"]=="1"){ ?>
                        var tutar=$("#ntutar").html();
                        var intutar=$("#indx").html();
var hesap=tutar-intutar;
                        $("#komisyongenel").html('<div id="ntutar" style="display:none;">'+tutar+'</div>'+hesap + "<strong>₺</strong>");
<?php } ?>
                    }
                });
}
</script>
						<script>
						function fiyatgunc(yon,miktar,id){
							setTimeout(function(){
								var adet = $('#adetid'+id).val();
								var hesap=miktar*adet;
								$('#urunfiyat'+id).html(hesap+" TL");
							
								var kod=$('#indirimcoe').val();
								var form_data = new FormData($('#formposta')[0]);
			$.ajax({
    type: 'POST',
    url: "<?=$site.settings("sepet_url");?>",
     async: false, 
     cache: false, 
     contentType: false, 
     processData: false, 
    data: form_data ,
    success: function (response) { 
$("#fiyatups").html(response);
if(kod!=undefined && kod!=""){  
$('#indirimcoe').val(kod);
		indirimcheck(kod);
}
	}
    
});
								}, 100);
						}
						</script>