<?php  
session_start();
	
	if(!isset($_SESSION['linkarisesuloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	if($_SESSION['linkariseutype']!='Superuser'){
			header('Location: index.php');
		return;
	} 
	include("connect.php");	header("Access-Control-Allow-Origin: *");
	
	
	$eve = "select * from res_company_master order by companymid desc";
	
	$re = mysqli_query($conn, $eve);
	
	
	$response = array();
	$posts = array();
	
	$result="0";
	
	if(mysqli_num_rows($re) > 0)
	{
		$i=1;
		while($rt = mysqli_fetch_assoc($re))
		{
			 	$cmpmid=$rt['companymid'];
			 	$cmpname=$rt['companyname'];
				$companyaddress=$rt['companyaddress'];
				$cpname=$rt['companycontactperson'];
				$companycontectno=$rt['companycontectno'];
				$companytype=$rt['companytype'];
			
				
			
				$uinfo="<a href='businessregisterdetail.php?id=$cmpmid' data-toggle='tooltip' data-placement='top' title='Edit-round' class='fa fa-eye fa-md' > </a>";
				$uedit="<a href='businessregisteredit.php?id=$cmpmid' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-md' > </a>";
				$udelete="<a href='businessregisterdelete.php?id=$cmpmid' data-toggle='tooltip' data-placement='top' title='Delete' class='far fa-trash-alt fa' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);'> </a>";
				 $op=$uinfo."&nbsp;".$uedit."&nbsp;".$udelete;
				//$cdelete="<a href='customeredit.php?id=$bmumid' onClick=\"return confirm('are you sure you want to delete??');\">Delete</a>";
				
				
				
				$posts[] = array('brmid'=> $i, 'cmpname'=> $cmpname, 'cmptype'=> $companytype, 'cpname'=> $cpname,'mobile'=> $companycontectno,'cmpaddress'=> $companyaddress,'op'=>$op);
	
			
			$i++;
			
		}
		 
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('data' => $posts)));
		mysqli_close($conn);
		return;
	}
	
   else
	{
		$result="0";
		$msg="Invalid Error";
		
		$posts[] = array('p1'=> $result,'p2'=> $msg);
	
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('item' => $posts)));
	}
   
	mysqli_close($conn);	
?>