<?php
$path="../../"; include("../../map.php");
include("../../scripts.php");
$sql=mysqli_query($conn, "select * from t1 where (id='".$_GET["id"]."' or id='".Guid2ID($_GET["id"])."')"); $rs=mysqli_fetch_assoc($sql);
$sqlc0=mysqli_query($conn, "select * from t5 where ne='uye' and id=".$rs["s19"].""); $rsc0=mysqli_fetch_assoc($sqlc0);
if(mysqli_num_rows($sqlc0)>0){$s19_ID=$rsc0["id"]; $s19_Name=$rsc0["t1"];}else{$s19_ID=0; $s19_Name=ctranslate("Admin");}
$sqlc1=mysqli_query($conn, "select * from t5 where ne='uye' and id=".$rs["s1"].""); $rsc1=mysqli_fetch_assoc($sqlc1);
if(mysqli_num_rows($sqlc1)>0){$s1_ID=$rsc1["id"]; $s1_Name=$rsc1["t1"];}else{$s1_ID=0; $s1_Name=$t25s[0];}
?>
<style>
	legend { margin-bottom: 5px; border-bottom: 0px solid #e5e5e5; font-weight: bold; font-size: 14px; }
	.sam { display:none !important; }
	.cke_contents{ height:165px; }
	#cke_1_top {display:none !important;}
	ul {list-style: none;margin-top: 45px;}
	.sent {position: relative; float:right; margin-top:-10px; padding: 10px; border-radius: 5px;}
	.replies {position: relative; float:left; margin-top:10px; padding: 10px; border-radius: 5px;}
</style>
	<form action="?ne=<?php echo $_GET['ne'];?>&islem=<?php echo $_GET['islem'];?>&durum=update&id=<?php echo $_GET["id"]?>" method="post">
	<input type="hidden" name="t5" value="<?php echo $rs["t5"]?>" id="t5">
	<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fancybox/3.0.47/jquery.fancybox.min.css" />
	<div class="v3-panel v3-panel-default">
		<div class="v3-panel-heading"><?php echo $sdil[207]; //Detay?> <span style="float:right;"><input type="datetime-local" class="v3-form-control" name="ts1" value="<?php echo dtarih($rs["ts1"],"yyyy-aa-ggTtime")?>"></span></div>
		<div class="v3-panel-body">
				<div class="v3-row">
					<div class="v3-col-md-5"><b><input type="text" class="v3-form-control" name="t1" value="<?php echo $rs["t1"]?>"></b></div>
					<div class="v3-col-md-4">
					<select name="s2" class="v3-form-control chosen-select">
							<option value="0">...</option>
						<?php $sqlu=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' $luye"); while($rsu=mysqli_fetch_assoc($sqlu)){?>
							<option value="<?php echo $rsu["id"];?>" <?php if($rs["s2"]==$rsu["id"]){echo "selected";}?>><?php //if($rsu["s9"]<>0){echo "".kategori($rsu["id"])." > ";}?><?php echo $rsu["t1"];?></option>
						<?php }?>
					</select>
					</div>
					<div class="v3-col-md-3">
					<select name="s1" class="v3-form-control chosen-select">
							<option value="0"><?php echo $t25s[0]?></option>
						<?php $sqlc=mysqli_query($conn, "select * from t5 where ne='uye' $luye"); while($rsc=mysqli_fetch_assoc($sqlc)){?>
							<option value="<?php echo $rsc["id"];?>" <?php if($rs["s1"]==$rsc["id"]){echo "selected";}?>><?php echo $rsc["t1"];?></option>
						<?php }?>
					</select>
					</div>
				</div>
				<div class="v3-row" style="margin-top:10px;">
					<div class="v3-col-md-12">
						<textarea name="n1" class="v3-form-control" id="rte"><?php echo $rs["n1"]?></textarea>
					</div>
				</div>
				<div class="row" style="clear:both; font-size:14px;">
					<div class="v3-col-md-12" id="inputs">
						<img src="../../assets/img/loading.gif">
					</div>
					<script type="text/JavaScript" language="JavaScript">
						jQuery(document).ready(function () { loadFunction('../ajax/ajax_inputs.php?ne=relations&nedir=relations&kid=<?php echo $_GET["id"]?>','#inputs'); });
					</script>
				</div>
				<div class="v3-col-sm-12 mt5 mmt5" style="clear:both; width:100%;">
					<div class="fl mfl ml5 mml5 fs30 mf30">
						<i class="emojies far fa-smile-wink v3-text-<?php if($rs["t5"]=="smile-wink"){echo "success";}else{echo "warning";}?> cp" onclick="jQuery('#t5').val('smile-wink')" title="Belki"></i>
						<i class="emojies far fa-smile v3-text-<?php if($rs["t5"]=="smile"){echo "success";}else{echo "warning";}?> cp" onclick="jQuery('#t5').val('smile')" title="Olumlu"></i>
						<i class="emojies far fa-laugh v3-text-<?php if($rs["t5"]=="laugh"){echo "success";}else{echo "warning";}?> cp" onclick="jQuery('#t5').val('laugh')" title="Oldu Bu İş"></i>
						<i class="emojies far fa-meh-rolling-eyes v3-text-<?php if($rs["t5"]=="meh-rolling-eyes"){echo "success";}else{echo "warning";}?> cp" onclick="jQuery('#t5').val('meh-rolling-eyes')" title="Kararsız"></i>
						<i class="emojies far fa-frown v3-text-<?php if($rs["t5"]=="frown"){echo "success";}else{echo "warning";}?> cp" onclick="jQuery('#t5').val('frown')" title="Olumsuz"></i>
						<i class="emojies far fa-meh v3-text-<?php if($rs["t5"]=="meh"){echo "success";}else{echo "warning";}?> cp" onclick="jQuery('#t5').val('meh')" title="İmkansız"></i>
					</div>
					<input type="submit" name="btn" class="v3-btn v3-btn-warning fr mfr mr5 mmr5" style="padding: 5px 7px;" value="Güncelle"></input>
					<i class="fa fa-bell-o v3-btn v3-btn-warning fr mfr mr5 mmr5" style="padding: 5px 10px; margin-right:20px;" onclick="toggle('#remember')"></i>
					<div class="fr mfr mr5 mmr5" style="display:none;" id="remember">
						<input type="date" name="t4" class="v3-form-control" value="<?php echo $rs["t4"]?>">
					</div>
				</div>
				<div class="v3-col-sm-12 mt5 mmt5">
					<select name="ss19[]" data-placeholder="Seçiniz" style="" class="v3-form-control chosen-select" tabindex="8" multiple>
						<option value="0" <?php echo ($rs["s19"] == '0' || in_array('0', multivalues($rs["s19"]))) ? 'selected' : '';?>>Admin</option>
						<?php $sql=mysqli_query($conn, "select s2,id,t1 from t5 where (s9=1 or s1=1) $luye"); while($rsm=mysqli_fetch_assoc($sql)){?>
						<option class="" value="<?php echo $rsm["id"];?>" title="<?php echo $rsm["t1"];?>" alt="<?php echo $rsm["t1"];?>" <?php echo ($rsm["id"] == $rs["s19"] || in_array($rsm["id"], multivalues($rs["s19"]))) ? 'selected' : '';?>><?php echo $rsm["t1"];?></option>
						<?php }?>
					</select>
				</div>
			</form>
				<div class="v3-col-sm-12 mt5 mmt5" style="clear:both; width:100%;">
					<div style="width: 100%; clear: both; padding: 10px 0px;">
						<a class="v3-btn v3-btn-success fr mfr mr5 mmr5" style="padding: 5px 7px;" onclick="jQuery('#s1').val('<?php echo $s1_ID;?>'); jQuery('#s2').val('<?php echo $s19_ID;?>'); jQuery('#ctext').attr('placeholder', '<?php echo $s1_Name;?>;'); toggle('#cform')"><i class="far fa-comment-dots"></i> <?php echo $s1_Name;?></a>
						<a class="v3-btn v3-btn-warning fr mfr mr5 mmr5" style="padding: 5px 7px;" onclick="jQuery('#s1').val('<?php echo $s19_ID;?>'); jQuery('#s2').val('<?php echo $s1_ID;?>'); jQuery('#ctext').attr('placeholder', '<?php echo $s19_Name;?>;'); toggle('#cform')"><i class="far fa-comment-dots"></i> <?php echo $s19_Name;?></a>
					</div>
					<form action="?ne=<?php echo $_GET['ne'];?>&islem=<?php echo $_GET['islem'];?>&durum=chat&id=<?php echo $_GET["id"]?>" method="post" id="cform" style="display:none; width:100%; clear:both; margin-top:40px;">
						<input type="hidden" id="s1" name="s1" value="">
						<input type="hidden" id="s2" name="s2" value="">
						<div class="v3-input-group">
							<textarea class="v3-form-control" id="ctext" name="text" placeholder="<?php echo ctranslate("Not")?>" style="border: 1px solid grey !important;"></textarea>
							<span class="v3-input-group-addon">
								<input type="submit" name="btn" class="v3-btn v3-btn-warning fr mfr mr5 mmr5" style="padding: 5px 7px;" value="Gönder"></input>
							</span>
						</div>
					</form>
					<ul>
					<?php $sqlc=mysqli_query($conn, "select id,t2,s1,s2,n1,ts1 from t2 where ne='chat' and t2='relations' and s3=".$_GET["id"]." order by id desc"); while($rsc=mysqli_fetch_assoc($sqlc)){ ?>
						<li class="<?php if($rsc["s1"]==$_SESSION["user_id"]){echo "w20 mw45 replies v3-bg-warning";}elseif($rsc["s2"]==$_SESSION["user_id"] or $rsc["t2"]=='all'){echo "w20 mw45 sent v3-bg-success";}?>" style="clear:both; margin-bottom:15px;">
							<?php if($rsc["s1"]==$_SESSION["user_id"]){?>
								<i class="fas fa-caret-left" style="color: #fff3cd; position: absolute; left: -7px; top: -11px; font-size: 30px; transform: rotate(-90deg);"></i>
							<?php }elseif($rsc["s2"]==$_SESSION["user_id"] or $rsc["t2"]=='all'){?>
								<i class="fas fa-caret-right" style="color: #d4edda; position: absolute; right: -7px; top: -11px; font-size: 30px; transform: rotate(90deg);"></i>
							<?php }?>
							<?php if($rsc["s1"]==$_SESSION["user_id"]){?>
								<span class="prf"><b><?php if($_SESSION["user_id"]>0){echo $_SESSION["user"];}else{echo translate("Admin");}?></b></span>
							<?php }else{?>
								<?php $sql=mysqli_query($conn, "select * from t5 where id=".$rsc["s1"]." or id=".$rsc["s2"].""); $rsu=mysqli_fetch_assoc($sql);?>
									<span class="prf"><b><?php echo $rsu["t1"];?></b></span>
								<?php }?>
								<p><?php echo $rsc["n1"]?><span style="font-size:9px; display:block;"><?php echo timeAgo($rsc["ts1"])?></span></p>
							</li>
						<?php }?>
					</ul>
				</div>
		</div>
		<div class="v3-panel-footer">By Crm +Plus</div>
	</div>
	<script>
		jQuery('.emojies').click(function () {
			jQuery('.emojies').each(function(index) {
				jQuery('.emojies').removeClass('v3-text-success');
				jQuery('.emojies').addClass('v3-text-warning');
			});
			jQuery(this).toggleClass('v3-text-warning v3-text-success');
		});
		if (document.getElementById("rte") != undefined) {
			CKEDITOR.replace('rte');
		};
	</script>
