<?php require "commonincludefiles.php"; 

function getDistrict($district_id){
	$qry="";
	if($district_id==0)
	{
		$qry = "SELECT dist_id,dist_nameeng FROM sms_distmaster ORDER BY dist_nameeng ASC"; // where dist_id = $district_hidden
	}
	else
	{
	  $qry = "SELECT dist_id,dist_nameeng FROM sms_distmaster where dist_id = $district_id";
	}
	
	$result = dbQuery($qry);
	return $result;

}
function getSchoolFacility($di){
	$qry = "SELECT sf.*,sm.school_name  
			   FROM sms_schoolmaster sm LEFT JOIN sms_schoolfacility sf ON sm.company_id = sf.company_id 
			   WHERE sm.dist_id = $di";
	$result = dbQuery($qry);
	return $result;
}
function getSchoolAdministrationCount($di, $admtype){
	$Counts=0;
	$qry = "SELECT count(*) AS Count  
			   FROM sms_schoolmaster sm 
			   WHERE sm.dist_id = $di AND sm.school_admtype LIKE '".$admtype."'";
	
	$out=dbQuery($qry);
        if (dbRows($out)>0) {
			$row=dbArray($out);
            extract($row);		
           $Counts=$Count;            
			dbFreeResult($out);
        }
		return $Counts;
}

function getEmployeeDetailCount($di,$pay ="", $teaching= "",$pension= ""){
	$Counts=0;
	$qry = "SELECT count(*) AS Count  
			   FROM sms_employeemaster em, sms_schoolmaster sm 
			   WHERE sm.dist_id = $di AND em.company_id = sm.company_id " ;
	if($pay !=""){		   
		$qry .= " AND em.employee_regularorfixpay LIKE '".$pay."' ";
	}
	else if($teaching != ""){
			$qry .=    " AND em.employee_isteaching LIKE '".$teaching."'";
	}
	else if($pension != ""){
			$qry .=    " AND em.employee_pension LIKE '".$pension."'";
	}
	
	$out=dbQuery($qry);
        if (dbRows($out)>0) {
			$row=dbArray($out);
            extract($row);		
           $Counts=$Count;            
			dbFreeResult($out);
        }
		return $Counts;
}
?>