<?php
include_once('c_monitor.php') ;
class c_page_cab_monitor_pl extends c_page_cab_monitor
{
 public $h1='Ход подписи пакетов титулов ПЛ' ;
 public $page_type='window' ;
 public $monitor_mode ;
 public $use_jwplayer=1 ;
 public $use_fusioncharts=1;
 public $use_WS=1;
 public $show_panel_cryptopro_status=0 ;

 function __construct($options = array())
 {
     parent::__construct($options);
     // если включен модуль подписи МО - добавляем в head скрипты со страницы c_cryptopro для подключения плагина браузера
     //if (GENERAL()->enabled['mo_ecp'] or GENERAL()->enabled['pl'])
         $this->use_cryptopro=1 ;

 }

 function set_head_tags()
 { parent::set_head_tags() ;
   $this->HEAD['js'][]=_PATH_TO_EXT.'/aspmo_pp/script.js' ;
   $this->HEAD['css'][]=_PATH_TO_EXT.'/aspmo_pp/style.css' ;
   // если пользователь видит только свою группу - работаем в старом мониторинге
   // если пользователь видит несколько групп - работает в новом мониторинге
   $additional_option='';
   if ($GLOBALS['LS_monitoring_use_WS'])
   {
       $this->HEAD['js'][]=_PATH_TO_EXT.'/aspmo_monitor/script_mon_ws.js?rand='.rand(1,1000) ;
       $JS_CLASS='monitor_WS_interface' ;
       $this->monitor_mode='WS'  ;
       $update_url='/'._CLASS_.'/ext/aspmo_monitor/monitor_event.php';
       $additional_option=(_MAIN_PROTOCOL == 'https://')? 'ws_protocol: "wss"':'ws_protocol: "ws"';
       $additional_option.=', ws_address_port:"'.(($GLOBALS['LS_WS_address_port_JS'])?:_MAIN_DOMAIN).'"' ;
		 	 $monitor_last_id=0 ;
   }
   else
   {	 $monitor_last_id=ESMO()->get_last_monitor_mess_id_HTML(MEMBER()->cur_group_id) ;
		   $monitor_last_id++ ;
       if (MEMBER()->cur_groups_visible==MEMBER()->cur_group_id)
       { $this->HEAD['js'][]=_PATH_TO_EXT.'/aspmo_monitor/script_mon_html.js?rand='.rand(1,1000) ;
           $JS_CLASS='monitor_HTML_interface' ;
           $this->monitor_mode='HTML'  ;
           $update_url='/'._CLASS_.'/ext/aspmo_monitor/monitor_event.php';
       }
       else
       { $this->HEAD['js'][]=_PATH_TO_EXT.'/aspmo_monitor/script_mon_html_group.js?rand='.rand(1,1000) ;
           $JS_CLASS='monitor_HTML_interface_group' ;
           $this->monitor_mode='HTML GROUP'  ;
           $update_url='/'._CLASS_.'/ext/aspmo_monitor/monitor_event_groups.php';
       }
   }

   //damp_array(MEMBER()) ;
   if (MEMBER()->id and MEMBER()->cur_group_id)
   {

    ?><script type="text/javascript">
        $j(document).ready(function()
             {  $j('body').<?echo $JS_CLASS?>({ from_id:<?echo $monitor_last_id?>,
                                                group:<?echo MEMBER()->cur_group_id?>,
                                                groups:"<?echo MEMBER()->cur_groups_visible?>",
                                                int_update_terminal_status:60,
                                                update_monitor_full:<?echo ($GLOBALS['LS_monitor_full_update_interval'])?:0?>,
                                                update_url: "<?echo $update_url?>",
                                                debug:0,
                                                <?echo $additional_option?>
                                              });
             }
         );
       </script><?
   }
 }


 function block_top()
 { ?><table><tr>
        <td class="terminals"><?$this->panel_terminal_status() ; ?></td>
        <td class="group"><?$this->panel_cur_group() ; ?></td>
    </tr></table><?
 }

 function panel_cur_group()
 {   ?><span id="panel_cur_group">Рабочая группа:<br><strong><?echo MEMBER()->cur_group_name?></strong></span><?
 }

 function block_main()
 {
	 $this->page_title();
	 $this->panel_top_time();

	 $options=[] ;

	 ?><p class="center"><button class="v2 button" cmd="pl/send_to_sing" <?echo ($GLOBALS['LS_pl_allow_active_doctor_sign_all'])? 'group_id='.MEMBER()->cur_group_id:'doctor_id='.MEMBER()->id ; ?> style="float:none;display:inline;" >Подписать все пакеты</button></p><?
	 include_once(_DIR_EXT.'/pl/report_pl_packets_sign.php');

	 $report_obj=new report_pl_packets_sign();
	 if ($GLOBALS['LS_pl_allow_active_doctor_sign_all']) $report_obj->group_id=MEMBER()->cur_group_id;
	 else $report_obj->doctor_id=MEMBER()->id;
	 $report_obj->status='2';
	 $report_obj->type='2,6';
	 //$report_obj->setting();
	 $report_obj->no_view_title=1;
	 $report_obj->no_view_button=1;
	 $report_obj->view();

	 $this->panel_tech_info();

     ?><style type="text/css">
       div#panel_top_time{top:35px;right:30px;}
       span.ok{color:green;font-weight:bold;}
       span.error{color:red;font-weight:bold;font-size:18px;}
       div#panel_WS_status{top:15px;right:42px;}
       div#panel_CP_status{top:15px;right:72px;}

     </style><?
   }


}
?>
