<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>
<link href="//fonts.googleapis.com/css?family=Patrick+Hand" rel="stylesheet">
<script src="//rawgit.com/jackmoore/autosize/master/dist/autosize.min.js"></script>
<div style="position: fixed; margin-left:50%; margin-rigth:50%; top: 100px; width: 60px; height: 60px; font-size: 150px; z-index: 9999999999999999999; display:none;" id="check" class="fa fa-check"></div>
<style>
	.form-control, .form-control:focus{ -webkit-box-shadow: none !important; -moz-box-shadow: none !important; box-shadow: none !important; border: none !important; background-color: transparent !important; resize: none !important; outline: none !important; color: #5b5555 !important; min-height:200px !important; }
	.form-control:not(.form-control-sm):not(.form-control-lg) { min-height: 200px !important; height:100%; }
	.dark-mode .card-header, .dark-mode .tm-title, .dark-mode .tm-box, .dark-mode legend, .dark-mode .wcon, .dark-mode .btn-default, .dark-mode .v3-btn-default, .dark-mode #addclient, .dark-mode .logos, .dark-mode #switchs fieldset { background-color: #000000c4 !important; background: #000000c4 !important; color: #f7f7f7 !important; }
	.dark-mode .form-control, .dark-mode .v3-form-control, .dark-mode .notranslate { background-color: transparent !important; background: transparent !important; color: #5b5555 !important; }
	.dark-mode .keeper{background:#000000c4;}
	.tools .btn {border: 0px; background: unset;}
	.tools .btn:hover {border: 1px solid black; background:#ffffffc4;}

	.fab-container { position: fixed; bottom: 40px; right: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; z-index: 999; }
	.fab-btn { width: 55px; height: 55px; border-radius: 50%; border: none; cursor: pointer; font-size: 26px; color: #fff; box-shadow: 0 3px 8px rgba(0,0,0,0.2); display: flex; justify-content: center; align-items: center; transition: all .2s ease-in-out; }
	.fab-btn:hover { transform: scale(1.1); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
	.fab-info { background-color: #17a2b8; }
	.fab-warning { background-color: #ffc107; color: #222; }
	.fab-search { position: relative; display: flex; align-items: center; }
	.fab-search input { display: none; position: absolute; right: 60px; width: 160px; padding: 6px 10px; border: 1px solid #17a2b8; border-radius: 5px; background: #e9f8fa; color: #333; }
	.fab-search input.show { display: block; }
</style>
<div class="inner-wrapper">
	<section role="main" class="content-body card-margin">
		<header class="page-header">
			<h2><span style="text-transform:capitalize;"><?php echo ctranslate('Keep(s)');?></h2>
				<div class="right-wrapper text-right">
					<ol class="breadcrumbs">
						<li>
							<a href=".">
								<i class="fa fa-home"></i>
							</a>
						</li>
						<li><span><span style="text-transform:capitalize;"><?php echo ctranslate('Keep(s)');?></span></li>
					</ol>
					<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
				</div>
			</header>
			<!-- start: page -->
			<div class="row">
				<div class="col">
					<section class="card">
						<div id="err" style="display:none; width:0px; height:0px;"></div>
						<!-- Sağ altta sabit buton grubu -->
							<div class="fab-container">
								<!-- Katmanla -->
								<button class="fab-btn fab-info" 
									onclick="location.href='?ne=<?php echo $_GET['ne'];?>&islem=<?php echo $_GET['islem'];?>&durum=katmanla'" 
									style="<?php if($mobile<>''){echo 'display:none;';}?>">
									<i class="fa-regular fa-copy"></i>
								</button>

								<!-- Arama -->
								<div class="fab-search">
									<input type="text" id="search" placeholder="Search..." />
									<button class="fab-btn fab-info" onclick="toggle('#search')">
										<i class="fa fa-search"></i>
									</button>
								</div>

								<!-- Yeni Ekle -->
								<button class="fab-btn fab-warning" onclick="toggle('#k0')" title="Yeni Ekle">
									<i class="fa fa-plus"></i>
								</button>
							</div>

						<div class="keeper" style="margin-top: -15px;">
							<style>
								.k0{
									z-index:1; filter: drop-shadow(2px 4px 6px black); <?php if($mobile==""){?>position:absolute;<?php }?> border: 1px solid #ccc; margin: 5px !important; min-height:265px;
									<?php if($mobile==""){echo "width:250px; height:250px;"; }else{echo "width:95%;"; }
									echo "background:#ffff8d;";
									?>
									color: rgba(0,0,0,.87); display: inline-table; padding:10px; font-size:14px; font-family: 'Patrick Hand', cursive;
								}
								.k0:before{content: "#0"; position: absolute; bottom: 45px; right: 25px; font-size: 50px; opacity: 0.1;}
							</style>
							<div data-id="0" id="k0" class="hdiv k0 v3-col-md-2" style="display:none;">
								<i class="fa fa-trash itrash cp" style="display:none; position: absolute; font-size: 14px; top: 5px; left: 5px;" onclick="toggle('#k0')"></i>
								<i class="fa fa-save isave cp"  style="display:none; position: absolute; font-size: 18px; top: 5px; right: 5px;" onclick="AjaxPResult('fonksiyon.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=add_keep','#f0','#f0');"></i>
								<form id="f0" method="post" style="margin-top:10px;height:90%;">
									<textarea class="form-control" name="n1" id="n1_0" placeholder="Yeni Not" style="height: inherit; border: none !important; overflow: auto; outline: none; -webkit-box-shadow: none !important; -moz-box-shadow: none; box-shadow: none !important;"></textarea>
									
									<div class="tools" id="m0" style="position:absolute; display:none; bottom:0px; width:70%;">
										<div id="mc0" style="position:absolute; z-index:1; width:100%; left: -3px; bottom: 10px; border-radius: 5px; padding-top: 2px; font-size: 12px;">
											<select name="s3" id="s3_0" style="float:left; width:36%; margin-right:5px; height:30px; padding:5px;">
												<option value="0" ><?php echo translate("Tekrar")?></option>
												<option value="1" ><?php echo $sdil[70]; //Aylık?></option>
												<option value="2" ><?php echo $sdil[71]; //Yıllık?></option>
											</select>
											<input type="date" value="" name="t4"  id="t4_0" style="float:left; width: 58%; margin-right:3px; padding:0px;">
										</div>								
									</div>
								</form>
								<script>
									<?php if($mobile==""){?>
										jQuery(".k0").mouseenter(function() {
											jQuery("#m0, .itrash, .isave").css("display", "block");
										}).mouseleave(function(){
											jQuery("#m0, .itrash, .isave").css("display", "none");
										});
									<?php }else{?>
										jQuery("#m0, .itrash, .isave").css("display", "block");
									<?php }?>
									jQuery('#f0').change(function(){
										AjaxPResult('fonksiyon.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=add_keep','#f0','#f0');
									});
								</script>
							</div>
							<?php
							$sql=mysqli_query($conn, "select * from genel where ne='not' and t3='keep' $levt order by id desc"); while($rs=mysqli_fetch_assoc($sql)){ $k++;
								$position=""; $properties="";
								$position = explode(',',$rs["n2"]);
								$properties = explode(',',$rs["n3"]);
								$sqlu=mysqli_query($conn, "select * from t5 where id=".$rs["s19"]." order by id desc"); $rsu=mysqli_fetch_assoc($sqlu);
								?>
								<style>
									.k<?php echo $rs["id"]?>{
										z-index:<?php if($rs["n5"]==""){echo $k;}else{echo $rs["n5"];}?>; filter: drop-shadow(2px 4px 6px black); <?php if($mobile==""){?>position:absolute;<?php }?> border: 1px solid #ccc; margin: 5px !important; min-height:265px;
										<?php
										if($mobile=="" and $properties[0]<>""){ echo "width:".($properties[0]+22)."px; height:".($properties[1]+22)."px;"; }elseif($mobile=="" and $properties[0]==""){ echo "width:250px; height:250px;"; }else{ echo "width:95%;"; }
										if($rs["n2"]<>"" and $mobile==""){ echo "top:".$position[0]."px; left:".$position[1]."px;"; }
										if($rs["n4"]==""){ echo "background:#ffff8d;"; }else{ echo "background:".$rs["n4"].";"; }
										?>
										color: rgba(0,0,0,.87); display: inline-table; padding:10px; font-size:14px; font-family: 'Patrick Hand', cursive;
									}
									.k<?php echo $rs["id"]?>:before{content: "#<?php echo $k?>"; position: absolute; bottom: 45px; right: 25px; font-size: 50px; opacity: 0.1;}
								</style>
								<div data-id="<?php echo $rs["id"]?>" keep-order="<?php echo $k?>" class="hdiv k<?php echo $rs["id"]?> v3-col-md-2">
									<i class="far fa-plus iplus cp" style="display:none; position: absolute; font-size: 20px; top: 5px; left: 5px;" onclick="toggle('#k0')"></i>
									<div style="display:none;" id="text_<?php echo $rs["id"]?>"><?php echo $rs["n1"];?></div>
									<div id="r<?php echo $rs["id"]?>" style="display: block; position: absolute; right: 10px; top: 5px;"></div>
									<form id="k<?php echo $rs["id"]?>" method="post" style="margin-top:10px;height:90%;">
										<input type="hidden" name="position" id="pos_<?php echo $rs["id"]?>" value="<?php echo $rs["n2"]?>">
										<input type="hidden" name="properties" id="pro_<?php echo $rs["id"]?>" value="<?php echo $rs["n3"]?>">
										<input type="hidden" name="color"  id="clr_<?php echo $rs["id"]?>" value="<?php echo $rs["n4"]?>">
										<input type="hidden" name="zindex" id="z_<?php echo $rs["id"]?>" value="<?php echo $rs["n5"]?>">
										<textarea class="form-control" name="n1" id="n1_<?php echo $rs["id"]?>" placeholder="Not Alanı" style="height: inherit; border: none !important; overflow: auto; outline: none; -webkit-box-shadow: none !important; -moz-box-shadow: none; box-shadow: none !important;"><?php echo $rs["n1"];?></textarea>
										<?php $sqlc=mysqli_query($conn, "select id from t2 where ne='chat' and t2='keep' and s3=".$rs["id"]." order by id desc"); $rsc=mysqli_fetch_assoc($sqlc);?>
										<?php if(mysqli_num_rows($sqlc)>0){?><span style="position: absolute; bottom: 15px; right: 95px; font-size:10px" title="Chat"><i class="fa-regular fa-comments"></i></span><?php }?>
										<span style="position: absolute; bottom: 15px; right: 10px; font-size:10px" title="Düzenlenme Tarihi"><?php if(mysqli_num_rows($sqlu)>0){echo $rsu["t1"];}else{echo "Admin";}?> <?php echo dtarih($rs["ts2"],"gg ka yy time");?></span>
										<div style="clear:both; height:20px"></div>
										<div class="tools" id="m<?php echo $rs["id"]?>" style="display:none; position:absolute; bottom:10px; width:95%;">
											<a class="btn btn-xs mfrm" data-toggle="modal" data-target="#myModal" data-title="<?php echo $sdil[48]; //E-Ajanda?>" data-ref="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&gun=<?php echo $i-$ilkgun+1;?>&ay=<?php echo $bay;?>&yil=<?php echo $yil;?>" data-width="60%" data-url="modules/events/note.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=noku&gun=<?php echo $cgun;?>&ay=<?php echo $bay;?>&yil=<?php echo $yil;?>&id=<?php echo $rs["id"];?>"><i class="fa fa-edit"></i></a>
											<a class="btn btn-xs btn-delete-div" data-href="modules/events/note.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $rs["id"];?>&durum=snot"><i class="fa fa-trash"></i></a>
											<a class="btn btn-xs kmfrm" onclick="toggle('#mc<?php echo $rs["id"]?>');"><i class="fa fa-calendar"></i></a>
											<div id="mc<?php echo $rs["id"]?>" style="position:absolute; z-index:999; width:100%; left: -3px; bottom: 30px; display:none; border-radius: 5px; padding-top: 2px; font-size: 12px;">
												<select name="s3" id="s3_<?php echo $rs["id"]?>" style="float:left; width:36%; margin-right:5px; height:30px; padding:5px;">
													<option value="0" <?php if($rs["s3"]==0){?>selected<?php }?>><?php echo translate("Tekrar")?></option>
													<option value="1" <?php if($rs["s3"]==1){?>selected<?php }?>><?php echo $sdil[70]; //Aylık?></option>
													<option value="2" <?php if($rs["s3"]==2){?>selected<?php }?>><?php echo $sdil[71]; //Yıllık?></option>
												</select>
												<input type="date" value="<?php echo $rs["t4"];?>" name="t4"  id="t4_<?php echo $rs["id"]?>" style="float:left; width: 58%; margin-right:3px; padding:0px;">
											</div>
											
											<a class="btn btn-xs kmfrm" onclick="toggle('#cm<?php echo $rs["id"]?>');"><i class="fa fa-paint-brush"></i></a>
											<div id="cm<?php echo $rs["id"]?>" style="position:absolute; z-index:999; width:100%; left: -3px; bottom: 30px; display:none; border: 1px solid #ccc; background: #e6e6e6; border-radius: 5px; padding-top: 2px; padding-left: 2px;">
												<i data-id="#ffffff" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#fff; font-size:18px; margin-right:5px;"></i>
												<i data-id="#ffff8d" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#ffff8d; font-size:18px; margin-right:5px;"></i>
												<i data-id="#ffd180" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#ffd180; font-size:18px; margin-right:5px;"></i>
												<i data-id="#ccff90" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#ccff90; font-size:18px; margin-right:5px;"></i>
												<i data-id="#b388ff" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#b388ff; font-size:18px; margin-right:5px;"></i>
												<i data-id="#90f4ff" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#90f4ff; font-size:18px; margin-right:5px;"></i>
												<i data-id="#ff9090" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#ff9090; font-size:18px; margin-right:5px;"></i>
												<i data-id="#de8dbd" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#de8dbd; font-size:18px; margin-right:5px;"></i>
												<i data-id="#80ffcb" class="fa fa-circle c<?php echo $rs["id"]?>" style="color:#80ffcb; font-size:18px; margin-right:5px;"></i>
											</div>
										</div>
									</form>
								</div>
								<script>
									<?php if($mobile==""){?>
										jQuery(".k<?php echo $rs["id"]?>").mouseenter(function() {
											jQuery("#m<?php echo $rs["id"]?>, .iplus").css("display", "block");
										}).mouseleave(function(){
											jQuery("#m<?php echo $rs["id"]?>, .iplus").css("display", "none");
										});
									<?php }else{?>
										jQuery("#m<?php echo $rs["id"]?>, .iplus").css("display", "block");
									<?php }?>
									autosize(document.getElementById("n<?php echo $rs["id"]?>"));
									jQuery('.k<?php echo $rs["id"]?>') .draggable() .resizable();
									<?php if($mobile==""){?>
										jQuery('.k<?php echo $rs["id"]?>').mouseleave(function(){
											skeep(<?php echo $rs["id"]?>);
										});
									<?php }?>
									jQuery('#k<?php echo $rs["id"]?>').change(function(){
										var n1 = jQuery('#n1_<?php echo $rs["id"]?>').val();
										jQuery('#text_<?php echo $rs["id"]?>').html(n1);
										AjaxPResult('fonksiyon.php?durum=keep&id=<?php echo $rs["id"]?>','#k<?php echo $rs["id"]?>','#r<?php echo $rs["id"]?>','nopl','');
									});
									function skeep(id) {
										var keep = '.k'+id+'';
										var vpos = jQuery('#pos_'+id+'').val();
										var vpro	=	jQuery('#pro_'+id+'').val();
										var position = jQuery(keep).position();
										var pos = "" + position.top + "," + position.left + "";
										var pro = ''+jQuery(keep).width()+','+jQuery(keep).height()+'';
										
										jQuery('#pos_'+id+'').val(pos);
										jQuery('#pro_'+id+'').val(pro);
										if(vpos!=pos || vpro!=pro){
											setTimeout(function(){
												AjaxPResult('fonksiyon.php?durum=keep&id='+id+'','#k'+id+'','#r'+id+'','nopl','');
											}, 1000);
										}
									}
									jQuery('.c<?php echo $rs["id"]?>').click(function(){
										var color = jQuery(this).attr('data-id');
										jQuery("#clr_<?php echo $rs["id"]?>").val(color);
										jQuery('.k<?php echo $rs["id"]?>').css({ background: color});
										AjaxPResult('fonksiyon.php?durum=keep&id=<?php echo $rs["id"]?>','#k<?php echo $rs["id"]?>','#r<?php echo $rs["id"]?>','nopl','');
									});
								</script>
							<?php }?>
						</div>
					</section>
				</div>
			</div>
		</section>
		<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>
	</div>
</section>
<script>
	jQuery(document).ready(function(){
		jQuery('#search').keyup(function(){
			var text = jQuery(this).val();
			jQuery('.hdiv').hide();
			jQuery('.hdiv:contains("'+text+'")').show();
		});
	});
	jQuery(".hdiv").click(function(){
		var index_highest = 0;
		jQuery('.hdiv').each(function(e){
			var index_current = parseInt(jQuery(this).css("zIndex"), 10);
			if(index_current > index_highest){
				index_highest = index_current;
			}
		});
		var id = jQuery(this).attr('data-id');
		jQuery(this).css('z-index',index_highest+1);
		jQuery('#z_'+id+'').val(index_highest+1);
	});
</script>
<?php
if ($_GET["durum"]=="katmanla"){
	$arr = array("","5","50","100","150","200","250","300","350","400","450","500","550","600","650","700","750","800","850","900","950");
	$i=0;$a=0;$b=0;$c=0;$d=0;$e=0;
	$sql=mysqli_query($conn, "select * from genel where ne='not' and t3='keep' and n4='' $luye order by id desc"); while($rs=mysqli_fetch_assoc($sql)){ $i++;
		if($i>=1 and $i<=10){ $a++;}elseif($i>=11 and $i<=20){ $b++;}elseif($i>=21 and $i<=30){ $c++;}elseif($i>=31 and $i<=40){ $d++;}elseif($i>=41 and $i<=50){ $e++;}
		if($i>=1 and $i<=10){ $pos="".$arr[$a].",5";}elseif($i>=11 and $i<=20){ $pos="".$arr[$b].",270";}elseif($i>=21 and $i<=30){ $pos="".$arr[$c].",540";}elseif($i>=31 and $i<=40){ $pos="".$arr[$d].",810";}elseif($i>=41 and $i<=50){ $pos="".$arr[$e].",1080";}
		$Rs = mysqli_query($conn, "update genel set n2='".$pos."', n3='228,243' where id=".$rs["id"]."");
	}
	echo location("".$weburl."/".$crmpath."/?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."",top,500,1);
}
?>