<?php
$path="../../";
include("../../map.php");
$sqlt=mysqli_query($conn, "select * from genel where ne='sftasarim'"); $rst=mysqli_fetch_assoc($sqlt);
if(mysqli_num_rows($sqlt)==0){
	$sqli = $conn->query("insert into genel (ne) values ('sftasarim')");
}
$fcadres = explode(',',$rst["n1"]);
$ftarih = explode(',',$rst["n2"]);
$furunler = explode(',',$rst["n3"]);
$ftoplam = explode(',',$rst["n4"]);
$fdetay = explode(',',$rst["n5"]);
$flogo = explode(',',$rst["n6"]);
$fsart = explode(',',$rst["n7"]);
$filetisim = explode(',',$rst["n8"]);
?>
<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 rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php if($MA<>1){?>
<body onload="window.print()">
<?php }?>
    <?php if($_SESSION["user"]=="Master" or $_SESSION["user"]=="SuperAdmin"){?>
        <form class="noprint" action="?id=<?php echo $_GET["id"]?>&islem=<?php echo $_GET["islem"]?>&durum=tkaydet" method="post" style="position:fixed; right:0px; top:30px; width:100px;">
           <input type="text" name="t1" value="<?php echo $rst["t1"]?>" Placeholder="td1" style="width:100px">
           <input type="text" name="t2" value="<?php echo $rst["t2"]?>" Placeholder="td2" style="width:100px">
           <input type="text" name="t3" value="<?php echo $rst["t3"]?>" Placeholder="td3" style="width:100px">
           <input type="text" name="t4" value="<?php echo $rst["t4"]?>" Placeholder="td4" style="width:100px">
           <input type="text" name="t5" value="<?php echo $rst["t5"]?>" Placeholder="td5" style="width:100px">
           <input type="submit" name="" value="Kaydet" style="display:none;">
       </form>
   <?php }?>
   <style type="text/css">
   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 }?>');}
     .fatura{border:solid 0px #ff3333; position:relative; width:900px; height:700px; padding:0px; margin:0px;cursor:pointer; border:dotted 1px #cccccc24;}
   .fadres:hover, .ftarih:hover, .fvd:hover, .fvn:hover, .furunler:hover, .ftoplam:hover, .fdetay:hover, .flogo:hover, .fsart:hover, .filetisim:hover{
       cursor:move;
       background: rgba(255, 255, 0, 0.5);
       border-top: 1px solid #d0d0d0;
   }
   .fadres {
    <?php if($rst["n1"]==""){?>
       position: absolute; left: 16px; top: 139px; width: 360px; height: 92px;
   <?php }else{?>
       position:absolute; left:<?php echo $fcadres[0]?>px; top:<?php echo $fcadres[1]?>px; width:<?php echo $fcadres[2]?>px; height:<?php echo $fcadres[3]?>px;
   <?php }?>
}
.ftarih {
    <?php if($rst["n2"]==""){?>
       position: absolute; left: 718px; top: 149px; width: 153px; height: 25px;
   <?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 {position:absolute; left:20px; width:150px;}
.fvn {position:absolute; left:20px; width:150px;}
.furunler {
    <?php if($rst["n3"]==""){?>
       position: absolute; left: 12px; top: 426px; width: 866px; height: 254px;
   <?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 "90";}else{echo $rst["t1"];}?>px;}
table tr td:nth-child(2) {width:<?php if($rst["t2"]==""){echo "330";}else{echo $rst["t2"];}?>px;}
table tr td:nth-child(3) {width:<?php if($rst["t3"]==""){echo "100";}else{echo $rst["t3"];}?>px;}
table tr td:nth-child(4) {width:<?php if($rst["t4"]==""){echo "140";}else{echo $rst["t4"];}?>px;}
table tr td:nth-child(5) {width:<?php if($rst["t5"]==""){echo "40";}else{echo $rst["t5"];}?>px;}
table tr td{border-bottom: solid 1px #ccc !important;}
.ftoplam {
    <?php if($rst["n4"]==""){?>
       position: absolute; left: 586px; top: 712px; width: 222px; height: 84px;
   <?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;}
.fdetay {
    <?php if($rst["n5"]==""){?>
       position: absolute; left: 13px; top: 244px; width: 867px; height: 158px;
   <?php }else{?>
       position:absolute; left:<?php echo $fdetay[0]?>px; top:<?php echo $fdetay[1]?>px; width:<?php echo $fdetay[2]?>px; height:<?php echo $fdetay[3]?>px;
   <?php }?>
}
.flogo {
    <?php if($rst["n6"]==""){?>
       position: absolute; left: 15px; top: 12px; width: 287px; height: 107px;
   <?php }else{?>
       position:absolute; left:<?php echo $flogo[0]?>px; top:<?php echo $flogo[1]?>px; width:<?php echo $flogo[2]?>px; height:<?php echo $flogo[3]?>px;
   <?php }?>
}
.filetisim {
    <?php if($rst["n8"]==""){?>
       position: absolute; left: 591px; top: 26px; width: 287px; height: 107px;
   <?php }else{?>
       position:absolute; left:<?php echo $filetisim[0]?>px; top:<?php echo $filetisim[1]?>px; width:<?php echo $filetisim[2]?>px; height:<?php echo $filetisim[3]?>px;
   <?php }?>
}
.fsart {
    <?php if($rst["n7"]==""){?>
       position: absolute; left: 14px; top: 727px; width: 548px; height: 72px;
   <?php }else{?>
       position:absolute; left:<?php echo $fsart[0]?>px; top:<?php echo $fsart[1]?>px; width:<?php echo $fsart[2]?>px; height:<?php echo $fsart[3]?>px;
   <?php }?>
}
ul {list-style:none; padding: 0px;}
ul li span {width:100px; float: left;}
</style>
<script>
    jQuery(function(){
        <?php if($_SESSION["user"]=="Master" or $_SESSION["user"]=="SuperAdmin"){?>
           jQuery('.fadres, .fvd, .fvn, .ftarih, .furunler, .ftoplam, .fkdv, .fgtoplam, .fdetay, .fsart, .flogo, .filetisim') .draggable() .resizable();
       <?php }?>
       jQuery('.fatura').click(function(){
          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=sftasarim'
         });
          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=sftasarim'
         });
          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=sftasarim'
         });
          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=sftasarim'
         });
          var d5p = jQuery('.fdetay').position();
          var d5h = jQuery('.fdetay').height();
          var d5w = jQuery('.fdetay').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=sftasarim'
         });
          var d6p = jQuery('.flogo').position();
          var d6h = jQuery('.flogo').height();
          var d6w = jQuery('.flogo').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=sftasarim'
         });
          var d7p = jQuery('.fsart').position();
          var d7h = jQuery('.fsart').height();
          var d7w = jQuery('.fsart').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=sftasarim'
         });
          var d8p = jQuery('.filetisim').position();
          var d8h = jQuery('.filetisim').height();
          var d8w = jQuery('.filetisim').width();
          var data8 = {"ne" : "n8", "l" : d8p.left, "t" : d8p.top, "w" : d8w, "h" : d8h};
          jQuery.ajax({
             type:'POST', data:data8, dataType:'json', url:'../../fonksiyon.php?durum=sftasarim'
         });
          return false;
      });
   });
