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.
 
 
 
 

101 lines
3.5 KiB

<?php
require_once('../ajax_asm.php');
if( $CUser->Data['id'] > 1 ){
$DTS = intval( $_POST['DTS'] );
if( $DTS ){
$TZ = new DateTimeZone( date_default_timezone_get() );
$DT = new DateTime("now", $TZ );
$DIDI = $TZ->getOffset( $DT );
//$DTS += $DIDI;
$Y = date("Y", $DTS );
$M = date("m", $DTS );
$D = date("d", $DTS );
$DS = date("Y/m/d", $DTS );
$NONO = '';
$MUMU = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/stat.db' );
$QS = "SELECT * FROM `days` WHERE `year`={$Y} AND `month`={$M} AND `day`={$D}";
$LOLO = $MUMU->Query( $QS );
$S = 0;
$V = 0;
$E = 0;
if( count( $LOLO ) ){
$S = intval( $LOLO[0]['session_count'] );
$V = intval( $LOLO[0]['videos_count'] );
$E = intval( $LOLO[0]['evt_count'] );
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/' . $DS . '/report.db' );
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 )";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$st_ignore = true;
$DH = 0;
$BID = 0;
$EID = 0;
$BTM = 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( $st_ignore == false && $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} }";
};
if( count( $JIGA ) ){
$NONO = "{ text: 'Sessions', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
} else {
$NONO = "{ text: 'No Sessions', leaf: true }";
};
};
$QS = "SELECT DISTINCT `ts`/3600 AS JUJA FROM `events`";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$st_ignore = true;
$DH = 0;
$SIGA = array();
foreach( $NDD as $N ){
$BTS = intval($N['JUJA'])*3600;
$DADA = date( "H:i", $BTS );
$ETS = $BTS+3600;
$BID = 0;
$EID = 0;
$QS="SELECT `id` FROM `events` WHERE `ts`>({$BTS}-1) LIMIT 1";
$KK = $ZIZI->Query( $QS );
if( count( $KK ) ) $BID = $KK[0]['id'];
$QS="SELECT `id` FROM `events` WHERE `ts`<({$ETS}-1) ORDER BY `id` DESC LIMIT 1";
$KK = $ZIZI->Query( $QS );
if( count( $KK ) ) $EID = $KK[0]['id']; else $EID = $BID;
if( $BID && $EID ){
$SIGA[] = "{ text: '{$DADA}', leaf: true, bid: {$BID}, eid: {$EID} }";
};
};
$EVEVE = "{ text: 'Events by Hours', leaf: false, expanded: true, children:[". implode( ",", $SIGA ) . "]}";
};
};
if( $NONO=='' ) $NONO = "{ text: 'No Sessions', leaf: true }";
if( $EVEVE=='' ) $EVEVE = "{ text: 'No Events', leaf: true }";
echo "{expanded: true, children: [{$NONO},{$EVEVE}], sessions:{$S}, events:{$E}, videos:{$V} }";
} else {
echo "[]";
};
} else {
header('location: /');
};
?>