function writeGlobalSummary($source) { $result = array(); if ($this->repGlobalSummary) { if (is_array($source["summary"])) { for ($i = 0; $i < count($this->fieldsArr); $i++) { if (is_array($source["summary"][$this->fieldsArr[$i]['name']])) { if ($this->fieldsArr[$i]['totalMax']) { $result["global_total" . $this->fieldsArr[$i]['goodName'] . "_max"] = getFormattedValue($this->pageObject, $source['summary'][$this->fieldsArr[$i]['name']]['MAX'], $this->fieldsArr[$i]['name'], $this->fieldsArr[$i]['viewFormat'], $this->fieldsArr[$i]['editFormat'], $this->mode); } if ($this->fieldsArr[$i]['totalMin']) { $result["global_total" . $this->fieldsArr[$i]['goodName'] . "_min"] = getFormattedValue($this->pageObject, $source['summary'][$this->fieldsArr[$i]['name']]['MIN'], $this->fieldsArr[$i]['name'], $this->fieldsArr[$i]['viewFormat'], $this->fieldsArr[$i]['editFormat'], $this->mode); } if ($this->fieldsArr[$i]['totalAvg']) { $result["global_total" . $this->fieldsArr[$i]['goodName'] . "_avg"] = getFormattedValue($this->pageObject, $source['summary'][$this->fieldsArr[$i]['name']]['AVG'], $this->fieldsArr[$i]['name'], $this->fieldsArr[$i]['viewFormat'], $this->fieldsArr[$i]['editFormat'], $this->mode); } if ($this->fieldsArr[$i]['totalSum']) { $result["global_total" . $this->fieldsArr[$i]['goodName'] . "_sum"] = getFormattedValue($this->pageObject, $source['summary'][$this->fieldsArr[$i]['name']]['SUM'], $this->fieldsArr[$i]['name'], $this->fieldsArr[$i]['viewFormat'], $this->fieldsArr[$i]['editFormat'], $this->mode); } } } } $result["global_total_cnt"] = $source['count']; } return $result; }
// do query and select values $uID = $_SESSION['uID']; $sql = "\n SELECT `sensor`.`ID`, `sensor`.`description`, `sensor`.`value`, `sensortype`.`sieenheid`, `sensorsoort`.`soort`, `wifimodule`.`online`, `wifimodule`.`ID` as IDWIFI FROM `NoWire`.`sensor`\n LEFT JOIN `NoWire`.`wifimodule_gebruikers` ON `sensor`.`IDwifimodule` = `wifimodule_gebruikers`.`IDwifimodule`\n\tLEFT JOIN `NoWire`.`sensortype` ON `sensor`.`IDtype` = `sensortype`.`ID`\n\tLEFT JOIN `NoWire`.`sensorsoort` ON `sensortype`.`soort` = `sensorsoort`.`ID`\n\tLEFT JOIN `NoWire`.`wifimodule` ON `sensor`.`IDwifimodule` = `wifimodule`.`ID`\n WHERE `wifimodule_gebruikers`.`IDgebruiker` = {$uID}\n ORDER BY `sensor`.`description` ASC\n "; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while ($row = $result->fetch_assoc()) { $sensdata_id = $row["ID"]; $sensdata_descr = $row["description"]; $sensdata_val = $row["value"]; $sensdata_siunit = $row["sieenheid"]; $sensdata_sort = $row["soort"]; $sensdata_online = intval($row["online"]); $sensdata_wifi = intval($row["IDWIFI"]); $sensdata_descr = ucwords($sensdata_descr); $sensdata_TotVal = getFormattedValue($sensdata_sort, $sensdata_val, $sensdata_siunit); if ($sensorSelected == $sensdata_id) { echo '<li class="active">'; } else { echo '<li>'; } echo '<a href="' . "index.php?p=1&s={$sensdata_id}&w={$sensdata_wifi}" . '"><div>'; if ($sensdata_online == 0) { echo '<span class="fa fa-circle-o"></span> <strong>'; } else { echo '<span class="fa fa-dot-circle-o"></span> <strong>'; } echo "{$sensdata_descr}"; echo '</strong>'; if ($sensorSelected == $sensdata_id) { echo '<span class="badge badge-dark pull-right">';
$sensorSelectedDataview = intval($_SESSION['sensorDataSelected']); // do query for value, unit and type if ($getIDSensor == 0 && $sensorSelectedDataview == 0) { echo json_encode(array("value" => "", "unit" => "", "type" => "", "totVal" => "", "online" => "")); } else { // do query and select values if ($getIDSensor == 0) { $getIDSensor = $sensorSelectedDataview; } $sql = "\nSELECT `sensor`.`value`, `sensortype`.`sieenheid`, `sensorsoort`.`soort`, `wifimodule`.`online`\n FROM `NoWire`.`sensor`\n LEFT JOIN `NoWire`.`sensortype` ON `sensor`.`IDtype` = `sensortype`.`ID`\n LEFT JOIN `NoWire`.`sensorsoort` ON `sensortype`.`soort` = `sensorsoort`.`ID`\n\tLEFT JOIN `NoWire`.`wifimodule` ON `sensor`.`IDwifimodule` = `wifimodule`.`ID`\n WHERE `sensor`.`ID` = {$getIDSensor}\n "; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row if ($row = $result->fetch_assoc()) { $uinfo_val = floatval($row["value"]); $uinfo_sie = $row["sieenheid"]; $uinfo_soort = $row["soort"]; $uinfo_online = intval($row["online"]); $uinfo_TotVal = getFormattedValue($uinfo_soort, $uinfo_val, $uinfo_sie); if ($uinfo_online == 0) { $uinfo_val = 0; } echo json_encode(array("value" => "{$uinfo_val}", "unit" => "{$uinfo_sie}", "type" => "{$uinfo_soort}", "totVal" => "{$uinfo_TotVal}", "online" => "{$uinfo_online}")); } else { echo json_encode(array("value" => "", "unit" => "", "type" => "", "totVal" => "", "online" => "")); } } else { echo json_encode(array("value" => "", "unit" => "", "type" => "", "totVal" => "", "online" => "")); } } $conn->close();