<?php  
session_start();
if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	} 

	include("connect.php");	header("Access-Control-Allow-Origin: *");
	
	 $eve = "select * from res_moduleallocation_detail  group by rolemid";
	$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))
		 {
			 	
				$mallocationmid=$rt['mallocationmid'];
				$rolemid=$rt['rolemid'];
				$smodulemid=$rt['smodulemid'];
				
				$pidedit="<a href='moduleallocationedit.php?id=".$rt['rolemid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg'>  </a>";
				
				$pidview="<a href='moduleallocationdetail.php?id=".$rt['rolemid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-eye fa-lg'>  </a>";
				
				
				
				
				$piddelete="<a href='moduleallocationdelete.php?id=".$rt['rolemid']."'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>";			
                $op=$pidview."&nbsp;&nbsp;&nbsp; ".$pidedit."&nbsp;&nbsp;&nbsp; ".$piddelete;
								
								
				
				
				$rights='';
					
						 
						
						
						
				
				$eve1 = "select * from res_role_master where rolemid=$rolemid";
				$re1 = mysqli_query($conn, $eve1);
				$rolename='';
				if(mysqli_num_rows($re1) > 0)
				{
					
					 while($rt1 = mysqli_fetch_assoc($re1))
					 {
							
						$rolename=$rt1['rolename'];
					 }
				}
				
								
				$posts[] = array('srno'=> $i++,'op'=> $op,'piddelete'=> $piddelete, 'rolename'=> $rolename);
		 }
		 
		$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);	
	
?>