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.

200 lines
11 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. require_once('../php/argus/server.php');
  4. require_once('../php/argus/templates.php');
  5. ob_start();
  6. $UID = intval( $CUser->Data['id'] );
  7. $ACCESS = intval( $CUser->Data['access'] );
  8. if( $UID > 1 ){
  9. $PID = intval( $_POST['PID'] );
  10. $QS = "SELECT * FROM `metro_platforms` WHERE `id`={$PID}";
  11. $Result = $DATABASE->Query( $QS, false );
  12. if( count( $Result ) ){
  13. $STID = $Result[0]['station_id'];
  14. $QS = "SELECT * FROM `metro_stations` WHERE `id`={$STID}";
  15. $SR = $DATABASE->Query( $QS, false );
  16. if( count( $SR ) ){
  17. $Data['status']='ok';
  18. $CR = $Result[0];
  19. $PLAT_IDS = array();
  20. $MODU_IDS = array();
  21. $PLAT_PARTS = array();
  22. $MAIN_TPL = str_ireplace( '%%STATION%NAME%%', $SR[0]['name'], $PLATFORM_VIEW_CTX );
  23. $MAIN_TPL = str_ireplace( '%%STATION%ID%%', $STID, $MAIN_TPL );
  24. $MAIN_TPL = str_ireplace( '%%PLATFORM%NAME%%', $Result[0]['name'], $MAIN_TPL );
  25. $CTITLE = $CR['name'] . ' <span class="level_label_title">'.$CR['level'].'</span>';
  26. $PLO = getPlatformLineInfo( $PID );
  27. if( count( $PLO ) ){
  28. $LINES='<table><tr>';
  29. 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>";
  30. $LINES.='</tr></table>';
  31. } else {
  32. $LINES=$Labels->GetLabel('_NOBI_LINE_');
  33. };
  34. //$PLAT_PARTS[] = '{ xtype:\'spacer\', height: 10 }';
  35. $PLAT_PARTS[] = createTopLabel( $SR[0]['name'], $Result[0]['name'], $LINES );
  36. //foreach( $Result as $CR )
  37. {
  38. $CID = intval( $CR['id'] );
  39. $ITEMS = array();
  40. $PLAT_IDS[] = $CID;
  41. $PINFO = getPlatformInfo( $CID );
  42. $QS = "SELECT * FROM `metro_tracks` WHERE `platform_id`={$CID} ORDER BY `side` ASC";
  43. $TI = $DATABASE->Query( $QS, false );
  44. $TCO = count( $TI );
  45. if( $TCO ){
  46. $COS = count( $PINFO['PREV'] );
  47. if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
  48. $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>";
  49. if( count( $TI ) > 1 ){
  50. $COS = count( $PINFO['NEXT'] );
  51. if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
  52. $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>";
  53. };
  54. } else {
  55. $COS = count( $PINFO['PREV'] );
  56. if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
  57. $TRU = "<td width=\"120px\" {$COS} class=\"_infoPanel\" style=\"color:#fff; font-weight: bold; background-color:#000; text-align: center;\">&nbsp;</td>";
  58. $COS = count( $PINFO['NEXT'] );
  59. if( $COS ) $COS = "rowspan={$COS} "; else $COS="";
  60. $TRB = "<td width=\"120px\" {$COS} class=\"_infoPanel\" style=\"color:#fff; font-weight: bold; background-color:#000; text-align: center;\">&nbsp;</td>";
  61. };
  62. $TOP ="<td><table width=\"100%\" border=0><tr><td><table border=0 width=\"100%\" style=\"border-collapse: collapse; border-spacing: 5px 5px;\">";
  63. if( $PINFO['PREV_IS_MULTI'] ){
  64. foreach( $PINFO['PREV'] as $P ){
  65. //{$P['bg_style']}
  66. $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>";
  67. }
  68. } else {
  69. if( count( $PINFO['PREV'] )){
  70. //{$PINFO['PREV'][0]['bg_style']}
  71. $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>";
  72. } else {
  73. //background-color:#000;
  74. $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>";
  75. };
  76. };
  77. $TOP .="</table></td>{$TRU}</tr></table></td>";
  78. $BOTTOM ="<td><table width=\"100%\" border=0><tr>{$TRB}<td><table border=0 width=\"100%\" style=\"border-collapse: collapse; border-spacing: 5px 5px;\">";
  79. if( $PINFO['NEXT_IS_MULTI'] ){
  80. foreach( $PINFO['NEXT'] as $P ){
  81. //{$P['bg_style']}
  82. $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>";
  83. }
  84. } else {
  85. if( count( $PINFO['NEXT'] )){
  86. //{$PINFO['NEXT'][0]['bg_style']}
  87. $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>";
  88. } else {
  89. // background-color:#000;
  90. $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>";
  91. };
  92. };
  93. $BOTTOM .="</table></td></tr></table></td>";
  94. $ITEM = str_ireplace( '%%%PLATFORM%TITLE%%%', $CTITLE , $PLATFORM_PLATFORM_CTX );
  95. $ITEM = str_ireplace( '%%%PLATFORM%ID%%%', $CID , $ITEM );
  96. $QS = "SELECT * FROM `metro_tracks` WHERE `platform_id`={$CID}";
  97. $TRES = $DATABASE->Query( $QS );
  98. if( count( $TRES ) ){
  99. $vcount = 1;
  100. foreach( $TRES as $CTRK ){
  101. if( $CTRK['side'] == 'U' ){
  102. $QS = "SELECT * FROM `metro_modules` WHERE `track_id`={$CTRK['id']} ORDER BY `side`";
  103. $MRES = $DATABASE->Query( $QS );
  104. foreach( $MRES as $MM ){
  105. $TTL = "{$CTRK['short']}:{$MM['name']}";
  106. $MDT = array();
  107. $MDT['id'] = $MM['id'];
  108. $MDT['name'] = $TTL;
  109. $MDT['status'] = 0;
  110. if( $MM['side']=='F'){
  111. $MDD[0] = $MDT;
  112. } else {
  113. $MDD[1] = $MDT;
  114. };
  115. //if( $MM['cam_stream'] != 0 ){
  116. // $URL = "http://{$MM['IP4']}/video_feed/stream?id={$MM['cam_stream']}";
  117. //} else {
  118. $URL = '/style/assets/no-signal_h.png';
  119. //};
  120. $CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $SIMPLE_VIDEO_CTX );
  121. $CVTPL = str_ireplace( '%%MID%%', $MM['id'], $CVTPL );
  122. $CVTPL = str_ireplace( '%%TRACK%ID%%',$CTRK['id'], $CVTPL );
  123. $CVTPL = str_ireplace( '%%%%TITLE%%%', $TTL, $CVTPL );
  124. $CVTPL = str_ireplace( '%%%STATUS%CLASS%%', 'aaBB', $CVTPL );
  125. $CVTPL = str_ireplace( '%%%IMG%URL%%%', $URL, $CVTPL );
  126. $CVTPL = str_ireplace( '%%%STATUS%%%', 'Status', $CVTPL );
  127. $ITEM = str_ireplace( '%%%VIDEO'.$vcount.'%%%', $CVTPL, $ITEM );
  128. $MODU_IDS[] = $MM['id'];
  129. $vcount++;
  130. };
  131. } else {
  132. $QS = "SELECT * FROM `metro_modules` WHERE `track_id`={$CTRK['id']} ORDER BY `side` DESC ";
  133. $MRES = $DATABASE->Query( $QS );
  134. foreach( $MRES as $MM ){
  135. $TTL = "{$CTRK['short']}:{$MM['name']}";
  136. $MDT = array();
  137. $MDT['id'] = $MM['id'];
  138. $MDT['name'] = $TTL;
  139. $MDT['status'] = 0;
  140. if( $MM['side']=='F'){
  141. $MDD[3] = $MDT;
  142. } else {
  143. $MDD[2] = $MDT;
  144. };
  145. //if( $MM['cam_stream'] != 0 ){
  146. //$URL = "http://{$MM['IP4']}/video_feed/stream?id={$MM['cam_stream']}";
  147. // $URL = "http://{$MM['IP4']}/video_feed/preview?id={$MM['cam_stream']}";
  148. //} else {
  149. $URL = '/style/assets/no-signal_h.png';
  150. //};
  151. $CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $SIMPLE_VIDEO_CTX );
  152. $CVTPL = str_ireplace( '%%MID%%', $MM['id'], $CVTPL );
  153. $CVTPL = str_ireplace( '%%TRACK%ID%%', $CTRK['id'], $CVTPL );
  154. $CVTPL = str_ireplace( '%%%%TITLE%%%', $TTL, $CVTPL );
  155. $CVTPL = str_ireplace( '%%%STATUS%CLASS%%', 'aaBB', $CVTPL );
  156. $CVTPL = str_ireplace( '%%%IMG%URL%%%', $URL, $CVTPL );
  157. $CVTPL = str_ireplace( '%%%STATUS%%%', 'Status', $CVTPL );
  158. $ITEM = str_ireplace( '%%%VIDEO'.$vcount.'%%%', $CVTPL, $ITEM );
  159. $MODU_IDS[] = $MM['id'];
  160. $vcount++;
  161. };
  162. };
  163. };
  164. if( $vcount < 5 ){
  165. for( ;$vcount < 5; $vcount++ ){
  166. $CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $EMPTY_VIDEO_CTX );
  167. $CVTPL = str_ireplace( '%%MID%%', 'A'.$vcount, $CVTPL );
  168. $ITEM = str_ireplace( '%%%VIDEO'.$vcount.'%%%', $CVTPL, $ITEM );
  169. $MODU_IDS[] = $vcount;
  170. };
  171. };
  172. } else {
  173. for( $i = 1; $i < 5; $i++ ){
  174. $CVTPL = str_ireplace( '%%%PLATFORM%ID%%%', $CID, $EMPTY_VIDEO_CTX );
  175. $CVTPL = str_ireplace( '%%MID%%', 'A'.$i, $CVTPL );
  176. $ITEM = str_ireplace( '%%%VIDEO'.$i.'%%%', $CVTPL, $ITEM );
  177. $MODU_IDS[] = $i;
  178. };
  179. };
  180. $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>";
  181. $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>";
  182. $PLAT_PARTS[] = str_ireplace( '%%%PLATFORM%MAP%%%', $ITEM_X, $ITEM );
  183. };
  184. //$TIPTOP = str_ireplace('%%%PLATFORM_IDS%%%', implode( ',',$PLAT_IDS ), $TIPTOP );
  185. $TOP = str_ireplace('%%%PANELS%%%', implode( ",",$PLAT_PARTS ), $MAIN_TPL );
  186. $Data['pid'] = $PID;
  187. $Data['content']= $TOP;
  188. } else {
  189. $Data['status']='na';
  190. };
  191. };
  192. $Data['messages'] = ob_get_clean();
  193. echo json_encode( $Data );
  194. } else {
  195. header('location: /');
  196. };
  197. ?>