Web Interface For Lite Argus Control modules
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.

80 lines
2.8 KiB

​
​
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. if( $CUser->Data['id'] > 1 ){
  4. $DTS = intval( $_POST['DTS'] );
  5. if( $DTS ){
  6. $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db');
  7. $DS = $DTS;
  8. $DE = $DS + 86400; // -> 1 Day
  9. /*
  10. $QS ="SELECT DISTINCT `node_id` FROM `events` WHERE `ts` >= {$DS} AND `ts` <= {$DE}";
  11. $NDD = $ZIZI->Query( $QS );
  12. $lulu = true;
  13. $E = "]}";
  14. $NONO = array();
  15. foreach( $NDD as $NID ){
  16. $id = intval( $NID['node_id'] );
  17. $QS = "SELECT `name` FROM `nodes` WHERE `id`={$id}";
  18. $R = $DATABASE->Query( $QS );
  19. $Name = $R[0]['name'];
  20. if( $lulu ) {
  21. $S = "{ text: '{$Name}', leaf: false, expanded: true, children:[";
  22. $lulu = false;
  23. } else {
  24. $S = "{ text: '{$Name}', leaf: false, expanded: false, children:[";
  25. };
  26. $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`";
  27. //echo $QS;
  28. //exit();
  29. $JJJ = $ZIZI->Query( $QS );
  30. $JIGA = array();
  31. foreach( $JJJ as $J ){
  32. $TM = date( "H:i:s", $J['ts'] );
  33. $JIGA[] = "{ text: '{$TM}', leaf: true, ts: {$J['ts']}, nid: {$id} }";
  34. };
  35. $NONO[] = $S . implode( ",", $JIGA ) . $E;
  36. //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}]}";
  37. };
  38. echo "{expanded: true, children: [".implode(",", $NONO )."]}";
  39. */
  40. $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 )";
  41. $NDD = $ZIZI->Query( $QS );
  42. if( count( $NDD ) ){
  43. $st_ignore = true;
  44. $DH = 0;
  45. $JIGA = array();
  46. foreach( $NDD as $N ){
  47. if( $st_ignore && $N['evt_type']!=52 ) continue;
  48. if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false;
  49. if( $N['evt_type']==52 ) {
  50. $DH = 0;
  51. $BID = intval( $N['id'] );
  52. $BTM = date( "H:i:s", $N['ts'] );
  53. } else {
  54. $DH = 1;
  55. $EID = intval( $N['id'] );
  56. };
  57. if( $DH == 1 ){
  58. $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
  59. };
  60. };
  61. if( $DH == 0 ){
  62. //Ongoing Event goes next day - must catch up
  63. $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1";
  64. $NDD = $ZIZI->Query( $QS );
  65. if( count( $NDD ) ){
  66. $EID = intval( $NDD[0]['id'] );
  67. } else {
  68. $EID = 1000000000;//Infinity
  69. };
  70. $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
  71. };
  72. $NONO = "{ text: 'Events', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
  73. };
  74. echo "{expanded: true, children: [". $NONO ."]}";
  75. } else {
  76. echo "[]";
  77. };
  78. } else {
  79. header('location: /');
  80. };
  81. ?>