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.
 
 
 
 

201 lines
11 KiB

<?php
require_once('../ajax_asm.php');
require_once('../php/argus/server.php');
require_once('../php/argus/templates.php');
ob_start();
$UID = intval( $CUser->Data['id'] );
$ACCESS = intval( $CUser->Data['access'] );
if( $UID > 1 ){
$PID = intval( $_POST['PID'] );
$QS = "SELECT * FROM `metro_platforms` WHERE `id`={$PID}";
$Result = $DATABASE->Query( $QS, false );
if( count( $Result ) ){
$STID = $Result[0]['station_id'];
$QS = "SELECT * FROM `metro_stations` WHERE `id`={$STID}";
$SR = $DATABASE->Query( $QS, false );
if( count( $SR ) ){
$Data['status']='ok';
$CR = $Result[0];
$PLAT_IDS = array();
$MODU_IDS = array();
$PLAT_PARTS = array();
$MAIN_TPL = str_ireplace( '%%STATION%NAME%%', $SR[0]['name'], $PLATFORM_VIEW_CTX );
$MAIN_TPL = str_ireplace( '%%STATION%ID%%', $STID, $MAIN_TPL );
$MAIN_TPL = str_ireplace( '%%PLATFORM%NAME%%', $Result[0]['name'], $MAIN_TPL );
$CTITLE = $CR['name'] . ' <span class="level_label_title">'.$CR['level'].'</span>';
$PLO = getPlatformLineInfo( $PID );
if( count( $PLO ) ){
$LINES='<table><tr>';
foreach( $PLO as $Z ) $LINES.="<td><div style=\"border-radius:16px;width:32px;height:32px;background-color:#{$Z['color']};color:#fff;font-size:16px;padding-left:10px;padding-top:6px;\">{$Z['short']}</div></td>";
$LINES.='</tr></table>';
} else {
$LINES=$Labels->GetLabel('_NOBI_LINE_');
};
//$PLAT_PARTS[] = '{ xtype:\'spacer\', height: 10 }';
$PLAT_PARTS[] = createTopLabel( $SR[0]['name'], $Result[0]['name'], $LINES );
//foreach( $Result as $CR )
{
$CID = intval( $CR['id'] );
$ITEMS = array();
$PLAT_IDS[] = $CID;
$PINFO = getPlatformInfo( $CID );
$QS = "SELECT * FROM `metro_tracks` WHERE `platform_id`={$CID} ORDER BY `side` ASC";
$TI = $DATABASE->Query( $QS, false );
$TCO = count( $TI );
if( $TCO ){
$COS = count( $PINFO['PREV'] );
if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
$TRU = "<td width=\"120px\" {$COS} onclick=\"loadTrackView({$TI[0]['id']})\" class=\"_infoPanel active_overlay_orange_bl\" style=\"color:#fff; font-weight: bold; text-align: center;\">{$TI[0]['short']}</td>";
if( count( $TI ) > 1 ){
$COS = count( $PINFO['NEXT'] );
if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
$TRB = "<td width=\"120px\" {$COS} onclick=\"loadTrackView({$TI[1]['id']})\" class=\"_infoPanel active_overlay_orange_bl\" style=\"color:#fff; font-weight: bold; text-align: center;\">{$TI[1]['short']}</td>";
};
} else {
$COS = count( $PINFO['PREV'] );
if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
$TRU = "<td width=\"120px\" {$COS} class=\"_infoPanel\" style=\"color:#fff; font-weight: bold; background-color:#000; text-align: center;\">&nbsp;</td>";
$COS = count( $PINFO['NEXT'] );
if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
$TRB = "<td width=\"120px\" {$COS} class=\"_infoPanel\" style=\"color:#fff; font-weight: bold; background-color:#000; text-align: center;\">&nbsp;</td>";
};
$TOP ="<td><table width=\"100%\" border=0><tr><td><table border=0 width=\"100%\" style=\"border-collapse: collapse; border-spacing: 5px 5px;\">";
if( $PINFO['PREV_IS_MULTI'] ){
foreach( $PINFO['PREV'] as $P ){
//{$P['bg_style']}
$TOP .= "<tr><td><table border=0 width=\"100%\" class=\"_infoPanel active_overlay_orange\" style=\"color:#fff; font-weight: bold;\"><tr><td class=\"ar_to_left\">&nbsp;</td><td align=\"left\"><span class=\"inline_link\" onclick=\"loadStationView({$P['id']});\">{$P['name']}</span></td></tr></table></td></tr>";
}
} else {
if( count( $PINFO['PREV'] )){
//{$PINFO['PREV'][0]['bg_style']}
$TOP .= "<tr><td><table border=0 width=\"100%\" class=\"_infoPanel active_overlay_orange\" style=\"color:#fff; font-weight: bold;\"><tr><td class=\"ar_to_left\">&nbsp;</td><td align=\"left\"><span class=\"inline_link\" onclick=\"loadStationView({$PINFO['PREV'][0]['id']});\">{$PINFO['PREV'][0]['name']}</span></td></tr></table></td></tr>";
} else {
//background-color:#000;
$TOP .="<tr><td><table border=0 width=\"100%\" class=\"_infoPanel active_overlay_orange\" style=\"color:#fff; font-weight: bold;\"><tr><td class=\"ar_to_left\">&nbsp;</td><td align=\"left\">{$Labels->GetLabel('_SMM_NO_NESTA_')}</td></tr></table></td></tr>";
};
};
$TOP .="</table></td>{$TRU}</tr></table></td>";
$BOTTOM ="<td><table width=\"100%\" border=0><tr>{$TRB}<td><table border=0 width=\"100%\" style=\"border-collapse: collapse; border-spacing: 5px 5px;\">";
if( $PINFO['NEXT_IS_MULTI'] ){
foreach( $PINFO['NEXT'] as $P ){
//{$P['bg_style']}
$BOTTOM .= "<tr><td><table border=0 width=\"100%\" class=\"_infoPanel active_overlay_orange\" style=\"color:#fff; font-weight: bold;\"><tr><td align=\"right\"><span class=\"inline_link\" onclick=\"loadStationView({$P['id']});\">{$P['name']}</span></td><td class=\"ar_to_right\">&nbsp;</td></tr></table></td></tr>";
}
} else {
if( count( $PINFO['NEXT'] )){
//{$PINFO['NEXT'][0]['bg_style']}
$BOTTOM .= "<tr><td><table border=0 width=\"100%\" class=\"_infoPanel active_overlay_orange\" style=\"color:#fff; font-weight: bold;\"><tr><td align=\"right\"><span class=\"inline_link\" onclick=\"loadStationView({$PINFO['NEXT'][0]['id']});\">{$PINFO['NEXT'][0]['name']}</span></td><td class=\"ar_to_right\">&nbsp;</td></tr></table></td></tr>";
} else {
// background-color:#000;
$BOTTOM .= "<tr><td><table border=0 width=\"100%\" class=\"_infoPanel active_overlay_orange\" style=\"color:#fff; font-weight: bold;\"><tr><td align=\"right\">{$Labels->GetLabel('_SMM_NO_NESTA_')}</td><td class=\"ar_to_right\">&nbsp;</td></tr></table></td></tr>";
};
};
$BOTTOM .="</table></td></tr></table></td>";
$ITEM = str_ireplace( '%%%PLATFORM%TITLE%%%', $CTITLE , $PLATFORM_PLATFORM_CTX );
$ITEM = str_ireplace( '%%%PLATFORM%ID%%%', $CID , $ITEM );
$QS = "SELECT * FROM `metro_tracks` WHERE `platform_id`={$CID}";
$TRES = $DATABASE->Query( $QS );
if( count( $TRES ) ){
$vcount = 1;
foreach( $TRES as $CTRK ){
if( $CTRK['side'] == 'U' ){
$QS = "SELECT * FROM `metro_modules` WHERE `track_id`={$CTRK['id']} ORDER BY `side`";
$MRES = $DATABASE->Query( $QS );
foreach( $MRES as $MM ){
$TTL = "{$CTRK['short']}:{$MM['name']}";
$MDT = array();
$MDT['id'] = $MM['id'];
$MDT['name'] = $TTL;
$MDT['status'] = 0;
if( $MM['side']=='F'){
$MDD[0] = $MDT;
} else {
$MDD[1] = $MDT;
};
//if( $MM['cam_stream'] != 0 ){
// $URL = "http://{$MM['IP4']}/video_feed/stream?id={$MM['cam_stream']}";
//} else {
$URL = '/style/assets/no-signal_h.png';
//};
$CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $SIMPLE_VIDEO_CTX );
$CVTPL = str_ireplace( '%%MID%%', $MM['id'], $CVTPL );
$CVTPL = str_ireplace( '%%TRACK%ID%%',$CTRK['id'], $CVTPL );
$CVTPL = str_ireplace( '%%%%TITLE%%%', $TTL, $CVTPL );
$CVTPL = str_ireplace( '%%%STATUS%CLASS%%', 'aaBB', $CVTPL );
$CVTPL = str_ireplace( '%%%IMG%URL%%%', $URL, $CVTPL );
$CVTPL = str_ireplace( '%%%STATUS%%%', 'Status', $CVTPL );
$ITEM = str_ireplace( '%%%VIDEO'.$vcount.'%%%', $CVTPL, $ITEM );
$MODU_IDS[] = $MM['id'];
$vcount++;
};
} else {
$QS = "SELECT * FROM `metro_modules` WHERE `track_id`={$CTRK['id']} ORDER BY `side` DESC ";
$MRES = $DATABASE->Query( $QS );
foreach( $MRES as $MM ){
$TTL = "{$CTRK['short']}:{$MM['name']}";
$MDT = array();
$MDT['id'] = $MM['id'];
$MDT['name'] = $TTL;
$MDT['status'] = 0;
if( $MM['side']=='F'){
$MDD[3] = $MDT;
} else {
$MDD[2] = $MDT;
};
//if( $MM['cam_stream'] != 0 ){
//$URL = "http://{$MM['IP4']}/video_feed/stream?id={$MM['cam_stream']}";
// $URL = "http://{$MM['IP4']}/video_feed/preview?id={$MM['cam_stream']}";
//} else {
$URL = '/style/assets/no-signal_h.png';
//};
$CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $SIMPLE_VIDEO_CTX );
$CVTPL = str_ireplace( '%%MID%%', $MM['id'], $CVTPL );
$CVTPL = str_ireplace( '%%TRACK%ID%%', $CTRK['id'], $CVTPL );
$CVTPL = str_ireplace( '%%%%TITLE%%%', $TTL, $CVTPL );
$CVTPL = str_ireplace( '%%%STATUS%CLASS%%', 'aaBB', $CVTPL );
$CVTPL = str_ireplace( '%%%IMG%URL%%%', $URL, $CVTPL );
$CVTPL = str_ireplace( '%%%STATUS%%%', 'Status', $CVTPL );
$ITEM = str_ireplace( '%%%VIDEO'.$vcount.'%%%', $CVTPL, $ITEM );
$MODU_IDS[] = $MM['id'];
$vcount++;
};
};
};
if( $vcount < 5 ){
for( ;$vcount < 5; $vcount++ ){
$CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $EMPTY_VIDEO_CTX );
$CVTPL = str_ireplace( '%%MID%%', 'A'.$vcount, $CVTPL );
$ITEM = str_ireplace( '%%%VIDEO'.$vcount.'%%%', $CVTPL, $ITEM );
$MODU_IDS[] = $vcount;
};
};
} else {
for( $i = 1; $i < 5; $i++ ){
$CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $EMPTY_VIDEO_CTX );
$CVTPL = str_ireplace( '%%MID%%', 'A'.$i, $CVTPL );
$ITEM = str_ireplace( '%%%VIDEO'.$i.'%%%', $CVTPL, $ITEM );
$MODU_IDS[] = $i;
};
};
$SCADA = "<td class=\"mon_scada_passive_panel\"><b>SCADA Status</b><hr/><table width=\"100%\"><tr><td>Module Status:</td><td colspan=4><div class=\"mon_scada_status_tag_na\">Not Assigned</div></td></tr><tr><td>&nbsp</td><td class=\"mon_scada_head\">Track1:ALRM</td><td class=\"mon_scada_head\">Track2:ALRM</td><td class=\"mon_scada_head\">Helth</td><td class=\"mon_scada_head\">AUX</td></tr><tr><td>&nbsp;</td><td></td><td></td><td></td><td></td></tr></table></td>";
$ITEM_X="<table border=0 width=\"100%\" id=\"plat_table_{$CID}\"><tr>{$TOP}</tr><tr><td width=\"100%\">".createPlatformBackground( $CR['layout'], $CID, array()/*$MDD*/ )."</td></tr><tr>{$BOTTOM}</tr><tr>{$SCADA}</tr></table>";
$PLAT_PARTS[] = str_ireplace( '%%%PLATFORM%MAP%%%', $ITEM_X, $ITEM );
};
//$TIPTOP = str_ireplace('%%%PLATFORM_IDS%%%', implode( ',',$PLAT_IDS ), $TIPTOP );
$TOP = str_ireplace('%%%PANELS%%%', implode( ",",$PLAT_PARTS ), $MAIN_TPL );
$Data['pid'] = $PID;
$Data['content']= $TOP;
} else {
$Data['status']='na';
};
};
$Data['messages'] = ob_get_clean();
echo json_encode( $Data );
} else {
header('location: /');
};
?>