1
0
moha/webserver/index.php

61 lines
1.8 KiB
PHP
Raw Normal View History

<?php
require_once "header.php";
require_once "config.php";
2022-05-05 21:28:26 +02:00
require_once $mohaPath . "/utils.php";
2022-04-23 02:00:52 +02:00
require_once $mohaPath . "/constants.php";
2022-05-05 21:28:26 +02:00
require_once "class/db.class.php";
2022-04-23 02:00:52 +02:00
require_once $configPath . "properties2log.php";
2022-04-23 02:00:52 +02:00
$indexIeeeAddress = htmlGetFriendlyNames();
//print_r($indexIeeeAddress);
print (_("This is the Statistics of Moha"));
2022-04-23 02:00:52 +02:00
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>
2022-04-23 02:00:52 +02:00
<select name="device" id="devicesSelectList">' ;
foreach ($devices as $value)
{
if ( array_key_exists($value["device"], $indexIeeeAddress))
{
$devicesList[$value["device"]]["fn"] = $indexIeeeAddress[$value["device"]];
$devicesList[$value["device"]][] = $value["property"];
}
}
array_multisort($devicesList);
2022-04-23 02:00:52 +02:00
//$devicesList = array_intersect_key($indexIeeeAddress, $tmp);
//print_r($devicesList);
foreach($devicesList as $ieeeAddress => $array)
{
print '<optgroup label="' . $array["fn"] . '">';
foreach($array as $key => $property)
{
if ($key != "fn")
{
print '<option value="' . $ieeeAddress . '|' . $array["fn"] . '|' . $property . '">' . $property . '</option>' . EOL;
}
}
print '</optgroup>' . EOL;
}
2022-05-05 21:28:26 +02:00
print "</select>" . EOLH;
print '<input type="date" name="startDate">' . EOLH;
print '<input type="date" name="endDate">' . EOLH;
2022-04-23 02:00:52 +02:00
print '<input type="submit" value="Afficher les statistiques">';
print "</form>" . EOL;
}
require_once "footer.php";
?>