<?
function panel_monitoring_stats()
{  ?><div id="panel_monitoring_stats"><?
	$recs=execSQL('select pkey,obj_name,last_mo_event from obj_site_account where clss=206 order by obj_name') ;
 $list_files=get_files_list(_DIR_TO_ROOT.'/temp/monitor/') ;
 //damp_array($list_files) ;
 $arr_files_info=array() ;
 if (_sizeof($list_files)) foreach($list_files as $fdir)
 { $fname=basename($fdir) ;
   $fname=str_replace(array('evt_','.json'),'',$fname) ;
   list($group_id,$event_id)=explode('_',$fname) ;
   $arr_files_info[$group_id][$event_id]=array('size'=>filesize($fdir),'data'=>date('d.m.Y H:i:s',filemtime($fdir))) ;
 }
 if (_sizeof($arr_files_info)) foreach($arr_files_info as $group_id=>$recs_of_group) krsort($arr_files_info[$group_id]) ;
 ?><table class="basic fz_small full auto"><tr><th>ID</th><th>Рабочая группа</th><th>ID последнего сообщения</th><th>файл сообщения</th><th>Размер файла</th><th>Дата создания файла</th><th>Файлов в мониторинге</th></tr><?
 if (_sizeof($recs)) foreach($recs as $rec)
 {   $group_id=$rec['pkey'] ;
     $last_mess=(_sizeof($arr_files_info[$group_id]))? reset($arr_files_info[$group_id]):array('size'=>'-','data'=>'-') ;
     $arr=(_sizeof($arr_files_info[$group_id]))? array_keys($arr_files_info[$group_id]):array() ;
     $last_mess_id=(_sizeof($arr))? reset($arr):'-' ;
     ?><tr><td><?echo $group_id?></td>
        <td class="left"><?echo $rec['obj_name']?></td>
        <td><?echo $rec['last_mo_event']?></td>
        <td><?if (!$rec['last_mo_event']) echo '-' ; else echo ($rec['last_mo_event']==$last_mess_id)? 'OK':'NOT FOUND' ?></td>
        <td><?echo $last_mess['size']?></td>
        <td><?echo $last_mess['data']?></td>
        <td><?echo (_sizeof($arr_files_info[$group_id]))? _sizeof($arr_files_info[$group_id]):'-'?></td>
 <?}
	?></table></div><?

}

?>
