Updated to use new table name

This commit is contained in:
laf
2015-07-23 18:41:41 +01:00
parent 7951ad44d0
commit 0b93725029
4 changed files with 6 additions and 6 deletions

View File

@@ -73,7 +73,7 @@ if ($device['location']) {
}
}
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `coordinates` WHERE `location`=? LIMIT 1", array($device['location']));
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `locations` WHERE `location`=? LIMIT 1", array($device['location']));
if (is_array($loc)) {
echo '<tr>
<td>Lat / Lng</td>

View File

@@ -51,7 +51,7 @@ var greenMarker = L.AwesomeMarkers.icon({
});
<?php
foreach (dbFetchRows("SELECT `hostname`,`status`,`lat`,`lng` FROM `devices` LEFT JOIN `coordinates` ON `devices`.`location`=`coordinates`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' ORDER BY `status` ASC, `hostname`") as $map_devices) {
foreach (dbFetchRows("SELECT `hostname`,`status`,`lat`,`lng` FROM `devices` LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' ORDER BY `status` ASC, `hostname`") as $map_devices) {
$icon = 'greenMarker';
if ($map_devices['status'] == 0) {
$icon = 'redMarker';
@@ -109,7 +109,7 @@ if (isset($config['mapael']['default_lat']) && isset($config['mapael']['default_
<script src='js/jquery.mousewheel.min.js'></script>
<?php
$x=0;
foreach (dbFetchRows("SELECT `hostname`,`devices`.`location`,`status`, COUNT(`status`) AS `total`,`lat`,`lng` FROM `devices` LEFT JOIN `coordinates` ON `devices`.`location`=`coordinates`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' GROUP BY `status`,`lat`,`lng` ORDER BY `status` ASC, `hostname`") as $map_devices) {
foreach (dbFetchRows("SELECT `hostname`,`devices`.`location`,`status`, COUNT(`status`) AS `total`,`lat`,`lng` FROM `devices` LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' GROUP BY `status`,`lat`,`lng` ORDER BY `status` ASC, `hostname`") as $map_devices) {
$color = "#29FF3B";
$size = 15;
$status = 'Up';

View File

@@ -429,7 +429,7 @@ function location_to_latlng($device) {
if (!empty($device_location)) {
$new_device_location = preg_replace("/ /","+",$device_location);
// We have a location string for the device.
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `coordinates` WHERE `location`=? LIMIT 1", array($device_location));
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `location` WHERE `location`=? LIMIT 1", array($device_location));
if (is_array($loc) === false) {
// Grab data from which ever Geocode service we use.
switch ($config['geoloc']['engine']) {
@@ -460,7 +460,7 @@ function location_to_latlng($device) {
else {
$loc['timestamp'] = array('NOW()');
$loc['location'] = $device_location;
if (dbInsert($loc, 'coordinates')) {
if (dbInsert($loc, 'locations')) {
d_echo("Device lat/lng created\n");
}
else {

View File

@@ -1,4 +1,4 @@
CREATE TABLE `coordinates` ( `id` INT NOT NULL AUTO_INCREMENT ,`location` TEXT NOT NULL ,`lat` FLOAT( 10, 6 ) NOT NULL ,`lng` FLOAT( 10, 6 ) NOT NULL ,`timestamp` DATETIME NOT NULL ,INDEX ( `id` )) ENGINE = INNODB;
CREATE TABLE `locations` ( `id` INT NOT NULL AUTO_INCREMENT ,`location` TEXT NOT NULL ,`lat` FLOAT( 10, 6 ) NOT NULL ,`lng` FLOAT( 10, 6 ) NOT NULL ,`timestamp` DATETIME NOT NULL ,INDEX ( `id` )) ENGINE = INNODB;
LOCK TABLES `devices` WRITE;
ALTER TABLE `devices` ADD `override_sysLocation` bool DEFAULT false;
UNLOCK TABLES;