</script>
<?php
//-------------------/Fatura Düzenle/-------
if($_GET["id"]<>""){
	$sqlf=mysqli_query($conn, "select * from t4 where id=".$_GET["id"].""); $rsf=mysqli_fetch_assoc($sqlf);
	$jsi = json_decode($rsf["n17"], true);
	$jsm = json_decode($rsf["m1"], true);
	$ftarih="".$rsf["s4"]."-".$rsf["s3"]."-".$rsf["s2"].""; $fno=$rsf["t1"]; $t4=$rsf["t4"];
	$sqlm=mysqli_query($conn, "select * from t5 where id=".$rsf["s1"].""); $rs5=mysqli_fetch_assoc($sqlm);
	$fcariID=$rsf["s1"]; $fcariName=$rs5["t1"]; $fcariEmail=v3d($rs5["t2"]);
	include("../accounting/accounting_calc.php");
}
//-------------------/Fatura Düzenle/-------
?>
<div class="fatura">
    <div class="flogo"><img src="<?php echo "".$weburl."/deppo/image/".$t50."";?>" style="max-width:200px;"></div>
    <div class="filetisim">
        <b><?php echo $firma?></b><br>
        <?php echo $fadres?><br>
        <?php echo $ftel?><br>
        <?php echo $fmail?><br>
    </div>
    <div class="fadres">
        <b><?php echo $rs5["t1"]?></b><br /><br /><?php echo $rs5["n5"]?>
        <br>Email :<?php echo v3d($rs5["t2"])?><br>Phone :<?php echo $rs5["t4"]?>
    </div>
    <div class="ftarih"><?php echo $rsf["t9"];?></div>
    <div class="furunler">
        <table class="turunler" style="width:100%">
            <tr>
               <td><?php echo $t46;?></td>
               <td><?php echo $t24;?></td>
               <td><?php echo $sdil[88]; //Birim?></td>
               <td><?php echo $sdil[85]; //Fiyat?></td>
               <td><?php echo $sdil[144]; //Tutar?></td>
           </tr>
           <?php
           $sqlfu=mysqli_query($conn, "select * from t4 where ne='furun' and s1=".$_GET["id"].""); while($rsfu=mysqli_fetch_assoc($sqlfu)){
            $sqlu=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where id=".$rsfu["s2"].""); $rsu=mysqli_fetch_assoc($sqlu);
			$jsi = json_decode($rsfu["n17"], true);
          ?>
          <!----------------------------------------------/uSatır/--->
          <tr>
           <td><?php echo $rsu["t4"]?></td>
           <td><?php echo $rsu["t1"]?>
<?php $sqli=mysqli_query($conn, "select * from genel where ne='inputs' and (t2='All' or t2='".$_SESSION["lang"]."') and n3='kayit' and n4<>'switch' and (n2='0' or n2='".$rsu["id"]."') and n6='required' and s1=0 order by s10,id asc");?>
<?php if(mysqli_num_rows($sqli)>0){?>
<div style="font-size:12px;">
					<?php $i=0; while($rsi=mysqli_fetch_assoc($sqli)){$i++;?>
<?php if($rsi["n4"]=="input" or $rsi["n4"]=="textarea"){?>
<?php if($jsi["i".$i.""]<>""){?>	<b><?php echo $rsi["n1"];?></b> : <?php echo $jsi["i".$i.""];?><?php }?>
<?php }else{?>
<?php if($jsi["i".$i.""][0]<>""){?>	<b><?php echo $rsi["n1"];?></b> : <?php echo $jsi["i".$i.""][0];?><?php }?>
<?php }?>
					<?php }?>
</div>
<?php }?>
			</td>
           <td><?php echo $rsfu["s5"]?> <?php echo $rsu["t10"];?></td>
           <td><?php echo number_format($rsu["pb1"],2)?></td>
           <td><?php echo $ikpb?> <?php echo number_format($rsu["pb1"]*$rsfu["s5"],2)?></td>
       </tr>
   <?php }?>
