<div class="inner-wrapper">
	<section role="main" class="content-body card-margin">
		<header class="page-header">
			<h2><?php echo $nedir; //?> <?php echo $sdil[12]; //Kategoriler?></h2>
			<div class="right-wrapper text-right">
				<ol class="breadcrumbs">
					<li>
						<a href=".">
							<i class="fa fa-home"></i>
						</a>
					</li>
					<li><a href="?ne=<?php echo $_GET["ne"]?>&islem=kategori"><?php echo $nedir; //?> <?php echo $sdil[12]; //Kategoriler?></a></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 }elseif($_GET["durum"]=="hata"){?>
			<div class="alert alert-danger">
				<?php echo $sdil[9]; //Hata Oluştu !?>
			</div>
		<?php }?>
		<!-- start: page -->
		<div class="row">
			<div class="col-lg-12 p0">
				<section class="card">
					<header class="card-header">
						<div class="card-actions" id="v-<?php echo $_GET['islem'];?>">
							<a class="mb-1 mt-1 mr-1 btn btn-success savebtn" href="#isle" title="<?php echo $sdil[203]; //Güncelle?>"><i class="fa fa-refresh" aria-hidden="true"></i> <?php echo $sdil[203]; //Güncelle?></a>
<!--							
							<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 mdn"><?php echo $nedir; //?></h2>
					<p class="card-subtitle"><?php echo $sdil[12]; //Kategoriler?> </p>
				</header>
				<div class="card-body">
					<div class="scrollable has-scrollbar" data-plugin-scrollable="" style="height: 600px;">
						<div class="scrollable-content" tabindex="0" style="right: -17px;">
								<table class="table table-no-more table-bordered table-striped mb-0">
									<thead>
										<tr>
											<th class="w6">ID</th>
											<th> <span class="column-sort"> <a href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&order=asc" title="Sort up" class="sort-up <?php if($_GET["order"]=="asc"){?>active<?php }?>"></a> <a href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&order=desc" title="Sort down" class="sort-down <?php if($_GET["order"]=="desc"){?>active<?php }?>"></a> </span> <?php echo $sdil[73]; //Kategori?> </th>
											<th class="w10"> <?php echo $sdil[78]; //Alt Kategori?> </th>
											<th class="w5 mdn <?php if($h3<>1){echo "dn";}?>"> Komisyon </th>
											<th class="w5"> <?php echo $sdil[74]; //Sıra?> </th>
											<th class="w8" style="text-align: center;"> <?php echo $sdil[213]; //İşlemler?> </th>
										</tr>
									</thead>
							<form action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&Cat_ID=<?php echo $_GET["Cat_ID"];?>&durum=add" method="post">								
								<tr class="addtr">
									<th><input type="text" name="t1" value="" class="full-width" style="background: transparent; border: 0px" /></th>
									<td><input type="text" name="cat" value="" class="full-width" style="background: transparent; border: 0px" /><span class="fa fa-pencil clnspan"></span></td>
									<td class="mdn tac">...</td>
									<td style="" class="mdn <?php if($h3<>1){echo "dn";}?>">
										<input type="text" name="s6" value="" class="full-width" style="background: transparent; border: 0px" />
									</td>
									<td class="mdn">
										<input type="text" name="sira" value="0" onfocus="if(this.value == '0') { this.value = ''} "  onblur="if(this.value == '') { this.value='0'; }" class="full-width" style="background: transparent; border: 0px"><span class="fa fa-pencil clnspan"></span>
									</td>
									<td class="table-actions" style="text-align: center;">
										<button class="btn btn-warning type="submit"><i class="fa fa-plus" aria-hidden="true" style="color:white"></i> <span class="ddn" style="color:white"> <?php echo $sdil[203]; //Düzenle?></span></button>
									</td>
								</tr>
							</form>
							<form action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&Cat_ID=<?php echo $_GET["Cat_ID"];?>&durum=update" method="post">
									<tbody>
											<?php
											if (empty($_GET["order"])){ $order="sira asc,Cat_ID asc"; }else{ $order="Cat_".$_SESSION["lang"]." ".$_GET["order"].""; }
											if($_GET["Cat_ID"]==""){
												$sql=mysqli_query($conn, "select * from kategoriler where ne='".$_GET["ne"]."' and s1=0 order by ".$order."");
											}else{
												$sql=mysqli_query($conn, "select * from kategoriler where (ne='".$_GET["ne"]."' and s1=".$_GET["Cat_ID"].") order by ".$order."");
											}
											while($rsc=mysqli_fetch_assoc($sql)){
												if(($_SESSION["kim"]=="Admin") or ($_SESSION["kim"]=="yonetici" and $_SESSION["y10"]==3)){
													if ($rsc["s1"]==1 or $authority==0) {
														$yetki=0;
													}else{
														$yetki=1;
													}
												}else{
													$yetki=0;
												}
												?>
												<input type="hidden" name="KID[]" value="<?php echo $rsc["Cat_ID"]?>" />
												<tr data-id="<?php echo $rsc["Cat_ID"];?>">
													<th><input type="text" name="t1[]" value="<?php if($rsc["t1"]==""){echo i2a($rsc["Cat_ID"],7);}else{echo $rsc["t1"];}?>" class="full-width" style="background: transparent; border: 0px" /></th>
													<td><input type="text" name="cat[]" value="<?php echo $rsc["Cat_".$_SESSION["lang"].""]?>" class="full-width" style="background: transparent; border: 0px" /><span class="fa fa-pencil clnspan"></span></td>
													<td class="mdn tac">
															<?php $rs0 = mysqli_query($conn, "select count(*) FROM kategoriler where ne='".$_GET["ne"]."' and s1=".$rsc["Cat_ID"].""); $rsc0=mysqli_fetch_assoc($rs0);?>
															<a href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&Cat_ID=<?php echo $rsc["Cat_ID"];?>" class="button" title="<?php echo $sdil[78]; //Alt Kategorileri?>"><?php echo ctranslate("Alt Gruplar")?> {<?php echo $rsc0[0]?>}</a>
														</td>
															<td style="" class="mdn <?php if($h3<>1){echo "dn";}?>">
																<input type="text" name="s6[]" value="<?php echo $rsc["s6"]?>" class="full-width" style="background: transparent; border: 0px" />
															</td>
															<td class="mdn">
																<input type="text" name="sira[]" value="<?php echo $rsc["sira"];?>" onfocus="if(this.value == '0') { this.value = ''} "  onblur="if(this.value == '') { this.value='0'; }" class="full-width" style="background: transparent; border: 0px"><span class="fa fa-pencil clnspan"></span>
															</td>
															<td class="table-actions" style="text-align: center;">
																<a style="color:white" class="btn btn-warning btn-edit-row mfrm mbtn" 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"];?>&cID=<?php echo $rsc["Cat_ID"];?>" onClick="openwin();" target="islem" title="<?php echo $sdil[203]; //Düzenle?>"><i class="fa fa-pencil" aria-hidden="true" style="color:white"></i> <span class="ddn" style="color:white"> <?php echo $sdil[203]; //Düzenle?></span></a>
																<?php if ($yetki==1){?>
																	<a style="cursor:pointer; padding:1px 5px;color:white" title="<?php echo $sdil[204]; //Kaldir?>" class="btn btn-danger btn-delete-row mbtn" data-href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&cID=<?php echo $rsc["Cat_ID"];?>&durum=delete"><i class="fa fa-times" aria-hidden="true" style="color:white"></i> <span class="ddn" style="color:white"> <?php echo $sdil[204]; //Kaldir?></span></a>
																<?php }else{?>
																	<a style="cursor:pointer;color:white" title="<?php echo $sdil[215]; //Yetkili Değilsiniz ?>" class="btn btn-default btn-ban-row mbtn" href="#"><i class="fa fa-ban" aria-hidden="true" style="color:white"></i> <span class="ddn" style="color:white"> <?php echo $sdil[215]; //Yetkili Değilsiniz ?></span></a>
																<?php }?>
															</td>
														</tr>
													<?php }?>
													<button style="display: none;" type="submit" id="isle"></button>
												</form>
											</tbody>
										</table>
									</div>
									<div class="scrollable-pane" style="opacity: 1; visibility: visible;">
										<div class="scrollable-slider" style="height: 85px; transform: translate(0px, 0px);"></div>
									</div>
								</div>
							</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>
	<?php
