<?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'])  ? Escape($_REQUEST['registernoid'])  :  0;
	 $search_field     	 = isset($_REQUEST['searchfield'])   ? Escape($_REQUEST['searchfield'])  :  0;
	 $search_text	      = isset($_REQUEST['searchtext'])    ? Escape($_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();
	if($search_field=="book_name")	
	$result = $objBookMgmt ->getDistinctName();
	else if($search_field=="book_author")	
	$result = $objBookMgmt ->getDistinctAuthor();
	else if($search_field=="book_language")	
	$result = $objBookMgmt ->getDistinctLanguage();
	else if($search_field=="publisher_name")	
	$result = $objBookMgmt ->getDistinctpublisherName();
	else if($search_field=="book_category")	
	$result = $objBookMgmt ->getDistinctCategory();

	//$result1 = $objBookMgmt ->getAllRecords(0,0,$condition,"","");
	
//	$total = dbRows($result1);
	$arr = array();
	 
	$i=0;
	
	$generalsearchData = array("count" => $total, "result" => array());
	
	
	   $temparray = array();
	   
	   while($row = dbArray($result))
	   {
		/*	$temparray["book_id"]  				= $row["book_id"];
			$temparray["book_registerno"]   	= $row["book_registerno"];*/
			$temparray["general_name"]  			= $row[$search_field];
			/*$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);	
}
?>