<?php
$path="../../";
include("../../map.php");
include("../../scripts.php");
//-- Sipariş No -->
$ysn=date("dmYGis");
if (empty($_SESSION["StoresaleID"]) OR $_SESSION["StoreCustomerID"]<>$_SESSION["UyeID"]){
    $sqls=mysqli_query($conn, "select * from eticaret where ne='sepet' and s1='".$_SESSION["UyeID"]."' "); $rsg=mysqli_fetch_assoc($sqls);
    if(mysqli_num_rows($sqls)>0){
		setcookie("StoresaleID", $rsg["t4"], time()+3600); $_SESSION["StoresaleID"]=$rsg["t4"]; $_SESSION["StoreCustomerID"]=$_SESSION["UyeID"];
	}else{
		setcookie("StoresaleID", "$ysn", time()+3600); $_SESSION["StoresaleID"]=$ysn; $_SESSION["StoreCustomerID"]=$_SESSION["UyeID"];
	}
}
//-- Sipariş No -->
$sqlc=mysqli_query($conn, "select * from t5 where id='".$_SESSION["UyeID"]."'"); $rsc=mysqli_fetch_assoc($sqlc);
?>
<script>
// sayfa yüklendiğinde overlay ekle
document.addEventListener("DOMContentLoaded", function(){

    var productPanel = document.querySelector(".panel.product-list");
    if(productPanel){

        // overlay divini oluştur
        var overlay = document.createElement("div");
        overlay.id = "products-overlay";
        overlay.innerHTML = '<div class="overlay-text">Lütfen müşteri seçin</div>';
        overlay.style.position = "absolute";
        overlay.style.top = 0;
        overlay.style.left = 0;
        overlay.style.right = 0;
        overlay.style.bottom = 0;
        overlay.style.background = "rgba(255,255,255,0.7)";
        overlay.style.backdropFilter = "blur(6px)";
        overlay.style.display = "flex";
        overlay.style.alignItems = "center";
        overlay.style.justifyContent = "center";
        overlay.style.fontSize = "18px";
        overlay.style.fontWeight = "bold";
        overlay.style.color = "#333";
        overlay.style.borderRadius = "4px";
        overlay.style.zIndex = 10;
        overlay.style.pointerEvents = "all"; // tıklamayı engelle
        
        // panel içine append et
        productPanel.style.position = "relative"; // overlay için parent relative olmalı
        productPanel.appendChild(overlay);

        // overlay toggle fonksiyonu
        function toggleProductsOverlay(){
            var uye = document.getElementById("UyeID").value;
            overlay.style.display = (uye == "0" || uye === "") ? "flex" : "none";
        }

        // sayfa yüklendiğinde kontrol
        toggleProductsOverlay();

        // select değişince kontrol et
        document.getElementById("UyeID").addEventListener("change", toggleProductsOverlay);
    }
});
</script>


<style>
#products-overlay{
    position:absolute;
    top:0; left:0; right:0; bottom:0;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(6px);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:18px;
    font-weight:bold;
    color:#333;
    border-radius:8px;
    z-index:10;
}
</style>
<style>
    table thead tr th {font-size:13px;}
