	<?php
	/**
	* Created by PhpStorm.
	* User: ahmad
	* Date: 20/08/2019
	* Time: 11:48 AM
	*/

	require_once("../connection.php");
	
	$key=mysqli_real_escape_string($connect, $_GET['key']);
	$id_pelanggan=mysqli_real_escape_string($connect, $_GET['id_customer']);
	
	$getusers	= mysqli_query($connect,"SELECT * FROM users WHERE id_session='$key'");
	$u	   		= mysqli_fetch_array($getusers);
	$jumlah   	= mysqli_num_rows($getusers);
	
	
	$masterakun = mysqli_query($connect,"SELECT * FROM users WHERE phone_number='$u[master]'");
	$m=mysqli_fetch_array($masterakun);

	if ($jumlah > 0){

	$query = "SELECT * FROM customer WHERE id_customer='$id_pelanggan'";
	$hasil = mysqli_query($connect,$query);


	if(mysqli_num_rows($hasil) > 0 ){
	$response = array(
    'status' 	=> 'true',
    'errCode' 	=> '01',
	'msg' 		=> 'Success'
	);
  $x = mysqli_fetch_array($hasil);
  $response["data"] = array(
  'id_customer' 	=> $x['id_customer'],
  'name_customer' 	=> $x['name_customer'],
  'address' 			=> $x['address'],
  'email' 			=> $x['email'],
  'telephone' 			=> $x['telephone'],
  'img' 			=> 'https://'.$_SERVER[HTTP_HOST].'/geten/images/foto/'.$x['gbr']
  
  );
  
	echo json_encode($response);
	}else {
	$response = array(
    'status' 		=> 'true',
    'errCode' 		=> '02',
	'msg' 			=> 'no data'
	);
	echo json_encode($response);
	}


	}else{
	
	
	$json = array(
    'status' 	=> 'true',
    'errCode' 	=> '00',
	'msg' 		=> 'User Not Found'
	);

    echo json_encode($json);	
	}
	?>