<?php
/**
 * This is general file which contains
 * connection file, common function file, etc.,
 *
 * PHP version 5
 *
 * @category Admin_Tool
 * @package  Admin_Tool
 * @author   Aum Infosys <admin@auminfosys.com>
 * @license  ACE
 * @version  CVS:1.0.1
 * @link     http://auminfosys.com/
 * @filesource
 */
 
/**
 * This is general file which contains
 * connection file, common function file, etc.,
 *
 */
	require "../commonincludefiles.php";
	
	if($_SESSION["aCollegeId"]!="" && isset($_SESSION["aCollegeId"])){
	
		$condition ="";
		$bookreg_no	= 	Escape($_REQUEST['bookreg_no']); // for book
		$bookregid	 = 	Escape($_REQUEST['bookreg_id']);
		
		if($bookreg_no!=""){
			$condition .= " and book_registerno='$bookreg_no' ";
		}
		if($bookregid!=""){
			$condition .= " and book_registerid='$bookregid' ";
		}
		$count=0;
		$objBookMgmt=new BookMgmt();
		$out=$objBookMgmt->getAllRecords(1,0,$condition,"","");
		$count=dbRows($out);
		
		if($count > 0){
			while($row=dbArray($out)){
				$book_id = $row['book_id'];
				
				
			}
			dbResult($out);
			
		 	$condition ="";
			$condition .= " and lid.book_id='$book_id'";
			$condition .= " and lid.issue_isreturned = '0'";
			
			$objIssueMgmt = new IssueMgmt();	
			$out2 = $objIssueMgmt->getAllRecords(1,0,$condition,"","");
			
			if(dbRows($out2) > 0){
				
					echo '{"success":"true","msg":"1"}'; // book is already issued
				
			}
			else{
			   		echo '{"success":"false","msg":"2"}'; 
			}
		}
		else{
			echo '{"success":"false","msg":"3"}'; // book not available
		}
	}
?>