<?php
if(is_dir("deppo")){$path="";}elseif(is_dir("../deppo")){$path="../";}elseif(is_dir("../../deppo")){$path="../../";}else{$path="../../../";}
include("".$path."deppo/tools/script/cevir.php");
$path2="config/"; include("".$path."config/map.php");
include("".$path."deppo/tools/script/fonksiyon".$ver.".php");
$sqlt=mysqli_query($conn, "select * from genel where ne='tahsilat'"); $rst=mysqli_fetch_assoc($sqlt);
if(!empty($_POST)){
	$order_array = array();
	$order_items = array();
	$order_items["Order_No"] = $_SESSION["Order_No"];
	foreach ($_POST as $key => $value){
		//echo $key; echo ":"; echo $value; echo "<br>";
		$_SESSION["Order_".$key] = $value;
		$order_items[$key] = $value;
	}
	foreach ($_SESSION as $key => $value){
		//echo $key; echo ":"; echo $value; echo "<br>";
		$order_items[$key] = $value;
	}
	array_push($order_array,$order_items);
	$jsOrder = json_encode($order_array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	setcookie("Order_No", $_SESSION["Order_No"], time() + 3600, '/');
	$dir = "../../cache/";
	$file = $dir . $_SESSION["Order_No"] . ".json";
	if (!is_dir($dir)) {
		mkdir($dir, 0777, true); // recursive = true → alt klasörleri de oluşturur
	}

	if (!file_exists($file)) {
		$fp = fopen($file, 'w') or die("Err sd" . __LINE__);
		fwrite($fp, $jsOrder);
		fclose($fp);
	}

}
include("".$path."sale/vpos_extra.php");

if ($_POST["Card_Number"]=="0000 0000 0000 0000"){
	include("3demo/index.php");
}else{
	if($_POST["Payment_Method"]=="pos"){
		$sql = mysqli_query($conn, "select * from genel where ne='banka' and s1=".$_POST["Bank_Id"]." and s2=1"); $rsb = mysqli_fetch_assoc($sql);
		if ($_POST["Bank_Id"]==12){
			include("denizbank/index.php");
		}elseif ($_POST["Bank_Id"]==14){
			include("finansbank/index.php");
		}elseif ($_POST["Bank_Id"]==16){
			include("garanti/index.php");
		}elseif ($_POST["Bank_Id"]==20){
			include("kuveytturk/index.php");
		}elseif ($_POST["Bank_Id"]==38){
			include("vakifbank/index.php");
		}elseif ($_POST["Bank_Id"]==39){
			include("yapikredi/index.php");
		}else{
			include("est/index.php");
		}
	}else{
		include("fintech/".$_POST["Payment_Method"]."/index.php");
	}
}
include("../../../view/save.php");
?>