<?php
include "start.php";


$json_array_customer = array();
$json_array_item = array();


$query_data = "select * from t_".$key_table_prefix."_customer
			where cus_status = 'ACTIVE'
			";
			
if($_REQUEST["id"]!="")			
{
	$query_data = $query_data." and cus_id = '".$_REQUEST["id"]."' "; 
}
if($_REQUEST["code"]!="")			
{
	$query_data = $query_data." and cus_code = '".$_REQUEST["code"]."' "; 
}




			
$result_data = mysqli_query($dbconn, $query_data);
if($line_data = mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
	
	$this_customer_code = $line_data["cus_code"];
	
		$this_data = array(
			   "id" => $line_data["cus_id"],
			   "code" => $line_data["cus_code"],
			   "name" => $line_data["cus_name"],
			   "gst_no" => $line_data["cus_gst_no"],
			   "group" => $line_data["cus_group"],
			   "status" => $line_data["cus_status"],
			   "discount_percentage" => $line_data["cus_discount_percentage"],
			   "address_billing" => $line_data["cus_address_billing"],
			   "address_delivery" => $line_data["cus_address_delivery"],
			   "mobile_no" => $line_data["cus_mobile_no"],
			   "telephone_no" => $line_data["cus_telephone_no"],
			   "fax" => $line_data["cus_fax"],
			   "email" => $line_data["cus_email"],
			   "ic_no" => $line_data["cus_ic_no"],
			   "start_date" => $line_data["cus_start_date"],
			   "latitude" => $line_data["cus_latitude"],
			   "longitude" => $line_data["cus_longitude"],
			   "credit_block" => $line_data["cus_credit_block"],
			   
			   "validity_start" => $line_data["cus_validity_start"],
			   "validity_end" => $line_data["cus_validity_end"],
			   
			   "gender" => $line_data["cus_gender"],
			   "date_of_birth" => $line_data["cus_date_of_birth"],
			   "race" => $line_data["cus_race"],
			   "zone" => $line_data["cus_zone"],
			   "route_code" => $line_data["cus_route_code"],
			   
			   
			   "created_date" => $line_data["created_date"],
			   "modified_date" => $line_data["modified_date"]
			   
			);
	   
	    array_push($json_array_customer, $this_data);
	
	
	
	
	    



}
	
	
	

//=======================================================================================	
	

//======================================================================================




$query_data = "select * from t_".$key_table_prefix."_service_item
		 where svi_customer_code = '".$this_customer_code."'
		 order by svi_id 
		 ";

$result_data = mysqli_query($dbconn, $query_data);
while($line_data = mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
 
 
	$this_data = array(
		    "id" => $line_data["svi_id"],
		    "serial_no" => $line_data["svi_serial_no"],
		    "code" => $line_data["svi_product_code"],
		    "name" => $line_data["svi_product_name"],
		    
		    "size" => $line_data["svi_product_size"],
		    "color" => $line_data["svi_product_color"],
		    "pattern" => $line_data["svi_product_pattern"],
		    
		    "date_issued" => $line_data["svi_date_issued"],
		    
		    "status" => $line_data["svi_status"],
		    
		    "created_date" => $line_data["created_date"],
		    "modified_date" => $line_data["modified_date"]
		    
		 );
    
	array_push($json_array_item, $this_data);
 
 
}

	
	
	
	
$content_array["customer"] = $json_array_customer;	
$content_array["service_item"] = $json_array_item;	
$json = json_encode($content_array);
	
echo $json;

?>