<?php
	$path="../../";
	include("../../map.php");
	include("../../scripts.php");
	$sqlt=mysqli_query($conn, "select * from genel where ne='ftasarim'"); $rst=mysqli_fetch_assoc($sqlt);
	if(mysqli_num_rows($sqlt)==0){
		$sqli = $conn->query("insert into genel (ne) values ('ftasarim')");
	}
	$fadres = explode(',',$rst["n1"]);
	$ftarih = explode(',',$rst["n2"]);
	$furunler = explode(',',$rst["n3"]);
	$ftoplam = explode(',',$rst["n4"]);
	$fyaziile = explode(',',$rst["n5"]);
	$fvd = explode(',',$rst["n6"]);
	$fvn = explode(',',$rst["n7"]);
	if($rst["t9"]<>""){
		$fsize = $rst["t9"];
	}else{
		$fsize = 10;
	}
?>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>
<link href="ruler/ruler.css" rel="stylesheet" type="text/css">
<script src="ruler/jquery.ruler.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div style="position: fixed; margin-left:50%; margin-rigth:50%; top: 100px; width: 60px; height: 60px; font-size: 150px; z-index: 9999999999999999999; display:none;" id="check" class="fa fa-check"></div>
   <style type="text/css">
	@media print {
	  .hidden-print {
		display: none !important;
	  }
	}
   body { padding:0px; margin:0px; font-size:<?php echo $fsize?>px; font-family:arial; background-image:url('../../assets/img/<?php if($_SESSION["user"]=="Master" or $_SESSION["user"]=="SuperAdmin"){?>fatura.jpg<?php }?>');}
	table {font-size:<?php echo $fsize?>px; font-family:arial;}
   .fatura{border:solid 0px #ff3333; position:relative; width:100%; height:100%; padding:0px; margin:0px; cursor:pointer;}
   .fadres:hover, .ftarih:hover, .fvd:hover, .fvn:hover, .furunler:hover, .ftoplam:hover, .fyaziile:hover{
       cursor:move;
       background: rgba(255, 255, 0, 0.5);
       border-top: 1px solid #d0d0d0;
   }
   .fadres {
    <?php if($rst["n1"]==""){?>
       position:absolute; left:70px; top:-8px; width:300px;
   <?php }else{?>
       position:absolute; left:<?php echo $fadres[0]?>px; top:<?php echo $fadres[1]?>px; width:<?php echo $fadres[2]?>px; height:<?php echo $fadres[3]?>px;
   <?php }?>
}
	.ftarih {
		<?php if($rst["n2"]==""){?>
		   position:absolute; left:727px; top:81px; width:130px;
	   <?php }else{?>
		   position:absolute; left:<?php echo $ftarih[0]?>px; top:<?php echo $ftarih[1]?>px; width:<?php echo $ftarih[2]?>px; height:<?php echo $ftarih[3]?>px;
	   <?php }?>
	}
	.fvd {
	<?php if($rst["n6"]==""){?>
		position:absolute; top:125px; left:500px; width:100px; height:24px;
	<?php }else{?>
		position:absolute; top:<?php echo $fvd[1]?>px; left:<?php echo $fvd[0]?>px; width:<?php echo $fvd[2]?>px; height:<?php echo $fvd[3]?>px;
	<?php }?>
	}
	.fvn {
	<?php if($rst["n7"]==""){?>
		position:absolute; top:150px; left:500px; width:100px; height:24px;
	<?php }else{?>
		position:absolute; top:<?php echo $fvn[1]?>px; left:<?php echo $fvn[0]?>px; width:<?php echo $fvn[2]?>px; height:<?php echo $fvn[3]?>px;
	<?php }?>
	}
	.furunler {
		<?php if($rst["n3"]==""){?>
		   position:absolute; left:50px;  top:225px; width:95%;
	   <?php }else{?>
		   position:absolute; left:<?php echo $furunler[0]?>px; top:<?php echo $furunler[1]?>px; width:<?php echo $furunler[2]?>px; height:<?php echo $furunler[3]?>px;
	   <?php }?>
	}
	.furun {display:flex; width:95%;}
	table tr td:first-child {width:<?php if($rst["t1"]==""){echo "50";}else{echo $rst["t1"];}?>px;}
	table tr td:nth-child(2) {width:<?php if($rst["t2"]==""){echo "300";}else{echo $rst["t2"];}?>px;}
	table tr td:nth-child(3) {width:<?php if($rst["t3"]==""){echo "60";}else{echo $rst["t3"];}?>px;}
	table tr td:nth-child(4) {width:<?php if($rst["t4"]==""){echo "80";}else{echo $rst["t4"];}?>px;}
	table tr td:nth-child(5) {width:<?php if($rst["t5"]==""){echo "40";}else{echo $rst["t5"];}?>px;}
	.ftoplam {
		<?php if($rst["n4"]==""){?>
		   position:absolute; left:680px; top:698px; width:200px;
	   <?php }else{?>
		   position:absolute; left:<?php echo $ftoplam[0]?>px; top:<?php echo $ftoplam[1]?>px; width:<?php echo $ftoplam[2]?>px; height:<?php echo $ftoplam[3]?>px;
	   <?php }?>
	}
	.fkdv {position:absolute; left:20px; width:300px;}
	.fgtoplam {position:absolute; left:20px; width:300px;}
	.fyaziile {
		<?php if($rst["n5"]==""){?>
		   position:absolute; left:149px; top:591px; width:415px;
	   <?php }else{?>
		   position:absolute; left:<?php echo $fyaziile[0]?>px; top:<?php echo $fyaziile[1]?>px; width:<?php echo $fyaziile[2]?>px; height:<?php echo $fyaziile[3]?>px;
	   <?php }?>
	}
	ul {list-style:none; padding: 0px;}
	ul li span {width:125px; float: left;}
</style>
<script>
    jQuery(function(){
        <?php if($_SESSION["user"]=="Master" or $_SESSION["user"]=="SuperAdmin"){?>
			//jQuery('body').ruler();    
           jQuery('.fadres, .fvd, .fvn, .ftarih, .furunler, .ftoplam, .fkdv, .fgtoplam, .fyaziile') .draggable() .resizable();
       
       jQuery('.fatura').click(function(){
		  stime('#check','show',1500);
          var d1p = jQuery('.fadres').position();
          var d1h = jQuery('.fadres').height();
          var d1w = jQuery('.fadres').width();
          var data = {"ne" : "n1", "l" : d1p.left, "t" : d1p.top, "w" : d1w, "h" : d1h};
          jQuery.ajax({
             type:'POST', data:data, dataType:'json', url:'../../fonksiyon.php?durum=ftasarim'
         });
          var d2p = jQuery('.ftarih').position();
          var d2h = jQuery('.ftarih').height();
          var d2w = jQuery('.ftarih').width();
          var data2 = {"ne" : "n2", "l" : d2p.left, "t" : d2p.top, "w" : d2w, "h" : d2h};
          jQuery.ajax({
             type:'POST', data:data2, dataType:'json', url:'../../fonksiyon.php?durum=ftasarim'
         });
          var d3p = jQuery('.furunler').position();
          var d3h = jQuery('.furunler').height();
          var d3w = jQuery('.furunler').width();
          var data3 = {"ne" : "n3", "l" : d3p.left, "t" : d3p.top, "w" : d3w, "h" : d3h};
          jQuery.ajax({
             type:'POST', data:data3, dataType:'json', url:'../../fonksiyon.php?durum=ftasarim'
         });
          var d4p = jQuery('.ftoplam').position();
          var d4h = jQuery('.ftoplam').height();
          var d4w = jQuery('.ftoplam').width();
          var data4 = {"ne" : "n4", "l" : d4p.left, "t" : d4p.top, "w" : d4w, "h" : d4h};
          jQuery.ajax({
             type:'POST', data:data4, dataType:'json', url:'../../fonksiyon.php?durum=ftasarim'
         });
          var d5p = jQuery('.fyaziile').position();
          var d5h = jQuery('.fyaziile').height();
          var d5w = jQuery('.fyaziile').width();
          var data5 = {"ne" : "n5", "l" : d5p.left, "t" : d5p.top, "w" : d5w, "h" : d5h};
          jQuery.ajax({
             type:'POST', data:data5, dataType:'json', url:'../../fonksiyon.php?durum=ftasarim'
         });
          var d6p = jQuery('.fvd').position();
          var d6h = jQuery('.fvd').height();
          var d6w = jQuery('.fvd').width();
          var data6 = {"ne" : "n6", "l" : d6p.left, "t" : d6p.top, "w" : d6w, "h" : d6h};
          jQuery.ajax({
             type:'POST', data:data6, dataType:'json', url:'../../fonksiyon.php?durum=ftasarim'
         });
          var d7p = jQuery('.fvn').position();
          var d7h = jQuery('.fvn').height();
          var d7w = jQuery('.fvn').width();
          var data7 = {"ne" : "n7", "l" : d7p.left, "t" : d7p.top, "w" : d7w, "h" : d7h};
          jQuery.ajax({
             type:'POST', data:data7, dataType:'json', url:'../../fonksiyon.php?durum=ftasarim'
         });
          return false;
      });
	<?php }?>
   });
</script>
<?php
$sqlo = mysqli_query($conn, "select * from eticaret where ne='siparis' and id=".$_GET["id"].""); $siparis=mysqli_fetch_assoc($sqlo);
$sqlm = mysqli_query($conn, "select * from t5 where id=".$siparis["s1"].""); $rsm=mysqli_fetch_assoc($sqlm);
$jsi = json_decode($rsm["n17"], true);
//$fadres=order_adress($siparis["id"],"invoice");
//-- Sipariş Hesapla -->
$sqlsh = mysqli_query($conn, "select * from eticaret where ne='sepet' and s5=".$siparis["id"].""); while($sepet=mysqli_fetch_assoc($sqlsh)){
	include("../../../deppo/tools/script/order_calc.php");
}
//-- Sipariş Hesapla -->
?>
<div class="fatura">
    <div class="fadres">
        <b><?php echo order_adress($siparis["id"],"invoice","firma")?><br>
        <?php echo order_adress($siparis["id"],"invoice")?>
    </div>
    <div class="fvd">
        VD: <?php echo order_adress($siparis["id"],"invoice","vd")?>
    </div>
    <div class="fvn">
        VN: <?php echo order_adress($siparis["id"],"invoice","vn")?>
    </div>
    <div class="ftarih"><?php echo dtarih($siparis["ts1"],"gg.aa.yyyy")?></div>
    <div class="furunler">
        <table class="turunler noshadow">
            <?php
            $sqls = mysqli_query($conn, "select * from eticaret where ne='sepet' and s5=".$_GET["id"].""); while($sepet=mysqli_fetch_assoc($sqls)){
                echo $siparisep["n1"];
                $ufiyat=$sepet["pb1"];
         ?>
         <!----------------------------------------------/uSatır/--->
         <tr>
           <td><?php echo $sepet["s3"];?></td>
           <td><?php echo $sepet["n1"];?></td>
           <td><?php echo $sepet["s2"];?> Adet</td>
           <td><?php echo number_format(($ufiyat),2)?>&nbsp;<?php echo $module["currency"]?></td>
           <td><?php echo number_format($ufiyat*$sepet["s2"],2)?>&nbsp;<?php echo $module["currency"]?></td>
       </tr>
   <?php }?>
</table>
</div>
<div class="fyaziile"><?php echo yaziile(str_replace(",","",number_format(($gtoplam),2)),2,"Türk Lirası","Kuruş","#");?></div>
<div class="ftoplam">
    <ul>
        <li><span><?php echo $sdil[175]; //Ara Toplam?> (<?php echo $module["currency"]?>)</span> : <?php echo number_format($stutar,2)?> <?php echo $spb?></li>
		<?php if($kargof<>0){?>
            <li><span><?php echo $sdil[7]; //Sevkiyat?></span> : <?php echo number_format(($kargof),2)?> <?php echo $spb?></li>
		<?php }?>
		<?php if($vadef<>0){?>
            <li><span>Vade Farkı</span> : <?php echo number_format(($vadef),2)?> <?php echo $spb?></li>
		<?php }?>
        <?php if(!empty($kdvbir)){?><li><span><?php echo $sdil[86];?> 1%</span> : <?php echo number_format(($kdvbir),2)?> <?php echo $spb?></li><?php }?>
        <?php if(!empty($kdvsekiz)){?><li><span><?php echo $sdil[86];?> 8%</span> : <?php echo number_format(($kdvsekiz),2)?> <?php echo $spb?></li><?php }?>
        <?php if(!empty($kdvonsekiz)){?><li><span><?php echo $sdil[86];?> 18%</span> : <?php echo number_format(($kdvonsekiz),2)?> <?php echo $spb?></li><?php }?>
        <?php if($siparis["t5"]=="havale" and $siparis["pb3"]<>"0"){?>
            <li><span><?php echo $sdil[102]; //indirim?></span> : <?php echo number_format(($indirim),2)?> <?php echo $spb?></li>
        <?php }?>
        <li><span><?php echo $sdil[176]; //G.Toplam?></span> : <?php echo number_format($gtoplam,2)?> <?php echo $spb?></li>
    </ul>
</div>
</div>