<?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; }
?>
<div class="inner-wrapper">
	<section role="main" class="content-body">
		<header class="page-header">
			<h2>Notlar</h2>
			
			<div class="right-wrapper text-right">
				<ol class="breadcrumbs">
					<li>
						<a href=".">
							<i class="fa fa-home"></i>
						</a>
					</li>
					<li><span>Crm +Plus</span></li>
					<li><span><?php echo $sdil[68]; //Notlar?></span></li>
				</ol>
				
				<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
			</div>
		</header>
		<?php if($_GET["durum"]=="ok"){?>
			<div class="alert alert-success">
				<?php echo $sdil[212]; //Islem Basariyla Gerçeklestirilmistir !?>
			</div>
		<?php }?>
		
		<div class="row">
			<div class="col">
				<section class="card">
					<header class="card-header v3-bg-info">
						<div class="card-actions" id="v-<?php echo $_GET['islem'];?>">
<!--
							<a href="#" class="card-action card-action-toggle" data-card-toggle=""></a>
							<a href="#" class="card-action card-action-dismiss" data-card-dismiss=""></a>
						-->
					</div>
					
					<h2 class="card-title"><?php echo $sdil[68]; //Notlar?></h2>
				</header>
				<div class="card-body">
					<table class="table" style="font-size:13px;">
		<thead>
			<tr class="">
				<th style="width: 6%;">#</th>
				<th style="">Konu</th>
				<th style="width: 20%;"><?php echo $t25s[0];?></th>
				<th style="width: 12%;">Tarih</th>
				<th style="width: 10%;">İşlemler</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>
						<td class="">
							<a href="?islem=duye&ne=uye&id=<?php echo $etk["s1"]?>&s2=&key=&sayfa=#&tab-hizmet" target="_blank" class="btn btn-success mfl mmr5" title="Düzenle"><i class="fa fa-edit"></i></a>
							<a title="Sil" class="btn btn-danger mfr" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $etk["id"]?>&durum=shizmet" onClick="return confirm('#Bu Kayıt Silinecektir ! Onaylıyor musunuz ?')"><i class="fa fa-times"></i></a>
						</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 class="">
							<a href="#" class="btn btn-success mfrm mfl mmr5" data-toggle="modal" data-target="#myModal" data-url="modules/events/note.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=noku&id=<?php echo $etk["id"]?>&ay=<?php echo $ay?>&yil=<?php echo $AktifYil?>" title="Düzenle"><i class="fa fa-edit"></i></a>
							<a title="Sil" class="btn btn-danger mfr" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $etk["id"]?>&durum=snot" onClick="return confirm('#Bu Kayıt Silinecektir ! Onaylıyor musunuz ?')"><i class="fa fa-times"></i></a>
						</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>
						<td class="">
							<a href="#" class="btn btn-success mfrm mfl mmr5" data-toggle="modal" data-target="#myModal" data-url="modules/events/note.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=noku&id=<?php echo $etk["id"]?>&ay=<?php echo $ay?>&yil=<?php echo $AktifYil?>" title="Düzenle"><i class="fa fa-edit"></i></a>
							<a title="Sil" class="btn btn-danger mfr" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $etk["id"]?>&durum=snot" onClick="return confirm('#Bu Kayıt Silinecektir ! Onaylıyor musunuz ?')"><i class="fa fa-times"></i></a>
						</td>
					</tr>
				<?php }}?>
<?php if($total>0){?>
					<tr class="mdn">
						<td style=""></td>
						<td></td>
						<td></td>
						<td><?php echo wprice($total)?> <?php echo $ikpb?></td>
						<td></td>
					</tr>
<?php }?>
			</tbody>
		</table>
			</div>
		</section>
	</div>
</div>
<!-- end: page -->
</section>
</div>
<aside id="sidebar-right" class="sidebar-right">
	<div class="nano">
		<div class="nano-content">
			<a href="#" class="mobile-close d-md-none">
				Collapse <i class="fa fa-chevron-right"></i>
			</a>
			<div class="sidebar-right-wrapper">
				...
			</div>
		</div>
	</div>
</aside>
</section>
<?php 
if($_GET["durum"] == "snot"){
	$Rs = mysqli_query($conn, "delete from genel where id=".$_GET["id"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&ay=".$_GET["ay"]."&yil=".$_GET["yil"]."&durum=ok",top,500,1);
}elseif($_GET["durum"] == "shizmet"){
	$Rs = mysqli_query($conn, "delete from t4 where id=".$_GET["id"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&ay=".$_GET["ay"]."&yil=".$_GET["yil"]."&durum=ok",top,500,1);
}
?>