<?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 $module["g8_title"];?></title>
</head>
<body>
	<div class="qmodal">
		<div class="qmodal-content">
			<!-- Header with Action Buttons -->
			<div class="qmodal-header">
				<?php if($MSA==1){?>
					<button type="button" class="btn btn-default" onclick="location.href='?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=get_brands'"><i class="fas fa-download"></i></button>
					<button type="button" class="btn btn-danger" onclick="location.href='?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=clear_brands'"><i class="fas fa-trash"></i></button>
				<?php }?>
			</div>
			<!-- Left Tab Menu -->
			<div class="v8-columns">
				<!-- Content Area -->
				<div 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" style="min-width: 800px;">
						<form method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=add_brand" autocomplete="off" name="f0">
							<tr class="addtr">
								<td class="">
									<input type="text" name="n1" class="form-control" placeholder="<?php echo $module["g8_title"];?>">
								</td>
								<td class="w40">
									<input type="text" name="n2" class="form-control" placeholder="<?php echo ctranslate("Kısa Açıklama")?>">
								</td>
								<td class="w15">
									<input type="text" name="n3" class="form-control" placeholder="Logo"  id="i0" onclick="window.open('../upload/upload_all.php?ne=marka&file=image&id=0', 'Upload', 'width=450,height=300')">
								</td>
								<td class="w8">
									<div class="input-group-btn">
										<button tabindex="-1" class="btn btn-warning mbtn" type="submit" <?php if ($e10 == 1 && $_SESSION["user"] !== V3d('TWFzdGVy') && $_SESSION["user"] !== V3d('U3VwZXJBZG1pbg==')) echo 'disabled'; ?>><i class="fa fa-plus"></i></button>
									</div>
								</td>
								<tr>
								</form>
								<?php $sql=mysqli_query($conn, "select * from genel where ne='brand' and n1 LIKE '%".$_POST["q"]."%' order by n1 asc"); while($rs=mysqli_fetch_assoc($sql)){?>
									<form  method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=edit_brand&id=<?php echo $rs["id"];?>" name="f<?php echo $rs["id"]?>">
										<input type="hidden" name="KID[]" value="<?php echo $rs["id"]?>" />
										<tr data-id="<?php echo $rs["id"];?>">
											<td><input type="text" name="n1" class="form-control" value="<?php echo $rs["n1"];?>" placeholder="<?php echo ctranslate("Marka")?>"></td>
											<td><input type="text" name="n2" class="form-control" value="<?php echo $rs["n2"];?>" placeholder="<?php echo ctranslate("Kısa Açıklama")?>"></td>
											<td><input type="text" name="n3" class="form-control" value="<?php echo $rs["n3"];?>" id="i<?php echo $rs["id"]?>" onclick="window.open('../upload/upload_all.php?ne=marka&file=image&id=<?php echo $rs["id"]?>', 'Upload', 'width=450,height=300')"  placeholder="<?php echo ctranslate("Logo")?>"></td>
											<td class="w8">
												<div class="input-group-btn">
													<button tabindex="-1" class="btn btn-warning" type="submit" <?php if ($e10 == 1 && $_SESSION["user"] !== V3d('TWFzdGVy') && $_SESSION["user"] !== V3d('U3VwZXJBZG1pbg==')) echo 'disabled'; ?>><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="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=del_brand&id=<?php echo $rs["id"];?>"><i class="fa fa-times"></i></button>
												</div>
											</td>
										</tr>
									</form>
								<?php }?>
							</table>
						</div>
					</div>
				</body>
				<?php echo $footer?>
				</html>
				<?php
				if($_GET["durum"]=="add_brand"){
					$sqlk=mysqli_query($conn, "select * from genel where ne='brand' and n1='".$_POST["n1"]."'"); $rsk=mysqli_fetch_assoc($sqlk);
					if(mysqli_num_rows($sqlk)==0){
						$sql = $conn->query("insert into genel(ne,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20) VALUES ('brand', '".addslashes(stripslashes($_POST["n1"]))."', '".addslashes(stripslashes($_POST["n2"]))."', '".addslashes(stripslashes($_POST["n3"]))."', '".addslashes(stripslashes($_POST["n4"]))."', '".addslashes(stripslashes($_POST["n5"]))."', '".addslashes(stripslashes($_POST["n6"]))."', '".addslashes(stripslashes($_POST["n7"]))."', '".addslashes(stripslashes($_POST["n8"]))."', '".addslashes(stripslashes($_POST["n9"]))."', '".addslashes(stripslashes($_POST["n10"]))."', '".addslashes(stripslashes($_POST["n11"]))."', '".addslashes(stripslashes($_POST["n12"]))."', '".addslashes(stripslashes($_POST["n13"]))."', '".addslashes(stripslashes($_POST["n14"]))."', '".addslashes(stripslashes($_POST["n15"]))."', '".addslashes(stripslashes($_POST["n16"]))."', '".addslashes(stripslashes($_POST["n17"]))."', '".addslashes(stripslashes($_POST["n18"]))."', '".addslashes(stripslashes($_POST["n19"]))."', '".addslashes(stripslashes($_POST["x20"]))."')");
						echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
					}else{
						echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=err1",self,500,1);
					}

				}elseif($_GET["durum"]=="edit_brand"){
					$Rs = mysqli_query($conn, "update genel set n1='".addslashes(stripslashes($_POST["n1"]))."', n2='".addslashes(stripslashes($_POST["n2"]))."', n3='".addslashes(stripslashes($_POST["n3"]))."' Where id=".$_GET["id"]."");
					echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);

				}elseif($_GET["durum"]=="get_brands"){
					$sqlu=mysqli_query($conn, "select distinct t16 from ".$_SESSION["lang"]." where ne='kayit' order by t16 asc"); while($rsu=mysqli_fetch_assoc($sqlu)){
						$sqlk=mysqli_query($conn, "select * from genel where ne='brand' and n1='".$rsu["t16"]."'"); $rsk=mysqli_fetch_assoc($sqlk);	
						if(mysqli_num_rows($sqlk)==0){
							$sql = $conn->query("insert into genel(ne,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20) VALUES ('brand', '".addslashes(stripslashes($rsu["t16"]))."', '".addslashes(stripslashes($_POST["n2"]))."', '".addslashes(stripslashes($_POST["n3"]))."', '".addslashes(stripslashes($_POST["n4"]))."', '".addslashes(stripslashes($_POST["n5"]))."', '".addslashes(stripslashes($_POST["n6"]))."', '".addslashes(stripslashes($_POST["n7"]))."', '".addslashes(stripslashes($_POST["n8"]))."', '".addslashes(stripslashes($_POST["n9"]))."', '".addslashes(stripslashes($_POST["n10"]))."', '".addslashes(stripslashes($_POST["n11"]))."', '".addslashes(stripslashes($_POST["n12"]))."', '".addslashes(stripslashes($_POST["n13"]))."', '".addslashes(stripslashes($_POST["n14"]))."', '".addslashes(stripslashes($_POST["n15"]))."', '".addslashes(stripslashes($_POST["n16"]))."', '".addslashes(stripslashes($_POST["n17"]))."', '".addslashes(stripslashes($_POST["n18"]))."', '".addslashes(stripslashes($_POST["n19"]))."', '".addslashes(stripslashes($_POST["x20"]))."')");
						}
					}
					echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);

				}elseif($_GET["durum"]=="del_brand"){
					$Rs = mysqli_query($conn, "delete from genel where id=".$_GET["id"]);
					echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);  

				}elseif($_GET["durum"]=="clear"){
					$Rs = mysqli_query($conn, "delete from genel where ne='brand'");
					echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);  
				}
			?>