<?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'];
										$campusmid1=$_SESSION['campusmid1'];
										
										$lower = $_SESSION['lowerdate'];
		$upper = $_SESSION['upperdate'];
		$aa = "and date(res_collegeapp_master.doapplication) >='$lower' and date(res_collegeapp_master.doapplication) <= '$upper'";
		
	
	 //$eve = "select * from res_inquiry_master where imid in (select imid from  res_collegeapp_master where clgappmid in (select linkmid from res_inquiryservice_detail where ispendingamount < 1 and ptype='Application') and coursemid in (select coursemid from res_course_master where campusmid = $campusmid1))";
	 
	  $eve = "select * from res_inquiry_master,res_collegeapp_master,res_course_master where res_collegeapp_master.imid = res_inquiry_master.imid and  res_collegeapp_master.clgappmid in (select linkmid from res_inquiryservice_detail where ispendingamount < 1 and ptype='Application') and res_course_master.coursemid = res_collegeapp_master.coursemid and res_course_master.campusmid = $campusmid1 $aa";
	$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))
		 {
			 	$ipname=$rt['ipname'];
				$ipmiddlename=$rt['ipmiddlename'];
				$ipsurname=$rt['ipsurname'];
				$capplicationfee=$rt['capplicationfee'];
				$ipname=$ipname." ".$ipmiddlename." ".$ipsurname;
						$doapplication=date("d-m-Y",strtotime($rt['doapplication']));
						$coursemid=$rt['coursemid'];
											 $eve22 = "select coursename from res_course_master,res_coursename_master where res_course_master.coursemid=$coursemid and     res_coursename_master.cnmid = res_course_master.cnmid";
											$re22 = mysqli_query($conn, $eve22);
											while($rt22 = mysqli_fetch_assoc($re22))
										{
											$coursename = $rt22['coursename'];
										}	

/* $eve23 = "select * " */										
				
								
				$posts[] = array('srno'=> $i++,'ipname'=> $ipname, 'doapplication'=> $doapplication, 'coursename'=> $coursename);
		 }
		 
		$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);	
	
?>