<?php 
require "../commonincludefiles.php";

if($_SESSION["cCompany_id"]!="" && isset($_SESSION["cCompany_id"]))
{	
	$phone = $_POST["phone"];
	

	
	$objCustomerMgmt = new CustomerMgmt();
	
	$limit=0;
	$start=0;
	$condition="";
	if ($phone != "")
	{
		$condition = " AND `customer_phone1` LIKE '%".$phone."%' OR `customer_phone2` LIKE '%".$phone."%' OR customer_cpmobile1 LIKE '%".$phone."%'";
	}
	
	$order_field="customer_orgname";
	$order_type="ASC";
	
	$result = $objCustomerMgmt->getAllRecords(0,0,$condition,$order_field,$order_type) ;
	$total = dbRows($result);
	$i=0;
	$distictData = array("count" => $total, "rows" => array());
	if	(dbRows($result) > 0) 
		   {
				$temparray = array();
				while($row = dbArray($result)){
					
					$temparray["customer_id"]  = $row["customer_id"];
					$temparray["customer_orgname"]   = $row["customer_orgname"];
					$distictData["rows"][$i] = $temparray;   
				$i++;
			}										
	}				   		 
 	echo json_encode($distictData);	
}
?>