<?php
include("map.php");
if($_GET["islem"]=="notification"){

// CORS izinleri
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Authorization');
header('Content-Type: application/json; charset=utf-8');

//İlan Onay Bildirim
	if($h3==1){
		$sqlu = mysqli_query($conn, "select id FROM ".$_SESSION["lang"]." where ne='kayit' ".$luye." and s13=0"); $rsu=mysqli_fetch_assoc($sqlu);
		if(mysqli_num_rows($sqlu)>0){$notification++;};
	}

//Üye Onay Bildirim
	if($m15>1){
		$sqlc = mysqli_query($conn, "select id FROM t5 where s4=0 ".$luye.""); $rsc=mysqli_fetch_assoc($sqlc);
		if(mysqli_num_rows($sqlc)>0){$notification++;};
	}

//Hizmet Bildirim
	if($m15>1){$nsorgu=" where s4=1";}
	$sqlc=mysqli_query($conn, "select * from t5 $nsorgu order by id desc"); while($rsc=mysqli_fetch_assoc($sqlc)){$s="";
		$sqlh=mysqli_query($conn, "select * from t4 where ne='hizmet' and s1=".$rsc["id"].""); while($rsh=mysqli_fetch_assoc($sqlh)){
			$gun=tfark2(date('Y-m-d'),$rsh["t4"]); $ndate = strtotime("".$rsh["t4"]."  00:00:00");
			if(($gun >= $module["servicenf"] and $gun<=$module["servicenl"] and $rsh["s3"]==0) or (date('d', strtotime($module["servicenf"]." day", $ndate)) <= date('d') and date('d') <= date('d', strtotime("+".$module["servicenl"]." day", $ndate))  and $rsh["s3"]==1) or (date('d', strtotime($module["servicenf"]." day", $ndate)) <= date('d') and date('d') <= date('d', strtotime("+".$module["servicenl"]." day", $ndate))  and  date("m")==date('m', strtotime($ndate)) and $rsh["s3"]==2)){ $s++; }
		}
		if(is_numeric($s)){$notification++;}
	}

//İlişki Bildirim
	if($module["uye_relations"]=="1"){
		$sqlh=mysqli_query($conn, "select * from t1 where ne='relations' ".$luye." order by id asc"); while($rsh=mysqli_fetch_assoc($sqlh)){
			$dates = explode('-',$rsh["t4"]);
			if(($dates[2]==date('d') and $dates[1]==date('m') and $dates[0]==date('Y'))){ $notification++; }
		}
	}

//Sipariş Bildirim -> Desktop
	$sqls=mysqli_query($conn, "select * from eticaret where ne='siparis' and (s4=0 or s4=1) $luye order by id desc");while($siparis=mysqli_fetch_assoc($sqls)){ $jso=json_decode($siparis["n12"],true);	//bildirim
		if($jso["nbrowser"]<>1){ $notification++; }
		if($_GET["crm"]<>"" and $jso["desktop"]<>1){
			$notify = array ('desktop' => '1');
			$ojsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
			$Rs = mysqli_query($conn, "update eticaret set n12='".addslashes(stripslashes($ojsn))."' where id=".$siparis["id"]."");
			$sqlb = mysqli_query($conn, "select * from eticaret where ne='sepet' and s5=".$siparis["id"].""); while($sepet=mysqli_fetch_assoc($sqlb)){
				include("../deppo/tools/script/order_calc.php");
			}
			$ncrm['notifications'][] = ['id'=>$siparis['id'],'title'=>ctranslate('Yeni Sipariş').' → '.$firma,'body'=>($user['t1'] ?? '').' ('.wprice($gtoplam).' '.$siparis['t2'].') '.dtarih($siparis['ts1'],"gg.ka.yy+time",""),'icon'=>'https://cdn-icons-png.flaticon.com/128/2058/2058148.png','url'=>ssl($weburl),'tag'=>'siparis-'.$siparis['id'],'timestamp'=>strtotime($siparis['ts1']),'viewed'=>false];
		}
	}

//Teklif Bildirim -> Desktop
	$sqlf=mysqli_query($conn, "select * from t4 where ne='service' and s13=3 ".$luye." order by id desc");while($rsf=mysqli_fetch_assoc($sqlf)){ $jso=json_decode($rsf["n12"],true);	//bildirim
		if($jso["nbrowser"]<>1){ $notification++; }		
		if($_GET["crm"]<>"" and $jso["desktop"]<>1){
			$notify = array ('desktop' => '1');
			$ojsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
			$Rs = mysqli_query($conn, "update t4 set n12='".addslashes(stripslashes($ojsn))."' where id=".$rsf["id"]."");
			$ncrm['notifications'][] = ['id'=>$rsf['id'],'title'=>ctranslate('Teklif Onaylandı'),'body'=>($user['t1'] ?? '').' '.dtarih($rsf['t9'],"gg ka yy time",""),'icon'=>'https://cdn-icons-png.flaticon.com/128/2058/2058148.png','url'=>ssl($weburl),'tag'=>'teklif-'.$rsf['id'],'timestamp'=>strtotime($rsf['t9'] ?? date('Y-m-d H:i:s')),'viewed'=>false];
		}
	}

//Tahsilat Bildirim -> Desktop
	if($msg>0){$notification++;}
	$sqld=mysqli_query($conn, "select * from t1 where ne='dekont' order by id desc"); while($rsd=mysqli_fetch_assoc($sqld)){
		$jsm=json_decode($rsd["n12"],true);	//bildirim
		if($jsm["nbrowser"]<>1){ $notification++; }
		if($_GET["crm"]<>"" and $jsm["desktop"]<>1){
			$notify = array ('desktop' => '1');
			$mjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
			$Rs = mysqli_query($conn, "update t1 set n12='".addslashes(stripslashes($mjsn))."' where id=".$rsd["id"]."");
			$ncrm['notifications'][] = ['id'=>$rsd['id'],'title'=>ctranslate('Tahsilat').' → '.$firma,'body'=>($rsd['n1'] ?? '').' '.wprice($rsd['pb1']).' '.$rsd['t9'].' '.dtarih($rsd['ts1'],"gg.ka.yy+time",""),'icon'=>'https://cdn-icons-png.flaticon.com/128/2058/2058148.png','url'=>ssl($weburl),'tag'=>'tahsilat-'.$rsd['id'],'timestamp'=>strtotime($rsd['ts1']),'viewed'=>false];
		}
	}
//Görev Bildirim
	$sqlg=mysqli_query($conn, "select * from genel where ne='gorev' and s13=1 order by id desc"); while($rsg=mysqli_fetch_assoc($sqlg)){
		$t11Sb = explode(',',$rsg["t11"]); foreach($t11Sb as $t11b){
			if($t11b==$_SESSION["user_id"] or $rsg["s19"]==$_SESSION["user_id"]){ $notification++; }
		}
	}
//Yorum Bildirim -> Desktop
	$sqlc = mysqli_query($conn, "select * FROM genel where ne='yorum' or ((ne='cek' or ne='senet') and s13=1)"); while($rsc=mysqli_fetch_assoc($sqlc)){ $jsc=json_decode($rsc["n12"],true);	//bildirim
		if($jsc["nbrowser"]<>1){ $notification++; }
		if(($_GET["crm"]<>"" and $jsc["desktop"]<>1) and $rsc["ne"]=="yorum"){
			$notify = array ('desktop' => '1');
			$cjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
			$Rs = mysqli_query($conn, "update genel set n12='".addslashes(stripslashes($cjsn))."' where id=".$rsc["id"]."");
			$ncrm['notifications'][] = ['id'=>$rsc['id'],'title'=>ctranslate('Yeni Yorum').' → '.$firma,'body'=>$rsc['n1'] ?? '','icon'=>'https://cdn-icons-png.flaticon.com/128/2058/2058148.png','url'=>ssl($weburl),'tag'=>'yorum-'.$rsc['id'],'timestamp'=>strtotime($rsc['ts1']),'viewed'=>false];
		}
	}

//Mesaj Bildirim -> Desktop
	$sqlm=mysqli_query($conn, "select id,n12,s1,n1,ts2 from t2 where ne='mesaj' and (s2=0) order by id desc"); while($rsm=mysqli_fetch_assoc($sqlm)){ $jsm=json_decode($rsm["n12"],true);	//bildirim
		if($jsm["nbrowser"]<>1){ $msg++; }
		if($_GET["crm"]<>"" and $jsm["desktop"]<>1){
			$notify = array ('desktop' => '1');
			$mjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
			$Rs = mysqli_query($conn, "update genel set n12='".addslashes(stripslashes($mjsn))."' where id=".$rsm["id"]."");
			$ncrm[notifications][] = array ('title'=>"".$user["t1"]." -> ".$firma."",'detail'=>"".$rsm["n1"]." ".dtarih($rsm["ts2"],"gg ka yy time"," ")."");
		}
	}

//Form Mesaj ve Talep Bildirim -> Desktop
	$sqlfm = mysqli_query($conn, "select id,t1,n2,n12,ts1 FROM t2 where ne='fmesaj' or (ne='request' $lreq)" ); while($rsfm=mysqli_fetch_assoc($sqlfm)){ $jsfm = json_decode($rsfm["n12"],true);	//bildirim
		if($jsfm["nbrowser"]<>1){
			$notification++;
		}
		if($_GET["crm"]<>"" and $jsfm["desktop"]<>1){
			$notify = array ('desktop' => '1');
			$fjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
			$Rs = mysqli_query($conn, "update t2 set n12='".addslashes(stripslashes($fjsn))."' where id=".$rsfm["id"]."");
			$jsi = json_decode($rsfm["n2"],true);	//json
			$ncrm['notifications'][] = ['id'=>$rsfm['id'],'title'=>ctranslate('Yeni Talep').' → '.$firma,'body'=>$jsi['Konu'] ?? '','icon'=>'https://cdn-icons-png.flaticon.com/128/2058/2058148.png','url'=>ssl($weburl),'tag'=>'talep-'.$rsfm['id'],'timestamp'=>strtotime($rsfm['ts1']),'viewed'=>false];
		}
	}

//Ödeme Bildirim
	$sqlc=mysqli_query($conn, "select * from t4 where ne='cari' and (t1<>'Çek' AND t1<>'Senet') and t12<>'' $luye order by t12 asc"); $fdate="-3"; $ldate="3"; while($rsc=mysqli_fetch_assoc($sqlc)){
		$gun=tfark2(date('Y-m-d'),$rsc["t12"]); $ndate = strtotime($rsc["t12"]);
		if(($gun >= $fdate && $gun <= $ldate and $rsc["s3"]==0) || (date('d', strtotime("$fdate day", $ndate)) >= date('d') && date('d') <= date('d', strtotime("+$ldate day", $ndate)) && $rsc["s3"]==1) || (date('d', strtotime("$fdate day", $ndate)) >= date('d') && date('d') <= date('d', strtotime("+$ldate day", $ndate)) && date("m")==date('m', strtotime($ndate)) && $rsc["s3"]==2)){ $notification++; }
	}
	if($_SESSION["user"]=="admin"){
		$sqls=mysqli_query($conn, "select * from genel where ne='asifre' and t1='YWRtaW4='"); $rss=mysqli_fetch_assoc($sqls);
		if($rss["t2"]=="YWRtaW4="){ $notification++; }
	}
	if($_GET["crm"]<>""){
		echo json_encode($ncrm);
	}else{
		echo "<i class=\"fa fa-bell\"></i><span class=\"badge v3-bg-danger pulse\">".$notification."</span>";
	}
}elseif($_GET["islem"]=="notifications"){
	?>
	<script type="text/javascript">jQuery(function(){jQuery(".mfrm").click(function(){var theModal=jQuery(this).data("target"),frmSRC=jQuery(this).attr("data-url");jQuery(theModal+' iframe').attr('src',frmSRC);jQuery(theModal+' button.close').click(function(){jQuery(theModal+' iframe').attr('src','about:blank');});});});</script>

	<?php
	if($_SESSION["user"]=="admin"){
	$sqls=mysqli_query($conn, "select * from genel where ne='asifre' and t1='YWRtaW4='"); $rss=mysqli_fetch_assoc($sqls);
	if($rss["t2"]=="YWRtaW4="){
	?>
		<li>
			<a href="#" class="clearfix mfrm cp" data-width="90%" data-toggle="modal" data-target="#myModal" data-url="modules/public/settings_modal.php?ne=ayarlar&islem=ayarlar&id=#tab-sifre" data-title="Şifre Değiştir">
				<div class="image">
					<i class="fa fa-info bg-warning text-light"></i>
				</div>
				<span class="title"><?php echo ctranslate('Güvenlik Hatası')?> <span class="fr mfr mr5 mmr5" style="font-size:11px;"></span></span>
				<span style="font-size: 12px;"><?php echo ctranslate('Sistem güvenliği için şifrenizi değiştirin')?> <span class="v3-text-warning fr mfr mr5 mmr5"></span></span>
			</a>
		</li>
	<?php }?>
	<?php }?>
	<?php
		if($m15>1){$nsorgu=" where s4=1";}
		$sqlc=mysqli_query($conn, "select * from t5 $nsorgu order by id desc"); while($rsc=mysqli_fetch_assoc($sqlc)){
			$s=""; $ht1=""; $hn1=""; $hs3=""; $ht4="";
			$sqlh=mysqli_query($conn, "select * from t4 where ne='hizmet' and s1=".$rsc["id"].""); while($rsh=mysqli_fetch_assoc($sqlh)){
				$gun=tfark2(date('Y-m-d'),$rsh["t4"]); $ndate = strtotime("".$rsh["t4"]."  00:00:00");
				if(($gun >= $module["servicenf"] and $gun<=$module["servicenl"] and $rsh["s3"]==0) or (date('d', strtotime("-2 day", $ndate)) <= date('d') and date('d') <= date('d', strtotime("+1 day", $ndate))  and $rsh["s3"]==1) or (date('d', strtotime("-2 day", $ndate)) <= date('d') and date('d') <= date('d', strtotime("+1 day", $ndate))  and  date("m")==date('m', strtotime($ndate)) and $rsh["s3"]==2)){
					$s++; $ht1 .= "".$rsh["t1"].","; $hn1 .= "".$rsh["n1"].","; $hs3=$rsh["s3"]; $ht4=$rsh["t4"];
				}
			}		
		if(is_numeric($s)){
	?>
			<li>
				<a class="clearfix mfrm" style="cursor:pointer;" data-width="90%" data-toggle="modal" data-target="#myModal" data-url="modules/clients/client.php?ne=uye&islem=duye&id=<?php echo $rsc["id"]?>&durum=hok#&tab-hizmet" data-title="#<?php echo $rs["id"]?>">
					<div class="image" title="">
						<?php if($gun < $module["servicenf"] and $rsh["s3"]==0){?>
							<i class="fas fa-bell text-danger"></i>
						<?php }elseif($gun > $module["servicenf"] and $rsh["s3"]==0){?>
							<i class="fas fa-bell text-warning"></i>
						<?php }elseif($rsh["s3"]==1 or $rsh["s3"]==2){?>
							<i class="fas fa-refresh text-warning"></i>
						<?php }else{?>
							<i class="fas fa-clock text-warning"></i>
						<?php }?>
					</div>
					<span class="title"><?php echo ctranslate("Hesap Planı")?> [<?php if(rtrim($ht1,",")==""){echo ctranslate("Tanımsız");}else{echo rtrim($ht1,",");}?>] <span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php if($hs3==0){echo dtarih($ht4,"gg.ka.yy");}elseif($hs3==1){echo $dates[2]." ".aylar(ltrim(date("m"),"0"))." ".date("Y");}elseif($hs3==2){echo $dates[2]." ".aylar(ltrim($dates[1],"0"))." ".date("Y");}?></span></span>
					<span style="font-size: 12px;"><?php echo $rsc["t1"]?> <span class="fr mfr mr5 mmr5">"<?php echo rtrim($hn1,",");?>"</span></span>
				</a>
			</li>
		<?php }?>
	<?php }?>
		<?php
		if($module["uye_relations"]=="1"){
			$sqlh=mysqli_query($conn, "select * from t1 where ne='relations' ".$luye." order by id asc"); while($rsh=mysqli_fetch_assoc($sqlh)){
				$dates = explode('-',$rsh["t4"]); $jsri = json_decode($rsh["n17"], true);
				if(($dates[2]==date('d') and $dates[1]==date('m') and $dates[0]==date('Y'))){
				$sqlc=mysqli_query($conn, "select * from t5 where id=".$rsh["s1"]." order by id desc"); $rsc=mysqli_fetch_assoc($sqlc);
			?>
			<li>
				<a href="#" class="clearfix cp mfrm mtar" data-toggle="modal" data-target="#myModal" data-url="modules/clients/client_relation_detail.php?islem=relations&id=<?php echo $rsh["id"]?>" data-title="<?php echo $t25s[0];?> <?php echo ctranslate("İlişkileri")?>; <?php echo $rsh["t1"]?>">
					<div class="image" title="">
						<i class="fas fa-exchange text-warning"></i>
					</div>
					<span class="title"><?php echo $t25s[0];?> <?php echo ctranslate("İlişkileri")?> <span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php if($rsh["s3"]==0){echo dtarih($rsh["t4"],"gg.ka.yy");}elseif($rsh["s3"]==1){echo $dates[2]." ".aylar(ltrim(date("m"),"0"))." ".date("Y");}elseif($rsh["s3"]==2){echo $dates[2]." ".aylar(ltrim($dates[1],"0"))." ".date("Y");}?></span></span>
					<span style="font-size: 12px;"><?php echo $rsc["t1"]?> <span class="fr mfr mr5 mmr5">"<?php echo $rsh["t1"];?>"</span></span>
				</a>
			</li>
		<?php }?>
	<?php }}?>
	<?php
	$sqls=mysqli_query($conn, "select * from eticaret where ne='siparis' and (s4=0 or s4=1) $luye order by id desc");while($siparis=mysqli_fetch_assoc($sqls)){
		include("modules/ecommerce/ecommerce_order_calc.php");
		$sqlu=mysqli_query($conn, "select * from t5 where id=".$siparis["s1"]." order by id desc"); $user=mysqli_fetch_assoc($sqlu);
		$jso=json_decode($siparis["n12"],true);	//bildirim
		if($jso["browser"]<>1 or $jso["desktop"]<>1){
			$notify = array ('desktop' => '0','browser' => '0','nbrowser' => '1');
			$rjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
			$Rs = mysqli_query($conn, "update eticaret set n12='".addslashes(stripslashes($rjsn))."' where id=".$siparis["id"]."");
			?>
			<li>
				<a class="clearfix mfrm" style="cursor:pointer;" data-width="90%" data-toggle="modal" data-target="#myModal" data-url="modules/ecommerce/ecommerce_order.php?ne=eticaret&islem=siparis&id=<?php echo $siparis["id"]?>" data-title="#<?php echo $siparis["id"]?>">
					<div class="image">
						<i class="fas fa-shopping-cart text-danger"></i>
					</div>
					<span class="title"><?php echo ctranslate('Yeni Sipariş')?> <span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($siparis["ts1"],"gg.ka.yy+time"," ")?></span></span>
					<span style="font-size: 12px;"><?php echo $user["t1"]?> <span class="v3-text-warning fr mfr mr5 mmr5"><skod class="mdn">(<?php echo $siparis["t4"]?>)</skod> <b><?php echo number_format(($gtoplam),2)?> <i class="fa fa-<?php echo strtolower($siparis["t2"])?>"></i></b></span></span>
				</a>
			</li>
			<?php $stutar="";}?>
		<?php }?>
		<?php
		$sql=mysqli_query($conn, "select * from t4 where ne='service' and s13=3 ".$luye." order by id desc"); while($service=mysqli_fetch_assoc($sql)){
			$sqlu=mysqli_query($conn, "select * from t5 where id=".$service["s1"]." order by id desc"); $user=mysqli_fetch_assoc($sqlu);
				$jso=json_decode($service["n12"],true);	//bildirim
				if($jso["browser"]<>1 or $jso["desktop"]<>1){
					$notify = array ('desktop' => '0','browser' => '0','nbrowser' => '1');
					$rjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
					$Rs = mysqli_query($conn, "update t4 set n12='".addslashes(stripslashes($rjsn))."' where id=".$service["id"]."");
					?>
					<li>
						<a class="clearfix mfrm" style="cursor:pointer;" data-width="90%" data-toggle="modal" data-target="#myModal" data-url="modules/services/service.php?ne=service&islem=dservice&id=<?php echo $service["id"]?>" data-title="#<?php echo $service["id"]?>">
							<div class="image">
								<i class="fa fa-columns text-danger"></i>
							</div>
							<span class="title"><?php echo ctranslate('Teklif Onaylandı')?> <span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($service["t9"],"gg.ka.yy+time"," ")?></span></span>
							<span style="font-size: 12px;"><?php echo $user["t1"]?> <span class="v3-text-warning fr mfr mr5 mmr5">(<?php echo $service["t1"]?>) </span></span>
						</a>
					</li>
				<?php }?>
			<?php }?>
			<?php
			$rsc = mysqli_query($conn, "select * FROM genel where ne='yorum'"); while($rs=mysqli_fetch_assoc($rsc)){
				$sql1 = mysqli_query($conn, "select * FROM t5 where id=".$rs["s2"].""); $rs5=mysqli_fetch_assoc($sql1);
				$sql2 = mysqli_query($conn, "select * FROM ".$rs["t1"]." where ne ='".$rs["t2"]."' and id=".$rs["s1"].""); $konu=mysqli_fetch_assoc($sql2);
			$jsc=json_decode($rs["n12"],true);	//bildirim
			if($jsc["browser"]<>1 or $jsc["desktop"]<>1){
				$notify = array ('nbrowser' => '1');
				$rjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
				$Up = mysqli_query($conn, "update genel set n12='".addslashes(stripslashes($rjsn))."' where id=".$rs["id"]."");
				?>
				<li>
					<a class="clearfix mfrm" data-toggle="modal" data-target="#myModal" data-url="modules/comments/comment.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&yid=<?php echo $rs["id"];?>&durum=cevap">
						<div class="image">
							<i class="fa fa-comment text-danger"></i>
						</div>
						<span class="title"><?php echo $sdil[18]; //Yorumlar?> <span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($rs["ts1"],"gg.ka.yy+time"," ")?></span></span>
						<span style="font-size: 12px;"><?php if(mysqli_num_rows($sql1)>0){?><?php echo $rs5["t1"];?><?php }else{?><?php if(!empty($rs["t4"])){?><?php echo kisalt($rs["t4"],2);?><?php }else{?>N/A<?php }?><?php }?> (<?php if($rs["s2"]<>0){?>U<?php }else{?>V<?php }?>) <span class="fr mfr mr5 mmr5 tar mtar"><?php if(mysqli_num_rows($sql2)>0){?><?php echo kisalt($konu["t1"],2);?><?php }else{?>N/A<?php }?></span></span>
					</a>
				</li>
			<?php }?>
		<?php }?>
		<?php
			$rsc = mysqli_query($conn, "select * FROM genel where (ne='cek' or ne='senet') and s13=1"); while($rs=mysqli_fetch_assoc($rsc)){
				$sql1 = mysqli_query($conn, "select * FROM t5 where id=".$rs["s1"].""); $rs5=mysqli_fetch_assoc($sql1);
				$jsc=json_decode($rs["n12"],true);	//bildirim
				if($jsc["browser"]<>1 or $jsc["desktop"]<>1){
			?>
				<li>
					<a class="clearfix" href="?ne=muhasebe&islem=<?php echo $rs["ne"];?>&key=<?php echo $rs["t11"];?>">
						<div class="image">
							<i class="fas fa-money-check text-danger"></i>
						</div>
						<span class="title"><?php echo ctranslate(ihb($rs["ne"]))?> <?php echo $rs["t11"];?>/<?php echo $rs["t2"];?> <span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($rs["t4"],"gg ka yy")?></span></span>
						<span style="font-size: 12px;"><?php if(mysqli_num_rows($sql1)>0){?><?php echo $rs5["t1"];?><?php }?><span class="fr mfr mr5 mmr5 tar mtar"><?php echo wprice($rs["pb1"]);?> <?php echo $module["currency"];?></span></span>
					</a>
				</li>
			<?php }?>
		<?php }?>
		<?php
		$rsc = mysqli_query($conn, "select * FROM t1 where ne='dekont' order by id desc"); while($rs=mysqli_fetch_assoc($rsc)){
			$jsc=json_decode($rs["n12"],true);	//bildirim
			if($jsc["browser"]<>1 or $jsc["desktop"]<>1){
				$notify = array ('desktop' => '0','browser' => '0','nbrowser' => '1');
				$rjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
				$Up = mysqli_query($conn, "update t1 set n12='".addslashes(stripslashes($rjsn))."' where id=".$rs["id"]."");
				?>
				<li>
					<a class="<?php if($rs["s13"]=="0"){echo "alert-danger";}else{echo "alert-success";}?> clearfix  mfrm " data-toggle="modal" data-target="#myModal" data-url="fonksiyon.php?islem=dekont&id=<?php echo $rs["id"];?>">
						<div class="image">
							<i class="fa fa-credit-card text-danger"></i>
						</div>
						<span class="title">Tahsilat <span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($rs["ts1"],"gg ka yy time"," ")?></span></span>
						<span style="font-size: 12px;"><?php echo $rs["n1"]?> <span class="fr mfr mr5 mmr5 tar mtar"><b><?php echo number_format($rs["pb1"],2)?> <i class="fa fa-<?php echo strtolower($rs["t9"])?>"></i></b> </span></span>
					</a>
				</li>
			<?php }?>
		<?php }?>
		<?php
		$rsc = mysqli_query($conn, "select * FROM t2 where ne='fmesaj' or (ne='request' $lreq)"); while($rs=mysqli_fetch_assoc($rsc)){
			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);
			$sql2 = mysqli_query($conn, "select * FROM ".$rs["t1"]." where ne ='".$rs["t2"]."' and id=".$rs["s1"].""); $konu=mysqli_fetch_assoc($sql2);
			$jsf = json_decode($rs["n2"],true);
			$jsfm = json_decode($rs["n12"],true);	//bildirim
			if($jsfm["browser"]<>1 or $jsfm["desktop"]<>1){
				$notify = array ('desktop' => '0','browser' => '0','nbrowser' => '1');
				$rjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
				$Up = mysqli_query($conn, "update genel set n12='".addslashes(stripslashes($rjsn))."' where id=".$rs["id"]."");
				?>
				<li>
					<a class="clearfix mfrm" data-toggle="modal" data-target="#myModal" data-url="modules/requests/request.php?islem=fmesaj&id=<?php echo $rs["id"];?>" data-title="<?php echo $sdil[17]; //Mesaj Form?> {<?php echo $jsf["İleti No"]?>}">
						<div class="image">
							<i class="fa fa-comment bg-danger text-light"></i>
						</div>
						<span class="title">
							<?php if($rs["ne"]=="fmesaj"){echo "Form Mesaj";}else{echo "Talep";}?>
							<span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($rs["ts1"],"gg.ka.yy+time"," ")?></span>
						</span>
						<span style="font-size: 12px;"><?php if(mysqli_num_rows($sqlu)>0){echo "".$rsu["t1"]."";}elseif($Name<>""){echo $Name;}else{echo ctranslate("Misafir");}?><span class="fr mfr mr5 mmr5 tar mtar"><?php if($rs["t2"]==""){echo kisalt($rs["t1"],2);}else{echo kisalt($rs["t2"],2);};?>  </span></span>
					</a>
				</li>
			<?php }?>
		<?php }?>
		<?php
		$sqlm=mysqli_query($conn, "select id,n12,t2,ts1,s1 from t2 where ne='mesaj' and s2=0 order by id desc"); while($rsm=mysqli_fetch_assoc($sqlm)){
			$sqlu=mysqli_query($conn, "select id,t1 from t5 where id=".$rsm["s1"]." order by id desc"); $user=mysqli_fetch_assoc($sqlu);
				$jsm=json_decode($rsm["n12"],true);	//bildirim
				if($jsm["browser"]<>1 or $jsm["desktop"]<>1){
					$notify = array ('desktop' => '1','browser' => '1','nbrowser' => '1');
					$rjsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
					$Up = mysqli_query($conn, "update genel set n12='".addslashes(stripslashes($rjsn))."' where id=".$rsm["id"]."");
					?>
					<li>
						<a class="clearfix mfrm cp" data-toggle="modal" data-target="#myModal" data-width="90%" data-title="Help Desk" data-url="modules/messages/messages.php?id=<?php echo $user["id"];?>">
							<div class="image">
								<i class="fa fa-comment bg-danger text-light"></i>
							</div>
							<span class="title">
								<?php echo ctranslate("Destek Talebi");?>
								<span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($rsm["ts1"],"gg ka yy time"," ")?></span>
							</span>
							<span style="font-size: 12px;"><?php echo $user["t1"];?><span class="fr mfr mr5 mmr5 tar mtar"><?php if($rsm["t2"]<>""){echo "<i class=\"fa fa-paperclip\"></i>";}?> <?php echo kisalt($rsm["t1"],2);?> </span></span></span>
						</a>
					</li>
				<?php }?>
			<?php }?>
			<?php
			if($h3==1){
				$sqlu = mysqli_query($conn, "select * FROM ".$_SESSION["lang"]." where ne='kayit' and s13=0 ".$luye.""); $rsu=mysqli_fetch_assoc($sqlu);
				if(mysqli_num_rows($sqlu)>0){
					?>
					<li>
						<a href="?ne=kayit&islem=kayitlar&key=&s9=&sayfa=&durum=order&order=s13+asc" class="clearfix">
							<div class="image">
								<i class="fa fa-cubes bg-danger text-light"></i>
							</div>
							<span class="title">
								<?php echo $t24;?> (<?php echo mysqli_num_rows($sqlu);?>)
								<span class="fr mfr mr5 mmr5" style="font-size:11px;"></span>
							</span>
							<span style="font-size: 12px;"><?php echo ctranslate("Onay Bekleyen");?> <b><?php echo $t24;?></b></span>
						</a>
					</li>
				<?php }?>
			<?php }?>
			<?php
			if($m15>1){
				$sqlc = mysqli_query($conn, "select * FROM t5 where s4=0 ".$luye.""); $rsu=mysqli_fetch_assoc($sqlc);
				if(mysqli_num_rows($sqlc)>0){
					?>
					<li>
						<a href="?ne=uye&islem=uyeler&key=&sayfa=&durum=order&order=s4+asc" class="clearfix">
							<div class="image">
								<i class="fa fa-users bg-danger text-light"></i>
							</div>
							<span class="title">
								<?php echo $t25;?> (<?php echo mysqli_num_rows($sqlc);?>)
								<span class="fr mfr mr5 mmr5" style="font-size:11px;"></span>
							</span>
							<span style="font-size: 12px;"><?php echo ctranslate("Onay Bekleyen");?> <b><?php echo $t25;?></b></span>
						</a>
					</li>
				<?php }?>
			<?php }?>
			<?php
			if($m14>1){
				$sqlc = mysqli_query($conn, "select * FROM ".$_SESSION["lang"]." where ne='kayit' and s13=0 ".$luye.""); $rsu=mysqli_fetch_assoc($sqlc);
				if(mysqli_num_rows($sqlc)>0){
					?>
					<li>
						<a href="?ne=kayit&islem=kayitlar&key=&sayfa=&durum=order&order=s13+asc" class="clearfix">
							<div class="image">
								<i class="fa fa-users bg-danger text-light"></i>
							</div>
							<span class="title">
								<?php echo $t24;?> (<?php echo mysqli_num_rows($sqlc);?>)
								<span class="fr mfr mr5 mmr5" style="font-size:11px;"></span>
							</span>
							<span style="font-size: 12px;"><?php echo ctranslate("Onay Bekleyen");?> <b><?php echo $t24;?></b></span>
						</a>
					</li>
				<?php }?>
			<?php }?>
			<?php
			if($e8<>0){
				$sqlc=mysqli_query($conn, "select * from t4 where ne='cari' and (t1<>'Çek' and t1<>'Senet') and t12<>'' $luye order by t12 asc"); $fdate="-3"; $ldate="3"; while($rsc=mysqli_fetch_assoc($sqlc)){
					$sqlu=mysqli_query($conn, "select id,t1 from t5 where id=".$rsc["s1"]." order by id desc"); $user=mysqli_fetch_assoc($sqlu);
						$gun=tfark2(date('Y-m-d'),$rsc["t12"]); $ndate = strtotime($rsc["t12"]);
						if(($gun >= $fdate && $gun <= $ldate and $rsc["s3"]==0) || (date('d', strtotime("$fdate day", $ndate)) >= date('d') && date('d') <= date('d', strtotime("+$ldate day", $ndate)) && $rsc["s3"]==1) || (date('d', strtotime("$fdate day", $ndate)) >= date('d') && date('d') <= date('d', strtotime("+$ldate day", $ndate)) && date("m")==date('m', strtotime($ndate)) && $rsc["s3"]==2)){
						?>
						<li>
							<a class="clearfix mfrm" data-toggle="modal" data-target="#myModal" data-url="fonksiyon.php?islem=cdetail&id=<?php echo $rsc["s1"];?>&iid=<?php echo $rsc["id"];?>&s5=<?php echo $rsc["s5"];?>" data-title="<?php echo ctranslate("Planlı Ödeme")?> ">
								<div class="image">
									<?php if($gun < $fdate and $rsc["s3"]==0){?>
										<i class="fas fa-calculator text-danger"></i>
									<?php }elseif($gun > $fdate and $rsc["s3"]==0){?>
										<i class="fas fa-calculator text-warning"></i>
									<?php }elseif($rsc["s3"]==1 or $rsc["s3"]==2){?>
										<i class="fas fa-refresh text-warning"></i>
									<?php }else{?>
										<i class="fas fa-clock text-warning"></i>
									<?php }?>
								</div>
								<span class="title">
									<?php echo ctranslate("Planlı Ödeme")?> 
									<span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php echo dtarih($rsc["t12"],"gg ka yy"," ")?></span>
								</span>
								<span style="font-size: 12px;"><?php echo $user["t1"]?><span class="fr mfr mr5 mmr5" style="font-size:11px;"><?php if($rsc["pb1"]>0){echo wprice($rsc["pb1"]);}else{echo wprice($rsc["pb3"]);}?> <?php echo $rsc["t6"]?></span></span>
							</a>
						</li>
					<?php }?>
				<?php }?>
			<?php }?>
			<?php
			$sqlg=mysqli_query($conn, "select * from genel where ne='gorev' and s13=1 order by t9 asc"); while($rsg=mysqli_fetch_assoc($sqlg)){
				$t11Sb = explode(',',$rsg["t11"]); foreach($t11Sb as $t11b){if($t11b==$_SESSION["user_id"] or $rsg["s19"]==$_SESSION["user_id"]){
					$sqli=mysqli_query($conn, "select * from medya where ne='resim' and s1=".$rsg["id"].""); $rsi=mysqli_fetch_assoc($sqli);
					$sqld=mysqli_query($conn, "select * from medya where ne='dosya' and s1=".$rsg["id"].""); $rsd=mysqli_fetch_assoc($sqld);
					$sqlv=mysqli_query($conn, "select * from medya where ne='video' and s1=".$rsg["id"].""); $rsv=mysqli_fetch_assoc($sqlv);
					?>
					<li class="mfrm" data-toggle="modal" data-target="#myModal" data-url="fonksiyon.php?islem=dgorev&id=<?php echo $rsg["id"];?>" style="cursor:pointer;">
						<div class="clearfix">
							<div class="image">
								<i class="fa fa-bell bg-warning text-light"></i>
							</div>
							<span class="title">
								<?php echo $rsg["t1"];?>
								<span class="fr mfr mr5 mmr5"><?php echo dtarih($rsg["t10"],"gg ua yy");?> <?php echo $rsg["t8"];?></span>
							</span>
							<span style="font-size: 12px;">
								<span class="fl mfl"><?php echo $task;?></span>
								<span class="fr mfr mr5 mmr5">
									<?php if(mysqli_num_rows($sqli)>0){?><a  href="../deppo/image/<?php echo $rsi["t1"]; ?>" data-fancybox="gallery" style="float:left; margin-right:5px;"><i class="fa fa-image"></i></a><?php }?> 
									<?php if(mysqli_num_rows($sqlv)>0){?><a  href="<?php echo $rsv["n1"]; ?>" data-fancybox="gallery" style="float:left; margin-right:5px;"><i class="fa fa-youtube"></i></a><?php }?>
									<?php if(mysqli_num_rows($sqld)>0){?><a  href="../deppo/dosya/<?php echo $rsd["t1"]; ?>" style="float:left; margin-right:5px;"><i class="fa fa-file"></i></a><?php }?>
								</span>
								<span class="fr mfr mr5 mmr5">
									<?php $t5Sx = explode(',',$rsg["t11"]); $sqlm=mysqli_query($conn, "select * from t5"); while($rsm=mysqli_fetch_assoc($sqlm)){?>
										<?php foreach($t5Sx as $t5s){if($t5s==$rsm["id"]){echo "{".$rsm["t1"]."}";}}?>
									<?php }?>
								</span>
							</span>
						</div>
					</li>
				<?php }?>
			<?php }?>
		<?php }?>
	</ul>
	<?php }?>
<?php if($_GET["crm"]==""){?>
	<script type="text/javascript">
		jQuery(document).ready(function() {
			var lang = jQuery("body").attr("lang");
			var slang = "<?php echo $_SESSION["lang"]?>";
			if(lang!=slang){
				//jQuery('#conn').show(); jQuery('#conn').html('<span style="font-size:45px;"><i class="fas fa-exclamation-triangle" aria-hidden="true"></i> Dil Değişti</span><br>Arayüzden Dil Değiştirdiniz, Lütfen CrmPlus+ yenileyiniz</div>');
			}
		});
	</script>
<?php }?>