</table>
</div>
<div class="ftoplam">
	<ul>
       <li><span><?php echo $sdil[102]; //Sale?></span> : <?php echo $ikpb?> <?php echo number_format(($rsf["pb4"]*(($s12+100)/100)),2)?></li>
       <li><span><?php echo $sdil[176]; //Toplam?></span> : <?php echo $ikpb?> <?php echo number_format(($gtoplam),2)?></li>
	   <li><span><?php echo $sdil[159]; //Balance?></span> : <?php echo $ikpb?> <?php echo number_format(($gtoplam-$rsf["t7"]),2)?></li>
   </ul>
</div>
<div class="fsart"><?php echo $rsf["t9"];?> <?php echo translate("Depozito")?>; <b><?php echo $ikpb?> <?php if($rsf["t7"]<>""){echo number_format($rsf["t7"],2);}else{echo "0";}?></b> <br><?php echo $sdil[154]; //Ödeme Tipi?>; <b><?php echo translate($rsf["t2"])?></b>
<table class="noshadow tbl2" style="width:100%;">
							<?php $i=0;$sqli=mysqli_query($conn, "select * from genel where ne='senet' and s2=".$rsf["id"]." order by id desc"); while($rsi=mysqli_fetch_assoc($sqli)){$i++;?>
							<tr>
							<td style="vertical-align: top;" class="tar"><?php echo $i;?>.<?php echo translate("Taksit")?> <?php echo $rsi["t10"]?> - £ <?php echo $rsi["pb1"]?></td>
							</tr>
							<?php }?>
							</table>
</div>
<div class="fdetay"><?php echo $rsf["n1"]?></div>
</div>
<?php
if($_GET["durum"]=="tkaydet"){
	$Rs = mysqli_query($conn, "update genel set t1='".$_POST["t1"]."', t2='".$_POST["t2"]."', t3='".$_POST["t3"]."', t4='".$_POST["t4"]."', t5='".$_POST["t5"]."' where ne='sftasarim'");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."",self,500,1);
}
?>