<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="99"><?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
	$gun="";
	for ($x = 0; $x <= $day; $x++) {
	$gun = date("Y-m-d",strtotime('+'.$x.' days'));
?>
        <th style="width: 100px;" title="<?php echo $ts1;?>-<?php echo $ts2;?>"><?php echo dtarih($gun,"gg.aa.yy")?></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
	$gun="";
	for ($x = 0; $x <= $day; $x++) {
	$gun = date("Y-m-d",strtotime('+'.$x.' days'));
	$alacak=0; $alinan=0; $ts1="".$_POST["year"]."-".$a."-01"; $ts2="".$_POST["year"]."-".$a."-30";
	$i=0;$sqlc=mysqli_query($conn, "select id,pb1,pb3 from t4 where ne='cari' and s1=".$rs["id"]." and t4='".$gun."'"); while($hcari=mysqli_fetch_assoc($sqlc)){
		$alacak  = $alacak + ($hcari["pb1"]-($hcari["pb2"]+$hcari["pb3"]));
		$alinan  = $alinan + ($hcari["pb2"]+$hcari["pb3"]);
	}
?>
        <td style="text-align:right;"><?php if($_POST["type"]=="alacak"){echo wprice($alacak);}else{echo wprice($alinan);}?></td>
<?php }?>
    </tr>
<?php $delayed=0; $cpb1=0;$cpb2=0;$cpb3=0;$cpb4=0;}?>
</table>