<?php 
require "../commonincludefiles.php";
$search_text   = isset($_REQUEST['search_text']) ? Escape($_REQUEST['search_text'])  : "";
$book_branch_name   = isset($_REQUEST['book_branch_name'])  ? Escape($_REQUEST['book_branch_name'])  : "";
ucfirst($search_text);

if($_SESSION["aCollegeId"]!="" && isset($_SESSION["aCollegeId"])){
	
	$objBookMgmt = new BookMgmt();
	$order_field="book_registerid";
	$order_type="ASC";
	if($search_text != "" )
	{
		$condition.=" AND lbm.book_name LIKE '%".$search_text."%'";
	}
	if($book_branch_name != "")
	{
		$condition.=" AND lbm.branch_name='".$book_branch_name."'";
	}
	$condition.=" AND lbm.book_active='1' Group By `book_name`,`book_edition`";
	
	//$result = $objBookMgmt->getAllRecords_with_publisher($limit ,$start,$condition,$order_field,$order_type) ;
	$result1 = $objBookMgmt->getAllRecords_with_publisher(0,0,$condition,$order_field,$order_type) ;
	$total = dbRows($result1);
	$i=0;
	$bookData = array("count" => $total, "rows" => array());
	//for pubisher
	
	if(dbRows($result1) > 0) {
		$temparray = array();
		while($row = dbArray($result1)){
			
			$temparray["book_id"]  = $row["book_id"];
			$temparray["book_name"]   = $row["book_name"];
			$temparray["branch_name"]   = $row["branch_name"];
			$temparray["book_language"]   = $row["book_language"];
			$temparray["book_edition"]   = $row["book_edition"];
			$temparray["book_author"]   = $row["book_author"];
			$temparray["publisher_name"]   = $row["publisher_name"];
			$bookData["rows"][$i] = $temparray;   
			 $i++;
		}										
	}				   		 
	
	/*echo "<pre>";
	print_r($bookData);*/
	//exit;
	echo json_encode($bookData);

}	
?>