query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
if($DbResult->num_rows > 0)
{
$DbRow = $DbResult->fetch_assoc();
$Longitude = $this->Explode($DbRow['Longitude']);
$Latitude = $this->Explode($DbRow['Latitude']);
$Output = ''.$Latitude[0].'°'.$Latitude[1]."'".$Latitude[2].'" '.$Longitude[0].'°'.$Longitude[1]."'".$Longitude[2].'"';
}
return($Output);
}
function OnEdit($Item)
{
global $Database;
if($Item['Value'] != '')
{
$DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
if($DbResult->num_rows > 0)
{
$DbRow = $DbResult->fetch_assoc();
} else $DbRow = array('Longitude' => 0, 'Latitude' => 0);
} else $DbRow = array('Longitude' => 0, 'Latitude' => 0);
$Value = $this->Explode($DbRow['Latitude']);
$Output = '°';
$Output .= '\'';
$Output .= '"
';
$Value = $this->Explode($DbRow['Longitude']);
$Output .= '°';
$Output .= '\'';
$Output .= '"';
return($Output);
}
function OnLoad($Item)
{
global $Database;
$Latitude = $this->Implode($_POST[$Item['Name'].'-lat-deg'], $_POST[$Item['Name'].'-lat-min'], $_POST[$Item['Name'].'-lat-sec']);
$Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']);
$Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")');
return($Database->insert_id);
}
function Explode($Float)
{
$Degrees = intval($Float);
$Float = abs($Float);
$Float = ($Float - intval($Float)) * 60;
$Minutes = intval($Float);
$Float = ($Float - intval($Float)) * 60;
$Seconds = round($Float, 3);
return(array($Degrees, $Minutes, $Seconds));
}
function Implode($Degrees, $Minutes, $Seconds)
{
if($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60));
else return($Degrees + ($Minutes + $Seconds / 60) / 60);
}
}