<?php
$path="../../";
include("../../map.php");
?>
<?php if($_GET["durum"]=="ok"){?>
	<div class="alert alert-success">
		<?php echo $sdil[212]; //Islem Basariyla Gerçeklestirilmistir !?>
	</div>
<?php }?>
<?php
if(!empty($_GET["key"])){
	$sorgu="and (id LIKE '%".$_POST["key"]."%' or t1 LIKE '%".$_GET["key"]."%' or t4 LIKE '%".$_GET["key"]."%' or n2 LIKE '%".$_GET["key"]."%' or n4 LIKE '%".$_GET["key"]."%')"; 
	$order="order by id desc";
}else if($_GET["order"]<>""){
	$order="order by ".qa($_GET["order"])."";
}else{
	$order="order by t4,t2 asc";
}
$sqlu=mysqli_query($conn, "select * from t5 where ne='uye' $luye order by t1 asc"); while($rsu=mysqli_fetch_assoc($sqlu)){$u++; $users[] = $rsu; }
?>
<table class="table" style="font-size:13px;">
<thead>
	<tr class="">
		<th class="w6">#</th>
		<th style="">Konu</th>
		<th class="w20"><?php echo $t25s[0];?></th>
		<th class="w8">Tarih</th>
	</tr>
</thead>
<tbody>
	<?php
	foreach($users as $key=>$value){
		$sqle=mysqli_query($conn, "select * from t4 where ne='hizmet' and s1=".$value["id"]." $sorgu order by t4 asc"); while($etk=mysqli_fetch_assoc($sqle)){
			$date = explode('-',$etk["t4"]); $gdate = explode('-',$_GET["ts1"]);
			if(($_GET["ts1"]=="") or ($_GET["ts1"]<>"" and $etk["t4"]==$_GET["ts1"]) or ($date[2]==$gdate[2] and $etk["s3"]==1)){
				$dates = explode('-',$etk["t4"]);
				if($dates[2]<0){$durum="".$sdil[151]." ".$sdil[152]."";}else{$durum="".$sdil[151]." ".$sdil[153]."";}
				if($dates[2]<30 and $dates[2]>-15){ $hizmet++;
					$icon='<i class="fa fa-bell" style="color:orange;"></i>';
					$ctr="warning";
				}elseif($dates[2]<-15){
					$icon='<i class="fa fa-bell" style="color:red;"></i>';
					$ctr="danger";
				}else{
					$icon='<i class="fa fa-bell" style="color:grey;"></i>';
					$ctr="success";
				}
				if($etk["t2"]=="TRY"){
					$total=$total+$etk["pb1"];
				}elseif($etk["t2"]=="USD"){
					$total=$total+$etk["pb1"]*$usd;
				}elseif($etk["t2"]=="EUR"){
					$total=$total+$etk["pb1"]*$eur;
				}elseif($etk["t2"]=="GBP"){
					$total=$total+$etk["pb1"]*$gbp;
				}
			?>
			<tr class="alert-<?php echo $ctr?>">
				<th class="mdn v3-text-info"><?php echo i2a($etk["id"],7);?></th>
				<td><?php echo $etk["n1"]?><br><?php echo $etk["t1"]?></td>
				<td class="mdn"><?php echo $value["t1"]?></td>
				<td><?php echo dtarih($etk["t4"],"gg ka yy")?><br><?php echo number_format($etk["pb1"],2)?> <?php echo $etk["t2"]?></td>
			</tr>
		<?php }}}?>
	<?php
	$sqle=mysqli_query($conn, "select * from genel where ne='not' ".$sorgu." $levt ".$order.""); while($etk=mysqli_fetch_assoc($sqle)){
		if(($_GET["ts1"]=="") or ($_GET["ts1"]<>"" and $etk["t4"]==$_GET["ts1"])){
			$sqlu=mysqli_query($conn, "select * from t5 where id=".$etk["s1"].""); $uye=mysqli_fetch_assoc($sqlu);
			$dates = explode('-',$etk["t4"]);
			if($dates[2]<0){$durum="".$sdil[151]." ".$sdil[152]."";}else{$durum="".$sdil[151]." ".$sdil[153]."";}
			if($dates[2]<30 and $dates[2]>-15){ $hizmet++;
				$icon='<i class="fa fa-bell" style="color:orange;"></i>';
				$ctr="warning";
			}elseif($dates[2]<-15){
				$icon='<i class="fa fa-bell" style="color:red;"></i>';
				$ctr="danger";
			}else{
				$icon='<i class="fa fa-bell" style="color:grey;"></i>';
				$ctr="success";
			}
			$total=$total+$etk["pb1"];
			?>
			<tr class="alert-<?php echo $ctr?>">
				<th class="mdn v3-text-info"><?php echo i2a($etk["id"],7);?></th>
				<td >
					<?php echo $etk["t1"]?><br><?php echo $etk["n1"]?>
				</td>
				<td class="mdn">
					<?php $t5Sx = explode(',',$etk["t5"]); $sql=mysqli_query($conn, "select * from t5"); while($rsm=mysqli_fetch_assoc($sql)){?>
						<div><?php foreach($t5Sx as $t5s){if($t5s==$rsm["id"]){echo "".$rsm["t1"].", ";}}?></div>
					<?php }?>
				</td>
				<td><?php echo dtarih($etk["t4"],"gg ka yy")?><br><?php echo $etk["t2"]?></td>
				</td>
			</tr>
		<?php }}?>
		<?php
		$sqle=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='haber' and t4<>'' and s13=1 ".$sorgu." $levt ".$order.""); while($etk=mysqli_fetch_assoc($sqle)){
		if(($_GET["ts1"]=="") or ($_GET["ts1"]<>"" and $etk["t4"]==$_GET["ts1"])){
			$sqlu=mysqli_query($conn, "select * from t5 where id=".$etk["s1"].""); $uye=mysqli_fetch_assoc($sqlu);
			$dates = explode('-',$etk["t4"]);
			if($dates[2]<0){$durum="".$sdil[151]." ".$sdil[152]."";}else{$durum="".$sdil[151]." ".$sdil[153]."";}
			if($dates[2]<30 and $dates[2]>-15){ $hizmet++;
				$icon='<i class="fa fa-bell" style="color:orange;"></i>';
				$ctr="warning";
			}elseif($dates[2]<-15){
				$icon='<i class="fa fa-bell" style="color:red;"></i>';
				$ctr="danger";
			}else{
				$icon='<i class="fa fa-bell" style="color:grey;"></i>';
				$ctr="success";
			}
			?>
			<tr class="alert-<?php echo $ctr?>">
				<th class="mdn v3-text-info"><?php echo i2a($etk["id"],7);?></th>
				<td>
					<?php echo $etk["t1"]?><br><?php echo $etk["n2"]?>
				</td>
				<td class="mdn">
					<?php $t5Sx = explode(',',$etk["t5"]); $sql=mysqli_query($conn, "select * from t5"); while($rsm=mysqli_fetch_assoc($sql)){?>
						<div><?php foreach($t5Sx as $t5s){if($t5s==$rsm["id"]){echo "".$rsm["t1"].", ";}}?></div>
					<?php }?>
				</td>
				<td><?php echo dtarih($etk["t4"],"gg ka yy")?><br><?php echo $etk["t2"]?></td>
			</tr>
		<?php }}?>
	</tbody>
</table>