<?php  
session_start(); 
	include("connect.php");	
	header("Access-Control-Allow-Origin: *");
	if(!isset($_SESSION['latcsuperloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	if($_SESSION['latcutype']=='mainadmin'){
		$eve = "select * from res_user_master";
	}
	else{
		$eve = "select * from res_user_master where mumid=".$_SESSION['latcmumid'];
	}
	$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))
		{
			 	$umid=$rt['umid'];
				$uedit="<a href='useredit.php?id=".$rt['umid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-pencil fa-md' > </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=$uedit."&nbsp;&nbsp;&nbsp; ".$udelete;
				//$cdelete="<a href='customeredit.php?id=$bumid' onClick=\"return confirm('are you sure you want to delete??');\">Delete</a>";
				
				
				
				
				
				$ufullname=$rt['ufullname'];
				$ustatus=$rt['ustatus'];
				$username=$rt['username'];
				$uemail=$rt['uemail'];
				$umobile=$rt['umobile'];
				$ugroup=$rt['ugroup'];
				$imei=$rt['imei'];
				$muname="";
				
				
				
				
				
				
				if($ustatus=="Active")
				{
					
					$ustatus1="<a href='userstatus.php?id=".$rt['umid']."' ><span class='label label-sm label-success'>Active</span></a>";
				}
				else
				{
					$ustatus1="<a href='userstatus.php?id=".$rt['umid']."' ><span class='label label-sm label label-danger '>Blocked</span></a>";
				}
				if(strlen($imei)>0){
					$resetlogin="<a href='userresetlogin.php?id=".$rt['umid']."' ><span class='label label-sm label-danger'>Reset</span></a>";
				}else{
				$resetlogin="<span class='label label-sm label-warning'>No Login</span>";

				}
				
				$posts[] = array('umid'=> $i, 'uedit'=> $uedit, 'udelete'=> $udelete,'ustatus'=> $ustatus1, 'ufullname'=> $ufullname,'username'=> $username,'umobile'=> $umobile,'uemail'=> $uemail,'ugroup'=> $ugroup,'op'=> $op,'muname'=> $muname,'resetlogin'=> $resetlogin);
	
			
			$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);	
?>