<?php


if(isset($_POST['data']) && !empty(trim($_POST['data']))){

$data = $_POST['data'];




	
if(null != $data){
	
$data = json_decode($data,true);	

$st = $data['st'];
$idtot = $data['idtot'];

if($st == "5"){
	
$signindata = array("res" => "VALID","st" => "5");
$signindata = json_encode($signindata,JSON_UNESCAPED_UNICODE);
echo $signindata;	

}else if($st == "1"){

$factorItem = array("name" => "فروشگاه گل آور","date" => "12/12/12","fout" => "123", "fid" => "567");
$factorItem_s = array("name" => "فروشگاه گل آور 2","date" => "12/12/12","fout" => "123", "fid" => "564");	
$factorList = array();
array_push($factorList,$factorItem,$factorItem_s);
	
$signindata = array("res" => "VALID","st" => "1","factorlist" => $factorList);
$signindata = json_encode($signindata,JSON_UNESCAPED_UNICODE);
echo $signindata;		
	
}else if($st == "2"){
$factorDetailList = array();	
if($idtot == "567"){
	
$factorDetail = array("name" => "زیتون پرورده","id" => "1","vnumb" => "123", "barcode" => "56700", "numb_out" => "11", "numb" => "11", "box" => "22", "factorid" => "567","color"=>"2");
$factorDetail_s = array("name" => "کافی میت 400 گرمی","id" => "2","vnumb" => "123", "barcode" => "54500", "numb_out" => "8", "numb" => "12", "box" => "24", "factorid" => "567","color"=>"3");	
$factorDetail_z = array("name" => "چیپس چیتوز","id" => "2","vnumb" => "123", "barcode" => "54500", "numb_out" => "33", "numb" => "33", "box" => "99", "factorid" => "567","color"=>"4");
$factorDetail_zx = array("name" => "چیپس چیتوز","id" => "2","vnumb" => "123", "barcode" => "54500", "numb_out" => "33", "numb" => "33", "box" => "99", "factorid" => "567","color"=>"1");
array_push($factorDetailList,$factorDetail);
array_push($factorDetailList,$factorDetail_s);	
array_push($factorDetailList,$factorDetail_z);	
array_push($factorDetailList,$factorDetail_zx);	
}else{
$factorDetail = array("name" => "نوشابه پپسی","id" => "1","vnumb" => "123", "barcode" => "56700", "numb_out" => "10", "numb" => "11", "box" => "22", "factorid" => "567","color"=>"1");
$factorDetail_s = array("name" => "خشکبار درجه یک","id" => "2","vnumb" => "123", "barcode" => "54500", "numb_out" => "8", "numb" => "8", "box" => "24", "factorid" => "567","color"=>"2");	
array_push($factorDetailList,$factorDetail);
array_push($factorDetailList,$factorDetail_s);	
} 


$signindata = array("res" => "VALID","st" => "2","detaillist" => $factorDetailList);
$signindata = json_encode($signindata,JSON_UNESCAPED_UNICODE);
	
//$signindata = '{"res":"VALID","st":"2","detaillist":[{"name":"آبميوه تتراپک 200c اناناس مونه","id":"80","vnumb":"4+0","barcode":"1722001 ","numb_out":".000","numb":"144.0000","box":"36","factorid":"21"},{"name":"آبميوه تتراپک 200c انبه مونه","id":"81","vnumb":"4+0","barcode":"1722002 ","numb_out":".000","numb":"144.0000","box":"36","factorid":"21"},{"name":"ابميوه تتراپک 200c سيب موز مونه","id":"82","vnumb":"4+0","barcode":"1722003 ","numb_out":".000","numb":"144.0000","box":"36","factorid":"21"},{"name":"آبميوه تتراپک 200c هلو مونه","id":"83","vnumb":"4+0","barcode":"1722004 ","numb_out":".000","numb":"144.0000","box":"36","factorid":"21"},{"name":"آبميويه تتراپک 200c پرتقال مونه","id":"84","vnumb":"10+0","barcode":"1722005 ","numb_out":".000","numb":"360.0000","box":"36","factorid":"21"},{"name":"ناملي-کيک لايه اي ميوه اي 60 عددي1000فروش","id":"85","vnumb":"14+0","barcode":"1216015 ","numb_out":".000","numb":"840.0000","box":"60","factorid":"21"}]}';	
	
//$signindata = '{"res":"VALID","st":"2","detaillist":[{"name":"نوشابه پپسی","id":"80","vnumb":"40","barcode":"1722001 ","numb_out":"000","numb":"144.0000","box":"36","factorid":"21"}]}';	
	
		
echo $signindata;		
}else if($st == "3"){
	
$factorDetailList = array();		
$barcodeRes = array("msg" => "چیپس چیتوز");
array_push($factorDetailList,$barcodeRes);	
$signindata = array("res" => "VALID","st" => "3","resultlist" => $factorDetailList);
$signindata = json_encode($signindata,JSON_UNESCAPED_UNICODE);
	
	
echo $signindata;	
}
	

}else{

}	
}else{

}

?>