//-------------------------------------------------------------------------------------/Kategori Sil/--------->
if ($_GET["durum"]=="add"){
	if($_GET["Cat_ID"]==""){$s1=0;}else{$s1=$_GET["Cat_ID"];}
	$sql = $conn->query("insert into kategoriler (ne,t1,Cat_".$_SESSION["lang"].",sira,s1) VALUES ('".$_GET["ne"]."', '".$_POST["t1"]."', '".addslashes(stripslashes($_POST["cat"]))."', '".$_POST["sira"]."', '".$s1."');");
	$sqlc=mysqli_query($conn, "select * from kategoriler order by Cat_ID desc"); $rsc=mysqli_fetch_assoc($sqlc);
	for ($l = 1; $l <= $lx; $l++) {
		$Rss = mysqli_query($conn, "update kategoriler set Cat_lang".$l."='".$rsc["Cat_".$_SESSION["lang"].""]."' where Cat_ID=".$rsc["Cat_ID"]."");
	}
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&Cat_ID=".$_GET["Cat_ID"]."",self,0,0);
}elseif($_GET["durum"] == "delete"){
	$sql=mysqli_query($conn, "select * from kategoriler where Cat_ID=".$_GET["cID"].""); $rsc=mysqli_fetch_assoc($sql);
	$dosya1="../deppo/kategori/".$rsc["image"].""; unlink($dosya1);
	if ($rs["ne"]=="ukategori"){			                            //-------------------------------------------------------------------------------------/Ürün Kategori ise/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update lang".$l." set s9='0', s10='0', s11='0' where ne='".$_GET["ne"]."' and s9=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="ualt_kategori"){	                            //-------------------------------------------------------------------------------------/Ürün  Alt kategori ise/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update lang".$l." set s9='0', s10='0', s11='0' where ne='".$_GET["ne"]."' and s10=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="hkategori" or $rs["ne"]=="skategori"){ 		    //-------------------------------------------------------------------------------------/Sayfa veya Haber Kategori ise/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update lang".$l." set s2='0', s3='0' where ne='".$_GET["ne"]."' and s2=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="nkategori"){ 		                            //-------------------------------------------------------------------------------------/Marka/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update lang".$l." set t3='0' where ne='".$_GET["ne"]."' and t3=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="nalt_kategori"){						        //-------------------------------------------------------------------------------------/Model/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update lang".$l." set t5='0' where ne='".$_GET["ne"]."' and t5=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="rkategori"){ 		                            //-------------------------------------------------------------------------------------/Reklam/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update reklam set s1='0' where ne='".$_GET["ne"]."' and s1=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="ralt_kategori"){ 		                         //-------------------------------------------------------------------------------------/Reklam Alt/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update reklam set s2='0' where s2=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="halt_kategori" or $rs["ne"]=="salt_kategori"){	//-------------------------------------------------------------------------------------/Sayfa veya Haber Alt kategori ise/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update lang".$l." set s3='0' where ne='".$_GET["ne"]."' and s3=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="fkategori"){	                                //-------------------------------------------------------------------------------------/Forum kategori ise/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update t8 set s2='0' where s2=".$_GET["cID"]."");}
	}elseif($rs["ne"]=="falt_kategori"){	                            //-------------------------------------------------------------------------------------/Forum Alt kategori ise/--------->
		for ($l = 1; $l <= $lx; $l++) {$Rs = mysqli_query($conn, "update t8 set s3='0' where s3=".$_GET["cID"]."");}
	}
	$Rs = mysqli_query($conn, "delete from kategoriler where Cat_ID=".$_GET["cID"]);
	$Rs = mysqli_query($conn, "delete from kategoriler where c1=".$_GET["cID"]);
	$Rs = mysqli_query($conn, "delete from kategoriler where c2=".$_GET["cID"]);
	$Rs = mysqli_query($conn, "delete from kategoriler where s3=".$_GET["cID"]);
	$Rs = mysqli_query($conn, "delete from kategoriler where s4=".$_GET["cID"]);
	$Rs = mysqli_query($conn, "delete from kategoriler where s5=".$_GET["cID"]);
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&Cat_ID=".$_GET["Cat_ID"]."",self,0,0);
}elseif($_GET["durum"]=="s2"){
	$Rs = mysqli_query($conn, "update kategoriler set s2='".$_GET["s2"]."' where Cat_ID=".$_GET["cID"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&Cat_ID=".$_GET["Cat_ID"]."",self,0,0);
}elseif($_GET["durum"]=="update"){
	$KID0 = implode(',',$_POST["KID"]); $KIDS = explode(',',$KID0);
	$Ks0 = implode(',',$_POST["cat"]); $Ks = explode(',',$Ks0);
	$Ss0 = implode(',',$_POST["sira"]); $Ss = explode(',',$Ss0);
	$Ss60 = implode(',',$_POST["s6"]); $Ss6 = explode(',',$Ss60);
	$St10 = implode(',',$_POST["t1"]); $St1 = explode(',',$St10);
	$x=0;foreach($Ks as $X) {$x++;
		$Rs = mysqli_query($conn, "update kategoriler set Cat_".$_SESSION["lang"]."='".addslashes($X)."' where Cat_ID=".$KIDS[$x-1]."");
	}
	$y=0;foreach($Ss as $Y) {$y++;
		$Rs = mysqli_query($conn, "update kategoriler set sira='".$Y."' where Cat_ID=".$KIDS[$y-1]."");
	}
	$z=0;foreach($Ss6 as $Z) {$z++;
		$Rs = mysqli_query($conn, "update kategoriler set s6='".$Z."' where Cat_ID=".$KIDS[$z-1]."");
	}
	$q=0;foreach($St1 as $Q) {$q++;
		$Rs = mysqli_query($conn, "update kategoriler set t1='".$Q."' where Cat_ID=".$KIDS[$q-1]."");
	}
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&Cat_ID=".$_GET["Cat_ID"]."",self,0,0);
}
?>