You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.8 KiB
81 lines
2.8 KiB
<?php
|
|
require_once('../ajax_asm.php');
|
|
if( $CUser->Data['id'] > 1 ){
|
|
$DTS = intval( $_POST['DTS'] );
|
|
if( $DTS ){
|
|
$ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db');
|
|
$DS = $DTS;
|
|
$DE = $DS + 86400; // -> 1 Day
|
|
/*
|
|
$QS ="SELECT DISTINCT `node_id` FROM `events` WHERE `ts` >= {$DS} AND `ts` <= {$DE}";
|
|
$NDD = $ZIZI->Query( $QS );
|
|
$lulu = true;
|
|
$E = "]}";
|
|
$NONO = array();
|
|
foreach( $NDD as $NID ){
|
|
$id = intval( $NID['node_id'] );
|
|
$QS = "SELECT `name` FROM `nodes` WHERE `id`={$id}";
|
|
$R = $DATABASE->Query( $QS );
|
|
$Name = $R[0]['name'];
|
|
if( $lulu ) {
|
|
$S = "{ text: '{$Name}', leaf: false, expanded: true, children:[";
|
|
$lulu = false;
|
|
} else {
|
|
$S = "{ text: '{$Name}', leaf: false, expanded: false, children:[";
|
|
};
|
|
$QS = "SELECT `ts`, `id` FROM `events` WHERE `node_id`={$id} AND `ts` >= {$DS} AND `ts` <= {$DE} AND ( `evt_type`=52 ) ORDER BY `ts`, `ts_ms`";
|
|
//echo $QS;
|
|
//exit();
|
|
$JJJ = $ZIZI->Query( $QS );
|
|
$JIGA = array();
|
|
foreach( $JJJ as $J ){
|
|
$TM = date( "H:i:s", $J['ts'] );
|
|
$JIGA[] = "{ text: '{$TM}', leaf: true, ts: {$J['ts']}, nid: {$id} }";
|
|
};
|
|
$NONO[] = $S . implode( ",", $JIGA ) . $E;
|
|
//echo "{expanded: true, children: [{ text: 'Menu Option 1', leaf: false, expanded: true, children:[{ text: '14:53', leaf: true }] },{ text: 'Menu Option 2', leaf: true },{ text: 'Menu Option 3', leaf: true}]}";
|
|
};
|
|
echo "{expanded: true, children: [".implode(",", $NONO )."]}";
|
|
*/
|
|
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `ts` >= {$DS} AND `ts` <= {$DE} AND ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 )";
|
|
$NDD = $ZIZI->Query( $QS );
|
|
if( count( $NDD ) ){
|
|
$st_ignore = true;
|
|
$DH = 0;
|
|
$JIGA = array();
|
|
foreach( $NDD as $N ){
|
|
if( $st_ignore && $N['evt_type']!=52 ) continue;
|
|
if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false;
|
|
if( $N['evt_type']==52 ) {
|
|
$DH = 0;
|
|
$BID = intval( $N['id'] );
|
|
$BTM = date( "H:i:s", $N['ts'] );
|
|
} else {
|
|
$DH = 1;
|
|
$EID = intval( $N['id'] );
|
|
};
|
|
if( $DH == 1 ){
|
|
$JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
|
|
};
|
|
};
|
|
if( $DH == 0 ){
|
|
//Ongoing Event goes next day - must catch up
|
|
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1";
|
|
$NDD = $ZIZI->Query( $QS );
|
|
if( count( $NDD ) ){
|
|
$EID = intval( $NDD[0]['id'] );
|
|
} else {
|
|
$EID = 1000000000;//Infinity
|
|
};
|
|
$JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
|
|
};
|
|
$NONO = "{ text: 'Events', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
|
|
};
|
|
echo "{expanded: true, children: [". $NONO ."]}";
|
|
} else {
|
|
echo "[]";
|
|
};
|
|
} else {
|
|
header('location: /');
|
|
};
|
|
?>
|