<?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')");
	}
	if($rst["t9"]<>""){
		$fsize = $rst["t9"];
	}else{
		$fsize = 10;
	}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body onload="window.print()">
	<style type="text/css">
	   body { padding:0px; margin:0px; font-size:<?php echo $fsize?>px; font-family:arial; background-image:url('../../assets/img/fatura.jpg');}
		table {font-size:<?php echo $fsize?>px; font-family:arial;}
		.invoice{width:100%; margin-left:0px; margin-top:0px;}
		.tbl2 tr {height:24px;}
		.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
			border: 0px solid #ddd;
		}
	</style>
	<?php
		$sql = mysqli_query($conn, "select * from t4 where id=".$_GET["id"].""); $rsf=mysqli_fetch_assoc($sql);
		$ftarih=$rsf["t9"];
		$fno="".$rsf["t1"]."";
		$sqlm = mysqli_query($conn, "select * from t5 where id=".$rsf["s1"].""); $rsm=mysqli_fetch_assoc($sqlm);
		$sqla = mysqli_query($conn, "select * from t5 where id=".$rsf["s19"].""); $rsa=mysqli_fetch_assoc($sqla);
		$jsi = json_decode($rsm["n17"], true);
		if($h5<>1){
			$fadres = "".$rsm["n5"]."";
		}else{
			$sqla=mysqli_query($conn, "select * from t1 where ne='adress' and t2='".$_SESSION['lang']."' and id=".$siparis["s11"].""); $adress=mysqli_fetch_assoc($sqla);
			$fadres .= "".$adress["n2"]." (".$adress["n1"].") (".$adress["n6"]." ".loc($adress["n3"])." / ".loc($adress["n4"])." / ".loc($adress["n5"]).")";
		}
		$fcari=$rsm["id"];
		if($rsm["s5"]<>"0"){$fcisk=($rsm["s5"]+100)/100;}else{$fcisk=0;}
	?>
<table class="table noshadow invoice">
	<tr>
		<td colspan="" class="tal"><img src="<?php echo $logo;?>" style="height:80px;"></td>
		<td colspan="" class="tar" style="font-size:20px; font-weight:bold;">DELIVERY NOTE</td>
	</tr>
	<tr>
		<td colspan="" class="tal">Mobile : <?php echo $ftel;?></td>
		<td colspan="" class="tar">ORDER ID #<?php echo $rsf["t1"]?><br>Order Date : <?php echo $ftarih;?></td>
	</tr>
<!--
	<tr>
		<td class="tal" style="font-size:20px; font-weight:bold;">£ <span id="total"></span></td>
		<td class="tar" style="font-size:20px; font-weight:bold;">TOTAL</td>
	</tr>
-->
	<tr>
		<td colspan="2">
		<table class="noshadow tbl2" style="width:100%;">
			<tr>
				<td style="" class="w15">Name</td>
				<td style="">: <?php echo $rsm["t1"]?> <?php if($jsi["i1"]<>""){?>(<?php echo $jsi["i1"]?>)<?php }?></td>
				<td style="" class="w20">BRANCH</td>
				<td style=""> : </td>
			</tr>
			<tr>
				<td style="" class="w15">Address</td>
				<td style="">: <?php echo $fadres?></td>
				<td style="" class="w20">Sales Person</td>
				<td style=""> : <?php echo $rsa["t1"]?></td>
			</tr>
			<tr>
				<td style="" class="w15">Delivery Address</td>
				<td style="">: <?php echo $fadres?></td>
				<td style="" class="w20">Email</td>
				<td style=""> : <?php echo v3d($rsm["t2"])?></td>
			</tr>
			<tr>
				<td style="" class="w15"></td>
				<td style=""></td>
				<td style="" class="w20">Phone</td>
				<td style=""> : <?php echo $rsm["t4"]?></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<table class="noshadow tbl2" style="width:100%;">
			<tr>
				<td class="tal" style="font-size:16px; font-weight:bold;">Description</td>
				<td class="tac w30" style="font-size:16px; font-weight:bold;">Quantity</td>
<!--
				<td class="tar w10" style="font-size:16px; font-weight:bold;">Price</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);
                if(mysqli_num_rows($sqlu)>0){
                  $id=$rsu["id"];
                  include("../../../deppo/tools/script/prices.php");
				  include("../accounting/accounting_calc.php");
              }
              ?>
			<tr>
				<td class=""><?php echo $rsu["t1"]?></td>
				<td class="tac"><?php echo $rsfu["s5"]?></td>
<!--
				<td class="tar">£&nbsp;<?php echo number_format($rsu["pb1"],2)?></td>
-->
			</tr>
 <?php }?>
			<tr style="">
				<td class="" colspan="3" style="height:20px;"></td>
			</tr>
<!--
			<tr style="">
				<td class="" colspan="3">Payment History</td>
			</tr>
			<tr>
				<td class="" colspan=""><?php echo $ftarih;?> £ <?php echo $rsf["t6"]?> from customer (Deposit)</td>
				<td class="tar" colspan="">Sub TOTAL :</td>
				<td class="tar">£ <?php echo number_format(($ttoplam),2)?></td>
			</tr>
			<tr>
				<td class="" colspan=""><?php echo $ftarih;?> Remaining Balance <?php echo number_format(($gtoplam-$rsf["t6"]),2)?></td>
				<td class="tar" colspan="">Discount :</td>
				<td class="tar">£ <?php echo number_format(($rsf["pb4"]),2)?></td>
			</tr>
			<tr>
				<td class="" colspan=""></td>
				<td class="tar" colspan="">Total :</td>
				<td class="tar">£ <?php echo number_format(($gtoplam),2)?></td>
			</tr>
-->
			<tr>
				<td class="" colspan="3"><hr></td>
			</tr>
			<tr>
				<td class="" colspan="3">
				<table class="noshadow tbl2" style="width:100%;">
					<tr>
						<td style="vertical-align: top;">Company Signature</td>
						<td style="vertical-align: top;" class="tar">
<!--
							<b>I Understand that if I do not follow the payment plan, my delivery might be delayed.</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;?>.Payment <?php echo $rsi["t10"]?> - £ <?php echo $rsi["pb1"]?></td>
							</tr>
							<?php }?>
							</table>
-->
						</td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td class="" colspan="3" style="height:50px;"></td>
			</tr>
			<tr>
				<td class="" colspan="3">
					<?php echo $rsf["n1"]?>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<!--
<div style="padding:20px; position:absolute; top:1020px; font-size:12px;">
	<?php echo sabit(88,"sayfa","n1");?>
</div>
-->
<script>
$(document).ready(function() {
	$("#total").html('<?php echo number_format(($ntutar),2)?>');
});
</script>