<?php

class location {

	function addLocation($arr)
		{
			if (count($arr) > 0) 
				{
					//property_type 	property_area 	property_location 	property_side_area
					$sql = "INSERT INTO `location` (`sponsor_name`, `web_link`, `url`, `general_comments`, `lat`, `lng`, `icon`, `smallImage`, `property_type`, `property_area`, `property_location`, `property_side_area`, `file_id`, `address`, `agency`, `width`, `estimate_usable`) VALUES ('{$arr[0]}', '{$arr[1]}', '{$arr[2]}', '{$arr[3]}', '{$arr[4]}', '{$arr[5]}', '{$arr[6]}', '', '{$arr[7]}', '{$arr[8]}', '{$arr[9]}', '{$arr[10]}', '{$arr[11]}', '{$arr[12]}', '{$arr[13]}', '{$arr[14]}', '{$arr[15]}')";
				//	echo $sql;	exit;
					if (mysql_query($sql))
						return true;
					else
						return "Error: " . mysql_error();
						 
				}
			else
				{
					return "Error: Please enter the required field values.";
				}
		}
	
	function updateLocation_1($arr)
		{
			if (count($arr) > 0) 
				{
					$sql = sprintf("update locations 
									set loc_name = '%s', address = '%s', city = '%s', state = '%s', zipcode = '%s', country = '%s',
									lat = '%s', lon = '%s', retail_on_site = '%s',	vacancy = '%s', center_ranking = '%s',
									listing_broker = '%s', lb_contact_no = '%s', general_comments = '%s',
									icon = '%s', category = '%s', c_radius = '%s', video_poker = '%s'
									where id = '%s'",
									$arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $arr[6],$arr[7],
									$arr[8], $arr[9], $arr[10], $arr[11], $arr[12], $arr[13], $arr[14], $arr[15], $arr[16], $arr[17], $arr[18]);			

									
					if (mysql_query($sql))
						return true;
					else
						return "Error: " . mysql_error();
						 
				}
			else
				{
					return "Error: Please enter the required field values.";
				}
		}
		
	function updateLocation($arr)
		{
			if (count($arr) > 0) 
				{
					$sql = sprintf("update locations 
									set loc_name = '%s', address = '%s', city = '%s', state = '%s', zipcode = '%s', country = '%s',
									lat = '%s', lon = '%s', retail_on_site = '%s',	vacancy = '%s', center_ranking = '%s',
									listing_broker = '%s', lb_contact_no = '%s', general_comments = '%s', 	icon = '%s'
									where id = '%s'",
									$arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $arr[6],
									$arr[7], $arr[8], $arr[9], $arr[10], $arr[11], $arr[12], $arr[13], $arr[14], $arr[15]);
									
					if (mysql_query($sql))
						return true;
					else
						return "Error: " . mysql_error();
						 
				}
			else
				{
					return "Error: Please enter the required field values.";
				}
		}		
			
	function getLocationInfoById($lid)
		{
			$loc_id = ($lid != '') ? $lid : 0;
			
			$sql = sprintf("select * from location where id = '%s'", $loc_id);
			$res = mysql_query($sql);
			
			return mysql_fetch_array($res);
		}	
}

?>