Fix bugs in location code
This commit is contained in:
parent
0696a16030
commit
02b3cfd23f
|
@ -16,18 +16,17 @@ include("header.php");
|
||||||
|
|
||||||
// ************* <option value="0">{$lang_option_none}</option>
|
// ************* <option value="0">{$lang_option_none}</option>
|
||||||
|
|
||||||
$sql = "SELECT location_id AS id, location_name, location_parent, location_sort
|
$sql = "SELECT location_id AS id, location_name AS name,
|
||||||
|
location_parent AS parent, location_sort AS sort
|
||||||
FROM location
|
FROM location
|
||||||
ORDER BY location_parent, location_sort, location_name";
|
ORDER BY location_parent, location_sort, location_name";
|
||||||
$sth = $dbh->query($sql);
|
$sth = $dbh->query($sql);
|
||||||
$locations = $sth->fetchAll();
|
$locations = $sth->fetchAll();
|
||||||
|
|
||||||
$location_counter = count($locations);
|
if (count($locations) > 0) {
|
||||||
|
|
||||||
if ($location_counter > 0) {
|
|
||||||
foreach ($locations AS $location) {
|
foreach ($locations AS $location) {
|
||||||
$location_names[$location['location_id']] = $location['location_name'];
|
$location_names[$location['id']] = $location['name'];
|
||||||
$parents[$location['location_parent']][] = $location['location_id'];
|
$parents[$location['parent']][] = $location['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +42,6 @@ function location($parents, $parent = 0) {
|
||||||
$children[$child] = NULL;
|
$children[$child] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $children;
|
return $children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +61,11 @@ function checkchildren($locations, $level) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$tree = location($parents);
|
$tree = location($parents);
|
||||||
|
|
||||||
|
// create tree option list
|
||||||
$location_options = array(0 => '-');
|
$location_options = array(0 => '-');
|
||||||
checkchildren($tree, 0);
|
checkchildren($tree, 0);
|
||||||
|
|
||||||
$smarty->assign("location_options", $location_options);
|
$smarty->assign("location_options", $location_options);
|
||||||
$smarty->assign("location_parent", $location_parent);
|
$smarty->assign("location_parent", $location_parent);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ $sth = $dbh->prepare($sql);
|
||||||
$sth->execute([$location_id]);
|
$sth->execute([$location_id]);
|
||||||
$smarty->assign("location", $sth->fetch(PDO::FETCH_OBJ));
|
$smarty->assign("location", $sth->fetch(PDO::FETCH_OBJ));
|
||||||
|
|
||||||
$smarty->assign("subnet_options", $db->options_subnet());
|
$smarty->assign("subnet_options", db_get_options_subnet());
|
||||||
|
|
||||||
$smarty->display("locationsubnetadd.tpl");
|
$smarty->display("locationsubnetadd.tpl");
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ $sql = "SELECT location_id AS id, location_name AS name
|
||||||
FROM location
|
FROM location
|
||||||
WHERE location_id=?";
|
WHERE location_id=?";
|
||||||
$sth = $dbh->prepare($sql);
|
$sth = $dbh->prepare($sql);
|
||||||
$sth->execute([$zone_id]);
|
$sth->execute([$location_id]);
|
||||||
$smarty->assign("location", $sth->fetch(PDO::FETCH_OBJ));
|
$smarty->assign("location", $sth->fetch(PDO::FETCH_OBJ));
|
||||||
|
|
||||||
$smarty->display("locationsubnetedit.tpl");
|
$smarty->display("locationsubnetedit.tpl");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<form method="POST" action="submit.php">
|
<form method="POST" action="submit.php">
|
||||||
<input type="hidden" name="redirect" value="locationsubnet">
|
<input type="hidden" name="redirect" value="locationsubnet">
|
||||||
<input type="hidden" name="location_id" value="{$location_id}">
|
<input type="hidden" name="location_id" value="{$location->id}">
|
||||||
|
|
||||||
<table class="title">
|
<table class="title">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
{$lang_location_name}
|
{$lang_location_name}
|
||||||
</td>
|
</td>
|
||||||
<td class="value">
|
<td class="value">
|
||||||
<a href="locationview.php?location_id={$location_id}">{$location_name}</a>
|
<a href="locationview.php?location_id={$location->id}">{$location->name}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue