<?php 
error_reporting(0);
$path="../../../";
if(file_exists("".$path."config/map.php" )){$path2="config/"; include("".$path."config/map.php");}else{include("".$path."map.php");}
include("".$path."deppo/tools/script/fonksiyon".$ver.".php");
include("".$path."deppo/tools/script/cevir.php");
function HttpStatus($code) {
	$status = array(
		100 => 'Continue',  
		101 => 'Switching Protocols',  
		200 => 'OK',
		201 => 'Created',  
		202 => 'Accepted',  
		203 => 'Non-Authoritative Information',  
		204 => 'No Content',
		205 => 'Reset Content',
		206 => 'Partial Content',  
		300 => 'Multiple Choices',  
		301 => 'Moved Permanently',  
		302 => 'Found',  
		303 => 'See Other',  
		304 => 'Not Modified',  
		305 => 'Use Proxy',  
		306 => '(Unused)',  
		307 => 'Temporary Redirect',  
		400 => 'Bad Request',  
		401 => 'Unauthorized',  
		402 => 'Payment Required',  
		403 => 'Forbidden',  
		404 => 'Not Found',  
		405 => 'Method Not Allowed',  
		406 => 'Not Acceptable',  
		407 => 'Proxy Authentication Required',  
		408 => 'Request Timeout',  
		409 => 'Conflict',  
		410 => 'Gone',  
		411 => 'Length Required',  
		412 => 'Precondition Failed',  
		413 => 'Request Entity Too Large',  
		414 => 'Request-URI Too Long',  
		415 => 'Unsupported Media Type',  
		416 => 'Requested Range Not Satisfiable',  
		417 => 'Expectation Failed',  
		500 => 'Internal Server Error',  
		501 => 'Not Implemented',  
		502 => 'Bad Gateway',  
		503 => 'Service Unavailable',  
		504 => 'Gateway Timeout',  
		505 => 'HTTP Version Not Supported');
    // gönderilen kod listede yok ise 500 durum kodu gönderilsin. 
	return $status[$code] ? $status[$code] : $status[500];
}

function SetHeader($code){
	header("HTTP/1.1 ".$code." ".HttpStatus($code));
	header("Content-Type: application/json; charset=utf-8");
}

$Wuser=tanim("ws","n1",0);
$Wpass=tanim("ws","n2",0);
if($_POST["module"]<>""){
	$modules=$_POST["module"];
	$user=$_POST["user"];
	$pass=$_POST["pass"];
	$userid=$_POST["userid"];
	$itemid=$_POST["itemid"];
	$itemname=$_POST["itemname"];
	$rlimit=$_POST["limit"];
}elseif($_GET["module"]<>""){
	$modules=$_GET["module"];
	$user=$_GET["user"];
	$pass=$_GET["pass"];
	$userid=$_GET["userid"];
	$itemid=$_GET["itemid"];
	$itemname=qa($_GET["itemname"]);
	$rlimit=$_GET["limit"];
}

if($userid<>""){ $qry="and s19='".$userid."'"; }
if($itemid<>""){$itemid="and id='".$itemid."'"; $citemid="and Cat_ID='".$itemid."'";}
if($rlimit<>""){$slimit=explode(",",$rlimit); $limit="limit ".$slimit[0].",".$slimit[1].""; }
if($itemname <> ""){
    $keywords = explode(" ", $itemname); 
    $likeClauses = []; 
    $clikeClauses = [];

    foreach ($keywords as $keyword) {
        $keyword = mysqli_real_escape_string($conn, $keyword);
        // Her kelimenin t1 (başlık) içinde geçmesini zorunlu kılıyoruz
        $likeClauses[] = "t1 LIKE '%" . $keyword . "%'"; 
        $clikeClauses[] = "(Cat_lang1 LIKE '%" . $keyword . "%' or n2 LIKE '%" . $keyword . "%')"; 
    }

    // BURASI KRİTİK: 'or' olan yerleri 'and' ile değiştirdik.
    // Böylece "Loft Kadın Etek" içinde "ayakkabı" geçmediği için elenecek.
    $likeQuery = implode(" AND ", $likeClauses); 
    $clikeQuery = implode(" AND ", $clikeClauses);

    $qry = " AND (" . $likeQuery . ")"; 
    $cqry = " AND (" . $clikeQuery . ")";
}

