- Fixed display bug on admin page with drop-down selection of number of lines/rows to display per page.

- Fixed getTableFields() to return valid data on empty tables.
- Added placeholder text for empty query results.
This commit is contained in:
Frank Fegert 2009-06-05 10:50:25 +00:00
parent 00027e1f98
commit 01fb98ed1c
3 changed files with 38 additions and 33 deletions

View File

@ -233,9 +233,9 @@ if ($_POST["css"] != "") {
$sqlresth = $adodb->fetchArrayDB($sqlth);
$colarray = array();
$colarray['id'] = $_POST['id'];
$set = "";
$sqlcols = "";
$sqlvals = "";
$set = array();
$sqlcols = array();
$sqlvals = array();
// get all table fields to be selected
foreach ($sqlresth as $col) {
@ -252,34 +252,36 @@ if ($_POST["css"] != "") {
// if ($val != "") {
if ($_POST['AddSave'] == "Save") {
$colarray["`".$col['Field']."`"] = $val;
$sqlcols .= $col['Field'];
$sqlvals .= "'".$val."'";
$sqlcols .= ", ";
$sqlvals .= ", ";
$val = "'".$val."'";
array_push($sqlcols, $col['Field']);
array_push($sqlvals, $val);
} else if ($_POST['EditSave'] == "Save") {
$colarray["`".$col['Field']."`"] = $val;
$set .= $col['Field']."='".$val."'";
$set .= ", ";
array_push($set, $col['Field']."='".$val."'");
}
// }
}
}
$sqlcols = ereg_replace(", $", "", $sqlcols);
$sqlvals = ereg_replace(", $", "", $sqlvals);
if ($_POST['AddSave'] == "Save") {
$sql = "INSERT into cfg_".$_GET['q']." (".$sqlcols.") values (".$sqlvals.")";
$sql = "INSERT into cfg_".$_GET['q']." (".(implode(",", $sqlcols)).") values (".(implode(",", $sqlvals)).")";
} else if ($_POST['EditSave'] == "Save") {
$sql = "UPDATE cfg_".$_GET['q']." set ".$set." where id='".$_POST['id']."' LIMIT 1";
$sql = "UPDATE cfg_".$_GET['q']." set ".(implode(",", $set))." where id='".$_POST['id']."' LIMIT 1";
}
$adodb->updateDB("cfg_".$_GET['q'], $colarray, 'id');
}
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu']." method='post'>";
echo "<table class='zebra'>";
echo $tsmmonitor->getTableheader();
echo $tsmmonitor->getAdminTables("list");
$thead = $tsmmonitor->getTableheader();
echo $thead["header"];
$tbody = $tsmmonitor->getAdminTables("list");
if ($tbody != "") {
echo $tbody;
} else {
echo "<tr class='d0'><td colspan='".($thead["numfields"]+1)."' align='center'>No entries found in database.</td></tr>";
}
$nav = $tsmmonitor->showPageNavigation("40");
if ($nav!="") {
echo "<tr><td colspan='0' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>";
echo "<tr><td colspan='".($thead["numfields"]+1)."' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>";
}
echo "</table>";
echo "<input type='submit' class='button' name='Add' value='Add' onclick='submit();'>";

View File

@ -570,7 +570,7 @@ class TSMMonitor {
$tableheader = $tableheader."<th colspan=2><a class='navhead'></a></th>";
}
$tableheader=$tableheader."</tr>";
return $tableheader;
return array("numfields" => sizeof($fieldnames), "header" => "$tableheader");
}
@ -701,23 +701,18 @@ class TSMMonitor {
* @return void
*/
function getTableFields($tablename="") {
$sqlth = "SELECT * from ".$tablename." LIMIT 1";
$sqlresth = $this->adodb->fetchArrayDB($sqlth);
$columnnames = "";
$sqltf = "SHOW COLUMNS FROM ".$tablename;
$sqlrestf = $this->adodb->fetchArrayDB($sqltf);
$fieldnames = array();
// get all table fields to be selected
foreach ($sqlresth as $row) {
foreach ($row as $colname => $colval) {
if ($colname != "timestamp") {
$columnnames .= "`".$colname."`";
if ( $i < $numfields-1) $columnnames .= ", ";
}
foreach ($sqlrestf as $field) {
if ($field['Field'] != "timestamp") {
$tmp_field = "`".$field['Field']."`";
array_push($fieldnames, $tmp_field);
}
}
$columnnames = ereg_replace(", $", "", $columnnames);
return $columnnames;
return implode(",", $fieldnames);
}
@ -1489,6 +1484,9 @@ class TSMMonitor {
$ret = array();
while (list ($key, $val) = each ($rows)) {
$ret[$val['servername']] = (array)$val;
if ($retArray["defaultserver"] == "") {
$retArray["defaultserver"] = $val['servername'];
}
if ($val['default'] == 1) {
$retArray["defaultserver"] = $val['servername'];
}

View File

@ -185,11 +185,16 @@ include_once "includes/page_head.php";
}
echo "<table class='zebra'>";
$thead = $tsmmonitor->getTableheader();
echo $thead;
echo $tsmmonitor->execute('table');
echo $thead["header"];
$tbody = $tsmmonitor->execute('table');
if ($tbody != "") {
echo $tbody;
} else {
echo "<tr class='d0'><td colspan='".$thead["numfields"]."' align='center'>No entries found in database.</td></tr>";
}
$nav = $tsmmonitor->showPageNavigation("40");
if ($nav != "") {
echo "<tr><td colspan='".substr_count($thead, "<th>")."' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>";
echo "<tr><td colspan='".$thead["numfields"]."' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>";
}
echo "</table>";
}