<?php
require_once ("varables.php");

$myJSON["orders"]=array();
$myJSON['success']="0";
if(isset($_POST["nekot"]) && isset($_POST["an1d"]))
{
    $connect = @mysqli_connect($hostname,$username,$password,$database);
    if($connect)
    {
        @mysqli_query($connect,"SET CHARACTER SET utf8;");
//AND ".$tbl_orders.".localed = '0'
			$query_all = "SELECT ".$tbl_orders.".id,".$tbl_orders.".C_id,".$tbl_orders.".orderLat,".$tbl_orders.".orderLng,".$tbl_orders.".V_id,".$tbl_orders.".endprice,".$tbl_orders.".emergency,".$tbl_orders.".localed,".$tbl_orders.".visited,".$tbl_customer.".C_name,".$tbl_customer.".lat,".$tbl_customer.".lng,".$tbl_customer.".shop_name,".$tbl_visitors.".V_name,".$tbl_orders.".date FROM ".$tbl_visitors.", ".$tbl_orders.", ".$tbl_customer." WHERE ".$tbl_orders.".C_id = ".$tbl_customer.".id AND ".$tbl_orders.".V_id = ".$tbl_visitors.".id  ORDER BY ".$tbl_orders.".localed,".$tbl_orders.".visited,".$tbl_orders.".emergency,".$tbl_orders.".emergency,".$tbl_orders.".date DESC";
			$result = @mysqli_query($connect,$query_all);
			if($result){
				while($row = @mysqli_fetch_assoc($result))	{
					array_push($myJSON["orders"], $row);
				}
				$myJSON['success']="200";
			}
				else {
					$myJSON['success']=@mysqli_error($connect);
			 }




	}
	 else
		 $myJSON['success']="402";
}
echo json_encode($myJSON);
?>
