<?php
	header('Content-Type: text/html; charset=utf-8');
	error_reporting(0);
	$path="../../";
	include("../../map.php");
	include("../../scripts.php");
	include("../../secure.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo translate("Kampanyalar")?></title>
</head>
<body>
    <div class="qmodal">
        <div class="qmodal-content">
            <!-- Header with Action Buttons -->
            <!-- 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">
								<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="w10"><input type="text" name="t1" id="" title="" class="form-control" placeholder="<?php echo translate("Oran %")?>"></td>
										<td class="w10"><input type="date" name="t2" id="" title="" class="form-control" placeholder="<?php echo translate("Süre")?>"></td>
										<td class="w30">
											<select name="s1" class="form-control populate" data-plugin-selecttwo="">
												<option value="0"><?php echo translate("Kategori")?></option>
												<?php $sqlx=mysqli_query($conn, "select * from kategoriler where ne='ukategori' order by sira asc"); while($rsx=mysqli_fetch_assoc($sqlx)){$x++;?>
													<option value="<?php echo $rsx["Cat_ID"];?>">+ <?php echo $rsx["Cat_".$_SESSION['lang'].""];?></option>
													<?php $sqly=mysqli_query($conn, "select * from kategoriler where ne='ualt_kategori' and c1=".$rsx["Cat_ID"]." order by sira asc"); while($rsy=mysqli_fetch_assoc($sqly)){$y++;?>
														<option value="<?php echo $rsy["Cat_ID"];?>">⨧ <?php echo $rsy["Cat_".$_SESSION['lang'].""];?></option>
													<?php }?>
												<?php }?>
												<?php $sqlu=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' order by t1 asc"); while($rsu=mysqli_fetch_assoc($sqlu)){$u++;?>
													<option value="<?php echo $rsu["id"];?>"<?php if($rs["s1"]==$rsu["id"]){echo "Selected";}?>>- <?php echo $rsu["t1"];?></option>
												<?php }?>
											</select>
										</td>
										<td class="w10">
											<select name="s2" class="v3-form-control">
												<option value="0" <?php if($rs["s2"]==0){echo "Selected";}?>>Discount</option>
											</select>
										</td>
										<td class=""><input type="text" name="n1" id="" title="" class="form-control" placeholder="<?php echo translate("Açıklama")?>"></td>
										<td class="w8">
											<div class="input-group-btn">
												<button tabindex="-1" class="btn btn-warning mbtn" type="submit" <?php if(($e10==1 and $_SESSION["user"]<>V3d('TWFzdGVy')) or $E==1){?>disabled<?php }?>><i class="fa fa-plus"></i><span class="ddn"> <?php echo $sdil[201]; //ekle?></span></button>
											</div>
										</td>
										<tr>
										</form>
										<?php $sql=mysqli_query($conn, "select * from genel where ne='discount' 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-<?php if(dt($rs["t2"],"0")>1){echo "success";}else{echo "danger";}?>">
													<td class=""><input type="text" name="t1" id="" title="" class="form-control" placeholder="<?php echo translate("Oran %")?>" value="<?php echo $rs["t1"];?>"></td>
													<td class=""><input type="date" name="t2" id="" title="" class="form-control" placeholder="<?php echo translate("Süre")?>" value="<?php echo $rs["t2"];?>"></td>
													<td class="">
														<select name="s1" class="form-control populate" data-plugin-selecttwo="">
															<option value="0"><?php echo translate("Kategori")?></option>
															<?php $sqlx=mysqli_query($conn, "select * from kategoriler where ne='ukategori' order by sira asc"); while($rsx=mysqli_fetch_assoc($sqlx)){$x++;?>
																<option value="<?php echo $rsx["Cat_ID"];?>"<?php if($rs["s1"]==$rsx["Cat_ID"]){echo "Selected";}?>>[X] <?php echo $rsx["Cat_".$_SESSION['lang'].""];?></option>
																<?php $sqly=mysqli_query($conn, "select * from kategoriler where ne='ualt_kategori' and c1=".$rsx["Cat_ID"]." order by sira asc"); while($rsy=mysqli_fetch_assoc($sqly)){$y++;?>
																	<option value="<?php echo $rsy["Cat_ID"];?>"<?php if($rs["s1"]==$rsy["Cat_ID"]){echo "Selected";}?>>[Y] <?php echo $rsy["Cat_".$_SESSION['lang'].""];?></option>
																<?php }?>
															<?php }?>
															<?php $sqlu=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' order by t1 asc"); while($rsu=mysqli_fetch_assoc($sqlu)){$u++;?>
																<option value="<?php echo $rsu["id"];?>"<?php if($rs["s1"]==$rsu["id"]){echo "Selected";}?>>[P] <?php echo $rsu["t1"];?></option>
															<?php }?>
														</select>
													</td>
													<td class="">
														<select name="s2" class="v3-form-control">
															<option value="0" <?php if($rs["s2"]==0){echo "Selected";}?>>Discount</option>
														</select>
													</td>
													<td class=""><input type="text" name="n1" id="" title="" class="form-control" placeholder="<?php echo translate("Açıklama")?>" value="<?php echo $rs["n1"];?>"></td>
													<td>
														<div class="input-group-btn">
															<button tabindex="-1" class="btn btn-warning mbtn" type="submit" <?php if(($e10==1 and $_SESSION["user"]<>V3d('TWFzdGVy')) or $E==1){?>disabled<?php }?>><i class="fa fa-refresh"></i><span class="ddn"> <?php echo $sdil[203]; //Güncelle?></span></button>
															<a style="margin-left: 1px" tabindex="-1" class="btn btn-danger mbtn cw" href="<?php if(($e10==1 and $_SESSION["user"]<>V3d('TWFzdGVy')) or $E==1){?>#<?php }else{?>?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=sil&id=<?php echo $rs["id"];?><?php }?>" OnClick="return confirm(' Bu Kayıt Silinecektir ! Onaylıyor musunuz ?');"><i class="fa fa-<?php if(($e10==1 and $_SESSION["user"]<>V3d('TWFzdGVy')) or $E==1){?>ban<?php }else{?>times<?php }?>"></i><span class="ddn"> <?php echo $sdil[204]; //Kaldır?></span></a>
														</div>
													</td>
												</tr>
											</form>
										<?php }?>
									</table>
                 </div>
            </div>
</body>
<?php echo $footer?>
</html>
<?php
if($_GET["durum"]=="ekle"){
	$sql = $conn->query("insert into genel(t1,t2,ne,n1,s1,s2) VALUES ('".$_POST["t1"]."', '".$_POST["t2"]."', 'discount', '".$_POST["n1"]."', '".$_POST["s1"]."', '".$_POST["s2"]."')");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
	
}elseif($_GET["durum"]=="duzenle"){
	$Rs = mysqli_query($conn, "update genel set t1='".$_POST["t1"]."', t2='".$_POST["t2"]."', s1='".$_POST["s1"]."', s2='".$_POST["s2"]."', n1='".$_POST["n1"]."' 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);	
}
?>