</style>
<div class="alert alert-warning" id="err" style="display:none;"></div>
<?php if($_GET["step"]=="" or $_GET["step"]=="1"){?>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-users" aria-hidden="true"></i> <?php echo $t25;?> <span style="float:right;">#<?php echo $_SESSION["StoresaleID"]?></span></h3>
        </div>
        <div class="panel-body">
            <form id="uID" class="form">
                <div class="v3-col-md-3">
                    <select id="UyeID" name="UyeID" data-placeholder="<?php echo $t25s[0]." ".$sdil[221];?>" onChange="AjaxPResult('ajax.php?ne=eticaret&islem=satis','#uID','#err')" class="form-control chosen-select" tabindex="8">
                        <option value="0"><?php echo translate("Müşteri")?></option>
                        <?php $sql=mysqli_query($conn, "select * from t5 where t1 LIKE '%".$_GET["q"]."%' ".$luye.""); while($rsm=mysqli_fetch_assoc($sql)){?>
                            <option value="<?php echo $rsm["id"];?>" title="<?php echo $rsm["t1"];?>" alt="<?php echo $rsm["t1"];?>" style="color:#6699FF" <?php if ($rsm["id"]==$_SESSION["UyeID"]) {?>Selected<?php }?>><?php echo $rsm["t1"];?></option>
                        <?php }?>
                    </select>
                </div>
                <div class="v3-col-md-3">
                    <select name="s19ID" data-placeholder="<?php echo translate("İlgili")." ".$sdil[221];?>" onChange="AjaxPResult('ajax.php?ne=eticaret&islem=satis','#uID','#err')" class="form-control chosen-select" tabindex="8">
                        <option value="0"><?php echo translate("Yetkili")?> (Admin)</option>
                        <?php $sql=mysqli_query($conn, "select * from t5 where t1 LIKE '%".$_GET["q"]."%' ".$luye.""); while($rsm=mysqli_fetch_assoc($sql)){?>
                            <option value="<?php echo $rsm["id"];?>" title="<?php echo $rsm["t1"];?>" alt="<?php echo $rsm["t1"];?>" style="color:#6699FF" <?php if ($rsm["id"]==$_SESSION["s19ID"]) {?>Selected<?php }?>><?php echo $rsm["t1"];?></option>
                        <?php }?>
                    </select>
                </div>  
            </form>
        </div>
    </div>

    <div class="panel panel-default product-list">
        <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-cubes" aria-hidden="true"></i> <?php echo ctranslate("Ürün(ler)");?></h3>
        </div>
        <div class="panel-body">
            <table class="table table-no-more table-bordered table-striped mb-0">
                <thead>
                    <tr>
                        <th class=""><?php echo $sdil[39];?></th>
                        <th class="w5 tac"><?php echo $sdil[88]; //Birim?></th>
                        <th class="w5 tar"><?php echo translate("Kdv")?></th>
                        <th class="w10 tar"><?php echo $sdil[85]; //Fiyat?></th>
                        <th class="w10 tar"><?php echo $sdil[144]; //Tutar?></th>
                        <th class="w8"><?php echo $sdil[213];?></th>
                    </tr>
                </thead>
                <tbody>
                    <form action="?ne=eticaret&islem=satis&Sepet=ekle" method="post" id="Sform" name="Sform" autocomplete="off">
                        <tr class="addtr">
                            <td class="" style="position:relative;">
                                <div id="at1_name" style="display:none; position: absolute; right: 15px; top: 20px; width: 50%; overflow: hidden; height: 18px;"></div>
                                <input type="text" list="Pt4" id="at1" name="t1" class="form-control" value="" placeholder="<?php echo $t46;?>"  autofocus autocomplete="off">
                                <datalist ID="Pt4" style="display: none;"></datalist>
                                <select name="rb" data-placeholder="<?php echo $sdil[221]; //Varyasyon Seçiniz?>" style="display:none;" class="form-control w30 fl ml10" tabindex="8" id="var_select">
                                    <option value=""><?php echo $sdil[133]; //Varyasyon?></option>
                                </select>
                            </td>
                            <td class="w7 mw7 tw10">
								<div class="input-group">
								<input type="number" class="form-control tar mtal" style="text-align:right; border:1px solid #ced4da73 !important" value="1" onfocus="if(this.value == '1') { this.value = ''} " onblur="if(this.value == '') { this.value='1'; }" name="s5" id="as5">
								  <span class="input-group-addon" id="basic-addon1" style="padding: 5px;">
								  <select size=1 name="t10" id="at10" class="sfa sna" style="font-size: 9px; padding: 3px; border:0px !important;">
									<?php if(!empty($t28)){$sbirim = explode(',',$t28); foreach($sbirim as $sbrm) {$s++; if($s > 20) {$s = 1;}?>
									  <option value="<?php echo $sbrm;?>"><?php echo $sbrm;?></option>
									<?php }}?>
									</select>
								  </span>
								</div>
                        </td>
                        <td class="w5 mw5 tw7">
                            <input type="text" class="form-control" style=" border:0px; text-align:right;" value="<?php echo $module["s12"]?>" onfocus="if(this.value == '<?php echo $module["s12"]?>') { this.value = ''} " onblur="if(this.value == '') { this.value='<?php echo $module["s12"]?>'; }" id="as4" name="s4">
                        </td>
                        <td class="p0 mp0 w10 mw10 tw10" style="<?php if($_GET["islem"]<>"dservice"){echo "display:none;";}?>">
                            <div class="input-group">
                                <span class="input-group-addon" id="basic-addon1" style="padding: 5px;">
                                    <select class="sfa sna" name="t6" id="at6" style="font-size: 16px; padding: 3px;">
                                        <option value="TRY" <?php if($kpb=="TRY"){echo "selected";}?>>&#xf195;</option>
                                        <option value="EUR" <?php if($kpb=="EUR"){echo "selected";}?>>&#xf153;</option>
                                        <option value="USD" <?php if($kpb=="USD"){echo "selected";}?>>&#xf155;</option>
                                        <option value="GBP" <?php if($kpb=="GBP"){echo "selected";}?>>&#xf154;</option>
                                    </select>
                                </span>
                                <input type="text" name="fumaliyet" id="amaliyet" class="form-control repdot" style="border: 1px solid #ccc !important; text-align:right;" value="0.00" onfocus="if(this.value == '0.00') { this.value = ''} " onblur="if(this.value == '') { this.value='0.00'; }">
                            </div>
                        </td>
                        <td class="w10 mw10 tw10" style="<?php if($_GET["islem"]<>"dservice"){echo "display:none;";}?>">
                            <input type="text" name="fulfiyat" id="alprice" class="form-control repdot" style="border:0px; text-align:right;<?php if($rsfu["pb3"]<>0){echo "text-decoration: line-through;";}?>" value="0.00 " onfocus="if(this.value == '0.00') { this.value = ''} " onblur="if(this.value == '') { this.value='0.00'; }">
                        </td>
                        <td class="p0 mp0 w10 mw10 tw13">
                            <div class="input-group">
                                <span class="input-group-addon" id="basic-addon1" style="padding: 5px;">
                                    <select name="t2" class="sfa sna" style="font-size: 16px; padding: 3px;">
                                        <option value="TRY" <?php if($kpb=="TRY"){echo "selected";}?>>&#xf195;</option>
                                        <option value="EUR" <?php if($kpb=="EUR"){echo "selected";}?>>&#xf153;</option>
                                        <option value="USD" <?php if($kpb=="USD"){echo "selected";}?>>&#xf155;</option>
                                        <option value="GBP" <?php if($kpb=="GBP"){echo "selected";}?>>&#xf154;</option>
                                    </select>
                                </span>
                                <input type="text" name="price" class="form-control repdot" style="border: 1px solid #ccc !important; text-align:right;" value="0.00" onfocus="if(this.value == '0.00 <?php echo $kpb?>') { this.value = ''} " onblur="if(this.value == '') { this.value='0.00'; }" id="aprice"  aria-describedby="basic-addon1">
                            </div>
                        </td>
                        <td class="w10 mw10 tw10 tw10">
                            <input type="text" name="y6" id="atotal" class="form-control" style="border:0px; text-align:right;" value="0.00">
                        </td>
                        <td class="w10 mw10 tw10">
                            <button class="button with-tip" style="cursor:pointer;" type="button" onclick="AjaxPResult('ajax.php?ne=eticaret&islem=satis&Sepet=ekle','#Sform','#err')"><i class="fa fa-plus" aria-hidden="true"></i></button>
                        </td>
                    </tr>
                </form>
                <script type='text/javascript'>
                    jQuery(function() {
                        jQuery("#at1").keyup(delay(function(e){op(); }, 100));
                        jQuery("#at1").change(delay(function(e){op(); }, 100));
                        function op(){
                            var val = jQuery('#at1').val();
                            jQuery('#Pt4').load('../../modules/public/datalist.php?ne=kayit&val=t5&q='+val+'');
                            var price = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('price');
                            var pb = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('pb');
                            var unit = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('unit');
                            var lprice = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('lprice');
                            var mprice = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('mprice');
                            var tax = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('tax');
                            var id = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('id');
                            var attrvar = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('var');
                            var title = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('title');
                            var desc = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('desc');
                            if(attrvar=="1"){
                                show('var_select');
                                jQuery('#var_select').load('../../modules/public/products_var.php?id=' + id);
                            };
                            if(price !== undefined){
                                jQuery('#at1_name').show(); jQuery('#at1_name').html(title);
                                jQuery('#xaddtd').load('modules/services/attr.php?uid=' + id);
                                jQuery( "#as5" ).prop( "disabled", false ); jQuery("#as5").val('1');
                                jQuery( "#as4" ).prop( "disabled", false ); jQuery("#as4").val(tax);
                                jQuery( "#aprice" ).prop( "disabled", false ); jQuery("#aprice").val(price);
                                jQuery( "#alprice" ).prop( "disabled", false ); jQuery("#alprice").val(lprice);
                                if(mprice !== undefined){
                                    jQuery( "#amaliyet" ).prop( "disabled", false ); jQuery("#amaliyet").val(mprice);
                                }else{
                                    jQuery( "#amaliyet" ).prop( "disabled", false ); jQuery("#amaliyet").val(price);
                                }
                                jQuery('#atotal').prop('disabled', false); jQuery('#atotal').val(price);
                                jQuery('#at6').prop('disabled', false); jQuery("#at6").val(pb);
                                jQuery('#at10').prop('disabled', false); jQuery("#at10").val(unit);
                                jQuery('#an2').val(desc);
                            }else{
                                jQuery( "#as5" ).prop( "disabled", false ); jQuery("#as5").val('1');
                                jQuery( "#as4" ).prop( "disabled", false ); jQuery("#as4").val('<?php echo $module["s12"]?>');
                                jQuery( "#aprice" ).prop( "disabled", false ); jQuery("#aprice").val('0');
                                jQuery( "#atotal" ).prop( "disabled", false ); jQuery("#atotal").val('0');
                                jQuery("#an2").val(desc);
                            }
                        }
                        jQuery("#as5, #aprice").keyup(function(){
                            var s5 = jQuery('#as5').val();
                            var price = jQuery('#aprice').val();
                            jQuery("#atotal").val(price.replace(',','')*s5);
                        });
                        jQuery("#maliyet").keyup(function(){
                            var price = jQuery('#maliyet').val();
                            jQuery("#aprice").val(price.replace(',',''));
                        });
                        jQuery("#var_select").change(function(){
                            var price = jQuery('option:selected', this).data('price');
                            var id = jQuery('option:selected', this).data('id');
                            jQuery( "#as5" ).prop( "disabled", false ); jQuery("#as5").val('1');
                            jQuery( "#aprice" ).prop( "disabled", false ); jQuery("#aprice").val(price);
                            jQuery( "#atotal" ).prop( "disabled", false ); jQuery("#atotal").val(price);
                            jQuery("#an2").val(desc);
                        });
                        jQuery("#addtr").click(function(){
                            vtr('xaddtr');
                        });
                    });
                </script>
                <?php
                $sqls = mysqli_query($conn, "select * from eticaret where ne='sepet' and t4='".$_SESSION["StoresaleID"]."' and t5='sepet' order by id desc");
                  //if(mysqli_num_rows($sqls)==0){echo $sdil[145];}
                while($rsepet=mysqli_fetch_assoc($sqls)){
                    $ufiyat=$rsepet["pb1"];
                    $sqlu = mysqli_query($conn, "select * from ".$_SESSION['lang']." where id=".$rsepet["s3"].""); $rsu=mysqli_fetch_assoc($sqlu);
                    ?>
                    <form id="Sf<?php echo $rsepet["id"]?>" action="?ne=eticaret&islem=satis&Sepet=guncelle" method="post" class="v3-col-md-12" style="padding:0px; margin:0px;" autocomplete="off">
                        <input type="hidden" name="id" value="<?php echo $rsepet["id"]?>" />
                        <input type="hidden" name="s2" value="<?php echo $rsepet["s2"]?>" />
                        <input type="hidden" name="s3" value="<?php echo $rsepet["s3"]?>" />
                        <input type="hidden" name="s5" value="<?php echo $rsepet["s5"]?>" />
                        <tr>
                            <td><input type="text" name="t1" class="form-control" placeholder="Adı" value="<?php echo $rsu["t1"]?>"></td>
                            <td>
								<div class="input-group">
								  <input type="number" name="adet" class="form-control tar mtal" style="text-align:right; border:1px solid #ced4da73 !important" value="<?php echo $rsepet["s2"]?>" onfocus="if(this.value == '<?php echo $rsepet["s2"]?>') { this.value = ''} " onblur="if(this.value == '') { this.value='<?php echo $rsepet["s2"]?>'; }">
								  <span class="input-group-addon" id="basic-addon1" style="padding: 5px;">
								  <select size=1 name="t10" class="sfa sna" style="font-size: 9px; padding: 3px; border:0px !important;">
									<?php if(!empty($t28)){$sbirim = explode(',',$t28); foreach($sbirim as $sbrm) {$s++; if($s > 20) {$s = 1;}?>
										<option value="<?php echo $sbrm;?>" <?php if($rsepet["t10"]==$sbrm) {echo "Selected"; }?>><?php echo $sbrm;?></option>
									<?php }}?>
									</select>
								  </span>
								</div>
                        </td>
                        <td><input type="text" name="s4" id="" class="form-control" placeholder="Kdv" value="<?php echo $rsepet["s4"]?>" style="text-align: right;"></td>
                        <td class="p0 mp0 w10 mw10 tw10">
                            <div class="input-group">
                                <span class="input-group-addon" id="basic-addon1" style="padding: 5px;">
                                    <select class="sfa sna" name="t6" id="at6" style="font-size: 16px; padding: 3px;">
                                        <option value="TRY" <?php if($rsfu["t6"]=="TRY"){echo "selected";}?>>&#xf195;</option>
                                        <option value="EUR" <?php if($rsfu["t6"]=="EUR"){echo "selected";}?>>&#xf153;</option>
                                        <option value="USD" <?php if($rsfu["t6"]=="USD"){echo "selected";}?>>&#xf155;</option>
                                        <option value="GBP" <?php if($rsfu["t6"]=="GBP"){echo "selected";}?>>&#xf154;</option>
                                    </select>
                                </span>
                                <input type="text" name="pb1" class="form-control repdot notranslate" style="border: 1px solid #ccc !important; text-align:right;" value="<?php echo wprice($rsepet["pb1"]);?>" onfocus="if(this.value == '<?php echo wprice($rsepet["pb1"]);?>') { this.value = ''} " onblur="if(this.value == '') { this.value='<?php echo wprice($rsepet["pb1"]);?>'; }">
                            </div>
                        </td>
                        <td><input type="text" name="tfiyat" id="" class="form-control" placeholder="Tutar" value="<?php echo wprice($rsepet["pb1"]*$rsepet["s2"]);?>" style="text-align: right;"></td>
                        <td>
                            <button class="button with-tip" style="cursor:pointer;" type="button" onclick="AjaxPResult('ajax.php?ne=eticaret&islem=satis&Sepet=guncelle','#Sf<?php echo $rsepet["id"]?>','#err')" title="<?php echo $sdil[203]; //Düzenle?>"><i class="fa fa-refresh" aria-hidden="true"></i></button>
                            <button class="button with-tip" style="cursor:pointer;" type="button" onclick="AjaxGResult('ajax.php?ne=eticaret&islem=satis&Sepet=cikar&id=<?php echo $rsepet["id"]?>','','')" title="<?php echo $sdil[204]; //Kaldir?>" class="button with-tip"><i class="fa fa-times" aria-hidden="true"></i></button>
                        </td>
                    </tr>
                </form>
                <?php
                $skdv    += string_to_float($rsepet["pb3"]) * $rsepet["s2"];
				$sdesi   += $rsepet["s6"] * $rsepet["s2"];
				$toplam2 += string_to_float($rsepet["pb4"]) * $rsepet["s2"];
				$toplam1 += string_to_float($rsepet["pb2"]) * $rsepet["s2"];

                if($_SESSION["UyeID"]<>""){
                    $rsepet = mysqli_query($conn, "update eticaret set s1='".$_SESSION["UyeID"]."' where id=".$rsepet["id"]."");
                }
            }
            ?>
            <tr class="">
                <td colspan="3"></td>
                <td class="tar"><?php echo $adil[86]; //?></td>
                <td class="tar mw50 mfr"><input style="text-align: right;" type="text" name="atoplam" class="form-control" placeholder="<?php echo $adil[86]; //?>" value="<?php echo wprice($toplam1-$skdv);?>"></td>
                <td></td>
            </tr>
            <tr class="">
                <td colspan="3"></td>
                <td class="tar"><?php echo $adil[87]; //?></td>
                <td class="tar mw50 mfr"><input style="text-align: right;" type="text" name="ktoplam" class="form-control" placeholder="<?php echo $adil[86]; //?>" value="<?php echo wprice($skdv);?>"></td>
                <td></td>
            </tr>
            <?php if($module["hizmet_ucreti"]<>""){?>
                <tr class="">
                    <td colspan="3"></td>
                    <td class="tar"><?php echo translate("Sevkiyat Ücreti");?></td>
                    <?php
                    if($module["hizmet_limit"]-$toplam1>0){
                        $toplam1=$module["hizmet_ucreti"]+$toplam1;
                        ?>
                        <td class="tar mw50 mfr"><input style="text-align: right;" type="text" name="" class="form-control" placeholder="" value="<?php echo wprice($module["hizmet_ucreti"]);?>"></td>
                    <?php }else{?>
                        <td class="tar mw50 mfr"><input style="text-align: right;" type="text" name="" class="form-control" placeholder="" value="<?php echo translate("+#Ücretsiz Servis")?>"></td>
                    <?php }?>
                    <td></td>
                </tr>
            <?php }?>
            <tr class="">
                <td colspan="3"></td>
                <td class="tar"><?php echo $adil[113]; //?></td>
                <td class="tar mw50 mfr"><input style="text-align: right;" type="text" name="gtoplam" class="form-control" placeholder="<?php echo $adil[86]; //?>" value="<?php echo wprice($toplam1);?>"></td>
                <td></td>
            </tr>
            <tr>
                <td colspan="5" style="text-align: right;">
                    <a title="Kasaya Git" href="?ne=eticaret&islem=satis&step=2" class="v3-btn v3-btn-sm v3-btn-success"><?php echo $adil[89]; //?> <i class="fa fa-chevron-right" aria-hidden="true"></i></a>
                </td>
                <td></td>
            </tr>
        </tbody>
    </table>
</div>
</div>
<script type='text/javascript'>
    jQuery(function() {
        jQuery("#at1").change(function(){
            var val = jQuery('#at1').val();
            var price = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('price');
            var total = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('total');
            var tax = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('tax');
            var id = jQuery('#Pt4 option').filter(function() { return this.value == val; }).data('id');
            jQuery( "#as5" ).prop( "disabled", false);
            jQuery("#as5").val('1');
            jQuery( "#as4" ).prop( "disabled", false);
            jQuery("#as4").val(tax);
            jQuery( "#aprice" ).prop( "disabled", false);
            jQuery("#aprice").val(price);
            jQuery( "#atotal" ).prop( "disabled", false);
            jQuery("#atotal").val(total);
            jQuery("#UrunID").val(id);
            
        });
        jQuery("#as5").keyup(function(){
            var s5 = jQuery('#as5').val();
            var price = jQuery('#aprice').val();    
            jQuery("#atotal").val(price*s5);
        });
    });
</script>
<div>
<?php }elseif($_GET["step"]=="2"){?>
    <form id="Oform" class="form" action="?ne=eticaret&islem=satis&Siparis=odeme&step=2" method="post">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-cubes" aria-hidden="true"></i> <?php echo ctranslate("Ürün(ler)");?></h3>
            </div>
            <div class="panel-body">
                <table class="table " cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th width=""><?php echo $t46;?></th>
                            <th width="15%"><?php echo $sdil[88]; //Birim?></th>
                            <th width="15%" class="tar"><?php echo $sdil[85]; //Fiyat?></th>
                            <th width="20%" style="text-align:right;"><?php echo $sdil[144]; //Tutar?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $sqls = mysqli_query($conn, "select * from eticaret where ne='sepet' and t4='".$_SESSION["StoresaleID"]."' and t5='sepet' order by id desc");
                        if(mysqli_num_rows($sqls)==0){echo $sdil[145];}
                        while($rsepet=mysqli_fetch_assoc($sqls)){
                            $ufiyat=$rsepet["pb1"];
                            $sqlu = mysqli_query($conn, "select * from ".$_SESSION['lang']." where id=".$rsepet["s3"].""); $rsu=mysqli_fetch_assoc($sqlu);
                            ?>
                            <tr>
                                <td><?php echo $rsu["t1"]?></td>
                                <td><?php echo $rsepet["s2"]?></td>
                                <td class="tar"><?php echo number_format($ufiyat,2);?></td>
                                <td style="text-align:right;"><?php echo number_format(($ufiyat*$rsepet["s2"]),2);?></td>
                            </tr>
                            <?php 
                            $skdv    += string_to_float($rsepet["pb3"]) * $rsepet["s2"];
							$sdesi   += $rsepet["s6"] * $rsepet["s2"];
							$toplam2 += string_to_float($rsepet["pb4"]) * $rsepet["s2"];
							$toplam1 += string_to_float($rsepet["pb2"]) * $rsepet["s2"];

                        }
                        ?>
                        <tr>
                            <td colspan="2"></td>
                            <td style="text-align: right;"><?php echo $adil[86]; //?></td>
                            <td style="text-align: right;"><input type="text" name="atoplam" class="form-control" placeholder="<?php echo $adil[86]; //?>" value="<?php echo number_format(($toplam1-$skdv),2);?>" style="text-align:right;"></td>
                        </tr>
                        <tr style="">
                            <td colspan="2"></td>
                            <td style="text-align: right;"><?php echo $adil[87]; //?></td>
                            <td style="text-align: right;"><input type="text" name="ktoplam" class="form-control" placeholder="<?php echo $adil[86]; //?>" value="<?php echo number_format(($skdv),2);?>" style="text-align:right;"></td>
                        </tr>
                        <?php if($module["hizmet_ucreti"]<>""){?>
                            <tr>
                                <td colspan="2"></td>
                                <td style="text-align: right;"><?php echo translate("Sevkiyat Ücreti");?></td>
                                <?php
                                if($module["hizmet_limit"]-$toplam1>0){
                                    $toplam1=$toplam1+$module["hizmet_ucreti"];
                                    $toplam2=$toplam1-$module["hizmet_ucreti"];
                                    $kargof=$module["hizmet_ucreti"];
                                    if($module["hizmet_oran"]<>100 and $module["hizmet_oran"]<>""){
                                        $hizmet_komisyon=$module["hizmet_ucreti"] - ($module["hizmet_ucreti"] * ((100 - $module["hizmet_oran"]) / 100));
                                    }else{
                                        $hizmet_komisyon=0;
                                    }
                                    if($_SESSION["s19Komisyon"]<>"" or $hizmet_komisyon<>0){
                                        $komisyon = $toplam2 - ($toplam2 * ((100 - $_SESSION["s19Komisyon"]) / 100)) + $hizmet_komisyon;
                                    }else{
                                        $komisyon = 0;
                                    }
                                    ?>
                                    <td ><input style="text-align: right;" type="text" name="" class="form-control" placeholder="" value="<?php echo number_format(($module["hizmet_ucreti"]),2);?>"></td>
                                <?php }else{
                                    $kargof=0;
                                    ?>
                                    <td ><input style="text-align: right;" type="text" name="" class="form-control" placeholder="" value="<?php echo translate("+#Ücretsiz Servis")?>"></td>
                                <?php }?>
                            </tr>
                        <?php }?>
                        <tr>
                            <td colspan="2"></td>
                            <td style="text-align: right;"><?php echo $adil[113]; //?></td>
                            <td style="text-align: right;"><input type="text" name="gtoplam" total="<?php echo number_format(($toplam1),2)?>" id="total" class="form-control" placeholder="<?php echo $adil[86]; //?>" value="<?php echo number_format(($toplam1),2);?>" style="text-align:right;"></td>
                        </tr>
                        <tr style="<?php if($komisyon==0){echo "display:none;";}?>">
                            <td colspan="2"></td>
                            <td style="text-align: right;"><?php echo translate("Komisyon"); //?></td>
                            <td style="text-align: right;"><input type="text" name="okomisyon" class="form-control" placeholder="<?php echo $adil[86]; //?>" value="<?php echo number_format(($komisyon),2);?>" style="text-align:right;"></td>
                        </tr>
                    </tbody>
                </table>
                <?php $i=0;$sqli=mysqli_query($conn, "select * from genel where ne='inputs' and (t2='".$_SESSION["lang"]."' or t2='All') and n3='siparis' and n7<>'0' and s1=0 order by s10 asc");?>
                <?php if(mysqli_num_rows($sqli)>0){?>
                    <div class="v3-row" style="<?php if($mobile<>""){?>margin-top:10px;<?php }else{?>margin-top:15px; padding-bottom: 0px;<?php }?>clear:both;">
                        <?php while($rsi=mysqli_fetch_assoc($sqli)){$i++;?>
                            <div class="v3-col-md-3" style="">
                                <label><?php echo $rsi["n1"];?> <span style="font-size:8px; color:#ccc;"> (i<?php echo $i;?>)</span></label>
                                <?php if($rsi["n4"]=="input"){?>
                                    <input style="" class="v3-form-control i<?php echo $i;?>" type="<?php echo $rsi["n5"]?>" id="i<?php echo $i;?>" name="i<?php echo $i;?>" value="<?php echo $rs["i".$i.""];?>" style="" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>>
                                <?php }elseif($rsi["n4"]=="textarea"){?>
                                    <textarea style="" class="v3-form-controli <?php echo $i;?>" id="i<?php echo $i;?>" name="i<?php echo $i;?>" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>><?php echo $rs["i".$i.""];?></textarea>
                                <?php }elseif($rsi["n4"]=="select"){?>
                                    <select style="" class="v3-form-control i<?php echo $i;?>" id="i<?php echo $i;?>" name="i<?php echo $i;?>[]" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>>
                                        <option value=""><?php echo $sdil[221]; //Lütfen Seçiniz?></option>
                                        <?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
                                            <option value="<?php echo $rso["n2"]?>" <?php if($rso["n2"]==$sayfa2 or $rso["n3"]==1){echo "selected";}?>><?php echo $rso["n1"]?></option>
                                        <?php }?>
                                    </select>
                                <?php }elseif($rsi["n4"]=="radio"){?>
                                    <?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
                                        <div style="float:left; margin-right: 5px;">
                                            <label style="float:left; margin-right:5px;"><?php echo $rso["n1"];?>
                                            <input type="radio" class="i<?php echo $i;?>" name="i<?php echo $i;?>" value="<?php echo $rso["n2"];?>" <?php echo $rsi["n8"]?> <?php if($rs["i".$i.""]==$rso["n2"] or $rso["n3"]==1){echo "checked";}?>>
                                        </label>
                                    </div>
                                <?php }?>
                            <?php }elseif($rsi["n4"]=="checkbox"){?>
                                <?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
                                    <div style="float:left; margin-right: 5px;">
                                        <label style="float:left; margin-right:5px;"><?php echo $rso["n1"];?>
                                        <input type="checkbox" class="i<?php echo $i;?>" name="i<?php echo $i;?>[]" value="<?php echo $rso["n2"];?>" <?php echo $rsi["n8"]?> <?php foreach($jsi["i".$i.""] as $q){if($q==$rso["n2"] or $rso["n3"]==1){echo "checked";}}?>>
                                    </label>
                                </div>
                            <?php }?>
                        <?php }?>
                        <p style="font-size:10px;"><?php echo $rsi["n9"];?></p>
                    </div>
                <?php }?>
            </div>
        <?php }?>
    </div>
