<?php
    header('Content-Type: text/html; charset=utf-8');
    error_reporting(0);
    $path="../../";
    include("../../map.php");
    include("../../scripts.php");
    include("../../secure.php");
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"].""];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $rs["t1"];?></title>
</head>
<body>
    <div class="qmodal">
        <div class="qmodal-content">
            <!-- Header with Action Buttons -->
            <div class="qmodal-header">
                <div class="header-title">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="?<?php echo uri("get")?>"><i class="fa fa-home"></i></a></li>
                            <li class="breadcrumb-item"><a href="#"><?php echo $sdil[12]; //Kategoriler?></a></li>
                            <li class="breadcrumb-item active" aria-current="page"><?php echo $nedir; //?></li>
                        </ol>
                    </nav>
                </div>
                <button type="button" class="btn btn-info" onclick="location.href='?<?php echo uri("get")?>'"><i class="fas fa-home"></i></button>
                <button type="button" class="btn btn-warning mfrm cp" data-toggle="modal" data-target="#myModal" data-title="<?php echo $sdil[12]; //Kategoriler?>" data-url="categorie_add.php?<?php echo uri("get")?>"><i class="fas fa-plus"></i></button>
            </div>
            <!-- Left Tab Menu -->
            <div class="v8-columns">
                <!-- Content Area -->
                <div class="" ts1="<?php echo dtarih($rs["ts1"],"gg ka yy time");?>" ts2="<?php echo dtarih($rs["ts2"],"gg ka yy time");?>" ts3="<?php echo dtarih($rs["ts3"],"gg ka yy time");?>">
