<meta charset="UTF-8">
<?php
$path="../../";
include("../../map.php");
	date_default_timezone_set('Europe/Istanbul');
	$sts = strtotime($_POST["ts1"]); 
	$fts = strtotime($_POST["ts2"]);
	$day = ($fts - $sts) / 86400;
?>
<style>
table tr td {border:1px solid #ccc;}
body {font-family: tahoma;}
</style>
<table style="">
    <tr>
        <th colspan="14"><?php echo $_POST["year"]?> / <?php echo ihb($_POST["type"])?> Raporu</th>
	<tr>
    <tr>
        <th style="width: 100px;">ID</th>
        <th style="width: 200px; text-align:left;"><?php echo ctranslate("Ad Soyad/Firma");?></th>
<?php
	$a=0;$aylar = array("Ock","Şbt","Mrt","Nis","May","Haz","Tem","Ağs","Eyl","Ekm","Kas","Arl");
	foreach($aylar as $ay){$a++;
	if($a<10){$a="0".$a."";}
	$ts1="".$_POST["year"]."-".$a."-01"; $ts2="".$_POST["year"]."-".$a."-30";
?>
        <th style="width: 100px;" title="<?php echo $ts1;?>-<?php echo $ts2;?>"><?php echo $ay?></th>
<?php }?>
    </tr>
    <?php
    if($_POST["s2"]<>""){
       $sorgu="and s2='".$_POST["s2"]."'";
   }
   $sql = mysqli_query($conn, "select * FROM t5 where t1 like '%".$_GET["q"]."%' $sorgu $luye ORDER BY t1 asc"); while($rs = mysqli_fetch_assoc($sql)){ $jsi = json_decode($rs["n17"],true);
       ?>
       <tr>
        <td><?php echo i2a($rs["id"],7);?></td>
        <td><?php echo $rs["t1"]?> <?php if($jsi["ifirma"]<>""){echo "{".$jsi["ifirma"]."}";}?></td>
<?php
	$a=0;$cpb3=0; $aylar = array("Ock","Şbt","Mrt","Nis","May","Haz","Tem","Ağs","Eyl","Ekm","Kas","Arl");
	foreach($aylar as $ay){$a++;
	if($a<10){$a="0".$a."";}
	$ay=0; $ts1="".$_POST["year"]."-".$a."-01"; $ts2="".$_POST["year"]."-".$a."-30";
	$i=0;$sqlc=mysqli_query($conn, "select * from t4 where ne='cari' and s1=".$rs["id"]." order by t4 desc"); while($hcari=mysqli_fetch_assoc($sqlc)){$i++;
		$pb=$hcari["t6"];
		if($hcari["t4"]>=$ts1 and $hcari["t4"]<=$ts2){
			$alinan = ($alinan + ($hcari["pb2"]+$hcari["pb3"]));
			$alacak = ($alacak + $hcari["pb1"]);
		}
	}
?>
        <td style="text-align:right;"><?php if($_POST["type"]=="alacak"){echo wprice($alacak);}else{echo wprice($alinan);}?></td>
<?php $alacak=0;$alinan=0;}?>
    </tr>
<?php $delayed=0; $cpb1=0;$cpb2=0;$cpb3=0;$cpb4=0;}?>
</table>