<?php 
require "../commonincludefiles.php";
if($_SESSION["cCompany_id"]!="" && isset($_SESSION["cCompany_id"]))
{
	$order_field="company_id";
	$order_type="ASC";
	$where="";
	if($_SESSION["cUserRole"]=="admin")
	{
	  $where.="And company_id= '".$_SESSION["cCompany_id"]."'";
	}
	
	
	$objcompanyMgmt = new companyMgmt();	
	$result = $objcompanyMgmt->getAllRecords($limit,$start,$where,$order_field,$order_type);
	$total  = dbRows($result);
	
	$i=0;
	$companyData = array("count" => $total,"rows" => array());
	
	if	(dbRows($result) > 0) 
	{
			$temparray = array();
			while($row = dbArray($result)){
				
				$temparray["company_id"]  = $row["company_id"];
				$temparray["company_name"]   = $row["company_name"];
				$companyData["rows"][$i] = $temparray;   
				$i++;
			}										
	}				   		 
 	echo json_encode($companyData);	
}
?>