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

$myJSON["id"]="0";
$myJSON["C_name"]="";
$myJSON["shop_name"]="";
$myJSON["address"]="";
$myJSON["phone"]="";
$myJSON["mobile"]="";
$myJSON["C_id"]="";
$myJSON["lat"]="";
$myJSON["lng"]="";
$myJSON["last_visit"]="";
$myJSON["last_order"]="";
$myJSON["img"]="";
$myJSON["C_acc"]="";
$myJSON["C_etebar"]="";
$myJSON["black"]="0";
$myJSON["moaref"]="0";
$myJSON['success']="خطای منابع";
$telefonea = "0";
if(isset($_POST["nekot"]) && isset($_POST["an1d"]))
{

  if(isset($_POST["phoneade"])){
    $telefonea = $_POST["phoneade"];
  }

    $id =$_POST["an1d"];
    $connect = @mysqli_connect($hostname,$username,$password,$database);
    if($connect)
    {
        @mysqli_query($connect,"SET CHARACTER SET utf8;");
             $query_one = "SELECT * FROM ".$tbl_customer." WHERE id = '".$id."' AND C_mobile = '".$telefonea."'";
      if($telefonea == "0"){
			   $query_one = "SELECT * FROM ".$tbl_customer." WHERE id = '".$id."'";
       }
			$oneres = @mysqli_query($connect,$query_one);
			if($oneres){
			 while($row = @mysqli_fetch_assoc($oneres)){
				$myJSON["id"]=$row["id"];
				$myJSON["C_name"]=$row["C_name"];
				$myJSON["shop_name"]=$row["shop_name"];
				$myJSON["address"]=$row["address"];
				$myJSON["phone"]=$row["phone"];
				$myJSON["mobile"]=$row["C_mobile"];
				$myJSON["C_id"]=$row["C_id"];
				$myJSON["lat"]=$row["lat"];
				$myJSON["lng"]=$row["lng"];
				$myJSON["last_visit"]=$row["last_visit"];
				$myJSON["last_order"]=$row["last_order"];
				$myJSON["black"]=$row["blackList"];
				$myJSON["moaref"]=$row["moaref"];
				$myJSON["img"]=$row["img"];
				$myJSON["C_acc"]=$row["C_acc"];
				$myJSON["C_etebar"]=$row["C_etebar"];
				$myJSON['success']="200";
				if($telefonea !="0"){
					$qu = "UPDATE ".$tbl_customer." SET last_visit = '".jdate('Y/m/d')."' WHERE id = '".$id."'";
					@mysqli_query($connect,$qu);
				}
			 }
       if ($myJSON["id"] == "0")
             $myJSON['success']="404";
			}
			else
				$myJSON["customer"]['success']="403";


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