<form action="?<?php echo uri("get")?>&durum=isle" method="post">
                        <table class="v3-table resizable">
                            <thead>
                                <tr class="mdn">
                                    <th class="w2 mw2" style="text-align:center;">
                                        <div class="checkbox-custom" style="">
                                            <input type="checkbox" class="notoggle" id="c0" onclick="Checks(this); toggle('#alldel')" <?php if($_SESSION["kim"]=="yonetici" and $_SESSION["y15"]==0){echo "disabled";}?>>
                                            <label for="c0"></label>
                                        </div>
                                    </th>
                                    <th class="w8">ID</th>
                                    <th> <span class="column-sort"> <a href="?<?php echo uri("get")?>&order=asc" title="Sort up" class="sort-up <?php if($_GET["order"]=="asc"){?>active<?php }?>"></a> <a href="?<?php echo uri("get")?>&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 e"> </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"> Vitrin </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>
                            <tbody>
                                <form id="kaydet" action="?<?php echo uri("get")?>&durum=isle" method="post">
                                    <?php
                                    if (empty($_GET["order"])){ $order="sira asc,Cat_ID asc"; }else{ $order="Cat_".$_SESSION["lang"]." ".$_GET["order"].""; }
                                    if(empty($_GET["c"])){
                                        $sql=mysqli_query($conn, "select * from kategoriler where ne='".$q."kategori' $lcat order by ".$order."");
                                    }else{
                                        $sql=mysqli_query($conn, "select * from kategoriler where (ne='".$q."alt_kategori' and c1=".$_GET["c"].") or (ne='".$q."alt_kategori2' and c2=".$_GET["c"].") or (ne='".$q."alt_kategori3' and s3=".$_GET["c"].") or (ne='".$q."alt_kategori4' and s4=".$_GET["c"].") or (ne='".$q."alt_kategori5' and s5=".$_GET["c"].") $lcat order by ".$order."");
                                    }
                                    while($rsc=mysqli_fetch_assoc($sql)){
										$sqli=mysqli_query($conn, "select * from medya where ne='resim' and s1=".$rsc["Cat_ID"]." and s13=1"); $rsi=mysqli_fetch_assoc($sqli);
                                        if(($_SESSION["kim"]=="Admin") or ($_SESSION["kim"]=="yonetici" and $_SESSION["y9"]==3)){
                                            if ($rsc["s1"]==1 or $authority==0) {
                                                $yetki=0;
                                            }else{
                                                $yetki=1;
                                            }
                                        }else{
                                            $yetki=0;
                                        }
                                        $jsi = json_decode($rsc["n6"], true);
                                        ?>
                                        <input type="hidden" name="KID[]" value="<?php echo $rsc["Cat_ID"]?>" />
                                        <tr data-id="<?php echo $rsc["Cat_ID"];?>">
                                            <td style="text-align:center;" class="mw10  tw5">
                                                <div class="checkbox-custom" style="margin-top:10px">
                                                    <input type="checkbox" id="c<?php echo $rsc["Cat_ID"]?>" class="dchck notoggle" name="SID[]" value="<?php echo $rsc["Cat_ID"]?>" <?php if($yetki==0){echo "Disabled";}?>>
                                                    <label for="c<?php echo $rsc["Cat_ID"]?>"></label>
                                                </div>
                                            </td>
                                            <td class="mdn"><input type="text" name="t4[]" value="<?php if($rsc["t4"]==""){echo i2a($rsc["Cat_ID"],7);}else{echo $rsc["t4"];}?>" class="v3-form-control" style="background: transparent; border: 0px" /></td>
                                            <td class="mw65" style="position: relative;">
                                                    <input type="text" name="cat[]" value="<?php echo $rsc["Cat_".$_SESSION["lang"].""]?>" class="v3-form-control" style="background: transparent; border: 0px" /><span class="fa fa-pencil clnspan"></span>
                                                <div style="position: absolute; right: 50px; top: 10px;"> 
                                                <?php $sqld=mysqli_query($conn, "select id,n4 from genel where ne='tanim' and t2='sp' order by t2,n4 asc"); while($rsd=mysqli_fetch_assoc($sqld)){?>
                                                    <?php if($jsi["ic".cevir($rsd["n4"]).""]<>"" or $jsi["isc".cevir($rsd["n4"]).""]<>""){?><img src="https://cdn.crmplus.com.tr/images/<?php echo $rsd["n4"];?>.ico" style="height:16px; float:left; margin-left:5px;"><?php }?>
                                                <?php }?>
                                                </div>
                                            </td>
                                            <td class="e mdn">
                                                <select size=1 name="s9[]" data-plugin-selecttwo="" class="form-control populate">
                                                    <option value="0">Admin</option>
                                                    <?php $sqlm=mysqli_query($conn, "select id,t1 from t5"); while($rsm=mysqli_fetch_assoc($sqlm)){?>
                                                        <option value="<?php echo $rsm["id"];?>" title="<?php echo $rsm["t1"];?>" alt="<?php echo $rsm["t1"];?>" style="color:#6699FF" <?php if ($rsm["id"]==$rsc["s9"]) {?>Selected<?php }?>><?php echo $rsm["t1"];?></option>
                                                    <?php }?>
                                                </select>
                                            </td>
                                            <td class="mw25 tac">
                                                <?php if(($rsc["ne"]=="".$q."kategori" and $climit>1) or ($rsc["ne"]=="".$q."alt_kategori" and $climit>2) or ($rsc["ne"]=="".$q."alt_kategori2" and $climit>3) or ($rsc["ne"]=="".$q."alt_kategori3" and $climit>4) or ($rsc["ne"]=="".$q."alt_kategori4" and $a5=="5")){?>
                                                    <?php if($rsc["ne"]=="".$q."kategori"){$sor="ne='".$q."alt_kategori' and c1=".$rsc["Cat_ID"]."";}elseif($rsc["ne"]=="".$q."alt_kategori"){$sor="ne='".$q."alt_kategori2' and c2=".$rsc["Cat_ID"]."";}elseif($rsc["ne"]=="".$q."alt_kategori2"){$sor="ne='".$q."alt_kategori3' and s3=".$rsc["Cat_ID"]."";}elseif($rsc["ne"]=="".$q."alt_kategori3"){$sor="ne='".$q."alt_kategori4' and s4=".$rsc["Cat_ID"]."";}elseif($rsc["ne"]=="".$q."alt_kategori3"){$sor="ne='".$q."alt_kategori4' and s4=".$rsc["Cat_ID"]."";}?>
                                                    <?php $say = mysqli_query($conn, "select * FROM kategoriler where ".$sor.""); $rsay=mysqli_num_rows($say);?>
                                                    <a href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&c=<?php echo $rsc["Cat_ID"];?>&nedir=<?php echo $rsc["ne"];?>" class="button scat fs13 mfs11" title="<?php echo $sdil[78]; //Alt Kategorileri?>"><?php echo ctranslate("Alt Grup")?><span><?php echo $rsay?></span></a>
                                                    <?php }elseif($rsc["ne"]=="nkategori"){?>
                                                        <a href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&c=<?php echo $rsc["Cat_ID"];?>&nedir=<?php echo $rsc["ne"];?>" class="button scat fs13 mfs11" title="Model"><?php echo ctranslate("Alt Grup")?><span><?php echo $rsay?></span></a>
                                                    <?php }?>
                                             </td>
											<td style="" class="mdn <?php if($h3<>1){echo "dn";}?>">
												<input type="text" name="ikomisyon" value="<?php echo $jsi["ikomisyon"]?>" class="v3-form-control" style="background: transparent; border: 0px" placeholder="0" />
											</td>
											<td style="" class="mdn">
												<div onclick="AjaxGet('?islem=<?php echo $_GET["islem"];?>&ne=<?php echo $_GET["ne"];?>&c=<?php echo $_GET["c"];?>&nedir=<?php echo $_GET["nedir"];?>&durum=s2&Cat_ID=<?php echo $rsc["Cat_ID"];?>&s2=<?php echo $rsc["s2"] == 1 ? 0 : 1;?>','?islem=<?php echo $_GET["islem"];?>&ne=<?php echo $_GET["ne"];?>&c=<?php echo $_GET["c"];?>&nedir=<?php echo $_GET["nedir"];?>')">
													<div class="checkbox-custom" alt="<?php echo $sdil[218]; //Vitrin?>" title="<?php echo $sdil[218]; //Vitrin?>" style="margin-top: 10px; float:left;">
														<input type="checkbox" id="a<?php echo $rsc["Cat_ID"]?>" <?php if($rsc["s2"]==1){?>checked<?php }?> >
														<label for="a<?php echo $rsc["Cat_ID"]?>"></label>
														<span class="ddn"> <?php echo $sdil[218]; //Vitrin?></span>
													</div>
												</div>
											   <?php if(mysqli_num_rows($sqli)>0){?><a  data-fancybox="gallery" href="<?php echo medya($rsc["Cat_ID"],1,"resim","t1","",$weburl)?>" style="position: absolute; top: 22px; right: 5px;"><i class="fas fa-image" aria-hidden="true" style="font-size: 20px; margin-top: 0px; color: cornflowerblue;"></i></a><?php }?>
											</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="v3-form-control" style="background: transparent; border: 0px"><span class="fa fa-pencil clnspan"></span>
											</td>
											<td class="table-actions mw10" style="text-align: center;">
												<button type="button" class="btn btn-warning btn-edit-row mfrm" data-toggle="modal" data-target="#myModal" data-title="<?php echo $sdil[12]; //Kategoriler?>" data-ref="?<?php echo uri("get")?>" data-url="categorie.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $rsc["Cat_ID"];?>&Cat_ID=<?php echo $rsc["Cat_ID"];?>" title="<?php echo ctranslate("Detay")?>"><i class="fa fa-pencil" aria-hidden="true"></i></button>
												<?php if ($yetki==1){?>
													<button type="button" style="cursor:pointer; padding:1px 5px;" title="<?php echo $sdil[204]; //Kaldir?>" class="btn btn-danger btn-delete-row mdn" data-href="?<?php echo uri("get")?>&Cat_ID=<?php echo $rsc["Cat_ID"];?>&durum=sil"><i class="fa fa-times" aria-hidden="true"></i></button>
												<?php }else{?>
													<button type="button" style="cursor:pointer;" title="<?php echo $sdil[215]; //Yetkili Değilsiniz ?>" class="btn btn-danger btn-ban-row mdn" href="#"><i class="fa fa-lock" aria-hidden="true"></i> <span class="ddn"> <?php echo $sdil[204];?></span></button>
												<?php }?>
											</td>
										</tr>
									<?php }?>
									<button style="display: none;" type="submit" id="isle"></button>
								</form>
                 </div>
            </div>
