<?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'])) 
{
	
	
		$student_id = Escape($_REQUEST['student_id']);
		$category  = Escape($_REQUEST['category']);
		$memberid  = Escape($_REQUEST['txtgrno']);
		$section   = Escape($_REQUEST['section']);
	//	$BookLimit=5;
		$i=0;
		$objMemberMgmt=new MemberMgmt();
		if($category == 1){ 
		
		if($student_id=="" && $_REQUEST['member_id']!=""){
			$student_id= Escape($_REQUEST['member_id']);
		}
		$no_of_issue = $objMemberMgmt->getTotalNoofIssueBook($student_id,$category);
	    if($no_of_issue>=6)
		 {
			  echo "{success:false}";  
		 }
		 else
		 {
			echo "{success:true,data:{ member_id1:'".$student_id ."',txttotalIssueablebook:6,txttotalissuedbook:'".$no_of_issue."'}}";	
					   exit;		
		   }
		}
		else if($category == 2){ // employee
			$memberid  = $_REQUEST['txtgrno'];
			$condition = " And employee_id ='$memberid' and employee_active='Yes' ";
			$objMemberMgmt = new MemberMgmt();	
			$out1 = $objMemberMgmt->getEmployeeRecords(1,0,$condition,"","");
			$count=dbRows($out1);
			if($count > 0){
				$row=dbArray($out1);
				extract($row);
				$out2 = $objMemberMgmt->getTotalNoofIssueBook($employee_id,$category);
				echo "{success:true,data:{membername:'".$employee_name
					   ."',member_id:'".$employee_id
					   ."',txttotalIssueablebook:'".$FacultyBookLimit
					   ."',txttotalissuedbook:'".$out2
					   ."'}}";
			}
			else{ 
				echo "{success:false}";
			}			
		}
		else{ // member
			$condition = " and member_registerno ='$memberid' and member_active='1' ";
			$objMemberMgmt = new MemberMgmt();	
			$out1 = $objMemberMgmt->getAllRecords(1,0,$condition,"","");
			$out2 = $objMemberMgmt->getTotalNoofIssueBook($memberid,$category);
			$count=dbRows($out1);
			if($count > 0){
				$row=dbArray($out1);
				extract($row);
				echo "{success:true,data:{membername:'".$member_name
				       ."',member_id:'".$member_id
					   ."',txttotalIssueablebook:'".$member_maxissuelimit
					   ."',txttotalissuedbook:'".$out2
					   ."'}}";			
			}
			else{ 
				echo "{success:false}";
			}
		}
}
else{ 
		echo "{success:false}";
	}
	

?>