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

	include("connect.php");	header("Access-Control-Allow-Origin: *");
	
	$eve = "select * from res_mainmodule_master";
	$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))
		 {
			 
				$mmodulemid=$rt['mmodulemid'];
				
				$pidedit="<a href='mainmoduleedit.php?id=".$rt['mmodulemid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg'>  </a>";
				
				
				
				
				$piddelete="<a href='mainmoduledelete.php?id=".$rt['mmodulemid']."'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=$pidedit."&nbsp;&nbsp;&nbsp; ".$piddelete;
								
								
				$mainmodulename=$rt['mainmodulename'];
				
				
				$mmdisplayname=$rt['mmdisplayname'];
				$mmstatus=$rt['mmstatus'];
				
				if($mmstatus == 1)
				{
					$mmstatus1="<a href='mainmodulestatus.php?id=".$rt['mmodulemid']."' ><span class='label label-sm label-success'>Active</span></a>";
				}else{
					$mmstatus1="<a href='mainmodulestatus.php?id=".$rt['mmodulemid']."' ><span class='label label-sm label-danger'>Inactive</span></a>";
				}
				
				
				
								
				$posts[] = array('srno'=> $i++,'op'=> $op,'piddelete'=> $piddelete, 'mainmodulename'=> $mainmodulename, 'mmdisplayname'=> $mmdisplayname, 'mmstatus'=> $mmstatus1);
		 }
		 
		$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);	
	
?>