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

	include("connect.php");	header("Access-Control-Allow-Origin: *");
	$umid=$_SESSION['umid'];
	$attendancedate=$_SESSION['attendancedate'];
										$batchmid1=$_SESSION['batchmid1'];
	
	 $eve = "select * from res_attendence_detail where batchmid=$batchmid1 and attendancedate='$attendancedate' and batchmid in (select batchmid from res_batch_master where umid=$umid)";
	$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))
		 {
			 
				$attendencemid =$rt['attendencemid'];
											 $imid=$rt['imid'];
											 $attendence=$rt['attendence'];
											if($_SESSION['utype'] == 'admin')
											{
												if($attendence == 1)
											{
									$attendance1="<span class='label label-sm label-success'>Yes</span>";
											}else{
												$attendance1="<span class='label label-sm label-danger'>No</span>";
											}
											}else{
											if($attendence == 1)
											{
									$attendance1="<a href='addattendence.php?id=".$rt['attendencemid']."' ><span class='label label-sm label-success'>Yes</span></a>";
											}else{
												$attendance1="<a href='addattendence.php?id=".$rt['attendencemid']."' ><span class='label label-sm label-danger'>No</span></a>";
											}
											}
													
												$ipname='';	
												$eve1 = "select * from res_inquiry_master where imid=$imid";
												$re1 = mysqli_query($conn, $eve1);
												while($rt1 = mysqli_fetch_assoc($re1))
												{	
													
													
													$ipname=$rt1['ipname'];
													$ipmiddlename=$rt1['ipmiddlename'];
													$ipsurname=$rt1['ipsurname'];
													$ipname=$ipname." ".$ipmiddlename." ".$ipsurname;
												}
				
								
				$posts[] = array('srno'=> $i++,'ipname'=> $ipname, 'attendance1'=> $attendance1);
		 }
		 
		$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);	
	
?>