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.

1739 lines
53 KiB

​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
4 years ago
3 years ago
​
​
​
​
4 years ago
3 years ago
4 years ago
​
​
​
​
3 years ago
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
3 years ago
​
​
3 years ago
​
3 years ago
​
4 years ago
​
​
​
​
3 years ago
4 years ago
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
4 years ago
3 years ago
4 years ago
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
4 years ago
​
​
​
​
​
3 years ago
4 years ago
​
​
3 years ago
4 years ago
​
​
​
​
3 years ago
​
4 years ago
​
3 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
4 years ago
3 years ago
4 years ago
​
4 years ago
​
​
​
​
​
3 years ago
​
3 years ago
​
​
​
​
​
​
​
​
4 years ago
3 years ago
​
4 years ago
​
​
4 years ago
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var map = null;
  3. var selectedMarker = null;
  4. var timelineObj = null;
  5. var tlGroups = new vis.DataSet();
  6. var tlItems = new vis.DataSet();
  7. var selecredActiveSourceFilter = 0;
  8. var ActiveZones = null;
  9. var rep_store_id = 0;
  10. var rep_array = new Array();
  11. var rep_store = new Ext.data.JsonStore({
  12. autoDestroy: false,
  13. storeId: 'log_store',
  14. //idIndex: 0,
  15. idProperty: 'id',
  16. fields: [
  17. {name: 'id', type: 'int' },
  18. {name: 'node_id', type: 'int' },
  19. {name: 'node_name', type: 'string' },
  20. {name: 'dts', type: 'string'},
  21. {name: 'ts', type: 'int'},
  22. {name: 'ms', type: 'string'},
  23. {name: 'type', type: 'int'},
  24. {name: 'range', type: 'string'},
  25. {name: 'az', type: 'string'},
  26. {name: 'el', type: 'string'},
  27. {name: 'r', type: 'int'},
  28. {name: 'width', type: 'int'},
  29. {name: 'video_id',type: 'int'}
  30. //{name: 'lat', type: 'float'},
  31. //{name: 'lon', type: 'float'},
  32. //{name: 'alt', type: 'float'},
  33. //{name: 'area', type: 'float'},
  34. //{name: 'video', type: 'string'},
  35. //{name: 'v_cpoint', type: 'int'}
  36. ]
  37. });
  38. function rep_sn_Renderer( value, meta, record ){
  39. //Must be set according to events
  40. var kaka = record.data.node_id % 3;
  41. return '<div class="log_line_' + kaka + '">'+value+'</div>';
  42. };
  43. function rep_et_Renderer( value, meta, record ){
  44. var kaka = record.data.node_id % 3;
  45. switch( value ){
  46. case 6: ov = 'Device Enters Into Study Mode'; break;
  47. case 7: ov = 'Device Is BUSY'; break;
  48. case 8: ov = 'Flip Complete'; break;
  49. case 9: ov = 'Scan Complete'; break;
  50. case 12: ov = 'Black 2D Target'; break;
  51. case 13: ov = 'White 2D Target'; break;
  52. case 36: ov = 'Region Of Interest'; break;
  53. case 39: ov = '[Train Filter] Check Target'; break;
  54. case 40: ov = '[Train Filter] Upper Sensor Detection'; break;
  55. case 41: ov = '[Train Filter] Bottom Sensor Detection'; break;
  56. case 42: ov = '[Train Filter] Train Detected'; break;
  57. case 43: ov = '[Train Filter] Train Updated'; break;
  58. case 44: ov = '[Train Filter] Suspicious Activity'; break;
  59. case 45: ov = '[Train Filter] Suspicious NACK'; break;
  60. case 46: ov = '[Train Filter] Regular Detection'; break;
  61. case 47: ov = '[Train Filter] Detection Disabled'; break;
  62. case 48: ov = '[Train Filter] Suspicious Detection'; break;
  63. case 49: ov = '[Train Filter] Differential Detection'; break;
  64. case 52: ov = 'Event Started'; break;
  65. case 53: ov = 'Event Ended'; break;
  66. case 54: ov = 'Event Closed Manual'; break;
  67. case 55: ov = 'Connected'; break;
  68. case 56: ov = 'Disconnection'; break;
  69. case 57: ov = 'Communication Jamed'; break;
  70. case 58: ov = 'Video Framerate Decreased'; break;
  71. case 59: ov = 'Video Framerate Increased'; break;
  72. default: ov = 'Event ['+value+']';
  73. };
  74. return '<div class="log_line_' + kaka + '">'+ov+'</div>';
  75. };
  76. var rep_ColModel_ops = {
  77. columns: [
  78. {header: "Time", width: 100, fixed: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'dts' },
  79. {header: "Source", width: 100, renderer: rep_sn_Renderer, align: 'left', css: 'vertical-align: middle;', dataIndex: 'node_name' },
  80. {header: "Type", width: 180, renderer: rep_et_Renderer, fixed: false, align: 'center', css: 'vertical-align: middle;', dataIndex: 'type' },
  81. {header: "Range", width: 100, dataIndex: 'range' },
  82. {header: "Azimuth", width: 100, dataIndex: 'az' },
  83. {header: "Width", width: 100, dataIndex: 'width' },
  84. ],
  85. defaults: {
  86. sortable: false,
  87. fixed: true,
  88. menuDisabled: true,
  89. width: 100
  90. }
  91. };
  92. var cRowSelected = -1;
  93. var rep_SelModel_ops = {
  94. singleSelect: true,
  95. listeners: {
  96. rowselect: function(sm, row, rec ) {
  97. cRowSelected = row;
  98. loadEventData( rec.data );
  99. //alert( rec.data.id );
  100. //loadEventProperties( rec.data );
  101. //SelectedEvent = rec.data.id;
  102. //alert( SelectedEvent );
  103. //var CB = Ext.getCmp('con_to_src');
  104. //CB.enable();
  105. //selectedArchiveRecord = rec;
  106. //if( rec.data.bk_type!=3 ){
  107. //
  108. //} else {
  109. //
  110. //};
  111. }
  112. }
  113. };
  114. var selectedMarkerIcon = L.icon({
  115. iconUrl: '/style/assets/cursor.png',
  116. iconSize: [32, 32],
  117. iconAnchor: [16, 16]//,
  118. //popupAnchor: [-3, -76],
  119. //shadowUrl: 'my-icon-shadow.png',
  120. //shadowSize: [68, 95],
  121. //shadowAnchor: [22, 94]
  122. });
  123. selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } );
  124. var tlOptions = {
  125. groupOrder: 'content', // groupOrder can be a property name or a sorting function
  126. stack: true,
  127. showCurrentTime: true,
  128. //verticalScroll: true,
  129. //zoomKey: 'ctrlKey',
  130. minHeight: 308,
  131. maxHeight: 308
  132. };
  133. var tlLoadLocker = false;
  134. var tlLastTS = 0;
  135. var tlInterval = null;
  136. var tlMonitoring = false;
  137. // Calendar
  138. var CurrentDate=(new Date())/1000;
  139. var today=new Date();
  140. var SY=1900+today.getYear();
  141. var SMO=today.getMonth()+1;
  142. var SD=today.getDate();
  143. var SelectedDay = SD;
  144. var Dates = new Array();
  145. function CheckDate(D){
  146. for(j_index=0;j_index<Dates.length;j_index++){
  147. if (Dates[j_index]==D)return true;
  148. };
  149. return false;
  150. };
  151. function ShiftBAK(){
  152. CurrentDate=CurrentDate-24*3600*GetMonthLength(CurrentDate);
  153. BuildCalendar();
  154. SMO = GetMonthNum(CurrentDate);
  155. SY = GetYear(CurrentDate);
  156. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  157. loadCalendarDates();
  158. };
  159. function ShiftFWD(){
  160. CurrentDate=CurrentDate+24*3600*GetMonthLength(CurrentDate);
  161. BuildCalendar();
  162. SMO = GetMonthNum(CurrentDate);
  163. SY = GetYear(CurrentDate);
  164. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  165. loadCalendarDates();
  166. };
  167. function GetMonthName(UTS){ // Unix Time Stamp
  168. var MoNames= new Array();
  169. MoNames[0]='January';
  170. MoNames[1]='February';
  171. MoNames[2]='March';
  172. MoNames[3]='April';
  173. MoNames[4]='May';
  174. MoNames[5]='June';
  175. MoNames[6]='July';
  176. MoNames[7]='August';
  177. MoNames[8]='September';
  178. MoNames[9]='October';
  179. MoNames[10]='November';
  180. MoNames[11]='December';
  181. CDate=new Date();
  182. CDate.setTime(UTS*1000);
  183. CMo=CDate.getMonth();
  184. return MoNames[CMo];
  185. };
  186. function GetMonthShift(UTS){ // Unix Time Stamp
  187. CDate=new Date();
  188. CDate.setTime(UTS*1000);
  189. CDate.setTime((UTS-(CDate.getDate()-1)*86400)*1000);
  190. return CDate.getDay();
  191. };
  192. function GetMonthLength(UTS){ // Unix Time Stamp
  193. CDate=new Date();
  194. CDate.setTime(UTS*1000);
  195. CD=CDate.getDate();
  196. RetVal=31;
  197. CDate.setTime((UTS+(31-CD)*86400)*1000);
  198. if ( CDate.getDate()==31) return RetVal;
  199. RetVal=30;
  200. CDate.setTime((UTS+(30-CD)*86400)*1000);
  201. if ( CDate.getDate()==30) return RetVal;
  202. RetVal=29;
  203. CDate.setTime((UTS+(29-CD)*86400)*1000);
  204. if ( CDate.getDate()==29) return RetVal;
  205. RetVal=28;
  206. CDate.setTime((UTS+(28-CD)*86400)*1000);
  207. if ( CDate.getDate()==28) return RetVal;
  208. return -1;
  209. };
  210. function GetMonthNum(UTS){ // Unix Time Stamp
  211. CDate=new Date();
  212. CDate.setTime(UTS*1000);
  213. return CDate.getMonth()+1;
  214. };
  215. function GetYear(UTS){ // Unix Time Stamp
  216. CDate=new Date();
  217. CDate.setTime(UTS*1000);
  218. y=CDate.getYear();
  219. if (y<100)y+=2000;
  220. if (y<200)y+=1900;
  221. return y;
  222. };
  223. function GetDay(UTS){ // Unix Time Stamp
  224. CDate=new Date();
  225. CDate.setTime(UTS*1000);
  226. y=CDate.getDate();
  227. return y;
  228. };
  229. function selectDate( m, d ){
  230. SY = GetYear(CurrentDate);
  231. SMO = m;
  232. SD = d;
  233. SelectedDay = SD;
  234. getData( 'arch' );
  235. };
  236. function BuildCalendar( ){
  237. Msh=GetMonthShift(CurrentDate);
  238. Mnm=GetMonthName(CurrentDate);
  239. Mln=GetMonthLength(CurrentDate);
  240. Mid=GetMonthNum(CurrentDate);
  241. Mye=GetYear(CurrentDate);
  242. InDTA='<table cellpadding="2" cellspacing="0"><tr height="19px"><td valign="middle"><a href="#" onclick="ShiftBAK();"><img src="/style/img/calendar/l_cal_b.gif"></a></td><td colspan="5" class="CalendarMN" align="center">'+Mnm+' '+Mye+'</td><td><a href="#" onclick="ShiftFWD();"><img border=0 src="/style/img/calendar/r_cal_b.gif"></a></td></tr>';
  243. InDTA+='<tr><td class="CalendarWT" align="center">Su</td><td class="CalendarWT" align="center">Mo</td><td class="CalendarWT" align="center">Tu</td><td class="CalendarWT" align="center">We</td><td class="CalendarWT" align="center">Th</td><td class="CalendarWT" align="center">Fr</td><td class="CalendarWT" align="center">Sa</td></tr>';
  244. InDTA+='<tr>';
  245. for(index=0;index<Msh;index++){
  246. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  247. };
  248. for(;index<(Mln+Msh);index++){
  249. if( CheckDate(index-Msh+1) ){
  250. //InDTA+='<td style="padding: 1px"><div id="ds'+Mid.toString()+(index-Msh+1).toString()+'" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" href="#" title="'+(index-Msh+1).toString()+'" class="CalendarDE">'+(index-Msh+1).toString()+'</a></td>';
  251. if( SD == index ){
  252. InDTA+='<td style="padding: 1px"><div id="selected_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Selected" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
  253. } else {
  254. InDTA+='<td style="padding: 1px"><div id="have_data_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Have Events" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
  255. };
  256. } else {
  257. if( SD == index ){
  258. InDTA+='<td style="padding: 1px"><div id="selected_day" class="calendar_t" title="Selected">'+(index-Msh+1).toString()+'</a></td>';
  259. } else {
  260. InDTA+='<td style="padding: 1px"><div id="no_data_day" class="calendar_t" title="No Events">'+(index-Msh+1).toString()+'</a></td>';
  261. };
  262. };
  263. if ((index+1)%7==0){
  264. InDTA+='</tr><tr>';
  265. };
  266. };
  267. for(;(index)%7!=0;index++){
  268. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  269. };
  270. InDTA+='</tr></table>';
  271. tab=document.getElementById('calendar_TD');
  272. tab.innerHTML=InDTA;
  273. };
  274. function loadCalendarDates(){
  275. ReportSelectionMode = 0;
  276. Ext.MessageBox.wait("<?=$Labels->GetLabel('_Loading_Calo_');?>","<?=$Labels->GetLabel('_Please_Wait_');?>",{
  277. width: '100%',
  278. hidden: true,
  279. progress: true,
  280. closable: false
  281. });
  282. ReportLayoutLoadded = false;
  283. Ext.Ajax.request({
  284. url: '/lib/controller/getEventDates.php',
  285. params: {
  286. NID: selecredActiveSourceFilter,
  287. UID: <?=$UserID;?>,
  288. SID: '<?=$Session;?>',
  289. SYE: SY,
  290. SMO: SMO
  291. },
  292. success: function( response, opts ){
  293. Ext.MessageBox.hide();
  294. var data = Ext.decode( response.responseText );
  295. if( data.status == 'ok' ){
  296. Dates = data.days;
  297. BuildCalendar();
  298. //for( var i = 0; i < data.days.length; i++ ){
  299. //
  300. //};
  301. };
  302. },
  303. failure: function( response, opts ) {
  304. Ext.MessageBox.hide();
  305. }
  306. });
  307. };
  308. var eventsListStore = new Ext.data.JsonStore({
  309. root: 'log',
  310. totalProperty: 'totalCount',
  311. idProperty: 'id',
  312. remoteSort: true,
  313. fields: [{
  314. name: 'id',
  315. type: 'int'
  316. },{
  317. name: 'date',
  318. type: 'string'
  319. },{
  320. name: 'time',
  321. type: 'string'
  322. },{
  323. name: 'device',
  324. type: 'string'
  325. },{
  326. name: 'event',
  327. type: 'int'
  328. },{
  329. name: 'data',
  330. type: 'string',
  331. },{
  332. name: 'has_target',
  333. type: 'boolean'
  334. },{
  335. name: 'has_geo',
  336. type: 'boolean'
  337. },{
  338. name: 'has_images',
  339. type: 'boolean'
  340. },{
  341. name: 'images',
  342. type: 'Array'
  343. },{
  344. name: 'dev_type',
  345. type: 'int'
  346. },{
  347. name: 'geo',
  348. type: 'object'
  349. }] /*,
  350. proxy : new Ext.data.HttpProxy({
  351. method: 'POST',
  352. prettyUrls: false,
  353. url: '/lib/controller/getEventRecords.php',
  354. headers: {
  355. UID: <?=$UserID;?>,
  356. SID: '<?=$Session;?>',
  357. NID: 1
  358. }
  359. })*/
  360. });
  361. var SelectedEvent = 0;
  362. var EventPanelWindow = null;
  363. function showEventPanel(){
  364. if( EventPanelWindow == null ){
  365. EventPanelWindow = new Ext.Window({
  366. modal: true,
  367. title: '<?=$Labels->GetLabel("_EVENT_VIEWER_");?>',
  368. width: winW*0.66,
  369. height: winH*0.66,
  370. layout: 'fit',
  371. closeAction: 'hide',
  372. items:[{
  373. title: 'Cameras',
  374. html:'koko',
  375. autoScroll: true,
  376. height: 320
  377. },{
  378. html: 'koko22',
  379. height: 320
  380. }]
  381. });
  382. };
  383. EventPanelWindow .show();
  384. };
  385. function ModeRenderer(val){
  386. var p1, p2, p3;
  387. if( ( val & 1 ) == 1 ){
  388. p1 = '<img src="/style/img/cam_cap3.png" alt="Video Source">';
  389. } else {
  390. p1 = '<img src="/style/img/cam_cap0.png" alt="NO Video Source">';
  391. };
  392. if( ( val & 2 ) == 2 ){
  393. p2 = '<img src="/style/img/cam_cap2.png" alt="Audio Source">';
  394. } else {
  395. p2 = '<img src="/style/img/cam_cap0.png" alt="NO Audio Source">';
  396. };
  397. if( ( val & 4 ) == 4 ){
  398. p3 = '<img src="/style/img/cam_cap1.png" alt="PTZ Control">';
  399. } else {
  400. p3 = '<img src="/style/img/cam_cap0.png" alt="NO PTZ Control">';
  401. };
  402. return p1+p2+p3;
  403. };
  404. function LocRenderer( val ){
  405. if( val ){
  406. return '<img src="/style/icons/icons/accept.png" alt="Location" />';
  407. };
  408. return '<img src="/style/icons/icons/bullet_white.png" alt="NO Location" />';
  409. };
  410. function PicRenderer( val ){
  411. if( val ){
  412. return '<img src="/style/icons/icons/camera_link.png"/>';
  413. };
  414. return '<img src="/style/icons/icons/bullet_white.png"/>';
  415. };
  416. function EvtTypeRenderer( val ){
  417. switch( val ){
  418. case 6: return 'Device Enters Into Study Mode';
  419. case 7: return 'Device Is BUSY';
  420. case 8: return 'Flip Complete';
  421. case 9: return 'Scan Complete';
  422. case 10:
  423. case 11:
  424. case 12:
  425. case 13:
  426. case 14: return 'Target';
  427. case 36: return 'Region Of Interest';
  428. default: return 'Event ['+val+']';
  429. };
  430. };
  431. var eventsListColModel_ops = {
  432. columns: [
  433. {header: "ID", width: 100, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  434. {header: "Date",width: 100, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' },
  435. {header: "Time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' },
  436. {header: "Device", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' },
  437. {header: "Event", width: 120, sortable: false, dataIndex: 'event', renderer: EvtTypeRenderer },
  438. {header: "Info", width: 200, sortable: false, dataindex: 'data' },
  439. {header: "", width: 25, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer },
  440. {header: "", width: 25, sortable: false, dataIndex: 'has_images', renderer: PicRenderer }
  441. ],
  442. defaults: {
  443. sortable: true,
  444. menuDisabled: true,
  445. width: 100
  446. },
  447. listeners: {
  448. hiddenchange: function(cm, colIndex, hidden) {
  449. //saveConfig(colIndex, hidden);
  450. }
  451. }
  452. };
  453. var SelectedRow = -1;
  454. var eventsListSelModel_ops = {
  455. singleSelect: true,
  456. listeners: {
  457. rowselect: function(sm, row, rec ) {
  458. loadEventProperties( rec.data );
  459. SelectedEvent = rec.data.id;
  460. SelectedRow = row;
  461. //alert( SelectedEvent );
  462. //var CB = Ext.getCmp('con_to_src');
  463. //CB.enable();
  464. }
  465. }
  466. };
  467. function loadTimeLineGroups( NID ){
  468. Ext.Ajax.request({
  469. url: '/lib/controller/getTimeLineGroups.php',
  470. params: {
  471. NID: NID,
  472. UID: <?=$UserID;?>,
  473. SID: '<?=$Session;?>'
  474. },
  475. success: function( response, opts ){
  476. // If the response is JSON, you have to decode it
  477. var data = Ext.decode(response.responseText);
  478. //for(var i = 0; i < data.length; i++) {
  479. //tlGroups.add(data[i]);
  480. //};
  481. tlGroups.update( data );
  482. loadTimeLineItems( SelectedSite );
  483. tlInterval = window.setInterval( loadTimeLineItems, 333, SelectedSite );
  484. },
  485. failure: function( response, opts ) {
  486. //Ext.fly('some_div').update('Fail!');
  487. }/*,
  488. callback: function(options,success,response){
  489. // use this if you need to perform your own success/failure checking
  490. }*/
  491. });
  492. };
  493. function clickDeviceSelector( id ){
  494. var rr = document.getElementById(id+'_div');
  495. if( selecredActiveSourceFilter != id ){
  496. if( selecredActiveSourceFilter > 0 ){
  497. var oo = document.getElementById( selecredActiveSourceFilter + '_div');
  498. oo.classList.remove( "cardDeviceSourceSelected" );
  499. oo.classList.add( "cardDeviceSource" );
  500. };
  501. rr.classList.remove( "cardDeviceSource" );
  502. rr.classList.add( "cardDeviceSourceSelected" );
  503. selecredActiveSourceFilter = id;
  504. turnOffAllGzButThis( selecredActiveSourceFilter );
  505. } else {
  506. selecredActiveSourceFilter = 0;
  507. rr.classList.remove( "cardDeviceSourceSelected" );
  508. rr.classList.add( "cardDeviceSource" );
  509. turnAllGzOn();
  510. var tPanel = Ext.getCmp('prop_content');
  511. tPanel.remove(0);
  512. tPanel.add( {
  513. title: 'Event Information',
  514. border: false,
  515. frame: false,
  516. collapsible: false,
  517. draggable: false,
  518. html: '<p align="center">Select an Event from TimeLine to See Information</p>'
  519. } );
  520. tPanel.doLayout();
  521. };
  522. };
  523. function getZoneByNode( nid ){
  524. var rVal = -1;
  525. for( var i=0; i < ActiveZones.totalCount; i++ ){
  526. if( ActiveZones.zones[i].dev_id == nid ){
  527. rVal = i;
  528. break;
  529. };
  530. };
  531. return rVal;
  532. };
  533. function turnOffAllGzButThis( nid ){
  534. var chocho = -1;
  535. for( var i=0; i < ActiveZones.totalCount; i++ ){
  536. if( ActiveZones.zones[i].dev_id == nid ) chocho = i;
  537. map.removeLayer( ActiveZones.fig[i] );
  538. map.removeLayer( ActiveZones.zang[i] );
  539. map.removeLayer( ActiveZones.center[i] );
  540. };
  541. if( chocho > -1 ){
  542. map.addLayer( ActiveZones.fig[chocho] );
  543. map.addLayer( ActiveZones.zang[chocho] );
  544. map.addLayer( ActiveZones.center[chocho] );
  545. var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) );
  546. map.flyToBounds( cVisible.getBounds() );
  547. };
  548. };
  549. function turnAllGzOn(){
  550. var tall = Array();
  551. for( var i=0; i < ActiveZones.totalCount; i++ ){
  552. tall[i*3] = ActiveZones.fig[i];
  553. tall[i*3+1] = ActiveZones.zang[i];
  554. tall[i*3+2] = ActiveZones.center[i];
  555. if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] );
  556. if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] );
  557. if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] );
  558. };
  559. var cVisible = L.featureGroup( tall );
  560. map.flyToBounds( cVisible.getBounds() );
  561. };
  562. function loadMapZones( SID ){
  563. Ext.Ajax.request({
  564. url: '/lib/controller/getGeoZones.php',
  565. params: {
  566. SITE: SID,
  567. UID: <?=$UserID;?>,
  568. SID: '<?=$Session;?>'
  569. },
  570. success: function( response, opts ){
  571. // If the response is JSON, you have to decode it
  572. var data = Ext.decode(response.responseText);
  573. var pp = Ext.getCmp('sources_panel');
  574. if( typeof pp !== 'undefined' ) pp.removeAll();
  575. ActiveZones = data;
  576. ActiveZones.fig = new Array();
  577. ActiveZones.zang = new Array();
  578. ActiveZones.center = new Array();
  579. for(var i = 0; i < data.totalCount; i++ ) {
  580. switch( data.zones[i].type ){
  581. case 'circle':{
  582. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  583. ActiveZones.fig[i] = new L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } );
  584. //map.addLayer( ActiveZones.fig[i] );
  585. break;
  586. };
  587. case 'poly':{
  588. ActiveZones.fig[i] = new L.polygon( data.zones[i].points, {color: data.zones[i].color, dashArray: "4 1 2 3", weight: 1, opacity: 0.8, clickable: false, interactive: false, bubblingMouseEvents: false });//.addTo(map);
  589. //map.addLayer( ActiveZones.fig[i] );
  590. break;
  591. };
  592. case 'image':{
  593. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  594. //map.addLayer( ActiveZones.fig[i] );
  595. break;
  596. };
  597. case 'image_rot':{
  598. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  599. opacity: 0.8 //,
  600. //interactive: true,
  601. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geográfico Nacional de España</a>"
  602. });//.addTo( map );
  603. //map.addLayer( ActiveZones.fig[i] );
  604. break;
  605. };
  606. };
  607. if( data.zones[i].dev_is_source ){
  608. if( typeof pp !== 'undefined' ) {
  609. var sty = '';
  610. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  611. sty = 'cardDeviceSourceSelected';
  612. } else {
  613. sty = 'cardDeviceSource';
  614. };
  615. pp.add( {
  616. id: data.zones[i].dev_id+'_container',
  617. frame: false,
  618. border: false,
  619. width: 130,
  620. height: 130,
  621. html: '<div id="'+data.zones[i].dev_id+'_div" class="'+sty+'" onclick="clickDeviceSelector('+data.zones[i].dev_id+');"><img id="'+data.zones[i].dev_id+'_ind" width="16px" src="/style/assets/led_green_blink_300ms.gif"><center><img src="/style/assets/'+data.zones[i].dev_type+'_node.png"><br/><p class="dev_name">'+data.zones[i].dev_name+'</p></center></div>'
  622. });
  623. };
  624. };
  625. if( data.zones[i].zang != undefined ){
  626. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  627. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  628. };
  629. if( data.zones[i].center != undefined ){
  630. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  631. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
  632. };
  633. };
  634. if( selecredActiveSourceFilter == 0 ){
  635. turnAllGzOn();
  636. } else {
  637. turnOffAllGzButThis( selecredActiveSourceFilter );
  638. };
  639. if( typeof pp !== 'undefined' ) pp.doLayout();
  640. //LoadMapEvents( SelectedSite );
  641. //tlInterval = window.setInterval( LoadMapEvents, 333, SelectedSite );
  642. },
  643. failure: function( response, opts ) {
  644. //Ext.fly('some_div').update('Fail!');
  645. }
  646. });
  647. };
  648. var cevt = Array();
  649. var coz = Array();
  650. function showEventsOnMap( data, removeCursor = true ){
  651. if( removeCursor ) map.removeLayer( selectedMarker );
  652. if( cevt.length ){
  653. for( i=0; i< cevt.length; i++ ){
  654. if( cevt[i]!= null ){
  655. cevt[i].remove();
  656. delete( cevt[i] );
  657. cevt[i] = null;
  658. };
  659. };
  660. };
  661. if( coz.length ){
  662. for( i=0; i< coz.length; i++ ){
  663. if( coz[i]!= null ){
  664. coz[i].remove();
  665. delete( coz[i] );
  666. coz[i]=null;
  667. };
  668. };
  669. };
  670. var zz = ( 1.0 / ( data.log.length + 0 ) );
  671. var idx = 0;
  672. for( i=0; i < data.log.length; i++ ){
  673. if( data.log[i].has_geo ){
  674. var cp_color='#FF0000';
  675. switch( data.log[i].event ){
  676. case 36: cp_color='#0000FF'; break;
  677. };
  678. cevt[idx] = L.circleMarker( [data.log[i].geo.lat, data.log[i].geo.lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  679. loadEventPropertiesByID( this.options.id );
  680. } );
  681. cevt[idx].addTo(map);
  682. idx++;
  683. };
  684. };
  685. };
  686. function LoadMapEventsZ( Mode ){
  687. if( tlLoadLocker ) return;
  688. tlLoadLocker = true;
  689. Ext.Ajax.request({
  690. url: '/lib/controller/getGeoAlerts.php',
  691. params: {
  692. SITE: <?=$SiteID;?>,
  693. UID: <?=$UserID;?>,
  694. SID: '<?=$Session;?>',
  695. MODE: Mode
  696. },
  697. success: function( response, opts ){
  698. if( cevt.length ){
  699. for( i=0; i< cevt.length; i++ ){
  700. if( cevt[i]!= null ){
  701. cevt[i].remove();
  702. delete( cevt[i] );
  703. cevt[i] = null;
  704. };
  705. };
  706. };
  707. if( coz.length ){
  708. for( i=0; i< coz.length; i++ ){
  709. if( coz[i]!= null ){
  710. coz[i].remove();
  711. delete( coz[i] );
  712. coz[i]=null;
  713. };
  714. };
  715. };
  716. var data = Ext.decode( response.responseText );
  717. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  718. for( i=0; i < data.evt.length; i++ ){
  719. cevt[i] = L.circleMarker( [data.evt[i].lat,data.evt[i].lon], {id:data.evt[i].id, color: '#FF0000', radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  720. loadEventProperties( this.options.id );
  721. } );
  722. cevt[i].addTo(map);
  723. };
  724. for( i=0; i < data.other.length; i++ ){
  725. switch( data.other[i].type ){
  726. case 'circle':{
  727. coz[i] = L.circleMarker( data.other[i].loc, {id:data.other[i].id, color: data.other[i].color, radius: 5, stroke: false, fillOpacity: 1.0 } );
  728. coz[i].addTo(map);
  729. break;
  730. };
  731. };
  732. };
  733. //eventsListStore.reload();
  734. tlLoadLocker = false;
  735. },
  736. failure: function( response, opts ) {
  737. //Ext.fly('some_div').update('Fail!');
  738. tlLoadLocker = false;
  739. }
  740. });
  741. };
  742. function loadEventPropertiesByID( id ){
  743. var d = eventsListStore.findExact( 'id', id );
  744. if( d > -1 ) {
  745. var EventRec = eventsListStore.getAt( d );
  746. loadEventProperties( EventRec.data );
  747. };
  748. };
  749. function loadEventProperties( EventRec ){
  750. var tPanel = Ext.getCmp('prop_content');
  751. tPanel.removeAll();// remove( 0 );
  752. var tt = '';
  753. if( selectedMarker!= null ){
  754. selectedMarker.remove();
  755. //map.removeLayer( selectedMarker );
  756. if( EventRec.has_geo ){
  757. tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
  758. selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]);
  759. selectedMarker.addTo( map );
  760. };
  761. };
  762. tPanel.add( {
  763. title: 'Event Details',
  764. html: '<center><img src="/style/assets/'+EventRec.dev_type+'_node.png" /><p>' + EventRec.device+'</p>'+tt+'</center>'
  765. } );
  766. if( EventRec.has_images ){
  767. for( var i=0; i < EventRec.images.length; i++ ){
  768. tPanel.add( {
  769. frame: false,
  770. html: '<img width="100%" src="/lib/controller/getPicture.php?PID='+EventRec.images[i]+'" data-enlargeable000 ondblclick="fullScreen(\'img-'+EventRec.id+'\');" style="cursor: zoom-in" id="img-'+EventRec.id+'"/>'
  771. });
  772. };
  773. };
  774. tPanel.doLayout();
  775. };
  776. var VideoLinks = [];
  777. var VideoPlayer = null;
  778. var cEventTSS = 0;
  779. var cEventETS = 0;
  780. function loadEventData( record ){
  781. ReportSelectionMode = 3; // Just One Event
  782. cEventTSS = record.ts+record.ms/1000;
  783. clearAllRadars();
  784. if( record.type == 13 || record.type == 14 || record.type == 36 ){
  785. markEventOnRadar( record.node_id, record.az, record.r );
  786. };
  787. if( record.video_id > 0 ){
  788. showVideo();
  789. Ext.Ajax.request({
  790. url: '/lib/controller/getVideoInfo.php',
  791. params: {
  792. UID: <?=$UserID;?>,
  793. SID: '<?=$Session;?>',
  794. TS: record.ts,
  795. VID: record.video_id
  796. },
  797. success: function( response, opts ){
  798. var data = Ext.decode(response.responseText);
  799. var t = Ext.getCmp('db_download_video');
  800. if( t != undefined ){
  801. t.toggle( true, true );
  802. t.enable();
  803. }
  804. var video_t = document.getElementById( 'video-'+data.node_id );
  805. if( video_t != undefined ){
  806. if( cRowSelected+1 < rep_array.length ) {
  807. var ddd = rep_array[cRowSelected+1];
  808. cEventETS = ( ddd.ts + ddd.ms/1000 ) - ( data.uts+data.uts_ms/1000 );
  809. } else {
  810. cEventETS = 0;
  811. };
  812. VideoPlayer = videojs( video_t );
  813. var tVL = '/lib/controller/data/reports/'+data.base+'/'+data.md5+'.'+data.ext;
  814. if( tVL != VideoLinks[data.node_id] ){
  815. VideoLinks[data.node_id] = tVL;
  816. VideoPlayer.src({
  817. type: 'video/mp4',
  818. src: VideoLinks[data.node_id]
  819. });
  820. VideoPlayer.poster('/style/assets/no-signal.png');
  821. };
  822. var CT = cEventTSS - ( data.uts+data.uts_ms/1000 );
  823. VideoPlayer.currentTime( CT );
  824. VideoPlayer.play();
  825. };
  826. }
  827. });
  828. } else {
  829. var t = Ext.getCmp('db_download_video');
  830. if( t != undefined ){
  831. alert("ZagZag");
  832. t.toggle( false, true );
  833. t.disable();
  834. }
  835. //var video_t = document.getElementById( 'video-'+record.node_id );
  836. if( VideoPlayer != null ){
  837. //VideoPlayer.dispose();
  838. //VideoPlayer = null;
  839. VideoPlayer.pause();
  840. VideoPlayer.poster('/style/assets/no-signal.png');
  841. VideoPlayer.posterImage.show();
  842. };
  843. };
  844. };
  845. function clearAllRadars(){
  846. for( i=1; i< 1000; i++ ){
  847. var csvg = document.getElementById( 'draw_svgr_' + i );
  848. if( csvg!= undefined ){
  849. var roi = csvg.getElementById( "roi" );
  850. if( roi != null ) csvg.removeChild( roi );
  851. };
  852. };
  853. };
  854. function markEventOnRadar( rid, az, range ){
  855. var csvg = document.getElementById( 'draw_svgr_' + rid );
  856. if( csvg!= undefined ){
  857. var roi = csvg.getElementById( "roi" );
  858. if( roi != null ) csvg.removeChild( roi );
  859. var bBox = csvg.getBBox();
  860. var max = 2048;
  861. switch( drawZoomLevels[rid] ){
  862. case 50: max = 1024; break;
  863. case 25: max = 512; break;
  864. case 12: max = 256; break;
  865. };
  866. if( range < max ){
  867. var ak = 2.0*Math.PI/360;
  868. var ok = 1.0/35;
  869. var rk = bBox.width / ( max * 2 );
  870. var cpx = bBox.width / 2.0;
  871. var cpy = bBox.height / 2.0;
  872. x = cpx + rk * range * Math.cos( az*ak );
  873. y = cpy - rk * range * Math.sin( az*ak );
  874. var cc = document.createElementNS('http://www.w3.org/2000/svg', "circle");
  875. var rz = bBox.width / csvg.clientWidth;
  876. cc.setAttributeNS(null, "cx", x );
  877. cc.setAttributeNS(null, "cy", y );
  878. cc.setAttributeNS(null, "r", ""+(6*rz)+"" );
  879. cc.setAttributeNS(null, "stroke", "#800000" );
  880. cc.setAttributeNS(null, "stroke-width", ""+(2*rz)+"" );
  881. cc.setAttributeNS(null, "stroke-opacity", ""+(1.0));
  882. cc.setAttributeNS(null, "fill", "#ff0000" );
  883. cc.setAttributeNS(null, "fill-opacity", ""+(1.0));
  884. cc.setAttributeNS(null, "id", "roi" );
  885. csvg.appendChild( cc );
  886. };
  887. };
  888. };
  889. function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){
  890. if( tlLoadLocker ) return;
  891. tlLoadLocker = true;
  892. if( Mode == 'arch' ){
  893. Ext.MessageBox.wait("Loading Data","Please Wait",{
  894. width: '100%',
  895. hidden: true,
  896. animate: true,
  897. progress: true,
  898. closable: false
  899. });
  900. };
  901. Ext.Ajax.request({
  902. url: '/lib/controller/getEventRecords.php',
  903. params: {
  904. SITE: <?=$SiteID;?>,
  905. UID: <?=$UserID;?>,
  906. SID: '<?=$Session;?>',
  907. MODE: Mode,
  908. FIL: selecredActiveSourceFilter,
  909. SDA: SD,
  910. SMO: SMO,
  911. SYE: SY,
  912. STM: ST,
  913. ETM: ET,
  914. STR: SR,
  915. DIR: DR
  916. },
  917. success: function( response, opts ){
  918. tlLoadLocker = false;
  919. var data = Ext.decode(response.responseText);
  920. if( data.updateFROMTO ){
  921. Ext.getCmp('STimeFROM').setValue( data.STT );
  922. Ext.getCmp('STimeTO').setValue( data.ENT );
  923. if( data.SLD > 0 ){
  924. SMO = GetMonthNum(data.SLD);
  925. SY = GetYear(data.SLD);
  926. SD = GetDay(data.SLD);
  927. BuildCalendar();
  928. };
  929. };
  930. eventsListStore.loadData( data, false );
  931. if( Mode == 'arch' ){
  932. showEventsOnMap( data, true );
  933. Ext.MessageBox.hide();
  934. if( DR > 0 ){
  935. Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 );
  936. Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow();
  937. };
  938. if( DR < 0 ){
  939. Ext.getCmp('evtArchLog').getView().focusRow( 0 );
  940. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  941. };
  942. } else {
  943. showEventsOnMap( data, false );
  944. //LoadMapEventsZ( Mode );
  945. };
  946. },
  947. failure: failureAJAXFunction
  948. });
  949. };
  950. function loadArchive(){
  951. if( tlInterval!= null ){
  952. window.clearInterval( tlInterval );
  953. tlInterval = null;
  954. timelineObj = null;
  955. };
  956. setUserContent( 2 );
  957. var tPanel = Ext.getCmp('main_portal');
  958. tPanel.removeAll( true );
  959. Ext.getCmp('main_content').setTitle( 'Events Archive' );
  960. tPanel.add({
  961. columnWidth: 0.83,
  962. frame: false,
  963. border: false,
  964. items: [{
  965. title: 'Site Map',
  966. frame: false,
  967. border: false,
  968. layout: 'vbox',
  969. layoutConfig: {
  970. align : 'stretch',
  971. pack : 'start',
  972. },
  973. height: PanelH-300,
  974. items:[{
  975. height: PanelH-325,
  976. flex: 1,
  977. frame: false,
  978. border: false,
  979. layout: 'fit',
  980. items:{
  981. id: 'event_map',
  982. html: '&nbsp;'
  983. }
  984. }]
  985. },{
  986. frame: false,
  987. border: false,
  988. collapsible: false,
  989. draggable: false,
  990. layout: 'hbox',
  991. items:[{
  992. layout: 'form',
  993. title: 'Date/Time',
  994. width: 200,
  995. frame: true,
  996. border: false,
  997. labelAlign: 'right',
  998. labelWidth: 50,
  999. defaults: { width: 80},
  1000. items: [{
  1001. xtype: 'combo',
  1002. id: 'STimeFROM',
  1003. fieldLabel: 'From',
  1004. editable: false,
  1005. typeAhead: true,
  1006. triggerAction: 'all',
  1007. width: 120,
  1008. lazyRender:true,
  1009. mode: 'local',
  1010. store: new Ext.data.ArrayStore({
  1011. id: 0,
  1012. fields: ['ss', 'displayText' ],
  1013. data: [<?php
  1014. $zuzu = array();
  1015. for( $i = 0; $i < 24; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1016. echo implode( ',', $zuzu ); ?>]
  1017. }),
  1018. valueField: 'ss',
  1019. displayField: 'displayText'
  1020. },{
  1021. xtype: 'combo',
  1022. id: 'STimeTO',
  1023. fieldLabel: 'Till',
  1024. editable: false,
  1025. typeAhead: true,
  1026. triggerAction: 'all',
  1027. width: 120,
  1028. lazyRender:true,
  1029. mode: 'local',
  1030. store: new Ext.data.ArrayStore({
  1031. id: 0,
  1032. fields: ['ss', 'displayText' ],
  1033. data: [<?php
  1034. $zuzu = array();
  1035. for( $i = 1; $i < 25; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1036. echo implode( ',', $zuzu ); ?>]
  1037. }),
  1038. valueField: 'ss',
  1039. displayField: 'displayText'
  1040. }],
  1041. html: '<table width="100%"><tr><td id="calendar_TD" align="center"></td></tr></table>',
  1042. buttons: [{
  1043. xtype: 'button',
  1044. text: 'Display History',
  1045. handler: function(){
  1046. var STU = Ext.getCmp('STimeFROM').getValue();
  1047. var ETU = Ext.getCmp('STimeTO').getValue();
  1048. getData( 'arch', STU, ETU );
  1049. }
  1050. }]
  1051. },{
  1052. title: 'Event Log',
  1053. frame: false,
  1054. height: 303,
  1055. id: 'evtArchLog',
  1056. xtype: 'grid',
  1057. ds: eventsListStore,
  1058. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1059. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1060. listeners:{
  1061. keydown: function( e ) {
  1062. if( e.getKey() == e.UP ){
  1063. if( SelectedRow == 0 ){
  1064. var id = eventsListStore.getAt( 0 ).id;
  1065. getData( 'arch', 0, 0, id, 1 );
  1066. };
  1067. };
  1068. if( e.getKey() == e.DOWN ){
  1069. if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){
  1070. var id = eventsListStore.getAt( SelectedRow ).id;
  1071. getData( 'arch', 0, 0, id, -1 );
  1072. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  1073. Ext.getCmp('evtArchLog').focus( false, true );
  1074. };
  1075. };
  1076. }
  1077. }
  1078. }]
  1079. }]
  1080. });
  1081. tPanel.add({
  1082. columnWidth: 0.17,
  1083. frame: true,
  1084. title: 'Event Information',
  1085. id: 'prop_content',
  1086. border: false,
  1087. items: [{
  1088. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1089. }]
  1090. });
  1091. tPanel.doLayout();
  1092. /*
  1093. Ext.getCmp('evtLog').getEl().set({tabindex: "0"});
  1094. Ext.getCmp('evtLog').getEl().addKeyMap({
  1095. eventName: "keyup",
  1096. binding: [{
  1097. key: Ext.EventObject.SPACE,
  1098. fn: function(){ alert("Space key pressed"); }
  1099. },{
  1100. key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT],
  1101. shift: true,
  1102. fn: function(){ alert("Left or right pressed while pressing shift"); }
  1103. }]
  1104. });
  1105. */
  1106. //BuildCalendar();
  1107. loadCalendarDates();
  1108. map = L.map('event_map',{
  1109. attributionControl: true,
  1110. //preferCanvas: true,
  1111. zoomControl: true,
  1112. center: [SiteLat, SiteLon],
  1113. /*zoomControl: false,
  1114. zoom: 17,
  1115. minZoom: 17,
  1116. maxZoom: 17,*/
  1117. keyboard: false
  1118. }).setView([SiteLat, SiteLon], 17);
  1119. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1120. var mapLayers = [];
  1121. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1122. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1123. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1124. detectRetina: true
  1125. });*/
  1126. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1127. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1128. maxNativeZoom: 18,
  1129. maxZoom: 24,
  1130. })
  1131. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1132. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1133. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1134. maxZoom: 19
  1135. });
  1136. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1137. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1138. maxZoom: 19
  1139. });
  1140. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1141. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  1142. maxZoom: 24
  1143. });
  1144. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1145. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1146. maxZoom: 19
  1147. });
  1148. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1149. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1150. maxZoom: 19
  1151. });
  1152. /*
  1153. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1154. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1155. maxZoom: 22
  1156. });
  1157. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1158. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1159. maxZoom: 22
  1160. });
  1161. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1162. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1163. maxZoom: 22
  1164. });
  1165. */
  1166. var baseMaps = {
  1167. "MyMap": mapLayers["MyMap"],
  1168. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1169. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1170. "EsriSat": mapLayers["EsriSat"],
  1171. "EsriStreet": mapLayers["EsriStreet"],
  1172. "EsriTopo": mapLayers["EsriTopo"],
  1173. //"Bing": mapLayers["Bing"],
  1174. //"OSM-Cycle": mapLayers["Cycle"],
  1175. //"Landscape": mapLayers["Landscape"],
  1176. //"Outdoor": mapLayers["Outdoor"],
  1177. };
  1178. L.control.layers( baseMaps ).addTo(map);
  1179. mapLayers["MyMap"].addTo(map);
  1180. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1181. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1182. maxNativeZoom: 18,
  1183. maxZoom: 24,
  1184. }).addTo(map); */
  1185. //loadTimeLineGroups( selectedSite );
  1186. loadMapZones( SelectedSite );
  1187. getData( 'arch' );
  1188. //eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
  1189. };
  1190. function loadMonitoring(){
  1191. if( tlInterval!= null ){
  1192. window.clearInterval( tlInterval );
  1193. tlInterval = null;
  1194. timelineObj = null;
  1195. };
  1196. setUserContent( 1 );
  1197. var tPanel = Ext.getCmp('main_portal');
  1198. tPanel.removeAll( true );
  1199. Ext.getCmp('main_content').setTitle( 'Events Monitoring' );
  1200. tPanel.add({
  1201. columnWidth: 0.83,
  1202. frame: false,
  1203. border: false,
  1204. items: [{
  1205. title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
  1206. frame: false,
  1207. border: false,
  1208. collapsible: false,
  1209. draggable: false,
  1210. layout: 'vbox',
  1211. layoutConfig: {
  1212. align : 'stretch',
  1213. pack : 'start',
  1214. },
  1215. height: PanelH-300,
  1216. items:[{
  1217. height: PanelH-325,
  1218. flex: 1,
  1219. frame: false,
  1220. border: false,
  1221. layout: 'fit',
  1222. items:{
  1223. id: 'event_map',
  1224. html: '&nbsp;'
  1225. }
  1226. }]
  1227. },{
  1228. frame: false,
  1229. border: true,
  1230. collapsible: false,
  1231. draggable: false,
  1232. layout: 'hbox',
  1233. items:[{
  1234. title: 'Alarm Sources',
  1235. xtype: 'panel',
  1236. border: false,
  1237. frame: false,
  1238. collapsible: false,
  1239. draggable: false,
  1240. id: 'sources_panel',
  1241. width: 160,
  1242. autoScroll: 'auto',
  1243. height: 303
  1244. },{
  1245. title: 'Event Log',
  1246. height: 303,
  1247. xtype: 'grid',
  1248. border: false,
  1249. frame: false,
  1250. collapsible: false,
  1251. draggable: false,
  1252. ds: eventsListStore,
  1253. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1254. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1255. bbar: [{
  1256. text: 'Clear',
  1257. handler: function(){
  1258. Ext.Ajax.request({
  1259. url: '/lib/controller/clearEventCloud.php',
  1260. params: {
  1261. UID: <?=$UserID;?>,
  1262. SID: '<?=$Session;?>'
  1263. },
  1264. success: function( response, opts ){
  1265. },
  1266. failure: function( response, opts ) {
  1267. }
  1268. });
  1269. }
  1270. }]
  1271. }]
  1272. }]
  1273. });
  1274. tPanel.add({
  1275. columnWidth: 0.17,
  1276. title: 'Event Information',
  1277. frame: true,
  1278. id: 'prop_content',
  1279. border: false,
  1280. items: [{
  1281. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1282. }]
  1283. });
  1284. tPanel.doLayout();
  1285. map = L.map('event_map',{
  1286. attributionControl: true,
  1287. //preferCanvas: true,
  1288. zoomControl: true,
  1289. center: [SiteLat, SiteLon],
  1290. /*zoomControl: false,
  1291. zoom: 17,
  1292. minZoom: 17,
  1293. maxZoom: 17,*/
  1294. keyboard: false
  1295. }).setView([SiteLat, SiteLon], 17);
  1296. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1297. var mapLayers = [];
  1298. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1299. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1300. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1301. detectRetina: true
  1302. });*/
  1303. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1304. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1305. maxNativeZoom: 18,
  1306. maxZoom: 24,
  1307. })
  1308. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1309. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1310. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1311. maxZoom: 19
  1312. });
  1313. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1314. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1315. maxZoom: 19
  1316. });
  1317. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1318. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  1319. maxZoom: 24
  1320. });
  1321. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1322. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1323. maxZoom: 19
  1324. });
  1325. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1326. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1327. maxZoom: 19
  1328. });
  1329. /*
  1330. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1331. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1332. maxZoom: 22
  1333. });
  1334. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1335. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1336. maxZoom: 22
  1337. });
  1338. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1339. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1340. maxZoom: 22
  1341. });
  1342. */
  1343. var baseMaps = {
  1344. "MyMap": mapLayers["MyMap"],
  1345. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1346. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1347. "EsriSat": mapLayers["EsriSat"],
  1348. "EsriStreet": mapLayers["EsriStreet"],
  1349. "EsriTopo": mapLayers["EsriTopo"],
  1350. //"Bing": mapLayers["Bing"],
  1351. //"OSM-Cycle": mapLayers["Cycle"],
  1352. //"Landscape": mapLayers["Landscape"],
  1353. //"Outdoor": mapLayers["Outdoor"],
  1354. };
  1355. L.control.layers( baseMaps ).addTo(map);
  1356. mapLayers["MyMap"].addTo(map);
  1357. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1358. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1359. maxNativeZoom: 18,
  1360. maxZoom: 24,
  1361. }).addTo(map); */
  1362. loadMapZones( SelectedSite );
  1363. tlInterval = window.setInterval( getData, 333, 'live' );
  1364. };
  1365. function loadOnlineMonitoring(devID){
  1366. if( tlInterval!= null ){
  1367. window.clearInterval( tlInterval );
  1368. tlInterval = null;
  1369. timelineObj = null;
  1370. };
  1371. var tPanel = Ext.getCmp('main_content');
  1372. tPanel.removeAll( true );
  1373. tPanel.add({
  1374. html: 'Device Monitoring '+devID
  1375. });
  1376. tPanel.doLayout();
  1377. };
  1378. function shutImg( img, a = '' ){
  1379. if( a == '' ){
  1380. img.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAI=;';
  1381. } else {
  1382. img.src = a;
  1383. };
  1384. };
  1385. var ReportMask = null;
  1386. var ReportLayoutLoadded = false;
  1387. var ReportSelectionMode = 0; //All
  1388. function loadReportSegment( ts, bid, eid ){
  1389. if( !ReportLayoutLoadded ){
  1390. ReportMask = new Ext.LoadMask(Ext.getCmp('main_content').getEl(), {msg:"Please wait..."});
  1391. ReportMask.show();
  1392. Ext.Ajax.request({
  1393. url: '/lib/controller/getReportLayout.php',
  1394. params: {
  1395. UID: <?=$UserID;?>,
  1396. SID: '<?=$Session;?>'//,
  1397. //BID: nid,
  1398. //EID: evt_ts
  1399. },
  1400. success: function(response, opts ){
  1401. var data = Ext.decode( response.responseText );
  1402. var tPanel = Ext.getCmp('main_content');
  1403. tPanel.removeAll(true);
  1404. Ext.getCmp('main_content').add({
  1405. xtype: 'portal',
  1406. id: 'segment_portal',
  1407. frame: false,
  1408. border: false,
  1409. items:{
  1410. html: ''
  1411. },
  1412. listeners:{
  1413. drop: function( a ){
  1414. updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position );
  1415. }
  1416. }
  1417. });
  1418. Ext.getCmp('main_content').doLayout();
  1419. tPanel = Ext.getCmp('segment_portal');
  1420. //nodeDashboardStatuses = new Array();
  1421. for( i=0; i < data.length; i++) tPanel.add( data[i] );
  1422. tPanel.doLayout();
  1423. ReportMask.hide();
  1424. ReportLayoutLoadded = true;
  1425. loadReportData( ts, bid, eid );
  1426. },
  1427. error: function(){
  1428. ReportMask.hide();
  1429. }
  1430. });
  1431. } else {
  1432. loadReportData( ts, bid, eid );
  1433. };
  1434. };
  1435. function loadReportData( ts, bid, eid ){
  1436. ReportSelectionMode = 2; // Session Selected
  1437. Ext.Ajax.request({
  1438. url: '/lib/controller/getHistoryEvents.php',
  1439. params: {
  1440. UID: <?=$UserID;?>,
  1441. SID: '<?=$Session;?>',
  1442. TS: ts,
  1443. BID: bid,
  1444. EID: eid,
  1445. },
  1446. success: function(response, opts ){
  1447. hideVideo();
  1448. var data = Ext.decode( response.responseText );
  1449. if( data.log != undefined ){
  1450. if( data.log.length ){
  1451. rep_store_id = data.log[0].id;
  1452. rep_array = data.log;//.concat( rep_array );
  1453. //if( log_array.length > 32 ){
  1454. // log_array = log_array.slice( 0, 31 );
  1455. //};
  1456. rep_store.removeAll();
  1457. rep_store.loadData( rep_array );
  1458. };
  1459. } else {
  1460. alert('No Log');
  1461. // clear the log
  1462. //log_store.removeAll();
  1463. };
  1464. }
  1465. });
  1466. };
  1467. function loadReportDayTree( ts ){
  1468. ReportSelectionMode = 1;//Day Selected
  1469. ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
  1470. ReportMask.show();
  1471. Ext.Ajax.request({
  1472. url: '/lib/controller/getHistoryDay.php',
  1473. params: {
  1474. UID: <?=$UserID;?>,
  1475. SID: '<?=$Session;?>',
  1476. DTS: ts
  1477. },
  1478. success: function(response, opts ){
  1479. var data = Ext.decode( response.responseText );
  1480. var sPanel = Ext.getCmp('left_side_menu');
  1481. sPanel.removeAll( true );
  1482. sPanel.add({
  1483. xtype: 'panel',
  1484. layout: 'vbox',
  1485. frame: true,
  1486. border: false,
  1487. items:[{
  1488. xtype: 'spacer',
  1489. height: 3
  1490. },{
  1491. html: '<p class="cur_date">'+( new Date( ts * 1000)).toLocaleDateString()+'</p><p class="cur_sessions">'+data.sessions+'</p><p class="cur_events">'+data.events+'</p><p class="cur_videos">'+data.videos+'</p>',
  1492. frame: false,
  1493. width: '100%',
  1494. border: false
  1495. },{
  1496. xtype: 'spacer',
  1497. height: 5
  1498. },{
  1499. xtype: 'treepanel',
  1500. autoScroll: true,
  1501. width: '100%',
  1502. <?php if( $CUser->Data['access'] > 3 ){ ?>
  1503. height: PanelH-260,
  1504. <?php } else { ?>
  1505. height: PanelH-209,
  1506. <?php }; ?>
  1507. border: true,
  1508. frame: true,
  1509. loader: new Ext.tree.TreeLoader(),
  1510. rootVisible: false,
  1511. root: new Ext.tree.AsyncTreeNode( data ),
  1512. listeners: {
  1513. click: function(n) {
  1514. if( n.attributes.leaf ){
  1515. Ext.getCmp('chu_adate').show();
  1516. sPanel.doLayout();
  1517. loadReportSegment( ts, n.attributes.bid, n.attributes.eid );
  1518. //Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.ts + '"');
  1519. };
  1520. }
  1521. }
  1522. },{
  1523. xtype: 'spacer',
  1524. height: 10
  1525. },{
  1526. xtype: 'button',
  1527. id: 'chu_adate',
  1528. text: 'Show Dates',
  1529. hidden: true,
  1530. width: '100%',
  1531. iconCls: 'reports_dates_btn',
  1532. scale: 'large',
  1533. handler: function(){
  1534. Ext.getCmp('chu_adate').hide();
  1535. initReportsView();
  1536. }
  1537. <?php if( $CUser->Data['access'] > 3 ){ ?>
  1538. },{
  1539. xtype: 'spacer',
  1540. height: 10
  1541. },{
  1542. xtype: 'button',
  1543. width: '100%',
  1544. scale: 'large',
  1545. iconCls: 'reports_delete_btn',
  1546. text: 'Delete Selected',
  1547. handler: function(){
  1548. }
  1549. <?php }; ?>
  1550. }]
  1551. });
  1552. sPanel.doLayout();
  1553. ReportMask.hide();
  1554. }
  1555. });
  1556. };
  1557. function hideVideo(){
  1558. var juja = undefined;
  1559. for( i = 1; i++; i < 1000 ){
  1560. var juja = document.getElementById( 'video-'+i );
  1561. if( juja != undefined ) break;
  1562. };
  1563. if( juja != undefined ) juja.style.display = "none";
  1564. };
  1565. function showVideo(){
  1566. var juja = undefined;
  1567. for( i = 1; i++; i < 1000 ){
  1568. var juja = document.getElementById( 'video-'+i );
  1569. if( juja != undefined ) break;
  1570. };
  1571. if( juja != undefined ) juja.style.display = "block";
  1572. };
  1573. function initReportsView(){
  1574. ReportSelectionMode = 0; // All History
  1575. if( tlInterval!= null ){
  1576. window.clearInterval( tlInterval );
  1577. tlInterval = null;
  1578. timelineObj = null;
  1579. };
  1580. ReportLayoutLoadded = false;
  1581. var tPanel = Ext.getCmp('main_content');
  1582. var sPanel = Ext.getCmp('left_side_menu');
  1583. tPanel.removeAll( true );
  1584. sPanel.removeAll( true );
  1585. tPanel.add({
  1586. xtype: 'panel',
  1587. height: PanelH+15,
  1588. html: '<div id="activity_ph"></div>',
  1589. listeners:{
  1590. afterrender: function(){
  1591. ReportMask = new Ext.LoadMask(Ext.getCmp('main_content').getEl(), {msg:"Please wait..."});
  1592. ReportMask.show();
  1593. var jj = (PanelW - 230)/55;
  1594. changeStyleSheet('amap-empty-day','{width: '+jj+'px; height: '+jj+'px;}');
  1595. changeStyleSheet('amap-week-day','{width: '+jj+'px; height: '+jj+'px;}');
  1596. changeStyleSheet('amap-week-name','{width: '+jj+'px; height: '+jj+'px;}');
  1597. Ext.Ajax.request({
  1598. url: '/lib/controller/getHistoryDates.php',
  1599. params: {
  1600. UID: <?=$UserID;?>,
  1601. SID: '<?=$Session;?>'
  1602. },
  1603. success: function(response, opts ){
  1604. var data = Ext.decode( response.responseText );
  1605. var activityMap = new ActivityMap( data, {
  1606. id: "dji-volume-map",
  1607. parent: '#activity_ph',
  1608. showTitle: false,
  1609. showYears: true,
  1610. width: 100,
  1611. hue: 1,
  1612. fit: true,
  1613. compact: true,
  1614. timeColumn: "t",
  1615. valueColumn: "v"
  1616. });
  1617. activityMap.render();
  1618. ReportMask.hide();
  1619. }
  1620. });
  1621. }
  1622. }
  1623. });
  1624. tPanel.doLayout();
  1625. sPanel.add({
  1626. xtype: 'panel',
  1627. frame: true,
  1628. border: false,
  1629. items: [{
  1630. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
  1631. <?php if( $CUser->Data['access'] > 3 ){ ?>
  1632. height: PanelH - 70
  1633. },{
  1634. xtype: 'button',
  1635. width: '100%',
  1636. scale: 'large',
  1637. iconCls: 'reports_delete_btn',
  1638. text: 'Clear All History'
  1639. <?php } else { ?>
  1640. height: PanelH - 30
  1641. <?php }; ?>
  1642. }]
  1643. });
  1644. sPanel.doLayout();
  1645. };