<?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"]))
 {
	 $book_registerno      = isset($_REQUEST['registernoid'])  ? $_REQUEST['registernoid']  :  0;
	 $search_field     	   = isset($_REQUEST['searchfield'])   ? $_REQUEST['searchfield']  :  0;
	 $search_text	       = isset($_REQUEST['searchtext'])    ? $_REQUEST['searchtext']    :  0;		
	 $start   			   = isset($_REQUEST['start'])  ? $_REQUEST['start']  :  0;
     $limit   			   = isset($_REQUEST['limit'])  ? $_REQUEST['limit']  : 30;

	 $condition="";
	
	if($book_registerno != ""){
		$condition .= " and book_registerid='$book_registerno' and book_active='1'";
	}
	
	if($search_field != "" && $search_text != ""){
		$condition .= " and ".$search_field." like '%$search_text%' ";
	}	
		   
	$objBookMgmt = new BookMgmt();	
	$result = $objBookMgmt ->getAllRecords($limit,$start,$condition,"","");

	$result1 = $objBookMgmt ->getAllRecords(0,0,$condition,"","");
	
	$total = dbRows($result1);
	$arr = array();
	 
	$i=0;
	
	$generalsearchData = array("count" => $total, "result" => array());
	
	if (dbRows($result) > 0) 
	{
	   $temparray = array();
	   
	   while($row = dbArray($result))
	   {
			$temparray["book_id"]  				= $row["book_id"];
			$temparray["book_registerno"]   	= $row["book_registerno"];
			$temparray["book_name"]  			= $row["book_name"];
			$temparray["book_author"]   		= $row["book_author"];
			$temparray["book_publishername"]    = $row["book_publishername"];
			$temparray["book_category"]   		= $row["book_category"];
			$temparray["book_language"]   		= $row["book_language"];
			$temparray["book_rack"]   			= $row["book_rack"];
		   
			if($row["book_available"]==0)
			{
				$temparray["book_available"]  = "No";
			}
			else
			{
				 $temparray["book_available"]  = "Yes";									   
			}
		
			$generalsearchData["result"][$i] = $temparray;   
			$i++;
	  }										
  }	
  echo json_encode($generalsearchData);	
}
?>