</div>
<div class="">
    <div class="panel panel-default">
        <div class="panel-body" style="padding:0px">
            <?php $sql_dadress=mysqli_query($conn, "select * from t1 where ne='adress' and t1='uye' and s1=".$_SESSION["UyeID"]." order by s10 desc"); ?>
            <div class="col-md-6" style="height: 155px; overflow: auto;">
                <div class="row">
                    <div class="panel-heading bg-warning"><?php echo translate("Teslimat adresi")?> <a class="mfrm fa fa-pencil-square-o" data-toggle="modal" data-width="50%" data-target="#myModal" data-ref="<?php echo $weburl?>/<?php echo $crmpath?>/?ne=eticaret&islem=satis&step=2" data-url="../account/account_adress_pop.php?uid=<?php echo $_SESSION["UyeID"]?>" data-title="<?php echo translate("Adresler")?>" style="font-size: 20px; cursor:pointer;float:right;"></a></div>
                    <!--<label style="width:100%;" id=""><?php echo $sdil[32];?></label>-->
                    <div class="owl-carousel owl-theme">
                        <?php
                        $a=0; while($nx=mysqli_fetch_assoc($sql_dadress)){$a++; $jsi = json_decode($nx["n16"],true);
                        if($nx["n16"]==""){
                            $n1=$nx["n1"]; $n6=$nx["n6"];
                        }else{
                            $n1=$jsi["n1"]; $n6=$jsi["n6"];
                        }
                        ?>
                        <div class="item" style="padding:5px;">
                            <label for="dc<?php echo $nx["id"]?>" style="width:100%; border:1px solid #ccc; padding:10px; border-radius:10px; font-weight:100; cursor:pointer;">
                                <input type="radio" id="dc<?php echo $nx["id"]?>" name="Delivery_AdressID" value="<?php echo $nx["id"]?>" style="float: left; margin-right: 5px;" <?php if($a==1){echo "checked";}?>>
                                <b><?php echo $n1;?></b><br><?php echo $n6;?>
                            </label>
                        </div>
                    <?php }?>
                </div>
            </div>
        </div>
        <div class="col-md-6" style="height: 155px; overflow: auto;">
            <div class="row">
                <div class="panel-heading bg-warning"><?php echo translate("Fatura adresi")?> <a class="mfrm fa fa-pencil-square-o" data-toggle="modal" data-width="50%" data-target="#myModal" data-ref="<?php echo $weburl?>/<?php echo $crmpath?>/?ne=eticaret&islem=satis&step=2" data-url="../account/account_adress_pop.php?uid=<?php echo $_SESSION["UyeID"]?>" data-title="<?php echo translate("Adresler")?>" style="font-size: 20px; cursor:pointer;float:right;"></a></div>
                <!--<label style="width:100%;"><?php echo translate("Fatura Adresi");?></label>-->
                <div class="owl-carousel owl-theme">
                    <?php $a=0; $sql_dadress=mysqli_query($conn, "select * from t1 where ne='adress' and t1='uye' and s1=".$_SESSION["UyeID"]." order by s10 desc"); ?>
                    <?php
                    $a=0; while($nx=mysqli_fetch_assoc($sql_dadress)){$a++; $jsi = json_decode($nx["n16"],true);
                    if($nx["n16"]==""){
                        $n1=$nx["n1"]; $n6=$nx["n6"];
                    }else{
                        $n1=$jsi["n1"]; $n6=$jsi["n6"];
                    }
                    ?>
                    <div class="item" style="padding:5px;">
                        <label for="ic<?php echo $nx["id"]?>" style="width:100%; border:1px solid #ccc; padding:10px; border-radius:10px; font-weight:100; cursor:pointer;">
                            <input type="radio" id="ic<?php echo $nx["id"]?>" name="Invoice_AdressID" value="<?php echo $nx["id"]?>" style="float: left; margin-right: 5px;" <?php if($a==1){echo "checked";}?>>
                            <b><?php echo $n1;?></b><br><?php echo $n6;?>
                        </label>
                    </div>
                <?php }?>
            </div>
        </div>
    </div>
    <div class="col-md-3" style="margin-top:15px">
        <fieldset style="height: 100px;">
            <legend><?php echo translate("Sevkiyat Ücreti");?></legend>
            <select name="sevkiyat" class="form-control" id="sevkiyat">
                <?php if($kargof==0){?>
                    <option value="0+0+<?php echo translate("Ücretsiz Sevkiyat")?>"><?php echo translate("Ücretsiz Sevkiyat")?></option>
                <?php }else{?>
                    <option value="0+<?php echo $kargof;?>+<?php echo translate("Sevkiyat Ücreti");?>"><?php echo translate("Sevkiyat Ücreti");?> {<?php echo $module["hizmet_ucreti"]?> <?php echo $kpb?>}</option>
                    <option value="0+0+<?php echo translate("Ücretsiz Servis")?>"><?php echo translate("Ücretsiz Servis")?></option>
                <?php }?>
                <?php
                $sqlk = mysqli_query($conn, "select * from genel where ne='kargo' order by s10 asc"); while($rsk = mysqli_fetch_assoc($sqlk)){$n++;
                    $sqld = mysqli_query($conn, "select * from genel where ne='desi' and s1=".$rsk["id"]." and s2 <= intval(".$sdesi.") and s3 >= intval(".$sdesi.") order by s10 asc"); $rsd = mysqli_fetch_assoc($sqld);
                    if(mysqli_num_rows($sqld)>0){ $kargof=$rsd["pb1"]; }else{ $kargof="0"; } $kargo=$rsk["t1"];
                    ?>
                    <option value="<?php echo $rsk["id"];?>+<?php echo $kargof;?>+<?php echo $kargo;?>"><?php echo $rsk["t1"];?> [<?php if($kargof==0){?> <?php echo $adil[41];?> <?php }else{?> <?php echo $kargof;?> <?php }?>]</option>
                <?php }?>
            </select>
        </fieldset>
    </div>
    <div class="col-md-3" style="margin-top:15px">
        <fieldset style="height: 100px;">
            <legend><?php echo translate("Ödeme Tipi")?></legend>
            <select name="odeme" class="form-control" onchange="diger(this);" id="odeme">
                <option value="nakit+0+Nakit"><?php echo translate("Nakit")?></option>
                <?php $sql = mysqli_query($conn, "select * from genel where ne='banka' and s2=0 order by s10 asc"); if(mysqli_num_rows($sql)>0){ ?>
                    <optgroup label="<?php echo translate("Havale")?>">
                        <?php while($rs = mysqli_fetch_assoc($sql)){?>
                            <option value="havale+<?php echo $rs["s1"];?>+<?php echo $rs["t1"];?>"><?php echo $rs["t1"];?></option>
                        <?php }?>
                    </optgroup>
                <?php }?>
                <option value="pos+0+Pos"><?php echo translate("Pos")?></option>
                <option value="cari+0+Cari"><?php echo translate("Cari")?></option>
                <option value="diger+0+Diger"><?php echo translate("Diğer")?></option>
            </select>
        </fieldset>
    </div>
    <div class="col-md-3" style="margin-top:15px">
        <fieldset style="height: 100px;">
            <legend><?php echo translate("Fatura Adresi")?></legend>
            <input type="text" name="fno" value="" class="form-control" placeholder="<?php echo translate("Fatura No")?>" style="position: absolute; text-align: right; right: 15px; top: -3px; background: white !important; width: 60%; border: 1px solid grey !important; height: 25px;">
            <textarea name="n2" rows="3" class="form-control"></textarea>
        </fieldset>
    </div>
    <?php if($f3==1){?>
        <div class="col-md-3" style="margin-top:15px">
            <fieldset style="height: 100px;">
                <legend><?php echo translate("Teslimat Adresi")?></legend>
                <textarea name="n3" rows="3" class="form-control"></textarea>
            </fieldset>
        </div>
    <?php }?>
    <div class="col-md-12" style="">
        <fieldset style="">
            <legend onclick="toggle('#n10')"><?php echo translate("Not")?></legend>
            <div id="n10" style="display:none;">
                <textarea name="n10" style="height:100px;" class="form-control" placeholder="Sipariş Notu"></textarea>
            </div>
        </fieldset>
    </div>
    <div class="col-md-12" style="text-align: right; margin-top: 15px; margin-bottom: 15px;">
        <button id="kasabtn" title="Kasaya Git" type="button" onclick="AjaxPResult('ajax.php?ne=eticaret&islem=satis&Siparis=odeme&step=2','#Oform','#err')" class="btn btn-success" style=""><?php echo $adil[89]; //?> <i class="fa fa-chevron-right" aria-hidden="true"></i></button>
    </div>
