<?php
	require "../commonincludefiles.php";
	
	$where = '';
	
 	$school_id	=	$_SESSION["VedantnrCollegeId"];
	//$year_id	=	$_SESSION["aYear"];

	$start   = isset($_REQUEST['start'])  ? $_REQUEST['start']  :  0;
	$limit   = isset($_REQUEST['limit'])  ? $_REQUEST['limit']  :  0;
	$sort    = isset($_REQUEST['sort'])   ? $_REQUEST['sort']   : '';
	$dir     = isset($_REQUEST['dir'])    ? $_REQUEST['dir']    : 'ASC';
	$filters = isset($_REQUEST['filter']) ? $_REQUEST['filter'] : null;
	
	if($sort!=""){
		if($sort=='BranchName'){
			$sort=" em.branch_name ";
		}
		$order_field = $sort;
		$order_type=$dir;
	}
	
	
	$objEmployeeMgmt = new EmployeeMgmt();
	$arr = array();
	$k=0;
	$i=0;
	if($_REQUEST['section']!=""){
		
		$where.= " and em.employee_section = '".Escape($_REQUEST['section'])."'";
	}
	$rs = $objEmployeeMgmt->getAllRecords($limit,$start,$where,$order_field,$order_type);
	$total = dbRows($rs);
	$EmpData = array("count" => $total, "data" => array());
	if($total > 0){
		while($row = dbArray($rs)){
		
			$temparray["employee_id"]  					= $row["employee_id"];    	
			$temparray["school_id"] 					= $row["school_id"];
			$temparray["employee_salaryno"]  			= $row["employee_salaryno"]; 	
			$temparray["employee_no"]  			= $row["employee_no"]; 	
			$temparray["employee_name"]  				= ucwords($row["employee_name"]); 	
			$temparray["employee_shortname"]  			= $row["employee_shortname"]; 	
			$temparray["employee_gender"]  				= $row["employee_gender"]; 	
			$temparray["branch_id"]  					= $row["branch_id"]; 	
			$temparray["BranchName"]  					= ($row["BranchName"]==""?$row["branch_name"]:$row["BranchName"]); 	
			//$temparray["sectionmaster_id"]  			= $row["sectionmaster_id"]; 	
			$temparray["employee_designation"]  		= $row["employee_designation"]; 	
			$temparray["employee_isteaching"]  			= $row["employee_isteaching"]; 	
			$temparray["employee_workingperiods"]  		= $row["employee_workingperiods"]; 	
			$temparray["employee_category"]  			= $row["employee_category"]; 	
			$temparray["employee_ishandicap"]  			= $row["employee_ishandicap"]; 	
			if($row["employee_birthdate"] == "0000-00-00")	
			   	$temparray["employee_birthdate"] 		= ""; 	
			else
			   	$temparray["employee_birthdate"] 		= $row["employee_birthdate"]; 
			 	
			$temparray["employee_regularorfixpay"]  	= $row["employee_regularorfixpay"]; 	
			$temparray["employee_panno"]  				= $row["employee_panno"]; 	
			$temparray["employee_gpfacno"]  			= $row["employee_gpfacno"]; 	
			$temparray["employee_bankacno"]  			= $row["employee_bankacno"]; 
			if($row["employee_deptjoindate"] == "0000-00-00")	
			   	$temparray["employee_deptjoindate"] 		= ""; 	
			else
			   	$temparray["employee_deptjoindate"] 		= $row["employee_deptjoindate"]; 	
					
			if($row["employee_schooljoindate"] == "0000-00-00")	
			   	$temparray["employee_schooljoindate"] 		= ""; 	
			else
			   	$temparray["employee_schooljoindate"] 		= $row["employee_schooljoindate"]; 			
				
			$temparray["employee_payscale"]  			= $row["employee_payscale"]; 	
			$temparray["employee_basicsalary"]  		= $row["employee_basicsalary"]; 	

			if($row["employee_incrdate"] == "0000-00-00")	
			   	$temparray["employee_incrdate"] 		= ""; 	
			else
			   	$temparray["employee_incrdate"] 		= $row["employee_incrdate"];
	
			$temparray["employee_pension"]  			= $row["employee_pension"]; 	
			$temparray["employee_eduqualification"]		= $row["employee_eduqualification"]; 	
			$temparray["employee_edusub"]  				= $row["employee_edusub"]; 	
			$temparray["employee_eduuni"]  				= $row["employee_eduuni"]; 	
			if($row["employee_eduyear"] != 0){
				$temparray["employee_eduyear"]  		= $row["employee_eduyear"];
			} else{
				$temparray["employee_eduyear"]  		= "";
			}
			$temparray["employee_eduobtclass"]  		= $row["employee_eduobtclass"]; 	
			$temparray["employee_profqualification"]	= $row["employee_profqualification"]; 	
			$temparray["employee_profsub"]  			= $row["employee_profsub"]; 	
			$temparray["employee_profuni"]  			= $row["employee_profuni"]; 	
			if($row["employee_profyear"] != 0){
				$temparray["employee_profyear"]  		= $row["employee_profyear"]; 	
			} else{
				$temparray["employee_profyear"]  		= "";
			}
			$temparray["employee_profobtclass"]  		= $row["employee_profobtclass"]; 	
			$temparray["employee_otherqualification"]  	= $row["employee_otherqualification"]; 	
			$temparray["employee_othersub"]  			= $row["employee_othersub"]; 	
			$temparray["employee_otheruni"]  			= $row["employee_otheruni"]; 	
			if($row["employee_otheryear"] != 0){
				$temparray["employee_otheryear"]  		= $row["employee_otheryear"]; 	
			} else{
				$temparray["employee_otheryear"]  		= "";
			}
			$temparray["employee_otherobtclass"]  		= $row["employee_otherobtclass"]; 	
			if($row["employee_retddate"] == "0000-00-00")	
			   	$temparray["employee_retddate"] 		= ""; 	
			else
			   	$temparray["employee_retddate"] 		= $row["employee_retddate"];
			
			$temparray["employee_nominee"]  			= $row["employee_nominee"]; 	
			$temparray["employee_active"]  				= $row["employee_active"]; 	
			$temparray["employee_curaddress"]  			= $row["employee_curaddress"]; 	
			$temparray["employee_contactnores"]  		= $row["employee_contactnores"]; 	
			$temparray["employee_mobile"]  				= $row["employee_mobile"]; 	
			$temparray["employee_permaddress"]  		= $row["employee_permaddress"]; 	
			$temparray["employee_phone"]  				= $row["employee_phone"]; 	
			$temparray["employee_emailid"]  			= $row["employee_emailid"]; 	
			$temparray["employee_bloodgroup"]  			= $row["employee_bloodgroup"]; 	
			$temparray["employee_photo"]  				= $row["employee_photo"]; 	
			$temparray["user_id"]  				= $row["user_id"]; 	
			$temparray["employee_adharno"]  				= $row["employee_adharno"]; 	
			
			
			$temparray["employee_credit_amount"]  			= $row["employee_credit_amount"]; 	
			$temparray["employee_loan"]  				= $row["employee_loan"]; 	
			$temparray["loan_amount"]  				= $row["loan_amount"]; 	
			$temparray["loan_month"]  				= $row["loan_month"]; 	
			if($row["loan_date"] == "0000-00-00")	
			   	$temparray["loan_date"] 		= ""; 	
			else
			   	$temparray["loan_date"] 		= $row["loan_date"];
	
			$EmpData["data"][$i] = $temparray;   
			$i++;
		}
	}
	echo json_encode($EmpData);	
?>