<?php echo $footer?>
</body>
</html>
<?php
//-------------------------------------------------------------------------------------/Kategori Sil/--------->
if($_GET["durum"] == "sil"){
    $sql=mysqli_query($conn, "select * from kategoriler where Cat_ID=".$_GET["Cat_ID"].""); $rsc=mysqli_fetch_assoc($sql);
    $dosya1="../deppo/kategori/".$rsc["image"].""; unlink($dosya1);
    $Rs = mysqli_query($conn, "delete from kategoriler where Cat_ID=".$_GET["Cat_ID"]." or c1=".$_GET["Cat_ID"]." or c2=".$_GET["Cat_ID"]." or s3=".$_GET["Cat_ID"]." or s4=".$_GET["Cat_ID"]." or s5=".$_GET["Cat_ID"]."");
    echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&c=".$_GET["c"]."&nedir=".$_GET["nedir"]."",self,0,0);
}elseif($_GET["durum"]=="s2"){
    $Rs = mysqli_query($conn, "update kategoriler set s2='".$_GET["s2"]."' where Cat_ID=".$_GET["Cat_ID"]."");
    echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&c=".$_GET["c"]."&nedir=".$_GET["nedir"]."",self,0,0);
}elseif($_GET["durum"]=="isle"){
    if(isset($_POST['SID'])){
        $SID0 = implode(',',$_POST["SID"]); $SIDS = explode(',',$SID0);
        foreach($SIDS as $SID){
            $Rs = mysqli_query($conn, "delete from kategoriler where Cat_ID=".$SID." or c1=".$SID." or c2=".$SID." or s3=".$SID." or s4=".$SID." or s5=".$SID."");
            $dosya1=findDirectoryPath("deppo")."/kategori/".$rsc["image"].""; unlink($dosya1);
        }
    }
    $KID0 = implode(',',$_POST["KID"]); $KIDS = explode(',',$KID0);
    $Ks0 = implode(',',virgul($_POST["cat"],"boz")); $Ks = explode(',',$Ks0);
    $Ss0 = implode(',',$_POST["sira"]); $Ss = explode(',',$Ss0);
    $Ss60 = implode(',',$_POST["s6"]); $Ss6 = explode(',',$Ss60);
    $Ss90 = implode(',',$_POST["s9"]); $Ss9 = explode(',',$Ss90);
    $St40 = implode(',',$_POST["t4"]); $St4 = explode(',',$St40);
    $x=0;foreach($Ks as $X) {$x++;
        $Rs = mysqli_query($conn, "update kategoriler set Cat_".$_SESSION["lang"]."='".addslashes(virgul($X,"duz"))."' 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]."");
    }
    $w=0;foreach($Ss9 as $W) {$w++;
        $Rs = mysqli_query($conn, "update kategoriler set s9='".$W."' where Cat_ID=".$KIDS[$w-1]."");
    }
    $q=0;foreach($St4 as $Q) {$q++;
        $Rs = mysqli_query($conn, "update kategoriler set t4='".$Q."' where Cat_ID=".$KIDS[$q-1]."");
    }
    echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&c=".$_GET["c"]."&nedir=".$_GET["nedir"]."&durum=ok",self,0,0);
}
?>