<?php
	$path="../../"; include("../../map.php");
	if($_GET["islem"]=="relations"){
		$fci="i";
		$fcs="m";
		$from="t1";
		$col="v3-col-md-3";
	}elseif($_GET["islem"]=="dreklam"){
		$fci="i";
		$fcs="m";
		$from="genel";
		$col="v3-col-md-3";
	}elseif($_GET["islem"]=="dform"){
		$fci="q";
		$fcs="w";
		$from="".$_SESSION['lang']."";
		$col="v3-col-md-3";
	}elseif($_GET["islem"]=="dservice"){
		$fci="i";
		$fcs="m";
		$from="t4";
		$col="v3-col-md-4";
	}elseif($_GET["islem"]=="siparis"){
		$fci="i";
		$fcs="m";
		$from="eticaret";
		$col="v3-col-md-4";
	}elseif($_GET["islem"]=="duye"){
		$fci="i";
		$fcs="m";
		$from="t5";
		$col="v3-col-md-3";
	}elseif($_GET["nedir"]=="isayfa"){
		$fci="i";
		$fcs="m";
		$from="t1";
		$col="v3-col-md-3";
	}else{
		$fci="i";
		$fcs="m";
		$from="".$_SESSION['lang']."";
		$col="v3-col-md-3";
	}
	$sql=mysqli_query($conn, "select * from ".$from." where id=".$_GET["id"].""); $rs=mysqli_fetch_assoc($sql);
	if($_GET["nedir"]=="side"){
		$fci="is";
		$fcs="ms";
		$col="";
		$ne="".$_GET["ne"][0]."Side";
		$n2="and (n2='".$_GET["ne"][0]."Side')";
	}elseif($_GET["nedir"]=="isayfa"){
		$fci="spi";
		$fcs="m";
		$col="";
		$ne="".$_GET["ne"]."";
		$n2="and (n2='0' or n2='".$rs["id"]."' or n2='".$rs["s1"]."' or n2='".$rs["s2"]."' or n2='".$rs["s9"]."' or n2='".$rs["s10"]."' or n2='".$rs["s11"]."')";
	}else{
		$n2="and (n2='0' or n2='".$rs["id"]."' or n2='".$rs["s1"]."' or n2='".$rs["s2"]."' or n2='".$rs["s9"]."' or n2='".$rs["s10"]."' or n2='".$rs["s11"]."')";
		$ne="".$_GET["ne"]."";
	}
	$jsi = json_decode($rs["n17"], true);
	$jsl = json_decode($rs["n16"], true);
	$jsm = json_decode($rs["n18"], true);
	//$jsm = json_decode($rs["m1"], true);
	$jsa = json_decode($rs["m2"], true);
