<?php
	$path="../../../../";
	if(file_exists("".$path."config/map.php" )){$path2="config/"; include("".$path."config/map.php");}else{include("".$path."map.php");}
	if($_GET["islem"]=="uye"){ $from="t5";}else{ $from=$_SESSION['lang'];}
	if($_GET["type"]<>""){ $n7=" and n7=".$_GET["type"]."";}else{ $n7=" and n7=3";}
	if($_GET["type"]==1){$label="display:none"; $col="v3-col-md-12 v3-col-sm-12 v3-col-xs-12";}elseif($_GET["type"]==2){$col="v3-col-md-6 v3-col-sm-6 v3-col-xs-12";}else{$col="v3-col-md-3 v3-col-sm-3 v3-col-xs-12";}
	$sql=mysqli_query($conn, "select * from ".$from." where id=".$_GET["id"].""); $rs=mysqli_fetch_assoc($sql); $jsi = json_decode($rs["n17"], true); $jsl = json_decode($rs["n16"], true); $jsm = json_decode($rs["m1"], true); $jsa = json_decode($rs["m2"], true);
?>
<style>
legend { font-size: 15px !important; }
.clist li{display: flex;}
</style>
<div class="row">
<?php $i=0;$sqli=mysqli_query($conn, "select * from genel where ne='inputs' $linputs $n7 and (t2='All' or t2='".$_SESSION["lang"]."') and (n3='".$_GET["ne"]."' or n3='".$_GET["islem"]."') and n4<>'switch' 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='".$_GET["s2"]."' or n2='".$_GET["s9"]."' or n2='".$_GET["s10"]."') and s1=0 $luye order by s10,id asc"); while($rsi=mysqli_fetch_assoc($sqli)){$i++; $jso = json_decode($rsi["n17"], true);?>
	<div class="<?php echo $col?>" style="">
		<label style="<?php echo $label?>"><i class="<?php echo $rsi["n14"]?>"></i> <?php echo $rsi["n1"];?> <span style="font-size:8px; color:#ccc;"> (i<?php echo $i;?>)</span></label>
		<?php if($rsi["n4"]=="input"){?>
			<input class="form-control <?php echo $rsi["n13"]?>" type="<?php echo $rsi["n5"]?>" name="i<?php echo $i;?>" value="<?php if($jsi["i".$i.""]<>""){echo $jsi["i".$i.""];}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"]?>" name="i<?php echo $i;?>" placeholder="<?php echo $rsi["n11"]?>" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>><?php echo $jsi["i".$i.""];?></textarea>
		<?php }elseif($rsi["n4"]=="select"){?>
			<select class="form-control <?php echo $rsi["n13"]?> populate" data-plugin-selecttwo="" name="i<?php echo $i;?>[]" 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"]?>">
					<label 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";}?>></label>
				</div>
			<?php }}?>
		<?php }elseif($rsi["n4"]=="checkbox"){?>
			<ul class="clist" style="z-index:99999;position:absolute; display:none; height: 100px; top: 30px; overflow: auto;width: 95.5%; background:white;filter: drop-shadow(2px 4px 6px black); padding: 10px;" id="cl<?php echo $rsi["id"];?>">
				<?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" 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="padding: 7px; overflow: auto;" onclick="toggle('#cl<?php echo $rsi["id"];?>')"><?php if($ql<>""){echo substr($ql,0,-2);}else{echo "...";} //Lütfen Seçiniz?> <i class="fa fa-angle-down" style="float:right;color: black; font-size: 16px; font-weight: bold; margin-right: -2px;"></i></div>
			<?php $ql="";$q="";}?>
			<p style="font-size:10px;"><?php echo $rsi["n9"];?></p>
		</div>
	<?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 (n2='0' or n2='".$rs["id"]."' or n2='".$rs["s9"]."' or n2='".$rs["s10"]."') and s1=0 order by s10 asc"); while($rsw=mysqli_fetch_assoc($sqlw)){$w++;?>
		<div class="grey-bg col-md-3 col-sm-12 col-xs-12" style="">
			<legend><i class="<?php echo $rsi["n14"]?>"></i>  <?php echo $rsw["n1"];?><span style="font-size:8px; color:#ccc;">(m<?php echo $w;?>)</span></legend>
			<div class="switch switch-sm switch-success">
				<input type="checkbox" name="m<?php echo $w;?>" data-plugin-ios-switch="" value="1" class="switch" <?php if($jsm["m".$w.""]=="1"){?>Checked<?php }?>>
			</div>
		</div>
	<?php }?>
</div>
	<script src="<?php echo $weburl."/".$crmpath?>/assets/js/theme.init.js"></script>
<script>
	jQuery(document).ready(function(){irequired();});
	jQuery(".required").keyup(function (event) { irequired(); });
	jQuery('.required').change(function(){ irequired(); });
	function irequired() {
		jQuery('.required').each(function(i){
			if(jQuery(this).val()==''){
				var id = jQuery(this).attr('id');
				jQuery("#savebtn").attr('disabled', true);
				jQuery("#"+id+"").addClass("bg-danger"); jQuery("#"+id+"").attr("placeholder","*Lütfen Boş Bırakmayınız");
			}else{
				jQuery('#savebtn').attr('disabled', false);
				jQuery("#"+id+"").removeClass("bg-danger");
			}
		});
	}
	jQuery(".rental").keyup(function (event) {
		var val = jQuery('.rental').val();
		jQuery('#Order_Rental_Days').val(val);
	});
</script>