<?php 
$path="../../";
include("../../map.php");
$sql=mysqli_query($conn, "select s2,s9 from ".$_SESSION['lang']." where id=".$_GET["id"].""); $rs=mysqli_fetch_assoc($sql);
// Kategori n8 bilgisini çek
$sqlx=mysqli_query($conn,"select n8 from kategoriler where (Cat_ID='".$rs["s9"]."' or Cat_ID='".$rs["s2"]."')");
$rsx=mysqli_fetch_assoc($sqlx);

// Eğer kategoride n8 doluysa onu kullan
if(mysqli_num_rows($sqlx)>0 && $rsx["n8"]!=""){
	$maddeli=explode('+', srep($rsx["n8"]));
}else{
	// Kayıt sayfası ve modül boşsa varsayılan m2
	if($_GET["ne"]=="kayit" && $module["m5_kayit"]==""){
		$maddeli=explode('+', srep($m2));
	}
	// Üye sayfası ve modül boşsa varsayılan n17
	else if($_GET["ne"]=="uye" && $module["m5_uye"]==""){
		$maddeli=explode('+', srep($n17));
	}
	// Servis sayfası ve modül boşsa varsayılan n13
	else if($_GET["ne"]=="servis" && $module["m5_service"]==""){
		$maddeli=explode('+', srep($n13));
	}
	// Aksi durumda modül üzerinden al
	else{
		$maddeli=explode('+', srep($module["m5_".$_GET["ne"]]));
	}
}
?>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<div class="v8-tabs-extra">
	<div class="alert alert-warning dn" id="err" style="display:none; width:100%"></div>
	<div id="tab-locales">
		<ul class="v8-mini-tabs v8-no-margin v8-js-tabs v8-same-height">
			<?php
			$x=0; foreach($maddeli as $gname) {$x++;
				$xgrup=explode(':', $gname); if($xgrup[1]<>""){ $gname=$xgrup[0];}else{ $gname="Grup -".$x."";}
				?>
				<li><a data-id="tab-ext<?php echo $x?>" class="tbtn cp"><?php echo ctranslate($gname)?> <span style="font-size:8px; color:#ccc;">(S2-<?php echo $x?>)</span></a></li>
			<?php }?>
		</ul>
		<?php
		for ($y = 1; $y <= count($maddeli); $y++) {
			if($y==1){
				$grup=explode(',', $maddeli[0]);
			}elseif($y==2){
				$grup=explode(',', $maddeli[1]);
			}elseif($y==3){
				$grup=explode(',', $maddeli[2]);
			}elseif($y==4){
				$grup=explode(',', $maddeli[3]);
			}elseif($y==5){
				$grup=explode(',', $maddeli[4]);
			}
			$tsts="";
			if($_REQUEST["iq"]==""){
				if($y<>1){$tsts="display:none;";}
			}else{
				if($y<>$_REQUEST["iq"]){$tsts="display:none;";}
			}
			?>
			<div class="tbs" id="tab-ext<?php echo $y?>" style="<?php echo $tsts?>">
				<fieldset class="grey-bg row">
					<legend><?php echo ctranslate($sdil[126])?></legend>
					<form method="post" id="fextra<?php echo $y;?>" style="width:100%; overflow:auto;" class="nfx<?php echo $a?>" name="nfx<?php echo $a?>" autocomplete="off">
						<table class="table" style="min-width:800px;">
							<tr class="addtr" style="min-height: 30px;" data-id="" onclick="toggle('#bildirim0<?php echo $y?>');">
								<input type="hidden" name="xs2" value="<?php echo $y?>">
								<?php
								$a=0; foreach($grup as $imadde) {$a++;
									$xmadde=explode(':', $imadde); if($xmadde[1]<>""){ $imadde=$xmadde[1];}else{ $imadde=$xmadde[0];}
									$values=explode('%', $imadde); if($values[1]<>""){ $imadde=$values[0]; $value=$values[1];}else{$imadde=$values[0];}
									?>
									<td>
										<div style="position:absolute; margin-top: -5px; margin-left: -20px; display:none;" id="bildirim0<?php echo $y?>">
											<input title="<?php echo $sdil[218]; //Vitrin?>" type="checkbox" name="xs7" style="height: 18px;width:18px;margin-top: 5px;" value="1" /><br>
											<input title="<?php echo $sdil[220]; //Açık/Kapalı?>" type="checkbox" name="xs13" style="height: 18px;width:18px;margin-top: 5px;" value="1" Checked />
										</div>
										<input type="text" name="xc<?php echo $a?>" id="nx<?php echo $a?>" style="" class="nx<?php echo $a?> form-control v3-input-sm b1o" title="<?php echo $imadde;?>" value="<?php echo $value;?>" placeholder="<?php echo ctranslate($imadde);?>">
									</td>
									<?php $value=""; $values=""; $imadde="";}?>
									<td class="w7 mw7">
										<select name="xt2" id="tx2" class="form-control b1o">
											<option value="All">[0] <?php echo $sdil[132] //Tüm?></option>
											<?php $i = 0;$diller = explode(',',$m1); foreach($diller as $dil) {$i++; if($i > 99) {$i = 1;}?>
											<option value="lang<?php echo $i?>" <?php if ($_SESSION["lang"]=="lang".$i.""){?>Selected<?php }?>>[<?php echo $i;?>] <?php echo $dil;?></option>
										<?php }?>
									</select>
								</td>
								<td class="w5 mw5">
									<input type="text" name="xs10" style="" class="form-control v3-input-sm b1o" title="<?php echo $sdil[74]?>" placeholder="<?php echo $sdil[74]?>" value="0" onfocus="if(this.value == '0') { this.value = ''} "  onblur="if(this.value == '') { this.value='0'; }">
								</td>
								<td class="w8 mw8">
									<div class="input-group-btn">
										<button type="button" tabindex="-1" onclick="Pcke('../public/extra_ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&durum=extra','#fextra<?php echo $y;?>','#err','nfx<?php echo $a?>');" class="btn btn-warning" type="submit"><i class="fa fa-plus "></i></button>
										<button type="button" tabindex="-1" onclick="vtr('xn_<?php echo $y;?>');toggle('#vtr_01<?php echo $y;?>');toggle('#vtr_00<?php echo $y;?>')" class="btn btn-default" style="margin-left:1px !important" id="vtr_01<?php echo $y;?>"><i class="fa fa-angle-double-down"></i></button>
										<button type="button" tabindex="-1" onclick="htr('xn_<?php echo $y;?>');toggle('#vtr_01<?php echo $y;?>');toggle('#vtr_00<?php echo $y;?>')" class="btn btn-default" style="display:none;margin-left:1px !important" id="vtr_00<?php echo $y;?>"><i class="fa fa-angle-double-up"></i></button>
									</div>
								</td>
							</tr>
							<tr style="visibility: hidden;display: none;" id="xn_<?php echo $y;?>">
								<td colspan="<?php echo $a+3;?>" style="padding:0px;">
									<div id="">
										<textarea class="form-control" style="height:60px;" name="xn2" placeholder="<?php echo ctranslate("Kısa")?> [n2]"></textarea>
										<textarea class="form-control" style="margin-top:10px; height:50px;" name="xn1" id="rtex0_<?php echo $y;?>"></textarea>
										<script>CKEDITOR.replace('rtex0_<?php echo $y;?>');</script>
										<?php $i=0;$sqli=mysqli_query($conn, "select * from genel where ne='inputs' and (t2='All' or t2='".$_SESSION["lang"]."') and n3='".$_GET["ne"]."_extra' and n4<>'switch' and s1=0 order by s10 asc");?>
										<?php if(mysqli_num_rows($sqli)>0){?>
											<div class="v3-col-md-12 v3-row mt20">
												<a class="v3-btn v3-btn-xs v3-btn-default sam" style="" href="?ne=ayarlar&islem=inputs&nedir=extra&kid=<?php echo $xn["id"]?>"><i class="fa fa-wrench" aria-hidden="true"></i></a>
												<?php  while($rsi=mysqli_fetch_assoc($sqli)){$i++;?>
													<fieldset class="v3-col-md-3" style="">
														<legend><i class="<?php echo $rsi["n14"]?>"></i> <?php echo $rsi["n1"];?> <span style="font-size:8px; color:#ccc;"> (i<?php echo $i;?>)</span></legend>
														<?php if($rsi["n4"]=="input"){?>
															<input class="form-control <?php echo $rsi["n13"]?>" type="<?php echo $rsi["n5"]?>" name="xi<?php echo $i;?>" value="<?php echo $spjsi["xi".$i.""];?>" 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="xi<?php echo $i;?>" placeholder="<?php echo $rsi["n11"]?>" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>><?php echo $spjsi["xi".$i.""];?></textarea>
														<?php }elseif($rsi["n4"]=="select"){?>
															<select class="form-control <?php echo $rsi["n13"]?> chosen-select" name="xi<?php echo $i;?>[]" style="" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>>
																<option value=""><?php echo $sdil[221]; //Lütfen Seçiniz?></option>
																<?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
																	<option value="<?php echo $rso["n2"]?>" <?php $q="";foreach($spjsi["i".$i.""] as $q){?><?php if($q==$rso["n2"] or $rso["n3"]==1){echo "selected";}}?>><?php echo $rso["n1"]?></option>
																<?php }?>
															</select>
														<?php }elseif($rsi["n4"]=="radio"){?>
															<?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and t2='".$_SESSION["lang"]."' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
																<div style="float:left; margin-right: 5px;">
																	<label style="float:left; margin-right:5px;"><?php echo $rso["n1"];?>
																	<input type="radio" name="xi<?php echo $i;?>" value="<?php echo $rso["n2"];?>" <?php echo $rsi["n8"]?> <?php if($spjsi["xi".$i.""]==$rso["n2"] or $rso["n3"]==1){echo "checked";}?>></label>
																</div>
															<?php }?>
														<?php }elseif($rsi["n4"]=="checkbox"){?>
															<ul class="clist" style="z-index:99999;position:absolute; display:none;" id="cl<?php echo $rsi["id"];?>">
																<?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and t2='".$_SESSION["lang"]."' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
																	<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="xi<?php echo $i;?>[]" value="<?php echo $rso["n2"];?>" <?php echo $rsi["n8"]?> <?php foreach($spjsi["xi".$i.""] as $q){if($q==$rso["n2"] or $rso["n3"]==1){echo "checked"; $ql .="".$q.", ";}}?>> <?php echo $rso["n1"];?></li>
																<?php }?>
															</ul>
															<div style="cursor:pointer;" 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 }?>
												</div>
											<?php }?>
										</td>
									</tr>
								</table>
							</form>
							<?php
							$kdt=0;$kht=0;
							$sql=mysqli_query($conn, "select * from t1 where t1='".$_GET['ne']."' and (t2='All' or t2='".$_SESSION['lang']."') and s1=".$_GET["id"]." and s2=".$y." order by s10,n1 asc"); while($nx=mysqli_fetch_assoc($sql)){
								$spjsi = json_decode($nx["n17"], true);
								$nxjs = json_decode($nx["n12"], true);
								?>
								<form action="../public/extra_ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&extra_id=<?php echo $nx["id"];?>&durum=extra"  style="width:100%; overflow:auto;" method="post" autocomplete="off" id="xf<?php echo $nx["id"];?>" name="xf<?php echo $nx["id"];?>" class="f<?php echo $b?>">
									<table class="table" style="min-width:800px;">
										<tr class="edittr btr" data-id="<?php echo $nx["id"];?>" style="min-height: 30px;" onclick="toggle('#bildirim<?php echo $nx["id"];?>')">
											<input type="hidden" name="xs2" value="<?php echo $nxjs["xs2"];?>">
											<?php $b=0; foreach($grup as $imadde) {$b++; $xmadde=explode(':', $imadde); if($xmadde[1]<>""){ $imadde=$xmadde[1];}else{ $imadde=$xmadde[0];}?>
											<td>
												<?php if($b==1){?>
													<div style="position:absolute; margin-top: -5px; margin-left: -20px; display:none;" id="bildirim<?php echo $nx["id"];?>">
														<input title="<?php echo $sdil[218]; //Vitrin?>" type="checkbox" name="xs7" style="height: 18px;width:18px;margin-top: 5px;" value="1" <?php if($nxjs["xs7"]==1){?>Checked<?php }?> /><br>
														<input title="<?php echo $sdil[220]; //Açık/Kapalı?>" type="checkbox" name="xs13" style="height: 18px;width:18px;margin-top: 5px;" value="1" <?php if($nxjs["xs13"]==1){?>Checked<?php }?> />
													</div>
												<?php }?>
												<input type="text" name="xc<?php echo $b?>" list="lnx<?php echo $b?>" id="nx<?php echo $b?>-<?php echo $nx["id"];?>" style="" value="<?php if($nxjs["xc".$b.""]<>""){echo $nxjs["xc".$b.""];}else{echo $nx["n".$b.""];}?>" class="ox<?php echo $b?> form-control v3-input-sm" title="<?php echo $imadde;?>" placeholder="<?php echo ctranslate($imadde);?>">
											</td>
										<?php }?>
										<td class="w7 mw7">
											<select name="xt2" id="tx2" class="form-control">
												<option value="All" <?php if ($nxjs["xt2"]=="" or $nxjs["xt2"]=="All"){?>Selected<?php }?>>[0] <?php echo $sdil[132] //Tüm?></option>
												<?php $i = 0;$diller = explode(',',$m1); foreach($diller as $dil) {$i++; if($i > 99) {$i = 1;}?>
												<option value="lang<?php echo $i?>" <?php if ($nxjs["xt2"]=="lang".$i."" or ($nxjs["xt2"]=="" and $_SESSION["lang"]=="lang".$i."")){?>Selected<?php }?>>[<?php echo $i;?>] <?php echo $dil;?></option>
											<?php }?>
										</select>
									</td>
									<td class="w5 mw5">
										<input type="text" name="xs10" style="" class="form-control v3-input-sm" title="<?php echo $sdil[74]?>" value="<?php echo $nxjs["xs10"]?>" placeholder="<?php echo $sdil[74]?>" onfocus="if(this.value == '0') { this.value = ''} "  onblur="if(this.value == '') { this.value='0'; }">
									</td>
									<td class="w8 mw8">
										<div class="input-group-btn">
											<button type="button" tabindex="-1" class="btn btn-warning" id="b<?php echo $nx["id"];?>" onclick="Ajaxs('<?php echo $nx["id"];?>','#err','Pcke');" <?php if ($e10==1 and $_SESSION["user"]<>V3d('TWFzdGVy')){?>disabled<?php }?>><i class="fa fa-refresh"></i></button>
											<button type="button" style="margin-left: 1px" tabindex="-1" class="btn btn-danger btn-delete-row" data-href="../public/extra_ajax.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&durum=extra_s&extra_id=<?php echo $nx["id"];?>&sx2=<?php echo $nx["s2"];?>"><i class="fa fa-times "></i></button>
											<button type="button" tabindex="-1" onclick="vtr('xn<?php echo $nx["id"];?>');toggle('#vtr_1<?php echo $nx["id"];?>');toggle('#vtr_0<?php echo $nx["id"];?>')" id="vtr_1<?php echo $nx["id"];?>" class="btn btn-default" style="margin-left:1px !important"><i class="fa fa-angle-double-down"></i></button>
											<button type="button" tabindex="-1" onclick="htr('xn<?php echo $nx["id"];?>');toggle('#vtr_1<?php echo $nx["id"];?>');toggle('#vtr_0<?php echo $nx["id"];?>')" id="vtr_0<?php echo $nx["id"];?>" class="btn btn-default" style="display:none;margin-left:1px !important"><i class="fa fa-angle-double-up"></i></button>
										</div>
									</td>
								</tr>
								<tr style="visibility: hidden;display: none;" id="xn<?php echo $nx["id"];?>">
									<td colspan="<?php echo $a+3;?>">
										<div>
											<textarea class="form-control" style="height:60px;" name="xn2" placeholder="<?php echo $sdil[40]; //Kısa?> [n2]"><?php echo $nx["n2"];?></textarea>
											<textarea class="form-control" style="margin-top:10px; height:50px;" name="xn1" id="rtex<?php echo $nx["id"];?>_<?php echo $y;?>"><?php echo $nx["n1"];?></textarea>
										</div>
										<script>CKEDITOR.replace('rtex<?php echo $nx["id"];?>_<?php echo $y;?>');</script>
										<?php $i=0;$sqli=mysqli_query($conn, "select * from genel where ne='inputs' and (t2='All' or t2='".$_SESSION["lang"]."') and n3='".$_GET["ne"]."_extra' and n4<>'switch' and s1=0 order by s10 asc");?>
										<?php if(mysqli_num_rows($sqli)>0){?>
											<div class="v3-col-md-12 v3-row mt20">
												<a class="v3-btn v3-btn-xs v3-btn-default sam" style="" href="?ne=ayarlar&islem=inputs&nedir=extra&kid=<?php echo $nx["id"]?>"><i class="fa fa-wrench" aria-hidden="true"></i></a>
												<?php  while($rsi=mysqli_fetch_assoc($sqli)){$i++;?>
													<fieldset class="v3-col-md-3" style="">
														<legend><i class="<?php echo $rsi["n14"]?>"></i> <?php echo $rsi["n1"];?> <span style="font-size:8px; color:#ccc;"> (i<?php echo $i;?>)</span></legend>
														<?php if($rsi["n4"]=="input"){?>
															<input class="form-control <?php echo $rsi["n13"]?>" type="<?php echo $rsi["n5"]?>" name="xi<?php echo $i;?>" value="<?php echo $spjsi["xi".$i.""];?>" 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="xi<?php echo $i;?>" placeholder="<?php echo $rsi["n11"]?>" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>><?php echo $spjsi["xi".$i.""];?></textarea>
														<?php }elseif($rsi["n4"]=="select"){?>
															<select class="form-control <?php echo $rsi["n13"]?> chosen-select" name="xi<?php echo $i;?>[]" style="" <?php echo $rsi["n8"]?> <?php echo $rsi["n6"]?>>
																<option value=""><?php echo $sdil[221]; //Lütfen Seçiniz?></option>
																<?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
																	<option value="<?php echo $rso["n2"]?>" <?php $q="";foreach($spjsi["i".$i.""] as $q){?><?php if($q==$rso["n2"] or $rso["n3"]==1){echo "selected";}}?>><?php echo $rso["n1"]?></option>
																<?php }?>
															</select>
														<?php }elseif($rsi["n4"]=="radio"){?>
															<?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and t2='".$_SESSION["lang"]."' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
																<div style="float:left; margin-right: 5px;">
																	<label style="float:left; margin-right:5px;"><?php echo $rso["n1"];?>
																	<input type="radio" name="xi<?php echo $i;?>" value="<?php echo $rso["n2"];?>" <?php echo $rsi["n8"]?> <?php if($spjsi["xi".$i.""]==$rso["n2"] or $rso["n3"]==1){echo "checked";}?>></label>
																</div>
															<?php }?>
														<?php }elseif($rsi["n4"]=="checkbox"){?>
															<ul class="clist" style="z-index:99999;position:absolute; display:none;" id="cl<?php echo $rsi["id"];?>">
																<?php $o=0;$sqlo=mysqli_query($conn, "select * from genel where ne='inputs' and t2='".$_SESSION["lang"]."' and s1=".$rsi["id"]." order by s10 asc"); while($rso=mysqli_fetch_assoc($sqlo)){$o++;?>
																	<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="xi<?php echo $i;?>[]" value="<?php echo $rso["n2"];?>" <?php echo $rsi["n8"]?> <?php foreach($spjsi["xi".$i.""] as $q){if($q==$rso["n2"] or $rso["n3"]==1){echo "checked"; $ql .="".$q.", ";}}?>> <?php echo $rso["n1"];?></li>
																<?php }?>
															</ul>
															<div style="cursor:pointer;" 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 }?>
												</div>
											<?php }?>
										</td>
									</tr>
								</table>
							</form>
							<?php
							if(is_numeric($nx["n2"]) and is_numeric($nx["n3"]) and is_numeric($nx["n4"]) and is_numeric($nx["n5"])){
								$kdt=$kdt+$nx["n5"];
								$kht=$kht+($nx["n2"]*$nx["n3"]);
							}
							?>
						<?php }?>
					</fieldset>
				</div>
			<?php }?>
		</div>
	</div>
	<script type="text/javascript">
	jQuery(function($){
		$(document).on('click','.tbtn',function(){var id=$(this).data("id");$('#iextra .tbs').hide();$('#'+id).show();});
		$("tbody").sortable({delay:150,stop:function(){var o=[];$('tr').each(function(){o.push($(this).data("id"));});$.post("../public/extra_ajax.php",{position:o});}});
	});
	</script>