<?php
include("../../../secure.php");
$path="../../../";
include("../../../map.php");
include("../../../scripts.php");
$yfd = new DateTime('first day of January');
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<style type="text/css">
	table {font-family: 'Open Sans', sans-serif;}
	@media print { .noprint { display: none !important; } }
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
    padding: 3px;
    line-height: 1.2;
}
</style>
<?php if($_POST["ts1"]==""){?>
<form action="" method="post">
	<div class="col-sm-3">
		<input type="date" class="form-control" name="ts1" placeholder="" value="<?php echo $yfd->format('Y-m-d')?>">
	</div>
	<div class="col-sm-3">
		<input type="date" class="form-control" name="ts2" placeholder="" value="<?php echo date('Y-m-d')?>">
	</div>
	<div class="col-sm-3">
		<button type="submit" name="btn" class="btn btn-warning" style="float:right;margin-right:10px;"><?php echo translate("Listele")?></button>
	</div>
</form>
<?php }elseif($_POST["ts1"]<>""){
$btoplam=0;$atoplam=0;
$i=0;$sqlfu = mysqli_query($conn, "select * from t4 where s2=".$_SESSION["fID"]." and (t10>99 and t10<110) order by id asc"); while($rsfu=mysqli_fetch_assoc($sqlfu)){
	if($_REQUEST["ts1"]<>"" and ($rsfu["t9"]>=$_REQUEST["ts1"] and $rsfu["t9"]<=$_REQUEST["ts2"])){
		$btoplam=$btoplam+$rsfu["pb1"];
		$atoplam=$atoplam+$rsfu["pb2"];
		$nbakiye=$btoplam-$atoplam;
	}
}
$btoplam=0;$atoplam=0;
$i=0;$sqlfu = mysqli_query($conn, "select * from t4 where s2=".$_SESSION["fID"]." and (t10>119 and t10<130) order by id asc"); while($rsfu=mysqli_fetch_assoc($sqlfu)){
	if($_REQUEST["ts1"]<>"" and ($rsfu["t9"]>=$_REQUEST["ts1"] and $rsfu["t9"]<=$_REQUEST["ts2"])){
		$btoplam=$btoplam+$rsfu["pb1"];
		$atoplam=$atoplam+$rsfu["pb2"];
		$dbakiye=$btoplam-$atoplam;
	}
}
$btoplam=0;$atoplam=0;
$i=0;$sqlfu = mysqli_query($conn, "select * from t4 where s2=".$_SESSION["fID"]." and (t10>109 and t10<120) order by id asc"); while($rsfu=mysqli_fetch_assoc($sqlfu)){
	if($_REQUEST["ts1"]<>"" and ($rsfu["t9"]>=$_REQUEST["ts1"] and $rsfu["t9"]<=$_REQUEST["ts2"])){
		$btoplam=$btoplam+$rsfu["pb1"];
		$atoplam=$atoplam+$rsfu["pb2"];
		$fvbakiye=$btoplam-$atoplam;
	}
}
$btoplam=0;$atoplam=0;
$i=0;$sqlfu = mysqli_query($conn, "select * from t4 where s2=".$_SESSION["fID"]." and (t10>129 and t10<140) order by id asc"); while($rsfu=mysqli_fetch_assoc($sqlfu)){
	if($_REQUEST["ts1"]<>"" and ($rsfu["t9"]>=$_REQUEST["ts1"] and $rsfu["t9"]<=$_REQUEST["ts2"])){
		$btoplam=$btoplam+$rsfu["pb1"];
		$atoplam=$atoplam+$rsfu["pb2"];
		$gbakiye=$btoplam-$atoplam;
	}
}
$btoplam=0; $atoplam=0;
$i=0;$sqlfu = mysqli_query($conn, "select * from t4 where s2=".$_SESSION["fID"]." and t2='142 01 002' order by id asc"); while($rsfu=mysqli_fetch_assoc($sqlfu)){
	if($_REQUEST["ts1"]<>"" and ($rsfu["t9"]>=$_REQUEST["ts1"] and $rsfu["t9"]<=$_REQUEST["ts2"])){
		$btoplam=$btoplam+$rsfu["pb1"];
		$atoplam=$atoplam+$rsfu["pb2"];
		$gkbakiye=$btoplam-$atoplam;
	}
}
$btoplam=0;$atoplam=0;
$i=0;$sqlfu = mysqli_query($conn, "select * from t4 where s2=".$_SESSION["fID"]." and t2<>'142 01 002' and (t10>139 and t10<150) order by id asc"); while($rsfu=mysqli_fetch_assoc($sqlfu)){
	if($_REQUEST["ts1"]<>"" and ($rsfu["t9"]>=$_REQUEST["ts1"] and $rsfu["t9"]<=$_REQUEST["ts2"])){
		$btoplam=$btoplam+$rsfu["pb1"];
		$atoplam=$atoplam+$rsfu["pb2"];
		$dvbakiye=$btoplam-$atoplam;
	}
}
$btoplam=0;$atoplam=0;
$i=0;$sqlfu = mysqli_query($conn, "select * from t4 where s2=".$_SESSION["fID"]." and (t10>149 and t10<190) order by id asc"); while($rsfu=mysqli_fetch_assoc($sqlfu)){
	if($_REQUEST["ts1"]<>"" and ($rsfu["t9"]>=$_REQUEST["ts1"] and $rsfu["t9"]<=$_REQUEST["ts2"])){
		$btoplam=$btoplam+$rsfu["pb1"];
		$atoplam=$atoplam+$rsfu["pb2"];
		$dbbakiye=$btoplam-$atoplam;
	}
}
?>
<div class="container">
			<table class="table">
				<tr>
					<td scope="col" style="width:40%; font-size:11px;" class=""><?php echo $_SESSION["fName"]?></td>
					<td scope="col" style="text-align:center;" class=""><b><?php echo ihb($_REQUEST["tip"])?> BİLANÇO <?php if($_REQUEST["ts1"]<>"" or $_REQUEST["ts2"]<>""){?><br><?php echo dtarih($_REQUEST["ts1"],"gg.aa.yyyy")?>-<?php echo dtarih($_REQUEST["ts2"],"gg.aa.yyyy")?><?php }?></b></td>
					<td scope="col" style="width:30%; font-size:11px; text-align:right" class=""><?php echo dtarih(date("Y-m-d H:i:s"),"gg.aa.yyyy time")?></td>
				</tr>
			</table>
			<table class="table" style="font-size:11px; margin-top:25px;">
				<tr style="background: beige;">
					<th colspan="2" scope="col" style="" class="">BİLANÇO</th>
				</tr>
				<tr>
					<td scope="col" style="" class="">Varlıklar</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Nakit ve Benzerleri</td>
					<td scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format($nbakiye,2,',','.')?></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Teminata Verilen Nakit ve Nakit Benzerleri</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Ters Repo Alacakları</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Takas Alacakları</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Diğer Alacaklar</th>
					<td scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format($dbakiye,2,',','.')?></th>
				</tr>
				<tr>
					<td scope="col" style="" class="">Finansal Varlıklar</td>
					<td scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format($fvbakiye,2,',','.')?></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Teminata Verilen Finansal Varlıklar</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Gayrimenkuller</td>
					<td scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format($gbakiye,2,',','.')?></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Gayrimenkul Yatırımlarından Kaynaklanan KDV Alacakları</td>
					<td scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format($gkbakiye,2,',','.')?></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Diğer Varlıklar</td>
					<td scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format($dvbakiye,2,',','.')?></td>
				</tr>
				<tr style="background: beige;">
					<th scope="col" style="" class="">Toplam Varlıklar (A)</th>
					<th scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format(($nbakiye+$dbakiye+$fvbakiye+$gbakiye+$gkbakiye+$dvbakiye),2,',','.')?></th>
				</tr>
				<tr>
					<td scope="col" style="" class="">Yükümlülükler</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Repo Borçları</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Takas Borçları</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Krediler</td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Finansal Yükümlülükler </td>
					<td scope="col" style="width:20%; text-align:right;" class=""></td>
				</tr>
				<tr>
					<td scope="col" style="" class="">Diğer Borçlar</td>
					<td scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format($dbbakiye,2,',','.')?></td>
				</tr>
				<tr style="background: beige;">
					<th scope="col" style="" class="">Toplam Yükümlülükleri (B)</th>
					<th scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format(($dbbakiye),2,',','.')?></th>
				</tr>
				<tr style="background: beige;">
					<th scope="col" style="" class="">Toplam Değeri/Net Varlık Değeri (A-B)</th>
					<th scope="col" style="width:20%; text-align:right;" class=""><?php echo number_format((($nbakiye+$dbakiye+$fvbakiye+$gbakiye+$gkbakiye+$dvbakiye)+$dbbakiye),2,',','.')?></th>
				</tr>
			</table>
</div>
			<i class="btn btn-xs btn-warning fa fa-print noprint" style="position: absolute; top: 0px; right: 10px;" onclick="window.print();"></i>
			<a href="?" class="btn btn-xs btn-info fa fa-arrow-left noprint" style="position: absolute; top: 0px; right: 40px;"></a>
<?php }?>