<?php
	function getTownPlanZone($id)
{
	global $db;
	$query="select zonename from townplanzone where zoneid='$id'";
	$function_result=$db->query($query) or die($db->error);
	list($function_zone_name)=$function_result->fetch_row();
	return $function_zone_name;
}
	
function getLayout($id)
{
	global $db;
	$query="select layoutname from layout where layoutid='$id'";
	$function_result=$db->query($query) or die($db->error);
	list($function_layout_name)=$function_result->fetch_row();
	return $function_layout_name;
}	

function midPoint($easting, $northing)
{
	$x=(min($easting) + max($easting))/2;
	$y=(min($northing) + max($northing))/2;
	$mid =array("x"=>$x,"y"=>$y);
	return (object)  $mid;
}
function getFileNumber($id)
{
	global $db;
	$query="select filenumber from file where fileid='$id' limit 1";
	$function_result=$db->query($query) or die($db->error);
	list($function_file_count)=$function_result->fetch_row();
	return $function_file_count;
}
function getGender($v)
{
	$v=strtolower($v);
	$g=array("f"=>"Female","m"=>"Male","m/f"=>"Male/Female");
	if(!empty($g[$v]))return $g[$v]; else return "";
}
function labelGender($v)
{
	$v=strtolower($v);
	$g=array("f"=>"Female","m"=>"Male","m/f"=>"Joint","-"=>"Others");
	if(!empty($g[$v]))return $g[$v]; else return "Corporate";
}
function labelOwner($v)
{
	$v=strtolower($v);
	$g=array("1"=>"Individual","2"=>"Corporate","3"=>"Government","-"=>"Others");
	if(!empty($g[$v]))return $g[$v]; else return "Corporate";
}			
?>