</div>
<input type="hidden" name="okdv" value="<?php echo $skdv?>">
<input type="hidden" name="odesi" value="<?php echo $sdesi?>">
<input type="hidden" name="otoplam" value="<?php echo $toplam1?>">
</form>
</div>
</div>
<script type='text/javascript'>
    jQuery(document).ready(function(){
        if( !jQuery('#odeme,#sevkiyat').val() ) {
            jQuery('#kasabtn').prop('disabled', true);
        }
    });
    jQuery('#odeme,#sevkiyat').change(function() {
        if( !jQuery('#odeme,#sevkiyat').val() ) {
            jQuery('#kasabtn').prop('disabled', true);
        }else{
            jQuery('#kasabtn').prop('disabled', false);
        }
    });
    jQuery(function() {
        jQuery("#total").keyup(function(){
            var old_total = $(this).attr("total");
            var new_total = $(this).val();
            var number0 = Number(old_total.replace(/[^0-9.-]+/g,""));
            var number1 = Number(new_total.replace(/[^0-9.-]+/g,""));
            var stotal = number0-number1;
            var gtotal = stotal/<?php echo ($s12+100)/100?>;  
            $("#sale").val(gtotal.toFixed(2));
        });
        jQuery("#sale").keyup(function(){
            var old_total = $(this).attr("total");
            var sale = $(this).val();
            var number0 = Number(old_total.replace(/[^0-9.-]+/g,""));
            var number1 = Number(sale.replace(/[^0-9.-]+/g,""));
            var stotal = number0-number1;
            var gtotal = stotal*<?php echo ($s12+100)/100?>;
            $("#total").val(gtotal.toFixed(2));
        });
    });
