<?php
$path="../../";
include("../../map.php");
	if($_POST["rb"]==""){$rb=0;}else{$rb = $_POST["rb"];};
	if($_POST["s4"]==0){$ps4=0;}else{$ps4=$_POST["s4"];}
	if($_POST["s5"]==0){$ps5=1;}else{$ps5=$_POST["s5"];}
	$iarr = array();
	foreach ($_POST as $key => $value){
		if(substr($key,0,1)=="i"){
			$iarr = $iarr + array( $key => $value);
		}
	}
	$rjsi = json_encode($iarr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	$pb2=number_format($_POST["fufiyat"]*((($_POST["s4"]+100)/100)),2); //kdv dahil fiyat
if($_GET["durum"]=="uekle"){
	$sqlu = mysqli_query($conn, "select * from ".$_SESSION["lang"]." where t4='".$_POST["t1"]."' order by id desc"); $rsu=mysqli_fetch_assoc($sqlu);
		if(mysqli_num_rows($sqlu)>0){
			$uid=$rsu["id"];
			$sqlc = mysqli_query($conn, "select * from t4 where s1=".$_GET["id"]." and s2=".$uid.""); $rsc=mysqli_fetch_assoc($sqlc);
			if(mysqli_num_rows($sqlc)<>0 and $rb==""){
				$s5=$rsc["s5"]+$ps5;
				$Rs = mysqli_query($conn, "update t4 set s5='".$s5."', n17='".addslashes(stripslashes($rjsi))."' where s1=".$_GET["id"]."");
			}else{
				$sql   = $conn->query("insert into t4(t1,t2,t6,t10,ne,ts1,s1,s2,s4,s5,s6,pb1,pb2,pb3,pb4,n2,n17) values ('".$_GET["islem"]."', '".$_POST["t2"]."', '".$_POST["t6"]."', '".$_POST["t10"]."', 'furun', now(), ".$_GET["id"].", ".$uid.", ".$ps4.", '".$ps5."', '".$rb."', '".sprice($_POST["price"])."', '".sprice($pb2)."', '".sprice($_POST["fulfiyat"])."', '".sprice($_POST["fumaliyet"])."','".addslashes(stripslashes($_POST["fun2"]))."','".addslashes(stripslashes($rjsi))."')");
			}
		}else{
			$sql   = $conn->query("insert into t4(t1,t2,t6,t10,ne,ts1,s1,s2,s4,s5,s6,pb1,pb2,pb3,pb4,n1,n2,n17) values ('".$_GET["islem"]."', '".$_POST["t2"]."', '".$_POST["t6"]."', '".$_POST["t10"]."', 'furun', now(), ".$_GET["id"].", '0', ".$ps4.", '".$ps5."', '".$rb."', '".sprice($_POST["price"])."', '".sprice($pb2)."', '".sprice($_POST["fulfiyat"])."', '".sprice($_POST["fumaliyet"])."','".addslashes(stripslashes($_POST["t1"]))."','".addslashes(stripslashes($_POST["fun2"]))."','".addslashes(stripslashes($rjsi))."')");
		}
	//echo "url:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok";

}elseif($_GET["durum"]=="uguncelle"){
	$sqlu = mysqli_query($conn, "select * from ".$_SESSION["lang"]." where id=".$_POST["urunid"]." order by id desc"); $rsu=mysqli_fetch_assoc($sqlu);
	$sql  = mysqli_query($conn, "select * from t4 where id=".$_GET["uid"]." order by id desc"); $rs=mysqli_fetch_assoc($sql);
	sprice($_POST["fufiyat"]);
	$Rs = mysqli_query($conn, "update t4 set s5='".$_POST["fuadet"]."', pb1='".sprice($_POST["fufiyat"])."', pb2='".sprice($pb2)."', pb3='".sprice($_POST["fulfiyat"])."', pb4='".sprice($_POST["fumaliyet"])."', s4='".$ps4."', s6='".$rb."', n1='".addslashes(stripslashes($_POST["t1"]))."', t10='".$_POST["t10"]."', t2='".$_POST["t2"]."', t6='".$_POST["t6"]."', n2='".addslashes(stripslashes($_POST["fun2"]))."', n17='".addslashes(stripslashes($rjsi))."' where id=".$_GET["uid"]."");
	//echo "url:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&uid=".$_GET["uid"]."&durum=ok";

}elseif($_GET["durum"]=="usil"){
	$sql   = mysqli_query($conn, "delete from t1 where s2=".$_GET["id"]."");
	$sql   = mysqli_query($conn, "delete from t4 where id=".$_GET["uid"]."");
	//echo "url:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok";

}
?>