<?php
	$path="../../";
	include("../../map.php");
	if($_GET["op"]=="xls"){
		header("Content-type: application/vnd.ms-excel");
		$file="".cevir($_GET["islem"]).".xls";
		header("Content-type: application/vnd.ms-excel");
		header("Content-Disposition: attachment; filename=".$file."");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo "\xEF\xBB\xBF"; //UTF-8 BOM
		echo $out;
	}else{
		include("../../scripts.php");
	}
?>
<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;}
</style>
<?php
	if(!empty($_POST["s5"])){$s5=$_POST["s5"];}else{$s5="";}
	if($_GET["key"]<>""){
		$sorgu="and (id LIKE '%".$_GET["key"]."%' or t1 LIKE '%".$_GET["key"]."%' or t2 LIKE '%".$_GET["key"]."%')"; 
		$order="order by id desc";
		//echo "0";
	}elseif($_GET["uID"]<>""){
		$sorgu="and s3='".$_GET["uID"]."'";
		$order="order by id desc";
		//echo "1";
	}elseif($_GET["fID"]<>""){
		$sorgu="and s1='".$_GET["fID"]."'";
		$order="order by id desc";
		//echo "2";
	}elseif($_GET["s4"]<>""){
		$sorgu="and s4='".$_GET["s4"]."'";
		$order="order by id desc";
		//echo "3";
	}else if($_GET["order"]<>""){
		$order="order by ".qa($_GET["order"])."";
		//echo "4";
	}else{
		$order="order by id desc";
		//echo "5";
	}
	$sql = mysqli_query($conn, "select * from genel where ne='".$_GET["islem"]."' $sorgu $luye $order"); $rs=mysqli_fetch_assoc($sql); $cols = json_decode($rs["n2"], true);
?>
<table class="table" style="">
	<thead>
		<tr>
			<?php
				foreach($cols as $col_key=>$col_value){ 
				if($col_key<>"uid" and $col_key<>"ne" and $col_key<>"Subject" and $col_key<>"nedir"){
			?>
			<th><?php echo ltrim(translate(str_replace("_"," ",$col_key)),'#');?></th>
			<?php }}?>
			</tr>
		</thead>
		<tbody>
			<?php
			$sql = mysqli_query($conn, "select * from t2 where ne='".$_GET["islem"]."' $sorgu $luye $order"); while($rs=mysqli_fetch_assoc($sql)){
			$jsi = json_decode($rs["n2"], true); $filename="";
			if($rs["t4"]<>""){$ts=$rs["t4"];}else{$ts=$rs["ts1"];}
			if(($_GET["ts1"]=="" and $_GET["ts2"]=="" and (date($ts, strtotime('-".$module["servicenf"]." days') and date($ts, strtotime('-".$module["servicenl"]." days')))>=date("Y-m-d"))<=date("Y-m-d")) or ($_GET["ts1"]<>"" and $_GET["ts2"]<>"") and ($ts>=$_GET["ts1"] and $ts<=$_GET["ts2"])){
			if($_GET["s4"] == "0" and $rs["s4"]=="1"){$sts="display:none;";}
			if($_GET["s4"] == "1" and $rs["s4"]=="0"){$sts="display:none;";}
			if($rs["s3"]>0){$uqry="where id='".$rs["s3"]."'";}else{$uqry="t2='".v3e($jsi["Email"])."'";}
			$sqlu = mysqli_query($conn, "select * from t5 $uqry");  $rsu=mysqli_fetch_assoc($sqlu);
			$sqlu2 = mysqli_query($conn, "select * from t5 where id=".$rs["s19"]."");  $rsu2=mysqli_fetch_assoc($sqlu2);
			$jsfm = json_decode($rs["n12"],true);	//bildirim
			$ts1 = explode('-',$rs["ts1"]);
			foreach($jsi as $nkey=>$nvalue){
				if(substr($nkey,2)=="Name" or $nkey=="Name" or $nkey=="Ad_Soyad"){$Name=$nvalue;}
			}
		?>
		<tr style="<?php echo $sts?>">
			<?php
				foreach($jsi as $key=>$value){
				if($key<>"uid" and $key<>"ne" and $key<>"Subject" and $key<>"nedir"){
			?>
<?php if(is_array($value)){?>
			<td><?php foreach($value as $k=>$v){$val = "".$val.", ".$v."";}?><?php echo ltrim($val,",");?></td>
<?php }else{?>
			<td><?php echo $value;?></td>
<?php }?>
			<?php }}?>
		</tr>
		<?php $sts="";}}?>
	</tbody>
	</table>