</script>
<?php
}elseif($_GET["step"]=="3"){
    echo location("?ne=eticaret&islem=siparisler",self,500,1);
    ?>
    <div style="width:50%; margin-left: auto; margin-right: auto; padding: 50px; text-align: center; font-size: 40px;">
        <img src="../../../deppo/tools/img/saved.gif" style="background: transparent; box-shadow: none; margin-top:30px;"><br><br><br> <?php echo translate("Sipariş oluşturuldu")?>
    </div>
<?php }?>
</div>
</div>
</div>
</div>
</div>
</div>
<!--</form>-->
<?php echo $footer?>
<script>
jQuery( document ).ready(function() {
	jQuery('#cs9').on('change', function () {
		var ID = jQuery('#cs9 option:selected').val(); // Veya `data-id` kullanabilirsiniz
		jQuery('#pgrid').load('../public/datalist.php?ne=kayit&model=grid&Cat_ID=' + ID+'');
		if (ID) {
			jQuery('#cs10').load('../ajax/categorie<?php if($module["ajax_categories"]<>""){echo "s";}?>_ajax.php?ne=kayit&islem=kategori&islem=ualt_kategori&c=' + ID, function () {
				jQuery('#cs10').trigger('chosen:updated');
			});
		}
	});
	jQuery('#cs10').on('change', function () {
		var ID = jQuery('#cs10').val(); // Çoklu seçim için tüm seçilen değerleri alır (dizi olarak döner)
		if (ID) {
			jQuery('#pgrid').load('../public/datalist.php?ne=kayit&model=grid&Cat_ID=' + ID+'');
			jQuery('#cs11').load('../ajax/categorie<?php if($module["ajax_categories"]<>""){echo "s";}?>_ajax.php?ne=kayit&islem=kategori&islem=ualt_kategori2&c=' + ID, function () {
				jQuery('#cs11').trigger('chosen:updated');
			});
		}
	});
	jQuery('#cs11').on('change', function () {
		var ID = jQuery('#cs11').val(); // Çoklu seçim için tüm seçilen değerleri alır (dizi olarak döner)
		jQuery('#pgrid').load('../public/datalist.php?ne=kayit&model=grid&Cat_ID=' + ID+'');
	});
});
	jQuery('.owl-carousel').owlCarousel({
		loop:false,
		margin:10,
		nav:true,
		responsive:{
			0:{
				items:1
			},
			600:{
				items:3
			},
			1000:{
				items:3
			}
		}
	})
    function diger(that) {
        if (that.value == "diger+0+Diger") {
  //document.getElementById("diger").style.display = "block";
        } else {
  //document.getElementById("diger").style.display = "none";
        }
    }
</script>