<?php
header('Content-Type: text/html; charset=utf-8');
error_reporting(0);
$path="../../";
include("../../map.php");
include("../../scripts.php");
include("../../secure.php");
	//findDirectoryPath("deppo")
$sqlu=mysqli_query($conn, "select * from t5 where s9=1 order by t1 asc"); while($rsu=mysqli_fetch_assoc($sqlu)){$u++; $users[] = $rsu;}
?>
<!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">
			<div class="alert alert-warning" id="result" style="display:none;"></div>
			<!-- 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="?"><i class="fa fa-home"></i></a></li>
							<li class="breadcrumb-item"><a href="#"><?php echo $sdil[5]; //Siparişler?></a></li>
							<li class="breadcrumb-item active" aria-current="page"><?php echo translate("Bölgeler")?></li>
						</ol>
					</nav>
				</div>
				<!--<button type="button" class="btn btn-danger" onclick="location.href=''"><i class="fas fa-save"></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");?>">
					<table class="table table-no-more table-bordered table-striped mb-0 fs14 mfs14">
						<form method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=ekle" autocomplete="off" id="tform" name="tform">
							<tr class="addtr alert alert-warning">
								<td class="w15">
									<select name="n2" id="il" class="form-control">
										<option value=""><?php echo translate("Yükleniyor")?></option>
									</select>
									<script type="text/javascript">
										jQuery(document).ready(function(){
											jQuery('#ulke').load('../../../deppo/tools/script/location.php?ne=ulke&sID=<?php if($jsl["ulke"]<>""){echo $jsl["ulke"];}else{echo $module["countrycode"];}?>');
										});
										jQuery('#ulke').on('change', function(){
											var ID = jQuery('#ulke option:selected').attr('ID');
											jQuery('#il').load('../../../deppo/tools/script/location.php?ne=il&ID='+ID);
										})
									</script>
								</td>
								<td class="w15">
									<select name="n3"  id="ilce" class="form-control">
										<option value=""><?php echo translate("Yükleniyor")?></option>
									</select>
									<script type="text/javascript">
										jQuery(document).ready(function() {
											jQuery('#il').load('../../../deppo/tools/script/location.php?ne=il&ID=<?php if($jsl["ulke"]<>""){echo $jsl["ulke"];}else{echo $module["countrycode"];}?>&sID=<?php echo $jsl["sehir"]?>');
										});
										jQuery('#il').on('change', function(){
											var ID = jQuery('#il option:selected').attr('ID');
											jQuery('#ilce').load('../../../deppo/tools/script/location.php?ne=ilce&ID='+ID);
										})
									</script>
								</td>
								<td class="w15">
									<select name="n4" id="semt" class="form-control">
										<option value=""><?php echo translate("Yükleniyor")?></option>
									</select>
									<script type="text/javascript">
										jQuery(document).ready(function() {
											jQuery('#ilce').load('../../../deppo/tools/script/location.php?ne=ilce&ID=<?php echo $jsl["sehir"]?>&sID=<?php echo $jsl["ilce"]?>');
											jQuery('#semt').load('../../../deppo/tools/script/location.php?ne=semt&ID=<?php echo $jsl["ilce"]?>&sID=<?php echo $jsl["semt"]?>');
										});
										jQuery('#ilce').on('change', function(){
											var ID = jQuery('#ilce option:selected').attr('ID');
											jQuery('#semt').load('../../../deppo/tools/script/location.php?ne=semt&ID='+ID);
										})
									</script>
								</td>
								<td class="w15">
									<select size=1 name="s19" style="" class="form-control">
										<option value="0">Admin</option>
										<?php
										foreach($users as $key=>$value){
											$value["id"]==$rs["s19"] ? $selected="selected" : $selected="";
											echo "<option value=\"".$value["id"]."\" id=\"".$value["id"]."\" ".$selected.">".$value["t1"]."</option>";
										}
										?>
									</select>
								</td>
								<td class="w8"><input type="text" name="n5" id="" title="" class="form-control" placeholder="<?php echo translate("Teslimat Süresi")?>"></td>
								<td class="w8"><input type="text" name="n6" id="" title="" class="form-control" placeholder="<?php echo translate("Minimum Tutar")?>"></td>
								<td class="w8"><input type="text" name="n7" id="" title="" class="form-control" placeholder="<?php echo translate("Hizmet Ücreti")?>"></td>
								<td class="w8">
									<div class="input-group-btn">
										<button tabindex="-1" class="btn btn-warning mbtn" type="submit"><i class="fa fa-plus"></i></button>
									</div>
								</td>
								<tr>
								</form>
								<?php $sql=mysqli_query($conn, "select * from genel where ne='areas' order by id asc"); while($rs=mysqli_fetch_assoc($sql)){?>
									<form method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=duzenle&id=<?php echo $rs["id"];?>" autocomplete="off">
										<tr class="alert alert-info" id="tr<?php echo $rs["id"]?>" data-id="<?php echo $rs["id"];?>">
											<td class="">
												<select name="n2" id="il_<?php echo $rs["id"];?>" class="form-control">
													<option value=""><?php echo translate("Yükleniyor")?></option>
												</select>
												<script type="text/javascript">
													jQuery(document).ready(function() {
														jQuery('#ulke_<?php echo $rs["id"];?>').load('../../../deppo/tools/script/location.php?ne=ulke&sID=<?php if($rs["n1"]<>""){echo $rs["n1"];}else{echo $module["countrycode"];}?>');
													});
													jQuery('#ulke_<?php echo $rs["id"];?>').on('change', function(){
														var ID = jQuery('#ulke option:selected').attr('ID');
														jQuery('#il_<?php echo $rs["id"];?>').load('../../../deppo/tools/script/location.php?ne=il&ID='+ID);
													})
												</script>
											</td>
											<td class="">
												<select name="n3" id="ilce_<?php echo $rs["id"];?>" class="form-control">
													<option value=""><?php echo translate("Yükleniyor")?></option>
												</select>
												<script type="text/javascript">
													jQuery(document).ready(function() {
														jQuery('#il_<?php echo $rs["id"];?>').load('../../../deppo/tools/script/location.php?ne=il&ID=<?php if($rs["n1"]<>""){echo $rs["n1"];}else{echo $module["countrycode"];}?>&sID=<?php echo $rs["n2"]?>');
													});
													jQuery('#il_<?php echo $rs["id"];?>').on('change', function(){
														var ID = jQuery('#il_<?php echo $rs["id"];?> option:selected').attr('ID');
														jQuery('#ilce_<?php echo $rs["id"];?>').load('../../../deppo/tools/script/location.php?ne=ilce&ID='+ID);
													})
												</script>
											</td>
											<td class="">
												<select name="n4" id="semt_<?php echo $rs["id"];?>" class="form-control">
													<option value=""><?php echo translate("Yükleniyor")?></option>
												</select>
												<script type="text/javascript">
													jQuery(document).ready(function() {
														jQuery('#ilce_<?php echo $rs["id"];?>').load('../../../deppo/tools/script/location.php?ne=ilce&ID=<?php echo $rs["n2"]?>&sID=<?php echo $rs["n3"]?>');
														jQuery('#semt_<?php echo $rs["id"];?>').load('../../../deppo/tools/script/location.php?ne=semt&ID=<?php echo $rs["n3"]?>&sID=<?php echo $rs["n4"]?>');
													});
													jQuery('#ilce_<?php echo $rs["id"];?>').on('change', function(){
														var ID = jQuery('#ilce_<?php echo $rs["id"];?> option:selected').attr('ID');
														jQuery('#semt_<?php echo $rs["id"];?>').load('../../../deppo/tools/script/location.php?ne=semt&ID='+ID);
													})
												</script>
											</td>
											<td class="">
												<select size=1 name="s19" style="" class="form-control">
													<option value="0">Admin</option>
													<?php
													foreach($users as $key=>$value){
														$value["id"]==$rs["s19"] ? $selected="selected" : $selected="";
														echo "<option value=\"".$value["id"]."\" id=\"".$value["id"]."\" ".$selected.">".$value["t1"]."</option>";
													}
													?>
												</select>
											</td>
											<td class=""><input type="text" name="n5" id="" title="" class="form-control" placeholder="<?php echo translate("Süre")?>" value="<?php echo $rs["n5"];?>"></td>
											<td class=""><input type="text" name="n6" id="" title="" class="form-control" placeholder="<?php echo translate("Minimum")?>" value="<?php echo $rs["n6"];?>"></td>
											<td class=""><input type="text" name="n7" id="" title="" class="form-control" placeholder="<?php echo translate("Servis Ücreti")?>" value="<?php echo $rs["n7"];?>"></td>
											<td>
												<div class="input-group-btn">
													<button tabindex="-1" class="btn btn-warning" type="submit" ><i class="fa fa-refresh"></i></button>
													<button type="button" style="margin-left: 1px" tabindex="-1" data-href="#?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=sil&id=<?php echo $rs["id"];?>" class="btn btn-danger cp btn-delete-row"><i class="fa fa-times"></i></button>
												</div>
											</td>
										</tr>
									</form>
								<?php }?>
							</table>
						</div>
					</div>
				</body>
				<?php echo $footer?>
				</html>
				<?php
				if($_GET["durum"]=="ekle"){
					$sql = $conn->query("insert into genel(ne,n1,n2,n3,n4,n5,n6,n7,s19) VALUES ('areas', '".$_POST["n1"]."', '".$_POST["n2"]."', '".$_POST["n3"]."', '".$_POST["n4"]."', '".$_POST["n5"]."', '".$_POST["n6"]."', '".$_POST["n7"]."', '".$_POST["s19"]."')");
					echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
					
				}elseif($_GET["durum"]=="duzenle"){
					$Rs = mysqli_query($conn, "update genel set n1='".$_POST["n1"]."', n2='".$_POST["n2"]."', n3='".$_POST["n3"]."', n4='".$_POST["n4"]."', n5='".$_POST["n5"]."', n6='".$_POST["n6"]."', n7='".$_POST["n7"]."', s19='".$_POST["s19"]."' Where id=".$_GET["id"]."");
					echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
					
				}elseif($_GET["durum"]=="sil"){
					$Rs = mysqli_query($conn, "delete from genel where id=".$_GET["id"]);
					echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);	
				}
			?>