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

	include("connect.php");	header("Access-Control-Allow-Origin: *");
	
	$eve = "select * from res_immigration_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))
		 {
			 
				$imgmid=$rt['imgmid'];
				$countrymid=$rt['countrymid'];
				$visatmid=$rt['visatmid'];
				$subservicemid=$rt['subservicemid'];
				
				$eveag1 = "select * from res_country_master where countrymid=$countrymid";
				$reag1 = mysqli_query($conn, $eveag1);
				if(mysqli_num_rows($reag1) > 0)
				{
					while($rtag1 = mysqli_fetch_assoc($reag1))
					{
						$countryname=$rtag1['countryname'];
					}
				}
				else
				{
					$countryname="";
				}
				
				$eveag1 = "select * from res_visatype_master where visatmid=$visatmid";
				$reag1 = mysqli_query($conn, $eveag1);
				if(mysqli_num_rows($reag1) > 0)
				{
					while($rtag1 = mysqli_fetch_assoc($reag1))
					{
						$visatype=$rtag1['visatype'];
					}
				}
				else
				{
					$visatype="";
				}
				
				$eveag1 = "select * from res_subservice_master where subservicemid=$subservicemid";
				$reag1 = mysqli_query($conn, $eveag1);
				if(mysqli_num_rows($reag1) > 0)
				{
					while($rtag1 = mysqli_fetch_assoc($reag1))
					{
						$subservicename=$rtag1['subservicename'];
					}
				}
				else
				{
					$subservicename="";
				}
				
				$pidedit="<a href='immigrationedit.php?id=".$rt['imgmid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg'>  </a>";
				
				$piddetail="<a href='immigrationdetail.php?id=".$rt['imgmid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-eye fa-lg'>  </a>";
				
				
				
				
				$piddelete="<a href='immigrationdelete.php?id=".$rt['imgmid']."'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=$piddetail."&nbsp;&nbsp;&nbsp; ".$pidedit."&nbsp;&nbsp;&nbsp; ".$piddelete;
								
								
				/* $tmdocument=str_replace ("'","'",$rt['tmdocument']);
				$tmdocument=str_replace ('"','\"',$tmdocument);
				
				$tmdocument1 = "<a href='./docs/$tmdocument' target='_blank'>Download Now</a>";
				 */				
				$posts[] = array('srno'=> $i++,'op'=> $op,'piddelete'=> $piddelete, 'visatype'=> $visatype, 'countryname'=> $countryname, 'subservicename'=> $subservicename);
		 }
		 
		$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);	
	
?>