<?php 
if($_GET["durum"]=="update"){
	$ss19 = implode(',', array_map(function($value) {return "{".$value."}";}, $_POST["ss19"]));
	$iarr = array();
	foreach ($_POST as $key => $value){
		if(substr($key,0,1)=="i"){
			$iarr = $iarr + array( $key => $value);
		}
	}
	$rjsi = json_encode($iarr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	$Up = mysqli_query($conn, "update t1 set t1='".addslashes(stripslashes($_POST["t1"]))."', ts1='".$_POST["ts1"]."', s1='".$_POST["s1"]."', s2='".$_POST["s2"]."', s19='".$ss19."', t4='".$_POST["t4"]."', t5='".$_POST["t5"]."', n1='".addslashes(stripslashes($_POST["n1"]))."', n17='".addslashes(stripslashes($rjsi))."' where id=".$_GET["id"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."",self,500,1);
}elseif($_GET["durum"]=="chat"){
	$Sql = $conn->query("insert into t2(ne,t1,t2,s1,s2,s3,n1,ts1) values ('chat', '".getRealIpAddr()."', 'relations' , '".$_POST["s1"]."', '".$_POST["s2"]."', '".$_GET["id"]."', '".$_POST["text"]."', now())");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."",self,500,1);
}
echo $footer;
include("../public/log.php");
?>