<style>
	.dd-item > button[data-action="collapse"]:before {content: '≡';}
	.dd-item > button:before {content: '≡';}
	.dd-handle:hover {cursor: -webkit-grab; cursor: grab;}
</style>
<?php
$sqlu=mysqli_query($conn, "select id,t1,n17 from t5 where s9=1 order by t1 asc"); while($rsu=mysqli_fetch_assoc($sqlu)){$u++; $users[] = $rsu; }
if ($_GET["ne"] == "kayit"){
	$q="u"; $climit=$a4;
}elseif ($_GET["ne"] == "sayfa"){	
	$q="s"; $climit=$d10;
}elseif ($_GET["ne"] == "haber"){
	$q="h"; $climit=$b1;
}elseif ($_GET["ne"] == "msayfa"){
	$q="m"; $climit=$g7;
}elseif ($_GET["ne"] == "marka"){
	$q="n"; $climit="5";
}elseif ($_GET["ne"] == "uye"){
	$q="k"; $climit="3";
}elseif ($_GET["ne"] == "reklam"){
	$q="r"; $climit="3";
}elseif ($_GET["ne"] == "forum"){
	$q="f";
}else{
	$q=substr($_GET["ne"],0,1);
	$climit = $module["d10_".$_GET["ne"].""];
}
?>
<div class="inner-wrapper">
	<section role="main" class="content-body">
		<header class="page-header">
			<h2><?php echo translate("Kategori Yönetimi")?></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 translate("Kategori Yönetimi")?></span></li>
				</ol>
				
				<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
			</div>
		</header>
		<div class="alert alert-warning" id="err" style="display:none;"></div>
		<div class="row">
			<div class="col p0">
				<section class="card" style="margin-top: -15px;">
					<header class="card-header v3-bg-info">
						<div class="card-actions" id="v-kategori">
							<a href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>" class="btn btn-warning btn-sm fa fa-plus" style="font-size:14px; margin-top: 5px; margin-right: 5px;"></a>
							<a onclick="#AjaxGResult('modules/categories/save.php?durum=clear','#err','#err');" class="btn btn-danger  btn-sm fa fa-eraser" style="font-size:14px; margin-top: 5px; margin-right: 5px;"></a>
						</div>
						
						<h2 class="card-title">
							<?php echo translate("Kategori Yönetimi")?>
							<a class="fa fa-info-circle cp" data-container="body" data-toggle="popover" data-placement="top" data-content="Menü Yönetimi"></a>
						</h2>
					</header>
					<div class="card-body">
						<div class="row">
							<div class="col-lg-6">
								<?php $sql=mysqli_query($conn, "select * from kategoriler where Cat_ID=".$_GET["id"].""); $rs=mysqli_fetch_assoc($sql);$jslf = json_decode($rs["n1"],true);?>
								<form class="form" id="aform" name="rall">
									<fieldset class="grey-bg mt10">
										<legend><?php echo translate("Kategori Yönetimi")?></legend>
										<fieldset class="">
											<legend> <?php echo translate("Kategori")?>; <span style="font-size:8px; color:#ccc;">(n1)</span> </legend>
											<div class="row">
												<div class="v3-col-md-10 v3-col-xs-10">
													<input type="text" name="lang1" id="n1" value="<?php if($jslf["lang1"]<>""){echo $jslf["lang1"];}else{echo $rs["Cat_".$_SESSION['lang'].""];}?>" title="" class="form-control" placeholder="<?php echo translate("Başlık")?>">
												</div>
												<div class="v3-col-md-1 v3-col-xs-1" title="Vitrin">
													<div class="switch switch-sm switch-success">
														<input type="checkbox" data-plugin-ios-switch="" name="s7" id="s7" value="1" class="switch" <?php if($rs["s7"]=="1") {?>checked<?php }?>>
													</div>
												</div>
												<div class="v3-col-md-1 v3-col-xs-1" title="Silinemez">
													<div class="switch switch-sm switch-success msa">
														<input type="checkbox" data-plugin-ios-switch="" name="s6" id="s6" value="1" class="switch" <?php if($rs["s6"]=="1") {?>checked<?php }?>>
													</div>
												</div>
											</div>
										</fieldset>
										<fieldset class="">
											<legend> <?php echo translate("Yönlendirme")?>; <span style="font-size:8px; color:#ccc;">(n5-t6)</span> </legend>
											<div class="v3-row">
												<div class="v3-col-md-8 v3-col-xs-8">
													<input type="text" list="ln5" class="form-control" name="n5" value="<?php echo $rs["n5"];?>" placeholder="Http://www." autocomplete="off">
											</div>
											<div class="v3-col-md-2 v3-col-xs-2"></div>
											<div class="v3-col-md-2 v3-col-xs-4">
												<select size="1" name="t6" class="form-control">
													<option value="<?php echo $rs["t6"];?>">
														<?php if($rs["t6"]==""){echo "Target";}else{echo $rs["t6"];}?>
													</option>
													<option value="_self">_self</option>
													<option value="_blank">_blank</option>
													<option value="_top">_top</option>
												</select>
											</div>
										</div>
									</fieldset>
									<fieldset class="">
										<legend> <?php echo translate("Görünüm")?></legend>
										<div class="row">
											<div class="v3-col-md-3 v3-col-xs-3">
												<i class="<?php echo $rs["t3"];?>" style="float: left; margin-top: 8px;"></i> <input type="text" class="form-control" id="t3" onkeyup="icons(this);" onBlur="hide('#icons')" list="icons" name="t3" style="width:90%;" value="<?php echo $rs["t3"];?>" placeholder="fas fa-" autocomplete="off">
												<ul class="icons" id="icons" data-input="t3" style="display:none;"></ul>
											</div>
											<div class="v3-col-md-3 v3-col-xs-3">
												<input type="text" class="form-control" name="t4" style="" value="<?php echo $rs["t4"];?>" placeholder="class">
											</div>
											<div class="v3-col-md-3 v3-col-xs-3">
												<input type="text" class="form-control" name="t5" id="t6" style="" value="<?php echo $rs["t5"];?>" placeholder="img" onclick="window.open('modules/upload/upload_all.php?ne=menu&file=dosya', 'Upload', 'width=450,height=300')">
											</div>
											<div class="v3-col-md-2 v3-col-xs-3">
												<input type="text" class="form-control" name="sira" style="" value="<?php echo $rs["sira"];?>" placeholder="Sıra">
											</div>
										</div>
									</fieldset>
									<fieldset class="">
										<legend> Detay / Seo </legend>
										<div class="row">
											<div class="col-lg-12 col-xs-12">
												<input type="text" style="" name="n3" class="form-control" title="n3" value="<?php echo $rs["n3"];?>" placeholder="<?php echo $sdil[39]; //Title?>" />
											</div>
											<div class="col-lg-12 col-xs-12" style="padding: 0px 10px;">
												<input id="input-tags" data_role="tagsinput" class="form-control" name="n4" title="n4" placeholder="<?php echo $sdil[41]; //Etiket?>" value="<?php echo $rs["n4"];?>">
											</div>
											<div class="col-lg-12 col-xs-12">
												<input type="text" class="form-control" name="n2" value="<?php echo $rs["n2"];?>" placeholder="Açıklama">
											</div>
										</div>
									</fieldset>
									<div class="v3-row">
										<div class="v3-col-md-8 v3-col-xs-4">
											<button type="button" onclick="AjaxPResult('modules/categories/save.php?durum=kaydet&id=<?php echo $_GET["id"]?>&ne=<?php echo $_GET["ne"]?>','#aform','#err');" class="btn btn-warning"><?php if($_GET["id"]==""){echo translate("Ekle");}else{echo translate("Güncelle");}?></button>
										</div>
										<div class="v3-col-md-2 v3-col-xs-4">
										<?php if($_GET["id"]<>""){?>
											<a class="btn btn-info mfrm fr" data-toggle="modal" data-target="#myModal" data-title="<?php echo $sdil[12]; //Kategoriler?>" data-ref="<?php echo trim($weburl)?>/<?php echo $crmpath?>/?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>" data-url="modules/public/categorie.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&Cat_ID=<?php echo $_GET["id"]?>" onClick="openwin();" target="islem" title="<?php echo ctranslate("Detay")?>"><i class="fas fa-external-link-alt"></i></a>
										<?php if($rs["s1"]==0 or ($rs["s1"]<>0 and $rs["s2"]==0)){?>
											<a class="btn btn-info mfrm fr mr5" href="?ne=ayarlar&islem=inputs&kid=<?php echo $rs["Cat_ID"];?>" title="<?php echo ctranslate("Özel Alanlar")?>"><i class="fas fa-magic"></i></a>
										<?php }}?>
										</div>
										<div class="v3-col-md-2 v3-col-xs-4">
											<select size=1 name="s19" class="form-control">
												<option value="0">Admin</option>
												<?php if($module["uye_editor"]=="1" or $g10=="1"){?>
													<?php $sql=mysqli_query($conn, "select s2,id,t1 from t5 where s9=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"];?>" style="color:#6699FF" <?php if($rs["s19"]==$rsm["id"]){echo "Selected";}?>><?php echo $rsm["t1"];?></option>
													<?php }?>
												<?php }?>
											</select>
										</div>
									</div>
								</fieldset>
							</form>
						</div>
						<div class="col-lg-6">
							<?php
							$alerts=array("","#ffc1071a","#17a2b829","#e91e631f","#8bc34a21");
							$results = array();
							$a=0;$sqlsc=mysqli_query($conn, "select * from kategoriler where ((ne='".$q."kategori' and t1='') or t1='".$_GET["ne"]."') order by sira asc"); while($rssc=mysqli_fetch_assoc($sqlsc)){$a++;
								$results = $results + array($rssc["Cat_ID"] => $alerts[$a]);
							}
							?>
							<div class="dd" id="nestable" style="margin-top:20px;">
								<ol class="dd-list">
									<?php $sqla=mysqli_query($conn, "select * from kategoriler where (((ne='".$q."kategori' or ne='".$q."alt_kategori' or ne='".$q."alt_kategori2' or ne='".$q."alt_kategori3' or ne='".$q."alt_kategori4') and t1='') or (t1='".$_GET["ne"]."' and s1=0)) order by sira asc"); while($rsa=mysqli_fetch_assoc($sqla)){$jsla = json_decode($rsa["n1"],true);?>
									<li class="dd-item" data-id="<?php echo $rsa["Cat_ID"]?>">
										<a class="pa cw" style="right:100px;margin-top:7px"><?php if($rsa["s7"]<>0){echo "<i class=\"fas fa-check\"></i>";}?></a>
										<a class="fa fa-pencil btn btn-warning pa" style="right:40px; margin-top:7px" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=duzenle&id=<?php echo $rsa["Cat_ID"]?>"></a>
										<a class="fa fa-times btn btn-danger pa" style="right:10px; margin-top:7px" onclick="AjaxGResult('modules/categories/save.php?ne=<?php echo $_GET["ne"]?>&durum=sil&id=<?php echo $rsa["Cat_ID"]?>','#err','#err');"></a>
										<div class="dd-handle v3-bg-primary" style="background:<?php echo $results[$rsa["s3"]]?>"><?php if($rsa["t3"]<>""){echo "<i class=\"".$rsa["t3"]."\" style=\"opacity: 0.2;\"></i>";}?> <?php if($jsla[$_SESSION["lang"]]<>""){echo $jsla[$_SESSION["lang"]];}else{echo "<del>".$rsa["Cat_".$_SESSION["lang"].""]."</del>";}?> <?php if($rsa["n5"]<>""){echo "<i class=\"fa fa-link\" style=\"opacity: 0.2;\" title=\"".$rsa["n5"]."\"></i>";}?></div>
										<ol class="dd-list">
											<?php $sqlb=mysqli_query($conn, "select * from kategoriler where t1='".$_GET["ne"]."' and s1=".$rsa["Cat_ID"]." and s2=0 order by sira asc"); while($rsb=mysqli_fetch_assoc($sqlb)){$jslb = json_decode($rsb["n1"],true);?>
											<li class="dd-item" data-id="<?php echo $rsb["Cat_ID"]?>">
												<a class="pa" style="right:100px;margin-top:7px"></a>
												<a class="fa fa-pencil btn btn-warning pa" style="right:40px;margin-top:7px" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=duzenle&id=<?php echo $rsb["Cat_ID"]?>"></a>
												<a class="fa fa-times btn btn-danger pa" style="right:10px;margin-top:7px" onclick="AjaxGResult('modules/categories/save.php?ne=<?php echo $_GET["ne"]?>&durum=sil&id=<?php echo $rsb["Cat_ID"]?>','#err','#err');"></a>
												<div class="dd-handle v3-bg-info"><?php if($rsb["t3"]<>""){echo "<i class=\"".$rsb["t3"]."\" style=\"opacity: 0.2;\"></i>";}?> <?php if($jslb[$_SESSION["lang"]]<>""){echo $jslb[$_SESSION["lang"]];}else{echo "<del>".$rsb["Cat_".$_SESSION["lang"].""]."</del>";}?> <?php if($rsb["n5"]<>""){echo "<i class=\"fa fa-link\" style=\"opacity: 0.2;\" title=\"".$rsb["n5"]."\"></i>";}?></div>
												<ol class="dd-list">
													<?php $sqlc=mysqli_query($conn, "select * from kategoriler where t1='".$_GET["ne"]."' and s2=".$rsb["Cat_ID"]." and s3=0 order by sira asc"); while($rsc=mysqli_fetch_assoc($sqlc)){$jslc = json_decode($rsc["n1"],true);?>
													<li class="dd-item" data-id="<?php echo $rsc["Cat_ID"]?>">
														<a class="pa" style="right:100px;margin-top:7px"></a>
														<a class="fa fa-pencil btn btn-warning pa" style="right:40px;margin-top:7px" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=duzenle&id=<?php echo $rsc["Cat_ID"]?>"></a>
														<a class="fa fa-times btn btn-danger pa" style="right:10px;margin-top:7px"  onclick="AjaxGResult('modules/categories/save.php?ne=<?php echo $_GET["ne"]?>&durum=sil&id=<?php echo $rsc["Cat_ID"]?>','#err','#err');"></a>
														<div class="dd-handle v3-bg-success"><?php if($rsc["t3"]<>""){echo "<i class=\"".$rsc["t3"]."\" style=\"opacity: 0.2;\"></i>";}?>  <?php if($jslc[$_SESSION["lang"]]<>""){echo $jslc[$_SESSION["lang"]];}else{echo "<del>".$rsc["Cat_".$_SESSION["lang"].""]."</del>";}?> <?php if($rsc["n5"]<>""){echo "<i class=\"fa fa-link\" style=\"opacity: 0.2;\" title=\"".$rsc["n5"]."\"></i>";}?></div>
														<ol class="dd-list">
															<?php $sqld=mysqli_query($conn, "select * from kategoriler where t1='".$_GET["ne"]."' and s3=".$rsc["Cat_ID"]." and s4=0 order by sira asc"); while($rsd=mysqli_fetch_assoc($sqld)){$jsld = json_decode($rsd["n1"],true);?>
															<li class="dd-item" data-id="<?php echo $rsd["Cat_ID"]?>">
																<a class="pa" style="right:100px;margin-top:7px"></a>
																<a class="fa fa-pencil btn btn-warning pa" style="right:40px;margin-top:7px" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=duzenle&id=<?php echo $rsd["Cat_ID"]?>"></a>
																<a class="fa fa-times btn btn-danger pa" style="right:10px;margin-top:7px"  onclick="AjaxGResult('modules/categories/save.php?ne=<?php echo $_GET["ne"]?>&durum=sil&id=<?php echo $rsd["Cat_ID"]?>','#err','#err');"></a>
																<div class="dd-handle v3-bg-warning"><?php if($rsd["t3"]<>""){echo "<i class=\"".$rsd["t3"]."\" style=\"opacity: 0.2;\"></i>";}?>  <?php if($jsld[$_SESSION["lang"]]<>""){echo $jsld[$_SESSION["lang"]];}else{echo "<del>".$rsd["Cat_".$_SESSION["lang"].""]."</del>";}?> <?php if($rsd["n5"]<>""){echo "<i class=\"fa fa-link\" style=\"opacity: 0.2;\" title=\"".$rsd["n5"]."\"></i>";}?></div>
																<ol class="dd-list">
																	<?php $sqle=mysqli_query($conn, "select * from kategoriler where t1='".$_GET["ne"]."' and s4=".$rsd["Cat_ID"]." and s5=0 order by sira asc"); while($rse=mysqli_fetch_assoc($sqle)){$jsle = json_decode($rse["n1"],true);?>
																	<li class="dd-item" data-id="<?php echo $rse["Cat_ID"]?>"> 
																		<a class="pa" style="right:100px;margin-top:7px"></a>
																		<a class="fa fa-pencil btn btn-warning pa" style="right:40px;margin-top:7px" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=duzenle&id=<?php echo $rse["Cat_ID"]?>"></a>
																		<a class="fa fa-times btn btn-danger pa" style="right:10px;margin-top:7px"  onclick="AjaxGResult('modules/categories/save.php?ne=<?php echo $_GET["ne"]?>&durum=sil&id=<?php echo $rse["Cat_ID"]?>','#err','#err');"></a>
																		<div class="dd-handle"><?php //if($rse["t3"]<>""){echo "<i class=\"".$rse["t3"]."\" style=\"opacity: 0.2;\"></i>";}?>  <?php if($jsle[$_SESSION["lang"]]<>""){echo $jsle[$_SESSION["lang"]];}else{echo "<del>".$rse["Cat_".$_SESSION["lang"].""]."</del>";}?> <?php if($rse["n5"]<>""){echo "<i class=\"fa fa-link\" style=\"opacity: 0.2;\" title=\"".$rse["n5"]."\"></i>";}?></div>
																	</li>
																<?php }?>
																</ol>
															</li>
															<?php }?>
														</ol>
													</li>
													<?php }?>
											</ol>
										</li>
										<?php }?>
								</ol>
							</li>
							<?php }?>
					</ol>
			<textarea id="nestable-output" class="form-control dn"></textarea>
		</div>
	</div>
</div>
</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>
<script>
	jQuery('.dd').on('change', function() {
		jQuery("#preload").show();
		setTimeout(function(){
			var dataString = {  data : jQuery("#nestable-output").val(), };
			jQuery.ajax({
				type: "POST",
				url: "modules/categories/save.php",
				data: dataString,
				cache : false,
				success: function(data){  
					jQuery("#preload").hide(); 
				} ,error: function(xhr, status, error) { alert(error); },
			});
		}, 1000);
	});
</script>
<script src="assets/vendor/jquery-nestable/jquery-nestable.js"></script>
<script src="assets/js/examples/examples.nestable.js"></script>