?>
<a class="v3-btn v3-btn-xs v3-btn-default sam mfrm" data-width="95%" data-toggle="modal" data-target="#myModal" data-url="../public/inputs.php?ne=ayarlar&islem=inputs&nedir=<?php echo $_GET["ne"]?>&kid=<?php echo $_GET["id"]?>" data-title="<?php echo ctranslate("Özel Alan")?>" style="<?php if($_GET["nedir"]=="side"){echo "display:none;";}?>"><i class="fa fa-wrench" aria-hidden="true"></i></a>
<?php
$i=0; $val=""; $sqli=mysqli_query($conn, "select * from genel where ne='inputs' $linputs and (t2='All' or t2='".$_SESSION["lang"]."') and n3='".$_GET["ne"]."' and n4<>'switch' $n2 and s1=0 $luye order by s10,id asc"); while($rsi=mysqli_fetch_assoc($sqli)){$i++; $jso = json_decode($rsi["n17"], true);
if($rsi["t3"]<>""){$val=$rsi["t3"];}else{$val=$fci.$i;}
?>
	<fieldset class="<?php echo $col?> <?php if($rsi["n15"]==""){echo "v3-col-sm-3 v3-col-xs-12";}else{echo $rsi["n15"];}?>" style="">
		<legend><i class="<?php echo $rsi["n14"]?>"></i> <?php echo ctranslate($rsi["n1"]);?> <span style="font-size:8px; color:#ccc;"> (<?php echo $val;?>)</span></legend>
		<?php if($rsi["n4"]=="input"){?>
			<input class="form-control <?php echo $rsi["n13"]?> <?php echo $rsi["n6"]?>" type="<?php echo $rsi["n5"]?>" id="i<?php echo $rsi["id"]?>" name="<?php echo $val;?>" value="<?php if($jsi["".$val.""]<>""){echo $jsi["".$val.""];}else{echo $rsi["n12"];}?>" placeholder="<?php echo $rsi["n11"]?>" style="" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>>
		<?php }elseif($rsi["n4"]=="textarea"){?>
			<textarea class="form-control <?php echo $rsi["n13"]?> <?php echo $rsi["n6"]?>" name="<?php echo $val;?>" id="i<?php echo $rsi["id"]?>" placeholder="<?php echo $rsi["n11"]?>" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>><?php echo $jsi["".$val.""];?></textarea>
		<?php }elseif($rsi["n4"]=="select"){?>
			<select class="form-control <?php echo $rsi["n13"]?> <?php echo $rsi["n6"]?> populate" data-plugin-selecttwo="" id="i<?php echo $rsi["id"]?>" name="<?php echo $val;?>[]" style="" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>>
				<option value="">...</option>
				<?php usort($jso, fn($a, $b) => $a['s10'] <=> $b['s10']); $o=0; foreach($jso as $okey=>$oval){ $o++;?>
				<?php if($rsi["id"]==$oval["s1"]){?>
					<option value="<?php echo $oval["n2"]?>" <?php $q="";foreach($jsi["".$val.""] as $q){?><?php if($q==$oval["n2"]){echo "selected";}} if($jsi["".$val.""][0]=="" and $oval["n3"]=="1"){echo "selected";}?>><?php echo $oval["n1"]?></option>
				<?php }}?>
			</select>
		<?php }elseif($rsi["n4"]=="radio"){?>
			<?php usort($jso, fn($a, $b) => $a['s10'] <=> $b['s10']); $o=0; foreach($jso as $okey=>$oval){ $o++;?>
			<?php if($rsi["id"]==$oval["s1"]){?>
				<div style="float:left; margin-right: 5px;" class="<?php echo $rsi["n13"]?>">
					<legend style="float:left; margin-right:5px;"><?php echo $oval["n1"];?>
					<input type="radio" name="<?php echo $val;?>" id="i<?php echo $rsi["id"]?>" value="<?php echo $oval["n2"];?>" <?php echo $rsi["n8"]?> <?php if($jsi["".$val.""]==$oval["n2"] or $oval["n3"]==1){echo "checked";}?>></legend>
				</div>
			<?php }}?>
		<?php }elseif($rsi["n4"]=="checkbox"){?>
			<ul class="clist" style="z-index:99999; position:absolute; display:none; height: 200px; overflow: auto !important; width: <?php if($_GET["nedir"]=="side"){echo "90";}else{echo "95.5";}?>%;" id="cl<?php echo $rsi["id"];?>">
				<li style="cursor:pointer;"><input type="checkbox" id="cl<?php echo $rsi["id"];?>_all" onclick="toggleAll('<?php echo $rsi["id"];?>')"> <strong>Tümünü Seç</strong></li>
				<?php usort($jso, fn($a, $b) => $a['s10'] <=> $b['s10']); $o=0; foreach($jso as $okey=>$oval){ $o++;?>
				<?php if($rsi["id"]==$oval["s1"]){?>
					<li onclick="cbox('#cl<?php echo $rsi["id"];?>c<?php echo $o;?>')" style="cursor:pointer;"><input type="checkbox" class="cl<?php echo $rsi["id"];?>_checkbox" onclick="cbox('#cl<?php echo $rsi["id"];?>c<?php echo $o;?>')" id="cl<?php echo $rsi["id"];?>c<?php echo $o;?>" name="<?php echo $val;?>[]" value="<?php echo $oval["n2"];?>" <?php echo $rsi["n8"]?> <?php foreach($jsi["".$val.""] as $q){if($q==$oval["n2"] or $oval["n3"]==1){echo "checked"; $ql .="".$q.", ";}}?>> <?php echo $oval["n1"];?></li>
				<?php }}?>
			</ul>
			<div style="cursor:pointer;height: 60px; overflow: auto;" onclick="toggle('#cl<?php echo $rsi["id"];?>')"><?php if($ql<>""){echo substr($ql,0,-2);}else{echo $sdil[221];} //Lütfen Seçiniz?> <i class="fa fa-angle-down" style="float:right;"></i></div>
			<?php $ql="";$q="";}?>
			<p style="font-size:10px;"><?php echo $rsi["n9"];?></p>
		</fieldset>
	<?php }?>
	<?php $w=0;$sqlw=mysqli_query($conn, "select * from genel where ne='inputs' and (t2='All' or t2='".$_SESSION["lang"]."') and n3='".$_GET["ne"]."' and n4='switch' and s1=0 $n2 order by s10 asc"); while($rsw=mysqli_fetch_assoc($sqlw)){$w++; ?>
		<fieldset class="<?php echo $col?> " style="">
			<legend><i class="<?php echo $rsi["n14"]?>"></i>  <?php echo $rsw["n1"];?><span style="font-size:8px; color:#ccc;">(<?php echo $fcs.$w;?>)</span></legend>
			<div class="switch switch-sm switch-success">
				<input type="checkbox" name="<?php echo $fcs.$w;?>" id="i<?php echo $rsi["id"]?>" data-plugin-ios-switch="" value="1" class="switch" <?php if($jsm["".$fcs.$w.""]=="1"){?>Checked<?php }?>>
			</div>
		</fieldset>
	<?php }?>
<script>
	function toggleAll(id) {
		var checkboxes = document.querySelectorAll('.cl' + id + '_checkbox');
		var selectAllCheckbox = document.getElementById('cl' + id + '_all');
		
		checkboxes.forEach(function(checkbox) {
			checkbox.checked = selectAllCheckbox.checked;
		});
	}
</script>
<script src="<?php echo $weburl."/".$crmpath?>/assets/js/theme.init.js"></script>