if($modules=="sayfa" or $modules=="haber" or $modules=="msayfa"){
	$sqlm=mysqli_query($conn, "select * from medya where t3=''".$modules."");while($rsm=mysqli_fetch_assoc($sqlm)){$lmedias[] = $rsm;}
	$return_arr = array();
	$sqlc = mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='".$modules."' and s13=1 $qry $itemid"); $count = mysqli_num_rows($sqlc);
	$sql=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='".$modules."' and s13=1 $qry $itemid order by id desc $limit"); while($rs=mysqli_fetch_assoc($sql)){
		$jsons = json_decode($rs["n17"],true);
		$medias = array();
		foreach($lmedias as $key=>$value){
			if($value["t3"]==$modules and $value["s1"]==$rs["id"]){
				$marr['id'] = $value['id'];
				$marr['ne'] = $value['ne'];
				$marr['t1'] = $value['t1'];
				$marr['t2'] = $value['t2'];
				$marr['t3'] = $value['t3'];
				$marr['t4'] = $value['t4'];
				$marr['t5'] = $value['t5'];
				$marr['s1'] = $value['s1'];
				$marr['s2'] = $value['s2'];
				$marr['s3'] = $value['s3'];
				$marr['s4'] = $value['s4'];
				$marr['s5'] = $value['s5'];
				$marr['n1'] = $value['n1'];
				$marr['n2'] = $value['n2'];
				$marr['n3'] = $value['n3'];
				$marr['n4'] = $value['n4'];
				$marr['n5'] = $value['n5'];
				array_push($medias,$marr);
			}}
			$arr['id'] = $rs['id'];
			$arr['title'] = $rs['t1'];
			$arr['detail'] = $rs['n1'];
			$arr['description'] = $rs['n2'];
			$arr['keys'] = $rs['n4'];
			$arr['link'] = $rs['n5'];
			$arr['catName'] = kategori($rs['s2']);
			$arr['catID'] = $rs['s2'];
			$arr['adminID'] = $rs['s19'];
			$arr['image'] = $medias[0];
			$arr['medias'] = $medias;
			$arr['jsons'] = $jsons;
			array_push($return_arr,$arr);
		}
		$code="200";

	}elseif($modules=="kayit"){
		$return_arr = array();
		$sqlm=mysqli_query($conn, "select * from medya where t3=''".$modules."");while($rsm=mysqli_fetch_assoc($sqlm)){$lmedias[] = $rsm;}
		$sqlc = mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' and s13=1 $qry $itemid"); $count = mysqli_num_rows($sqlc);
		$sql=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' and s13=1 $qry $itemid order by id desc $limit"); while($rs=mysqli_fetch_assoc($sql)){
			$jsons = json_decode($rs["n17"],true);
			$medias = array();
			foreach($lmedias as $key=>$value){
				if($value["t3"]==$modules and $value["s1"]==$rs["id"]){
					$marr['id'] = $value['id'];
					$marr['ne'] = $value['ne'];
					$marr['t1'] = $value['t1'];
					$marr['t2'] = $value['t2'];
					$marr['t3'] = $value['t3'];
					$marr['t4'] = $value['t4'];
					$marr['t5'] = $value['t5'];
					$marr['s1'] = $value['s1'];
					$marr['s2'] = $value['s2'];
					$marr['s3'] = $value['s3'];
					$marr['s4'] = $value['s4'];
					$marr['s5'] = $value['s5'];
					$marr['n1'] = $value['n1'];
					$marr['n2'] = $value['n2'];
					$marr['n3'] = $value['n3'];
					$marr['n4'] = $value['n4'];
					$marr['n5'] = $value['n5'];
					array_push($medias,$marr);
					}
				}
				$arr['id'] = $rs['id'];
				$arr['code'] = $rs['t4'];
				$arr['barcode'] = $rs['t5'];
				$arr['title'] = $rs['t1'];
				$arr['detail'] = $rs['n1'];
				$arr['description'] = $rs['n2'];
				$arr['keys'] = $rs['n4'];
				$arr['link'] = "?d".$rs["id"]."/".cevir($rs["t1"])."";
				$arr['catID'] = $rs['s9'];
				$arr['subcatID'] = $rs['s10'];
				$arr['price'] = wprice($rs['pb1']);
				$arr['listPrice'] = wprice($rs['pb2']);
				$arr['tax_percent'] = $rs['s4'];
				$arr['tax_price'] = wprice($rs['pb1']-($rs['pb1']/(1+($rs['s4']/100))));
				$arr['currency'] = $rs['t2'];
				$arr['stock'] = $rs['s5'];
				$arr['adminID'] = $rs['s19'];
				$arr['image'] = $medias[0];
				$arr['medias'] = $medias;
				$arr['jsons'] = $jsons;
				array_push($return_arr,$arr);
			}
			$code="200";

	}elseif($modules=="categories"){
		$return_arr = array();
		$sql=mysqli_query($conn, "select * from kategoriler where ne='ukategori' $cqry $citemid order by Cat_ID desc"); $count = mysqli_num_rows($sql); while($rs=mysqli_fetch_assoc($sql)){
			$arr['id'] = $rs['Cat_ID'];
			$arr['title'] = $rs['Cat_'.$_SESSION["lang"].''];
			$arr['detail'] = $rs['n3'];
			$arr['description'] = $rs['n2'];
			$arr['keys'] = $rs['n4'];
			$arr['link'] = "?x".$rs["Cat_ID"]."/".cevir($rs['Cat_'.$_SESSION["lang"].''])."";
			array_push($return_arr,$arr);
		}
		$code="200";

		}elseif($modules=="uye"){
			$return_arr = array();
			$sqlm=mysqli_query($conn, "select * from medya where t3=''".$modules."");while($rsm=mysqli_fetch_assoc($sqlm)){$lmedias[] = $rsm;}
			$sqlc = mysqli_query($conn, "select * from t5 where t1 LIKE '%".$q."%' $qry $itemid"); $count = mysqli_num_rows($sqlc);
			$sql=mysqli_query($conn, "select * from t5 where t1 LIKE '%".$q."%' $qry $itemid order by id desc $limit"); while($rs=mysqli_fetch_assoc($sql)){ $jsi = json_decode($rs["n17"],true); $jsl = json_decode($rs["n16"],true);
			$medias = array();
			foreach($lmedias as $key=>$value){
				if($value["t3"]==$modules and $value["s1"]==$rs["id"]){
					$marr['id'] = $value['id'];
					$marr['ne'] = $value['ne'];
					$marr['t1'] = $value['t1'];
					$marr['t2'] = $value['t2'];
					$marr['t3'] = $value['t3'];
					$marr['t4'] = $value['t4'];
					$marr['t5'] = $value['t5'];
					$marr['s1'] = $value['s1'];
					$marr['s2'] = $value['s2'];
					$marr['s3'] = $value['s3'];
					$marr['s4'] = $value['s4'];
					$marr['s5'] = $value['s5'];
					$marr['n1'] = $value['n1'];
					$marr['n2'] = $value['n2'];
					$marr['n3'] = $value['n3'];
					$marr['n4'] = $value['n4'];
					$marr['n5'] = $value['n5'];
					array_push($medias,$marr);
				}}
				$arr['userId'] = $rs['id'];
				$arr['userCode'] = $jsi['it4'];
				$arr['userName'] = names($rs['t1'],'name');
				$arr['userSurname'] = names($rs['t1'],'surname');
				if($jsi['ifirma']<>""){$company=$jsi['ifirma'];}else{$company=$rs['t1'];}
				$arr['companyName'] = $company;
				$arr['taxAdministration'] = $jsi['ivdaire'];
				if($jsi['ivnumara']<>""){$taxNumber=$jsi['ivnumara'];}else{$taxNumber=$rs['t13'];}
				$arr['taxNumber'] = $taxNumber;
				$arr['city'] = loc($jsl['sehir']);
				$arr['town'] = loc($jsl['ilce']);
				$arr['email'] = v3d($rs['t2']);
				$arr['phone'] = $rs['t4'];
				$arr['adminID'] = $rs['s19'];
				$arr['image'] = $medias[0];
				$arr['medias'] = $medias;
				$arr['jsons'] = $jsui;
				array_push($return_arr,$arr);
			}
			$code="200";

		}elseif($modules=="tahsilat"){
			$return_arr = array();
			
			$sqlc = mysqli_query($conn, "select * from t1 where ne='dekont' $qry"); $count = mysqli_num_rows($sqlc);
			$sql=mysqli_query($conn, "select * from t1 where ne='dekont' $qry order by id asc $limit"); while($rs=mysqli_fetch_assoc($sql)){
				$sqlm=mysqli_query($conn, "select * from t5 where id=".$rs["s1"].""); $rsm=mysqli_fetch_assoc($sqlm); $jsmi = json_decode($rsm["n17"],true);  $jsml = json_decode($rsm["n16"],true);
				$arr['id'] = $rs['id'];
				$arr['code'] = $rs['t8'];
				$arr['cardNumber'] = private_str(V3d($rs["t11"]), 2, 12);
				$arr['cardHolder'] = $rs["t14"];
				$arr['bank'] = $rs['t6'];
				$arr['installment'] = $rs["t7"];
				$arr['amount'] = ($rs['pb1']-$rs['t16']);
				$arr['commission'] = $rs['t16'];
				$arr['commission_percentage'] = $rs['t17'];
				$arr['price'] = $rs['pb1'];
				$arr['currency'] = $rs['t9'];
				$arr['date'] = $rs['ts1'];
				$arr['detail'] = $rs['n1'];
				$arr['userId'] = $rsm['id'];
				$arr['userCode'] = $jsmi['it4'];
				$arr['userName'] = names($rsm['t1'],'name');
				$arr['userSurname'] = names($rsm['t1'],'surname');
				if($jsmi['ifirma']<>""){$company=$jsmi['ifirma'];}else{$company=$rsm['t1'];}
				$arr['companyName'] = $company;
				$arr['taxAdministration'] = $jsmi['ivdaire'];
				if($jsmi['ivnumara']<>""){$taxNumber=$jsmi['ivnumara'];}else{$taxNumber=$rsm['t13'];}
				$arr['taxNumber'] = $taxNumber;
				$arr['adress'] = $rsm["n6"];
				$arr['city'] = loc($jsml['sehir']);
				$arr['town'] = loc($jsml['ilce']);
				$arr['email'] = v3d($rsm['t2']);
				$arr['phone'] = $rsm['t4'];
				$arr['adminID'] = $rsm['s19'];
				array_push($return_arr,$arr);
			}
			$code="200";

		}elseif($modules=="fatura"){
			if($itemid==""){$qry="(ne='sfatura' or ne='afatura' or ne='ifatura')";}else{$qry=$itemid;}
			$return_arr = array();
			$sqlc = mysqli_query($conn, "select * from t4 where t4 like '%".$q."%' $qry"); $count = mysqli_num_rows($sqlc);
			$sqlf = mysqli_query($conn, "select * from t4 where t4 like '%".$q."%' $qry order by id asc $limit"); while($rsf=mysqli_fetch_assoc($sqlf)){
				$sqlm = mysqli_query($conn, "select * from t5 where id=".$rsf["s1"].""); $rsm=mysqli_fetch_assoc($sqlm); $jsmi = json_decode($rsm["n17"],true); $jsml = json_decode($rsm["n16"],true);
				$fid=$rsf["id"]; include("".$path."".$crmpath."/modules/accounting/accounting_calc.php");
				$product_arr = array();
				$sqlfu=mysqli_query($conn, "select * from t4 where ne='furun' and s1=".$rsf["id"].""); while($rsfu=mysqli_fetch_assoc($sqlfu)){
					$sqlu=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where id=".$rsfu["s2"].""); $rsu=mysqli_fetch_assoc($sqlu);
					$jsi = json_decode($rsu["n17"], true);
					include("".$path."deppo/tools/script/prices.php");
					$parr['ID'] = $rsu['id'];
					$parr['code'] = $rsu['t4'];
					$parr['ProductName'] = $rsu['t1'];
					$parr['image'] = medya($rsu["id"],1,"resim", "t1" ,"", $weburl);
					$parr['date'] = $rsfu['ts1'];
					$parr['qyt'] = $rsfu['s5'];
					$parr['currency'] = $rsu['t2'];
					$parr['tax_percent'] = $rsu['s4'];
					$parr['tax_price'] = wprice($rsfu['pb1'] - ($rsfu['pb1']/(1+($rsfu['s4']/100))));
					$parr['price'] = wprice($rsfu['pb1'] - ($rsfu['pb1'] - ($rsfu['pb1']/(1+($rsfu['s4']/100)))));
					$parr['price_with_tax'] = price($rsu['id'],"pb1");
					array_push($product_arr,$parr);
				}
				$arr['id'] = $rsf['id'];
				$arr['orderNo'] = $rsf['t1'];
				$arr['status'] = $rsf['ne'];
				$arr['detail'] = $rsf['n10'];
				$arr['date'] = $rsf['t9'];
				$arr['paymentType'] = $rsf['t2'];
				$arr['subTotal'] = wprice(($ttoplam));
				$arr['discount'] = wprice(($fcisko));
				$arr['tax1'] = wprice(($kdvbir));
				$arr['tax8'] = wprice(($kdvsekiz));
				$arr['tax18'] = wprice(($kdvonsekiz));
				$arr['tax'] = wprice(($kdvdiger));
				$arr['total'] = wprice(($gtoplam));
				$arr['products'] = $product_arr;
				$arr['userID'] = $rsf['s1'];
				$arr['userCode'] = $jsmi['it4'];
				$arr['userName'] = names($rsm['t1'],'name');
				$arr['userSurname'] = names($rsm['t1'],'surname');
				if($rsf['i1']<>""){$company=$rsf['i1'];}else{$company=$rsm['t1'];}
				$arr['companyName'] = $company;
				$arr['taxAdministration'] = $jsmi['ivdaire'];
				if($jsmi['ivnumara']<>""){$taxNumber=$jsmi['ivnumara'];}else{$taxNumber=$rsm['t13'];}
				$arr['taxNumber'] = $taxNumber;
				$arr['adress'] = $rsm["n6"];
				$arr['city'] = loc($jsml['sehir']);
				$arr['town'] = loc($jsml['ilce']);
				$arr['email'] = v3d($rsm['t2']);
				$arr['phone'] = $rsm['t4'];
				array_push($return_arr,$arr);
			}
			$code="200";

		}elseif($modules=="siparis"){
			$return_arr = array();
			$sqlc = mysqli_query($conn, "select * from eticaret where ne='siparis' $itemid"); $count = mysqli_num_rows($sqlc);
			$sql = mysqli_query($conn, "select * from eticaret where ne='siparis' $itemid order by id asc $limit"); while($siparis=mysqli_fetch_assoc($sql)){ $jso = json_decode($siparis["n12"],true);
			$sqlm = mysqli_query($conn, "select * from t5 where id=".$siparis["s1"].""); $rsm=mysqli_fetch_assoc($sqlm); $jsmi = json_decode($rsm["n17"],true);  $jsml = json_decode($rsm["n16"],true);
		//-- Sipariş Hesapla -->
			$gtoplam=0;
			$basket_arr = array();
			$sqlb = mysqli_query($conn, "select * from eticaret where ne='sepet' and s5=".$siparis["id"].""); while($sepet=mysqli_fetch_assoc($sqlb)){
				$sqlu = mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' and id=".$sepet["s3"].""); $rsu=mysqli_fetch_assoc($sqlu);
				include("".$path."deppo/tools/script/prices.php");
				include("".$path."deppo/tools/script/order_calc.php");
				$barr['id'] = $rsu['id'];
				$barr['code'] = $rsu['t4'];
				$barr['ProductName'] = $rsu['t1'];
				$barr['image'] = medya($rsu["id"],1,"resim", "t1" ,"", $weburl);
				$barr['date'] = $sepet['ts1'];
				$barr['qyt'] = $sepet['s2'];
				$barr['unit'] = $rsu['t10'];
				$barr['currency'] = $rsu['t2'];
				$barr['tax_percent'] = $rsu['s4'];
				$barr['tax_price'] = wprice((price($rsu['id'],"pb1","nfn") - $fiyat1));
				$barr['price'] = wprice($fiyat1);
				$barr['price_with_tax'] = price($rsu['id'],"pb1",'nfn');
				array_push($basket_arr,$barr);
			}
			$arr['id'] = $siparis['id'];
			$arr['orderNo'] = $siparis['t4'];
			$arr['status'] = $siparis['s4'];
			$arr['detail'] = $siparis['n10'];
			$arr['date'] = $siparis['ts1'];
			$arr['paymentMethod'] = ihb($siparis['t5']);
			$arr['subTotal'] = wprice(($stutar));
			$arr['discount'] = wprice(($indirim));
			$arr['tax1'] = wprice(($kdvbir));
			$arr['tax8'] = wprice(($kdvsekiz));
			$arr['tax18'] = wprice(($kdvonsekiz));
			$arr['tax'] = wprice(($kdvdiger));
			$arr['Interest'] = $siparis['pb5'];
			$arr['Interest_Percent'] = $jso["Order_Interest_Percent"];
			$arr['Installment'] = $jso["Order_Installment"];
			$arr['total'] = wprice(($gtoplam));
			$arr['cargoID'] = $siparis['s9'];
			$arr['cargoName'] = $siparis['t12'];
			$arr['cargoTrackingCode'] = $siparis['t13'];
			$arr['cargoPrice'] = wprice($kargof);
			$arr['cargoPrice_width_tax'] = wprice(($kargof*1.18));
			$arr['cargoPrice_tax'] = wprice(($kargof*1.18)-(($kargof*1.18) / (1+(18/100))));
			$arr['products'] = $basket_arr;
			$arr['userID'] = $rsm['id'];
			$arr['userCode'] = $jsmi['it4'];
			$arr['userName'] = names($rsm['t1'],'name');
			$arr['userSurname'] = names($rsm['t1'],'surname');
			if($rsf['i1']<>""){$company=$rsf['i1'];}else{$company=$rsm['t1'];}
			$arr['companyName'] = $company;
			$arr['taxAdministration'] = $jsmi['ivdaire'];
			if($jsmi['ivnumara']<>""){$taxNumber=$jsmi['ivnumara'];}else{$taxNumber=$rsm['t13'];}
			$arr['taxNumber'] = $taxNumber;
			$arr['email'] = v3d($rsm['t2']);
			$arr['phone'] = $rsm['t4'];
			$arr['adress'] = order_adress($siparis["id"], "invoice", "adres");
			$arr['city'] = order_adress($siparis["id"], "invoice", "sehir");
			$arr['town'] = order_adress($siparis["id"], "invoice", "ilce");
			array_push($return_arr,$arr);
			$stutar="";}
			$code="200";

		}elseif($modules=="adisyon"){
			$return_arr = array();
			$sqlc = mysqli_query($conn, "select * from eticaret where ne='adisyon' $itemid"); $count = mysqli_num_rows($sqlc);
			$sql = mysqli_query($conn, "select * from eticaret where ne='adisyon' $itemid order by id asc $limit"); while($siparis=mysqli_fetch_assoc($sql)){
				$sqlm = mysqli_query($conn, "select * from t5 where id=".$siparis["s19"].""); $rsm=mysqli_fetch_assoc($sqlm); $jsoi = json_decode($rsm["n17"],true);
				$sqlt = mysqli_query($conn, "select * from ".$_SESSION["lang"]." where id=".$siparis["t3"].""); $rst=mysqli_fetch_assoc($sqlt);
				$drinkIDs = array();
				$kitchenIDs = array();
				$sqli=mysqli_query($conn, "select * from eticaret where ne='items' and s5=".$siparis["id"]." order by id desc"); while($items=mysqli_fetch_assoc($sqli)){$p++;
					$sqlu=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' and id=".$items["s3"].""); $rsu=mysqli_fetch_assoc($sqlu);	
					$sqlx=mysqli_query($conn, "select * from kategoriler where ne='ukategori' and Cat_ID='".$rsu["s9"]."'"); $rsx=mysqli_fetch_assoc($sqlx);
					$jsxi = json_decode($rsx["n6"], true);
					if($jsxi["i1"][0]=="İçecek"){
						$drinkIDs[] = $items["id"];
					}elseif($jsxi["i1"][0]=="Mutfak"){
						$kitchenIDs[] = $items["id"];
					}
				}
			//-- Sipariş Hesapla -->
				$gtoplam=0;
				$basket_arr = array();
				$sqlb = mysqli_query($conn, "select * from eticaret where ne='items' and s5=".$siparis["id"].""); while($sepet=mysqli_fetch_assoc($sqlb)){
					$sqlu = mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' and id=".$sepet["s3"].""); $rsu=mysqli_fetch_assoc($sqlu);
					//if ($_GET["printer"]=="1"){
						$ufiyat=$sepet["pb1"];
						$barr['ID'] = $rsu['id'];			
						$barr['code'] = $rsu['t4'];
						$barr['ProductName'] = $rsu['t1'];
						$barr['qyt'] = $sepet['s2'];
						$barr['tax'] = $rsu['s4'];
						$barr['currency'] = $rsu['t2'];
						$barr['price'] = wprice($ufiyat);
					/*
					}elseif ($_GET["printer"]=="2" and in_array($sepet["id"],$kitchenIDs)){
						$ufiyat=$sepet["pb1"];
						$barr['ID'] = $rsu['id'];			
						$barr['code'] = $rsu['t4'];
						$barr['ProductName'] = $rsu['t1'];
						$barr['qyt'] = $sepet['s2'];
						$barr['tax'] = $rsu['s4'];
						$barr['currency'] = $rsu['t2'];
						$barr['price'] = wprice($ufiyat);
					}elseif ($_GET["printer"]=="3" and in_array($sepet["id"],$drinkIDs)){
						$ufiyat=$sepet["pb1"];
						$barr['ID'] = $rsu['id'];			
						$barr['code'] = $rsu['t4'];
						$barr['ProductName'] = $rsu['t1'];
						$barr['qyt'] = $sepet['s2'];
						$barr['tax'] = $rsu['s4'];
						$barr['currency'] = $rsu['t2'];
						$barr['price'] = wprice($ufiyat);
					}
					*/
					array_push($basket_arr,$barr);
					include("".$path."deppo/tools/script/order_calc.php");
					}
					$arr['id'] = $siparis['id'];
					$arr['tableID'] = $siparis['t3'];
					$arr['tableName'] = $rst['t1'];
					$arr['orderNo'] = $siparis['t4'];
					$arr['status'] = $siparis['s4'];
					$arr['detail'] = $siparis['n10'];
					$arr['date'] = $siparis['ts1'];
					$arr['subTotal'] = wprice(($stutar));
					$arr['discount'] = wprice(($indirim));
					$arr['tax1'] = wprice(($kdvbir));
					$arr['tax8'] = wprice(($kdvsekiz));
					$arr['tax18'] = wprice(($kdvonsekiz));
					$arr['tax'] = wprice(($kdvdiger));
					$arr['total'] = wprice(($gtoplam));
					$arr['userID'] = $siparis['s1'];
					$arr['staffID'] = $siparis['s19'];
					$arr['userCode'] = $jsoi['it4'];
					$arr['userName'] = $rsm['t1'];
					$arr['basket'] = $basket_arr;
					//if($_GET["printer"]=="1"){
					array_push($return_arr,$arr);
					/*
					}elseif($_GET["printer"]=="2" and !empty($kitchenIDs)){
						array_push($return_arr,$arr);
					}elseif($_GET["printer"]=="3" and !empty($drinkIDs)){
						array_push($return_arr,$arr);
					}
					*/
			$stutar="";
		}
		$code="200";
	}
	SetHeader($code);
	if(($user==$Wuser and $pass==$Wpass) or $MSA==1){
		echo '{"module":"'.$modules.'","count":'.$count.',"data":'.json_encode($return_arr).',"version":"'.$pver.'","by":"CrmPlus+"}';
	}else{
		$code="401";
		echo '{"module":"'.$modules.'","count":'.$count.',"data":'.HttpStatus($code).',"version":"'.$pver.'","by":"CrmPlus+"}';
	}
	//$ws = HTTPPOST("https://crmplus.com.tr/ws","user=user&pass=pass&module=sayfa&userid=0&itemid=0&limit=0,15"); kullanıcı adı ve şifre tanımlardan "ws" eklenecek, eklenmezse direk çağrılabilir.
?>