<?php
include("../db.php");
header("Access-Control-Allow-Origin: * ");

	$idno=$_REQUEST['idno'];
	$session=$_REQUEST['session'];
	$school_id=$_REQUEST['school_id'];
	$idno=mysql_real_escape_string($idno);
	$session=mysql_real_escape_string($session);
	$school_id=mysql_real_escape_string($school_id);
	
  $class=$db->getVal("Select class FROM student where idno='".$idno."'");
$aryList=$db->getRows("SELECT * FROM issueBook where school_id='".$school_id."' and sid='".$idno."' and status=0 order by id desc");
$aryList1=$db->getRows("SELECT * FROM issueBook where school_id='".$school_id."' and sid='".$idno."' and status=1 order by id desc");

//print_r($aryList);
//////////////Fetching values from array ///////
	$i=0;$data=$data1=array();
	
	foreach($aryList as $list){$i++;
		
		$book=$db->getRow("Select * FROM book where idno='".$list["bid"]."'");
		
		$data[$i]["order"]=$i;
		
		$data[$i]["book_name"]=$book["title"];
		
		$data[$i]["book_category"]=$book["category"];
		
		$data[$i]["issue_date"]=$list["idate"];
		
		$data[$i]["return_date"]=$list["rdate"];
		
		/*$data[$i]["date"]=date("d-m-Y",strtotime($list["date"]));
				
		if($list["upload_assignment"]!='')	$data[$i]["file"]=URL_ROOT."uploads/assignment/".$list['upload_assignment'];
		else 
			$data[$i]["file"]=NULL;
*/	}$i=0;
	foreach($aryList1 as $list){$i++;
		
		$book=$db->getRow("Select title,category FROM book where idno='".$list["bid"]."'");
		
		$data1[$i]["order"]=$i;
		
		$data1[$i]["book_name"]=$book["title"];
		
		$data1[$i]["book_category"]=$book["category"];
		
		$data1[$i]["issue_date"]=$list["idate"];
		
		$data1[$i]["return_date"]=$list["rdate"];
		
		$data1[$i]["fine"]=$list["fine"];
		
		/*$data[$i]["date"]=date("d-m-Y",strtotime($list["date"]));
				
		*/	
	}	
	
	$alldata=array('issue'=>$data,'return'=>$data1);
	
	
	
	
	if(is_array($aryList) && count($aryList)>0)
	{  
		echo json_encode(array('status' => 1, 'msg'=>'Data found Successfully..!', "data"=>$alldata));    
			
	}else
	{		
	 	echo json_encode(array('status' => 0, 'msg'=>'No Data Found..!'));
	}
