66 lines
2.0 KiB
PHP
66 lines
2.0 KiB
PHP
<?php
|
|
require_once "header.php";
|
|
require_once "config.php";
|
|
require_once $mohaPath . "/utils.php";
|
|
require_once $mohaPath . "/constants.php";
|
|
require_once "class/db.class.php";
|
|
require_once $configPath . "properties2log.php";
|
|
|
|
$indexIeeeAddress = htmlGetFriendlyNames();
|
|
|
|
//print_r($indexIeeeAddress);
|
|
print (_("This is the Statistics of Moha"));
|
|
|
|
if (empty($indexIeeeAddress))
|
|
{
|
|
$response = _("ERROR getting list of Friendly names: json error =>") . json_last_error_msg() .EOLH;
|
|
}else
|
|
{
|
|
$query = "SELECT DISTINCT device, property FROM logs";
|
|
$result = $mohaDB->query($query);
|
|
$devices = mysqli_fetch_all($result, MYSQLI_ASSOC);
|
|
$devicesList = array();
|
|
// print_r($devices);
|
|
print '<form method="GET" action="display_stats.php">';
|
|
//print '<input type="hidden" name="fn" value="">';
|
|
print '<label for="devicesSelectList">' . _("Choose a property to display:") . '</label>
|
|
<select name="device" id="devicesSelectList">' ;
|
|
foreach ($devices as $value)
|
|
{
|
|
if ( array_key_exists($value["device"], $indexIeeeAddress))
|
|
{
|
|
$fn = $indexIeeeAddress[$value["device"]];
|
|
$devicesList[$fn]["ieeeAddress"] = $value["device"];
|
|
$devicesList[$fn]["properties"][] = $value["property"];
|
|
}
|
|
}
|
|
ksort($devicesList, SORT_NATURAL | SORT_FLAG_CASE );
|
|
|
|
//$devicesList = array_intersect_key($indexIeeeAddress, $tmp);
|
|
//print_r($devicesList);
|
|
foreach($devicesList as $fn => $array)
|
|
{
|
|
print '<optgroup label="' . $fn . '">';
|
|
$ieeeAddress = $array["ieeeAddress"];
|
|
if (array_key_exists("properties", $array))
|
|
{
|
|
foreach($array["properties"] as $property)
|
|
{
|
|
print '<option value="' . $ieeeAddress . '|' . $fn . '|' . $property . '">' . $property . '</option>' . EOL;
|
|
}
|
|
print '</optgroup>' . EOL;
|
|
}else
|
|
{
|
|
echo _("Erreur: la clé de tableau 'properties' n'existe pas ") . __LINE__ . EOLH;
|
|
}
|
|
}
|
|
print "</select>" . EOLH;
|
|
print '<input type="date" name="startDate">' . EOLH;
|
|
print '<input type="date" name="endDate">' . EOLH;
|
|
print '<input type="submit" value="Afficher les statistiques">';
|
|
print "</form>" . EOL;
|
|
}
|
|
|
|
require_once "footer.php";
|
|
?>
|