<?php  
session_start(); 

	include("connect.php");	
	header("Access-Control-Allow-Origin: *");
	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
		$brmid=$_SESSION['linkarisebranchid'];
		$cmpmid=$_SESSION['linkarisecmpmid'];
	$eve = "select * from res_spot_master where cmpmid=$cmpmid ";
	
	$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))
		{
			 	$spotmid=$rt['spotmid'];
				$uedit="<a href='halledit.php?id=".$rt['spotmid']."'data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg' >  </a>";
				//$uedit="<a href='useredit.php?id=".$rt['umid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-pencil fa-md' > </a>";
				$udelete="";
			$uview="<a href='halldetail.php?id=".$rt['spotmid']."'data-toggle='tooltip' data-placement='top' title='View' class='fa fa-eye fa-lg' >  </a>";
				$udelete="<a href='halldelete.php?id=".$rt['spotmid']."' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);' data-toggle='tooltip' data-placement='top' title='Delete' class='far fa-trash-alt fa-lg'>  </a>";
				//$udelete="<a href='userdelete.php?id=".$rt['umid']."' data-toggle='tooltip' data-placement='top' title='Delete' class='fa fa-trash-o fa-md' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);'> </a>";
				
				 $op=$uview." &nbsp".$uedit." &nbsp".$udelete;
				//$cdelete="<a href='customeredit.php?id=$bumid' onClick=\"return confirm('are you sure you want to delete??');\">Delete</a>";
				
				$spotname=$rt['spotname'];
				$spotaddress=$rt['spotaddress'];
				
				$cpname=$rt['spotcpname'];
				$cpmobile=$rt['cpmobile'];
				$spotcapacity=$rt['spotcapacity'];
				$spotfacility=str_replace(array("\n", "\r"), '  ', $rt['spotfacility']);
				
				
			
				
				
				$posts[] = array('spotmid'=> $i, 'uedit'=> $uedit, 'udelete'=> $udelete,'spotname'=> $spotname, 'spotaddress'=> $spotaddress,'cpname'=> $cpname,'cpmobile'=> $cpmobile,'spotcapacity'=> $spotcapacity,'op'=> $op,'spotfacility'=>$spotfacility);
	
			
			$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);	
?>