<?php
include_once (_DIR_EXT.'/HTML/c_HTML.php') ;
class c_page_cabinet extends c_HTML
{ public $no_panel_smena_is_out=0 ;
  public $menu=array() ;
  public $second_menu=array() ;
  public $menu_show_account_item=1 ;
  public $menu_show_close_item=0 ;
  public $menu_show_logo_item=1 ;
  public $body_type='' ;
  public $page_type='' ; // = window для страниц, которые будут показываться в отдельном окне
  public $result_exec_cmd='' ;
  public $free_access=0 ;
  public $allow_access_to_rol=0 ;
  public $allow_access_to_member=0 ;
  public $access_denited=0 ;
  public $access_denited_comment='' ;
  public $allow_menu_items=array() ;
  public $menu_url_params='' ;
  public $use_datepicker=1;
  public $use_fusioncharts=0 ;
  public $use_highslide=0 ;
  public $no_main_menu=0 ;
  public $filter=array() ;
  public $rec_arm=array() ;
  public $cur_zone_id=0 ;
  public $cur_window_mode='cab' ;
  public $use_jwplayer=0 ;
  public $use_auto_complete=1 ;
  public $use_printPage=0 ;
  public $use_ckeditor=0 ;
  public $use_enlighterjs=0 ;
  public $use_multirange=0 ;
  public $use_textarea_autosize=0 ;
  public $use_cryptopro=1 ;
  public $show_panel_cryptopro_status=0 ;
  public $disabled_button_to_superreader=0 ;
  public $block_main_class='' ;
  public $use_WS=0 ; // подключить страницу к сокетам
  public $page_factory=null ;
  public $has_main_menu=0 ;
  public $sign_uid='' ;

  public $active_tab ;
   public $color_set ;
   public $form ;

    function __construct($options = array())
    {  if (_CUR_FILTER) $this->filter=ENGINE()->parse_url(_CUR_FILTER,array()) ;

       $this->cur_window_mode=_CUR_ROOT_DIR_NAME ;

       parent::__construct($options);

       // создаем экземляр формы на основе используемого дизайна
       $this->form=new i_form(array('post_array_name'=>'filter','filter'=>$this->filter,'page'=>_CUR_PAGE(),'report'=>$this));

       if (MEMBER()->id) date_default_timezone_set(MEMBER()->timezone) ;
       if (MEMBER()->id and MEMBER()->rol!=1 and !MEMBER()->personal_viewer_name) ACCOUNTS()->member_logout('Автовыход в связи необходимостью перелогирования после обновления') ;

       // если не "использовать сокеты только на страницах РМВ" - включаем сокеты на всех страницах
	   if (!$GLOBALS['LS_monitoring_use_WS_only_rmv']) $this->use_WS=1 ;

     }

    function set_head_tags()
    {  // временно, пока обновление не будет установлено на все инсталяции с AD, проверяем наличие зарегистрированного обработчика событий для авторизации
       // и если его нет - вызываем вручную
       //$event_listers_id=execSQL_value('select pkey from event_lister where obj_name="check_autorize"') ;
       //if (!$event_listers_id and function_exists('AD')) AD()->on_event_check_autorize(array('cur_page'=>$this)) ;

       //if ($result['code']=='check_sertificate') { redirect_301_to('/cab/cryptopro/check_sert/'.$result['account_id'].'/') ; return ; }
       //if (_sizeof($_COOKIE)) foreach($_COOKIE as $name=>$value) if (strpos($name,'SSE-')!==false) setcookie ($name, "");

        parent::set_head_tags() ;

        //$this->HEAD['favicon']='/favicon.png'  ;
        $this->HEAD['meta'][]=array('name'=>"viewport",'content'=>"width=device-width, initial-scale=0.9, minimum-scale=0.9, user-scalable=no")  ;

        // стандартный JQuery
        $this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery-3.4.1.min.js' ;
        $this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery-migrate-1.2.1.min.js' ;
        $this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery-migrate-3.0.0.js' ;
        $this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery-ui-1.12.1.custom/jquery-ui.js' ;
        $this->HEAD['css'][]=_PATH_TO_EXT.'/jquery/jquery-ui-1.12.1.custom/jquery-ui.css' ;

        $this->HEAD['js'][]=_PATH_TO_EXT.'/interface/jquery-validation/dist/jquery.validate.js' ; // !!!  используется только в форме авторизации
        $this->HEAD['js'][]=_PATH_TO_EXT.'/interface/jquery-validation/dist/localization/messages_ru.js' ; // !!!  используется только в форме авторизации

        //$this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery.modal.js' ; // !!! не используется
        $this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery.timers-1.2.js' ;
        //$this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/unserialize.jquery.latest.js' ; // !!! использовалось в мониторинге SSE, более не используется
        //$this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/imgpreview.full.jquery.js' ; // !!!  не используется http://james.padolsey.com/demos/imgPreview/full/


        // форматирование INPUT
        //$this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery.maskedinput-1.4.1.min.js' ; // !!! более не используется http://digitalbush.com/projects/masked-input-plugin/
        //$this->HEAD['js'][]=_PATH_TO_EXT.'/jquery.inputmask-3.x/js/jquery.inputmask.js' ; // !!! более не используется https://github.com/RobinHerbots/jquery.inputmask
        $this->HEAD['js'][]=_PATH_TO_ADDONS.'/jQuery-Mask-Plugin/src/jquery.mask.js' ; // https://igorescobar.github.io/jQuery-Mask-Plugin/

        // библитека jBox + замена mBox
        //$this->HEAD['js'][]=_PATH_TO_ADDONS.'/jquery/jquery.form.min.js' ; // испрользуется для отправки данных формы

        // библитека jBox + замена mBox
        $this->HEAD['js'][]=_PATH_TO_EXT.'/mBox/jBox-0.3.1/Source/jBox.min.js' ;
        $this->HEAD['css'][]=_PATH_TO_EXT.'/mBox/jBox-0.3.1/Source/jBox.css' ;
        $this->HEAD['js'][]=_PATH_TO_EXT.'/mBox/jquery.form.js' ; // испрользуется для отправки данных формы
        $this->HEAD['js'][]=_PATH_TO_EXT.'/mBox/modal_window.jBox.js' ;

        $this->HEAD['css'][]=_PATH_TO_ADDONS.'/font-awesome-4.7.1/css/font-awesome.css' ;
        //$this->HEAD['css'][]=_PATH_TO_ADDONS.'/font-awesome-free-5.11.2/css/fontawesome.css' ;
        $this->HEAD['css'][]=_PATH_TO_ADDONS.'/fontawesome-free-5.12.0/css/all.css' ;

        $this->HEAD['css'][]=_PATH_TO_EXT.'/interface/ios7-switch-master/ios7-switch.css' ;


        $this->HEAD['js'][]=_PATH_TO_EXT.'/interface/auto_form_style/settings_panel.js';
        $this->HEAD['css'][]=_PATH_TO_EXT.'/interface/auto_form_style/settings_panel.css';

        // $this->HEAD['js'][]=_PATH_TO_EXT.'/webcamera_capture/jquery.webcamera_capture.js' ;

        //select2
        //$this->HEAD['css'][]=_PATH_TO_ADDONS.'/select2_v4.0.1/dist/css/select2.css' ;
        //$this->HEAD['js'][]=_PATH_TO_ADDONS.'/select2_v4.0.1/dist/js/select2.js' ;

        //$this->HEAD['css'][]='/'._CLASS_.'/style_clss.css' ;
        $this->HEAD['css'][]='/'._CLASS_.'/style.css' ;
        $this->HEAD['js'][]='/'._CLASS_.'/script.js' ;

        // именно в конце, иначе модальные окна выводятся по верху экрана а не по центру
        //$this->HEAD['css'][]=_PATH_TO_ADDONS.'/bootstrap-modal/css/bootstrap-modal-bs3patch.css' ;
        //$this->HEAD['css'][]='/'._CLASS_.'/style_cab.css' ;

        ?><script type="text/javascript">
            var LS_popup_window_width="<?echo $GLOBALS['LS_popup_window_width']?>" ;
            var LS_popup_window_height="<?echo $GLOBALS['LS_popup_window_height']?>" ;
            var card_view_mode="<?echo _CUR_PAGE_MODE?>" ;
            var reading_time = <?echo ($GLOBALS['LS_mo_pass_reading_time'])?:0?>;
            var member_id = <?echo (MEMBER()->id)?:0?>;
            var member_rol_id = <?echo (MEMBER()->rol)?:0?>;
            var audio = new Audio();
          </script><?


			// подержка сокетов должна быть даже на разлогиненой странице
          if ($GLOBALS['LS_monitoring_use_WS'] and $this->use_WS and (MEMBER()->rol==1 or MEMBER()->rol==2)) $this->ws_include() ;

        if ($this->use_enlighterjs)
        {  $this->HEAD['js'][]=_PATH_TO_ADDONS.'/EnlighterJS/dist/enlighterjs.min.js' ;
           $this->HEAD['css'][]=_PATH_TO_ADDONS.'/EnlighterJS/dist/enlighterjs.min.css' ;
        }

        if ($this->use_cryptopro) $this->cryptopro_include() ; // подключаем cryptopro

    }

    function ws_include()
    {
          $this->HEAD['js'][]=_PATH_TO_EXT.'/aspmo_monitor/script_socket_event.js?rand='.rand(1,1000) ;
          $ws_protocol=(_MAIN_PROTOCOL == 'https://')? 'wss':'ws';

          ?><script type="text/javascript">
          $j(document).ready(function()
            {  $j('body').socket_events({ group:<?echo (MEMBER()->cur_group_id)?:0?>,
                                          groups:"<?echo (MEMBER()->cur_groups_visible)?:''?>",
                                          ws_protocol:"<?echo $ws_protocol?>",
                                          ws_address_port:"<?echo ($GLOBALS['LS_WS_address_port_JS'])?:_MAIN_DOMAIN?>",
                                          ws_check_domain:"<?echo ($GLOBALS['LS_WS_check_domain'])?:0?>",
                                          debug:0,
                                       });
            }
          );
          </script><?
    }

    function cryptopro_include()
    {
          if ($GLOBALS['LS_ecp_version'])
          {   $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/official_library/es6-promise.min.js?v=79fdb27' ;
              $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/official_library/ie_eventlistner_polyfill.js?v=bed561ec' ;
              $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/official_library/lights.js?v=fcd9dd20' ;
              $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/official_library/cadesplugin_api_v2.js?v=ea0a733' ;
              $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/official_library/Code.js?v=9679822' ;
              ?>
              <script type="text/javascript">
                  function include_async_code()
                  {  if(async_code_included) {return async_Promise;}
                      var fileref = document.createElement('script');
                      fileref.setAttribute("type", "text/javascript");
                      fileref.setAttribute("src", "<?echo _PATH_TO_EXT?>/cryptopro/official_library/async_code.js?v=b15db0f8");
                      document.getElementsByTagName("head")[0].appendChild(fileref);
                      async_Promise = new Promise(function(resolve, reject){async_resolve = resolve;});
                      async_code_included = 1;
                      return async_Promise;
                  }
              </script>
              <script language="javascript" src="<? echo _PATH_TO_SITE ?>/<? echo _CLASS_ ?>/ext/cryptopro/official_library/load_extension.js?v=b2c1bd9a"></script>
              <script language="javascript" src="<? echo _PATH_TO_SITE ?>/<? echo _CLASS_ ?>/ext/cryptopro/official_library/highlight.js?v=243c63a1"></script>
              <?

          }
          else
          {   $this->HEAD['js'][]=_PATH_TO_ADDONS.'/cryptopro/js_2.1.0/es6-promise.min.js' ;
              $this->HEAD['js'][]=_PATH_TO_ADDONS.'/cryptopro/js_2.1.0/ie_eventlistner_polyfill.js' ;
              $this->HEAD['js'][]=_PATH_TO_ADDONS.'/cryptopro/js_2.1.0/cadesplugin_api.js' ;
              $this->HEAD['js'][]=_PATH_TO_ADDONS.'/cryptopro/js_2.1.0/Code.js' ;
          }

           $this->HEAD['css'][]=_PATH_TO_EXT.'/cryptopro/official_library/style.css' ;
           $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/js/sign_async.js' ;
           $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/js/esmo_save.js' ;
           $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/js/esmo_sign.js' ;
           $this->HEAD['js'][]=_PATH_TO_EXT.'/cryptopro/js/esmo_fill.js' ;
           $this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/jquery.browser.min.js' ;
           $this->HEAD['css'][]=_PATH_TO_EXT.'/cryptopro/style_sign.css' ;
           $cert = MEMBER()->certificate;

           $this->sign_uid=ENGINE()->generate_UID() ;
          ?>


          <script  type="text/javascript">
              var sign_uid="<?echo $this->sign_uid?>" ;
              var session_sign_uid="<?echo $this->sign_uid?>" ;
              var AsyncMode=1 ;
              var LS_trace_sign_JS=<?echo ($GLOBALS['LS_trace_sign_JS'])? 1:0?> ;
              var doctor_id=<?echo (MEMBER()->id)?:0?> ;
              var show_cert=<?echo ($cert['Thumbprint'])? 'false':'true' ?> ;
              var emulate_sign=<?echo (MEMBER()->info['evulate_ECP'] or $GLOBALS['LS_evulate_ECP'])? 1:0 ?> ;
              var cert_IssuerName="<?echo addslashes($cert['IssuerName'])?>" ;
              var cert_SubjectName="<?echo addslashes($cert['SubjectName'])?>" ;
              var cert_ValidFromDate="<?echo $cert['ValidFromDate']?>" ;
               var cert_ValidToDate="<?echo $cert['ValidToDate']?>" ;
              var cert_Thumbprint="<?echo $cert['Thumbprint']?>" ;
              var cert_SerialNumber="<?echo $cert['SerialNumber']?>" ;


           var canPromise = !!window.Promise;
           if(canPromise)
           {
               cadesplugin.then(function ()
               {
                   // проверка подключения плагина
                   ESMO_Common_CheckForPlugIn();
               },
               function(error)
               {
                   $j('#PluginEnabledImg').attr("src", "/AddOns/cryptopro/img/red_dot.png");
                   $j('#CSPNameTxt').html(error);
                   sign_log('cadesplugin error:'+error) ;
                   send_ajax_request({cmd:'cryptopro/cadesplugin_error',
                                    account_id:<?echo MEMBER()->id?>,
                                    data:{ browser_name:$j.browser.name,
                                           browser_version:$j.browser.version
                                         }
                                   }) ;
               });
           }
           else
           {
               $j('#CSPNameTxt').html('NPAPI плагины более не поддерживаются. Необходим браузер с поддержкой асинхронных плагинов');
           }

              $j(document).ready(function()
              {
                  $j('#BrowserVers').html('Браузер: <strong>'+$j.browser.name+" "+$j.browser.version+'</strong>') ;

                  // событие успешной загрузки плагина криптопро
                  $j('body').on('cadesplugin_completted',function()
                  {   console.log('on_cadesplugin_completted') ;

                      $j('#panel_CP_status').addClass("active") ;
                      //$j('#block_main button').removeAttr('disabled') ;
                      //if (params.on_plugin_uploaded=='check_token') check_token(params.cert_id,0,params.content) ;

											<?if ($this->show_panel_cryptopro_status)
											{ ?>
														  $j('#PluginEnabledImg').attr("src", "/AddOns/cryptopro/img/green_dot.png");
           									  $j('#PlugInEnabledTxt').html("Плагин загружен.") ;

															// событие получения данных по версии CP
															$j('body').on('cadesplugin_cp_versions',function(event,cp_params,ss)
															{   console.log('on_cadesplugin_cp_versions') ;
																	console.log('cp_params:'+JSON.stringify(cp_params)) ;

																	$j('#PlugInVersionTxt').html("Версия плагина: <strong>" +cp_params.cryptopro.PlugInVersion+"</strong>");
																	$j('#CSPVersionTxt').html("Версия криптопровайдера: <strong>" + cp_params.cryptopro.CSPVersion+"</strong>");
																	$j('#CSPNameTxt').html("Криптопровайдер: " + cp_params.cryptopro.CSPName);

																	send_ajax_request({cmd:'cryptopro/save_cryptopro_to_account',
																										 account_id:<?echo MEMBER()->id?>,
																										 cp_params:cp_params
																										}) ;
																	//if (params.on_plugin_uploaded=='check_token') check_token(params.cert_id,0,params.content) ;

															}) ;
												<?

											}
											?>



                  }) ;


              });

          </script>
          <?
    }

    function set_bottom_head_tags()
    {
      if ($this->use_datepicker)
      {   $this->HEAD['js'][]=_PATH_TO_EXT.'/interface/datepicker/jquery.ui.datepicker-ru.js' ;
          $this->HEAD['js'][]=_PATH_TO_EXT.'/interface/datepicker/jquery-ui-timepicker-addon.js' ;
          $this->HEAD['css'][]=_PATH_TO_EXT.'/interface/datepicker/jquery.ui.datepicker.css' ;
          $this->HEAD['css'][]=_PATH_TO_EXT.'/interface/datepicker/jquery-ui-timepicker-addon.css' ;
          ?><script type="text/javascript">
            $j(document).ready(function()
            { $j('input.datepicker').datepicker($j.datepicker.regional["ru"]);
              $j('input.datetimepicker').datetimepicker($j.datepicker.regional["ru"]);
            }) ;
            </script>
          <?
      }

        if ($this->use_enlighterjs)
        {
           ?><script type="text/javascript">$j(document).ready(function(){EnlighterJS.init('pre', 'code',
                {language : 'javascript',
                 theme: 'enlighter',
                 indent : 2,
                 ampersandCleanup: true

                });});</script><?
        }


      // стандартное подключение highslide
      if ($this->use_highslide)
      {  $this->HEAD['js'][]=_PATH_TO_ADDONS.'/highslide/highslide-4.1.13/highslide.js' ;
         $this->HEAD['css'][]=_PATH_TO_ADDONS.'/highslide/highslide-4.1.13/highslide.css' ;
      }


      if ($this->use_fusioncharts and MEMBER()->id)
      { $this->HEAD['js'][]=_PATH_TO_ADDONS.'/fusioncharts-suite-xt/js/fusioncharts.js' ;
        $this->HEAD['js'][]=_PATH_TO_ADDONS.'/fusioncharts-suite-xt/js/fusioncharts.charts.js' ;
        $this->HEAD['js'][]=_PATH_TO_ADDONS.'/fusioncharts-suite-xt/js/themes/fusioncharts.theme.fint.js' ;
      }

      if ($this->use_jwplayer)
      {
          $this->HEAD['js'][]=_PATH_TO_EXT.'/jwplayer-7.2.4/jwplayer.js' ;
      }

      if ($this->use_printPage)
      {
          $this->HEAD['js'][]=_PATH_TO_ADDONS.'/printPage/jquery.printPage.js' ;
      }

      if ($this->use_auto_complete)
      {  $this->HEAD['js'][]=_PATH_TO_EXT.'/jQuery-autoComplete/jquery.auto-complete.js' ;
         $this->HEAD['css'][]=_PATH_TO_EXT.'/jQuery-autoComplete/jquery.auto-complete.css' ;
      }

      //if ($GLOBALS['LS_help_enabled'] and MEMBER()->rol==1) $this->use_ckeditor=1 ;
      if ($this->use_ckeditor)
      {   //$this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor5-build-classic/ckeditor.js' ;
          $this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor_4.12.1_full/ckeditor.js' ;
          //$this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor_4.12.1_full/config.js' ;
          $this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor_4.12.1_full/styles.js' ;
      }
      if ($this->use_ckeditor5)
      {   //$this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor5-build-classic/ckeditor.js' ;
          $this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor5_17.0.0/build/ckeditor.js' ;
          $this->HEAD['css'][]=_PATH_TO_ADDONS.'/ckeditor5_17.0.0/style.css' ;
          //$this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor_4.12.1_full/config.js' ;
          //$this->HEAD['js'][]=_PATH_TO_ADDONS.'/ckeditor5-build-decoupled-document.17.0.0/styles.js' ;
      }

      //if ($this->use_multirange)
      {  $this->HEAD['js'][]=_PATH_TO_EXT.'/interface/jRange-master/source/jquery.range.js' ;
         $this->HEAD['css'][]=_PATH_TO_EXT.'/interface/jRange-master/source/jquery.range.css' ;
      }

      if ($this->use_textarea_autosize)
      {  $this->HEAD['js'][]=_PATH_TO_EXT.'/interface/autosize-master/dist/autosize.js' ;
          ?><script type="text/javascript">
                  $j(document).ready(function()
                  { autosize(document.querySelectorAll('textarea'));
                  }) ;
                  </script>
          <?
      }


    }

 function local_page_head()
 {
     parent::local_page_head(); // TODO: Change the autogenerated stub
     // переделать потом для поддержки IE
     ?><!--[if lt IE 9]>
         <link rel="stylesheet" href="<?echo _PATH_TO_ADDONS?>/sky-mega-menu/version_1.2.1/css/sky-mega-menu-ie8.css">
         <link rel="stylesheet" href="<?echo _PATH_TO_ADDONS?>/sky-forms-pro/version_2.0.5/css/sky-forms-ie8.css">
         <script src="<?echo _PATH_TO_EXT?>/jquery/html5.js"></script>
         <script src="<?echo _PATH_TO_ADDONS?>/sky-forms-pro/version_2.0.5/js/sky-forms-ie8.js"></script>
         <![endif]-->
         <!--[if lt IE 10]>
            <script src="<?echo _PATH_TO_EXT?>/jquery/jquery.placeholder-0.2.4.min.js"></script>
        <![endif]--><?
 }

  function menu_upload()
  {  if (MEMBER()->id)
      { $this->allow_menu_items=execSQL_row('select obj_name,rol_id from obj_site_permit where rol_id="'.MEMBER()->info['rol'].'"') ;
        //echo '<div class=red>Формируем меню кабинета</div>' ;
        //$this->menu_config() ;
      }
      if ($this->result!=404) $this->menu_config() ;
      //damp_array($this->menu);

  }

  // -----------------------------------------------------------------------------------
  // РАЗЛИЧНЫЕ ВАРИАНТЫ BODY
  // -----------------------------------------------------------------------------------

  function body()
  { // переходим на страницу личного кабинета
    if (!MEMBER()->id and !$this->free_access)            $this->body_autorize() ;
    else  if ($this->result=='404')                       $this->body_404() ;
    else  if ($this->body_type=='print')                  $this->body_print() ;
    else                                                  $this->body_work() ;

    if ($this->disabled_button_to_superreader==1 and MEMBER()->superreader)
      {   ?>
          <script type="text/javascript">
            $j('button').attr('disabled',true);
            $j('input[type=submit]').attr('disabled',true);
          </script>
         <?
      }

  }

  function body_autorize()
  {
    ?><body class="x1 <?echo $this->color_set?> login_panel <?echo $this->block_main_class?>"><table id=wrapper class="login_panel"><tr><td><? $this->panel_autorize();?></td></tr></body><?
  }

  function body_404()
  {
    ?><body class="<?echo $this->color_set?> body_work body_404 <?echo $this->body_class?> <?echo $this->block_main_class?>"><div class="body"><aside>
           <?$this->panel_main_menu()?>
           <?$this->panel_second_menu()?>
           <div id=block_main><?  $this->panel_404();?><div class=clear></div>
           </div>
          </aside></div></body>
    <?
  }

  function body_work()
  { ?><body class="<?echo $this->color_set?> body_work <?echo $this->body_class?> <?echo $this->block_main_class?> <?echo _CUR_ROOT_DIR_NAME?>"><div class="body"><aside><?
       $this->panel_WS_status() ;
       $this->panel_main_menu() ;
       $this->panel_help_content();
       $this->panel_second_menu() ;

     ?><table id="block_center"><tr><td id="center_left"><?


                 $this->panel_block_main();
                 $this->panel_block_second();


                 ?></td><td id="center_right"><?$this->panel_block_right()?></td></tr></table>
    </aside></div><div id="div_print"></div></body>
    <script type="text/javascript">
      /*$j(document).ready(function(){ $j('body').everyTime(30000,'check_autorize',function(){$j.ajax({url:'/ajax.php',type:'POST',dataType:'xml',success:exec_ajax_cmd_success_JQ,data:{cmd:'aspmo/check_autorize2'}});}) ;});*/
    </script>
    <?


  }

  function body_print()
  { ?><body class="<?echo $this->body_class?> <?echo $this->block_main_class?>">
      <div id=block_main><div class=printSelection><?  if (!$this->check_access()) $this->panel_access_denited() ;
                             else $this->block_main();?></div></div>
      </body>
    <?
  }

  // -----------------------------------------------------------------------------------
  // РАЗЛИЧНЫЕ ВАРИАНТЫ BODY
  // -----------------------------------------------------------------------------------

  function panel_block_main()
  { ?><div id=block_main><?
       if (!$this->check_access() or $this->access_denited) $this->panel_access_denited() ;
       elseif (MEMBER()->_smena_status=='out' and !$this->no_panel_smena_is_out) $this->panel_smena_is_out() ;
       elseif (_sizeof($this->require_moduls_not_found)) $this->panel_require_moduls_not_found() ;
       else
       {   if ($GLOBALS['LS_help_enabled']) $this->panel_help();
           if ($this->use_cryptopro and $this->show_panel_cryptopro_status) \cab\ext\cryptopro\i_cryptopro_sign::panel_plugin_status();
           $this->panel_cmd_exec();
           $this->block_main();
       }
       if ($_SESSION['member']->info['smena_out'] and $this->no_panel_smena_is_out) $this->panel_smena_is_out(array('no_img'=>1)) ;
    ?><div class=clear></div></div><?
  }

  function panel_block_second()
  {}

  function panel_block_right() {} // используется в отчетах для вывода правого меню
  function block_right() {}

  function panel_block_before_menu(){?><div id="panel_block_before_menu"></div><?}
  function panel_help_content(){?><div id="panel_help_content"></div><?}
  function panel_help()
  {  $cur_url=(defined('_CUR_CAB_DIR'))? _CUR_CAB_DIR:_CUR_PAGE_PATH ;
      $id=execSQL_value('select pkey from help_content where obj_name="'.$cur_url.'"') ;
      ?><div id="panel_help_icons">
        <?if (MEMBER()->rol==1){?><i class="fa fa-edit v2" cmd="help/edit_help_content" url="<?echo $cur_url?>"></i><?}?>
        <?if ($id){?><i class="fa fa-question-circle v2" cmd="help/get_help_content" url="<?echo $cur_url?>"></i><?}?>
      </div>
    <?
  }

  function panel_autorize()
  { /*if ($GLOBALS['LS_auth_by_token'])
    { ?><SCRIPT type="text/javascript" src="/<?echo _CLASS_?>/ext/rutoken/script.js"></SCRIPT>
        <object type="application/x-rutoken-pki" id="plugin-object" width="0" height="0"><param name="onload" value="onPluginLoaded"/></object>
      <?
    } */
    if ($GLOBALS['LS_auth_by_pass'])
    {  include_once(_DIR_EXT.'/account/panel_form_autorize.php') ;
       panel_form_autorize() ;
    }
  }

  function panel_path($path=array(),$options=array()){}

  function page_title($title='',$path=array(),$options=array())
  { parent::page_title($title,$path,$options) ;

    //damp_array($this) ;
  }

  function panel_WS_status()
  {
     if ($this->use_WS){?><div id="panel_WS_status">WS</div><?}
     if ($this->use_cryptopro){?><div id="panel_CP_status">КриптоПро</div><?}
  }

  function panel_cmd_exec()
  { if ($this->cmd_exec_HTML_output)
    {   ?><div id="result_exec_cmd"><?
          if (_sizeof($this->cmd_exec_result)) $this->panel_exec_result() ;
        echo $this->cmd_exec_HTML_output ;
        ?></div><?
    }
  }

    function panel_exec_result()
     { ?><div id="panel_exec_result" class="<?echo $this->cmd_exec_result['type']?>"><?
         if ($this->cmd_exec_result['text']) echo $this->cmd_exec_result['text'] ;
         else if ($this->cmd_exec_result['code']) echo $this->cmd_exec_result['code'] ;
       //damp_array($this->cmd_exec_result,1,-1) ;
       ?></div><?
     }

     function exec_cmd($post) {}


   function cmd_exec()
   {
     if (!$this->access_denited) parent::cmd_exec() ;   // выполнение CMD только если select_obj_info не установил флаг access_denited
   }

  // -----------------------------------------------------------------------------------
  // шапка сайта
  // -----------------------------------------------------------------------------------

  function panel_top_time()
  {  include_once(_DIR_EXT.'/server_time/panel_cur_time.php') ;
     panel_cur_time('d.m.Y H:i',60) ;
  }

  function panel_terminal_status()  {}


  function panel_button_back()
  { ?><div id=panel_button_back><?
       if ($_SERVER['HTTP_REFERER']) {?><button class="v1" href="<?echo $_SERVER['HTTP_REFERER']?>">Назад</button><?}
    ?></div><?
  }

  // -----------------------------------------------------------------------------------
  // панель вкладок меню
  // -----------------------------------------------------------------------------------

 function check_access()
 { if (!MEMBER()->id and $this->free_access) return(1) ;
   if (MEMBER()->info['rol']==1) return(1) ;
   if ($this->allow_access_to_member and $this->allow_access_to_member==MEMBER()->id) return(1) ; // разрешаем доступ если указан аккаунт для страницы
   if ($this->allow_access_to_rol and $this->allow_access_to_rol==MEMBER()->rol) return(1) ; // разрешаем доступ есть указана  роль для страницы
   //$access=ACCOUNTS()->get_right_rol(MEMBER()->info['rol'],get_class($this)) ;
   $access=isset($this->allow_menu_items[get_class($this)]) ;
   return($access) ;
 }

 function panel_access_denited()
 { ?><div id="panel_access_denited">
     <?if ($this->access_denited_comment) echo '<h1>'.$this->access_denited_comment.'</h1>' ;
       else {?><h1>У вас нет прав доступа к данной странице</h1><?}
     ?>
      <img src="/images/access_denited.png">
    </div>
    <div class="small"><?echo 'script_file: '.hide_server_dir($this->script_file).'<br>' ;
                         echo 'class_name: '.$this->class_name.'<br>' ;
                         //damp_array($this) ;
                       ?>
    </div>
    <?
 }

 function panel_smena_is_out($options=array())
 { ?><div id="panel_access_denited">
      <h1>Ваша смена окончена</h1>
      <?if (!$options['no_img']){?><img src="/images/access_denited.png"><br><br><?}?>
      <button class="v2" cmd="account/account_logout">Выход</button>
    </div><?
 }


    function get_element_attr($attr=array())
    {  $arr=array() ;
       if (_sizeof($attr)) foreach($attr as $id=>$value)
        if (is_array($value))   $arr[]=$id.'="'.implode(' ',$value).'"' ;
        else if (!is_int($id))  $arr[]=$id.'="'.$value.'"' ;
        else                    $arr[]=$value ;
        return(implode(' ',$arr)) ;
    }

      // -----------------------------------------------------------------------------------
      // ГЛАВНОЕ МЕНЮ
      // -----------------------------------------------------------------------------------

     function menu_config()
     {   if ($this->cur_window_mode=='window') return ;
         if (_sizeof($_SESSION['list_created_sybsystems'])) foreach($_SESSION['list_created_sybsystems'] as $system_name)
          if (is_object($_SESSION[$system_name]) and method_exists($_SESSION[$system_name],'declare_menu_items_1')) $_SESSION[$system_name]->declare_menu_items_1($this) ;
         if (function_exists('declare_menu_items_1')) declare_menu_items_1($this) ;

        if (_sizeof($_SESSION['list_created_sybsystems'])) foreach($_SESSION['list_created_sybsystems'] as $system_name)
          if (is_object($_SESSION[$system_name]) and method_exists($_SESSION[$system_name],'declare_menu_items_2')) $_SESSION[$system_name]->declare_menu_items_2($this) ;
        if (function_exists('declare_menu_items_2')) declare_menu_items_2($this) ;

        if (_sizeof($_SESSION['list_created_sybsystems'])) foreach($_SESSION['list_created_sybsystems'] as $system_name)
          if (is_object($_SESSION[$system_name]) and method_exists($_SESSION[$system_name],'declare_menu_items_3')) $_SESSION[$system_name]->declare_menu_items_3($this) ;
        if (function_exists('declare_menu_items_3')) declare_menu_items_3($this) ;

        if (_sizeof($_SESSION['list_created_sybsystems'])) foreach($_SESSION['list_created_sybsystems'] as $system_name)
          if (is_object($_SESSION[$system_name]) and method_exists($_SESSION[$system_name],'declare_menu_items_4')) $_SESSION[$system_name]->declare_menu_items_4($this) ;
        if (function_exists('declare_menu_items_4')) declare_menu_items_4($this) ;

        if (_sizeof($GLOBALS['__functions']['main_menu'])) foreach($GLOBALS['__functions']['main_menu'] as $func_name) $func_name($this) ;


      if (_sizeof($_SESSION['list_created_sybsystems'])) foreach($_SESSION['list_created_sybsystems'] as $system_name)
         if (is_object($_SESSION[$system_name]) and method_exists($_SESSION[$system_name],'declare_menu_items_5')) $_SESSION[$system_name]->declare_menu_items_5($this) ;
      if (function_exists('declare_menu_items_5')) declare_menu_items_5($this) ;


      if (_sizeof($GLOBALS['_SETTING']['plugins'])) foreach($GLOBALS['_SETTING']['plugins'] as $plugin=>$enabled) if ($enabled)
      {  $func_name=strtoupper(str_replace('i_','',$plugin)) ;
         if (function_exists($func_name))
         { $obj=$func_name() ;
           if (is_object($obj) and method_exists($obj,'declare_menu')) $obj->declare_menu($this) ;
         }
      }

      // новый способ формирования меню - из ini.yaml
      $menu=ENGINE()->read_menu_from_yaml('main')  ;
      $this->menu+=$menu;


     }

     // cmd
     // id
     // class
     // title
     // items
     var $selected_item_by_url ; // URL, элемент с которым необхомо включить

    function panel_main_menu()
    {  if (MEMBER()->id and MEMBER()->info['rol']!=1) $this->member_menu_check($this->menu) ; // удаляем из меню пункты, к которым нет доступа

         if ($this->page_type=='window' or _CUR_ROOT_DIR_NAME=='window')
         {   $this->menu_show_account_item=0 ;
             $this->menu_show_close_item=1 ;
         }
         if ($this->page_type=='frame' or _CUR_ROOT_DIR_NAME=='frame')
         {   $this->menu_show_account_item=0 ;
             $this->menu_show_close_item=0 ;
             $this->menu_show_logo_item=0 ;
         }


       $this->panel_main_menu_view() ;
     }

     function panel_member_ecp_info()
     {
         if ($this->use_cryptopro)
          { if ($GLOBALS['LS_evulate_ECP'] or MEMBER()->info['evulate_ECP']) {?><div class="ecp_info" style="margin:10px 0;"><i class="fa fa-certificate" style="color:lightslategray;" aria-hidden="true"></i> Эмуляция ЭЦП</div><?}
            else if (MEMBER()->info['certificate']['Thumbprint'])
            { $ecp_valid_to=strtotime(MEMBER()->info['certificate']['ValidToDate']) ;
              if ($ecp_valid_to>time())
              {?><div class="ecp_info" style="margin:10px 0;"><i class="fa fa-certificate" style="color:green;" aria-hidden="true"></i> ЭЦП до <?echo date('d.m.Y',strtotime(MEMBER()->info['certificate']['ValidToDate']))?></div><?}
              else {?><div class="ecp_info" style="margin:10px 0;"><i class="fa fa-certificate" style="color:red;" aria-hidden="true"></i> ЭЦП просрочен</div><?}
            }
          }
     }

     function panel_main_menu_title()
     {  if ($this->menu_show_account_item)
         {?>    <li aria-haspopup="true">
        						<a><?echo '<strong>'.MEMBER()->name.'</strong>' ;
                                    if (MEMBER()->from_AD) echo ' <span><i class="fab fa-windows" aria-hidden="true"></i></span>' ;
                                    echo '<br>'.MEMBER()->working?>
                                   <?if (MEMBER()->info['bp_id']) echo '<br>Бюро пропусков: <strong>'.MEMBER()->bp_name.'</strong>' ;
                                     else if (MEMBER()->rol!=22 and MEMBER()->cur_group_name) echo '<br>Группа: <strong>'.MEMBER()->cur_group_name.'</strong>' ;

                                     $this->panel_member_ecp_info();

                                  ?>
                               <?if (MEMBER()->superreader) echo '<div class="red">Режим СУПЕРЧИТАТЕЛЯ</div>'?>
                                   <?if (MEMBER()->use_auch_as_smena) switch(MEMBER()->_smena_status)
                                    {  case 'close':     echo '<div class="red margin-top:5px;">Смена не открыта</div>' ; break ;
                                       case 'unactive':  echo '<div class="red margin-top:5px;">Смена не открыта</div>' ; break ;
                                       case 'active':    echo '<div class="margin-top:5px;">Начало смены: <strong>'.date('d.m.Y H:i',MEMBER()->info['smena_in']).'</strong></div>' ; break ;
                                       case 'pause':     echo '<div class="red margin-top:5px;">Смена приостановлена</div>' ; break ;
                                       case 'out':       echo '<div class="red margin-top:5px;">Смена окончена</div>' ; break ;
                                       case 'block':  echo '<div class="red margin-top:5px;">Смена заблокирована</div>' ; break ;
                                    }
                                    if (MEMBER()->rol==22)
                                    { echo '<br><br>'.$_SESSION['master_tk_info'].'<br><br>'.$_SESSION['master_smena_info'] ;

                                    }
                                    ?></a>
        						<div class="grid-container3">
        							<ul><?if (MEMBER()->rol==6){?><li><a href="/cab/client/setting/"><i class="fa fa-sliders"></i>Настройки аккаунта</a></li><?}
                                             else              {?><li><a href="/cab/setting/member/<?echo MEMBER()->id?>/"><i class="fa fa-sliders"></i>Настройки аккаунта</a></li><?}
                                            ?>
                                        <? // для тех пользователей, которые работают по сменам
                                           if (MEMBER()->use_auch_as_smena)
                                            {   // номельная ситуация оконачания смены
                                                if (MEMBER()->_smena_status=='active') {?><li><a href="/cab/smenaout/"><i class="fa fa-sign-out"></i>Завершить смену</a></li><?}
                                                // приостановленая смена
                                                elseif (MEMBER()->_smena_status=='pause') {?><li><a href="" class="v2" cmd="aspmo/smena_resume"><i class="fa fa-sign-out"></i>Продолжить смену</a></li>
                                                                                                                      <li><a href="/cab/smenaout/"><i class="fa fa-sign-out"></i>Завершить смену</a></li><?}
                                                // принудительное начало смены, когда идет смена другого сотрудника
                                                elseif (MEMBER()->_smena_status=='unactive') {?><li><a href="" class="v2" cmd="aspmo/smena_in"><i class="fa fa-sign-out"></i>Начать смену</a></li><?}
                                            }
                                        ?>
        								<li><a href="/" class="v2" cmd="account/account_logout"><i class="fa fa-sign-out"></i>Выход</a></li>
                                        <? // переход из админа в аккаунт другого пользователя
                                        if (MEMBER()->rol==1)
                                        {  $arr_rols=execSQL_line('select distinct(rol) from obj_site_account where rol!=1 and clss=210 and enabled=1 order by rol') ;
                                           ?><li><a href=""><i></i>Перейти в аккаунт</a><div class="grid-container3"><ul><?
                                                 if (_sizeof($arr_rols)) foreach($arr_rols as $rol_id) if (isset($_SESSION['ARR_roll'][$rol_id]))
                                                 { ?><li><a href="" class="v2" cmd="account/get_panel_login_as" rol_id="<?echo $rol_id?>"><i class=""></i><?echo $_SESSION['ARR_roll'][$rol_id]['obj_name']?></a></li><?}
                                           ?></ul></div></li><?
                                           ?><li><a href="" class="v2" cmd="account/get_panel_group_as"><i></i>Перейти в группу</a><div class="grid-container3"></div></li><?
                                        }
                                        elseif ($_SESSION['admin_login_id']) {?><li><a href="/" class="v2" cmd="account/account_login_as" member_id="<?echo $_SESSION['admin_login_id']?>"><i class="fa fa-sign-out"></i>Вернутся в аккаунт администратора</a></li><?}
                                        ?>

        							</ul>
        						</div>
        		</li><?}
        		if (MEMBER()->rol==1 and ENGINE()->exists_setup_dir())
        		    { ?><li  aria-haspopup="true" style="background-color:darkred;color:white;line-height:1em;padding-left:20px;">ВНИМАНИЕ!<br>Необходимо удалить<br> инсталяционные файлы
                        <div class="grid-container3">
                            <ul><li><a href="" class="v2" cmd="aspmo_setting/remove_setup_files"><i class="_fa _fa-sliders"></i>Удалить</a></li></ul>
                        </div>
        		       </li>
                      <?
        		    }

     }



      // -----------------------------------------------------------------------------------
      // ДОПОЛНИТЕЛЬНОЕ МЕНЮ
      // -----------------------------------------------------------------------------------
      function local_menu_config() {}
      function second_menu_config() {}
      function panel_main_menu_view() {}
      function panel_second_menu_view($menu_items=array()) {}

      function panel_second_menu()
      {   if ($this->result!=404) $this->second_menu_config() ;
          if (!_sizeof($this->second_menu)) return ;
          //damp_array($this->second_menu) ;
          // Внимание! При удалении пунктов меню принимается во внимание только информацния из таблицы прав доступа
          // другие флаги, такие как  allow_access_to_member не могут быть приняты во внимание при формировании меню, так как для этоого потребуется создавать каждвую стараницу
          if (MEMBER()->info['rol']!=1 and !$this->second_menu_show_all) $this->member_menu_check($this->second_menu) ; // удаляем из меню пункты, к которым нет доступа

          $this->panel_second_menu_view($this->second_menu);
      }

    // -----------------------------------------------------------------------------------
        // УДАЛЯЕМ ИЗ МЕНЮ ПУНКТЫ, ДОСТУП К КОТОРЫМ ЗАПРЕЩЕН ДЛЯ ПОЛЬЗОВАТЕЛЯ
    // -----------------------------------------------------------------------------------

    function member_menu_check(&$menu,$options=array())
    {  //if ($options['debug']) $options['debug']++ ;
       //if (_IS_SYSTEM_IP and !$options['debug']) $options['debug']=1 ;

       if ($options['debug']==1)  { ?><h2>PAGE->allow_menu_items</h2><? damp_array($this->allow_menu_items,1,-1) ; }
       if ($options['debug'])  { ?><h2>MENU</h2><?damp_array($menu,1,-1) ; }

       if (_sizeof($menu)) foreach($menu as $url=>$info) if (!isset($info['no_delete']))
       {  $arr=explode('/',$url) ;
          // надо удалить из URL все числа - ID объектов
          unset($arr[0],$arr[_sizeof($arr)]) ;
          if (_sizeof($arr)) foreach($arr as $i=>$value)
          { if (is_numeric($value))  unset($arr[$i]) ;
            if (strpos($value,'[')!==false) unset($arr[$i]) ;
            if ($value=='window') $arr[$i]='cab' ;
            if ($value=='frame') $arr[$i]='cab' ;
          }

          $page_class_name='c_page_'.implode('_',$arr) ;
          if (stripos($page_class_name,'c_page_cab_reports_')!==false) $page_class_name=str_replace('c_page_cab_reports_','report_',$page_class_name) ;
          //if ($options['debug']) echo '$page_class_name='.$page_class_name.'<br>' ;
          if (!isset($this->allow_menu_items[$page_class_name]))
          { unset($menu[$url]) ;
            if ($options['debug']) echo  'DELETE URL=<strong>'.$url.'</strong>, page='.$page_class_name.'<br>' ;
          }
          if (is_array($info) and _sizeof($info['items']) and _sizeof($menu[$url]['items'])) $this->member_menu_check($menu[$url]['items'],$options) ;
          //damp_array($info['items']) ;
          //echo '$page_class_name='.$page_class_name.'<br>' ;

       }
    }


     /*
     function panel_account_info()
      { global $member ;
        if ($member->id){?><span id=panel_account_info2><?
                            echo $_SESSION['ARR_roll'][$member->info['rol']]['obj_name'].'<br>' ;
                            ?><span class=name><?echo $member->name?></span>
                            <? if ($member->info['smena_out']){?><span class="green">Отчет подписан, смена окончена.</span><?}?>
                            <?if (is_member_right('use_auch_as_smena') and !$member->info['smena_out']) {?><a href="/cab/smenaout/">Окончить смену</a><?}
                              else                                      {?><a href="" class="v2" cmd="account/account_logout">Выход</a><?}?>
                           </span><?}
      }*/

      /*
      function panel_work_group()
      {  global $member ;
         ?><div id="panel_work_group2"><?
           if ($member->cur_group_id) echo 'Рабочая группа:<br> <strong>'.$member->cur_group_name.'</strong>' ;
         ?></div><?
      } */


  function parse_url($url,$options=array())
   {
      return(ENGINE()->parse_url($url,$options)) ;
   }

  var $rec_doc ;
  function panel_doc_view($options=array())
 {   if ($this->rec_doc['report_code']) $obj_doc=REPORTS()->get_report_obj_by_code($this->rec_doc['report_code']) ;
     $sign_before_print=0 ; //($obj_doc->sign_before_print or $options['sign_before_print'])? 1:0 ;
     $doc_is_sign=($this->rec_doc['sign'])? 1:0 ;
     ?><div id="panel_doc_view">
         <div class=panel_doc_info>
           <div class="panel_left">
             <div class="autor">Создан: <strong><?echo $this->rec_doc['_member_name']?></strong></div>
             <div class="time">Дата создания: <strong><?echo $this->rec_doc['_date_create']?></strong></div>
             <div class="autor">Подписан: <strong><?echo ($this->rec_doc['sign'])? 'Да':'Нет'?></strong></div>
             <?if ($this->rec_doc['sign']){?><div class="time">Дата подписи: <strong><?echo $this->rec_doc['_date_podpis']?></strong>, <a href="<?echo hide_server_dir($this->rec_doc['__doc_dir']).'.zip'?>" target="_blank">скачать подписанный документ</a></div><?}?>
           </div>
           <div class="clear"></div>
         </div>
         <? if ($sign_before_print and !$doc_is_sign){?><div id="panel_pdf_hidden_button">ПЕРЕД ПЕЧАТЬЮ ДОКУМЕНТ НЕОБХОДИМО ПОДПИСАТЬ</div><?}?>
         <iframe src="<?echo $this->rec_doc['__doc_url']?>" style="width:100%; height:700px;" frameborder="0" /></iframe><br><br>
       </div>
       <div class="sky-form no_box_shadow" id="panel_buttons">
            <?

            if (!$doc_is_sign and (MEMBER()->id==$this->rec_doc['member_id'] or MEMBER()->rol==1))
            {   // если пользователь имеет сертификат - то возможность подписания документа
                if (method_exists($obj_doc,'content_edit')) {?><button class="button v2" cmd="docs/doc_set_edit_mode" doc_id="<?echo $this->rec_doc['pkey']?>">Редактировать документ</button><?}
                // для эмуляции подписываем документ по старому
                if (MEMBER()->info['evulate_ECP']) {?><button class="button v2" cmd="ecp/sign_doc" doc_id="<?echo $this->rec_doc['pkey']?>" after_sign_doc_go_url="<?echo $options['after_sign_doc_go_url']?>">Подписать документ</button><?}
                else
                if (!$options['doc_sign_page']) {?><button class="button v1" href="<?echo (_CUR_ROOT_DIR_NAME=='cab')? $this->rec_doc['__href_cab']:$this->rec_doc['__href_window']?>sign/">Подписать документ</button><?}
                else                            {?><button class="button v1" href="<?echo $options['doc_sign_page']?>">Подписать документ</button><?}
                // пока не подписан - можно удалить
                ?><button class="button v2" cmd="docs/doc_delete" doc_id="<?echo $this->rec_doc['pkey']?>" after_delete_go_url="<?echo $options['after_delete_doc_go_url']?>">Удалить</button><?
            }
            // не показываем кнопку печати, если документ должен быть подписан
            if (!$sign_before_print or ($sign_before_print and $doc_is_sign)){?><button class="button" id="print_doc_over_window" href="<? echo $this->rec_doc['__doc_url']?>">Печать документа</button><?}
            //  автоматические перенаправление на страницу подписи, если документ требует подписи
            /*if ($obj_doc->sign_before_print and !$this->rec_doc['sign']){?><script type="text/javascript">document.location='<?echo $options['doc_sign_page']?>' ;</script><?}*/
            ?>
       </div>
     <script type="text/javascript">
        $j('#print_doc_over_window').on('click',function()
        {   var wnd=window.open($j(this).attr('href'),'window_print_<?echo rand(1,10000)?>','status=1,dependent=1,width=400,height=700,left=0,top=0, resizable=1, scrollbars=yes')
            wnd.focus();
            setTimeout(function(){wnd.print();}, 1000);

        });
        $j('#panel_pdf_hidden_button').top($j('#print-frame').top()) ;

     </script>
     <style type="text/css">
               #panel_pdf_hidden_button{width:400px;height:35px;position:absolute;right:45px;color:white;text-align:center;padding-top:15px;background:darkred;}
           </style>
     <?
    }


    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //
    //  работа с формами
    //
    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    function form_open($options=array()) {$this->form->form_open($options);}
    function form_close() {$this->form->form_close();}
	function row_open() {$this->form->row_open();}
	function col_open($n) {$this->form->col_open($n);}
	function row_buttons() { $this->form->row_buttons();}
	function row_close() {$this->form->row_close();}
	function col_close() {$this->form->col_close();}
	function row_close_open() {$this->form->row_close_open();}

	function filter_section_select($element_name,$element_title,$col_count,$recs,$options=array()) {$this->form->filter_section_select($element_name,$element_title,$col_count,$recs,$options);}
    function filter_section_select_multiple($element_name,$element_title,$col_count,$recs,$options=array()) {$this->form->filter_section_select_multiple($element_name,$element_title,$col_count,$recs,$options);}
    function filter_section_input_text($element_name,$element_title,$col_count,$options=array()) {$this->form->filter_section_input_text($element_name,$element_title,$col_count,$options) ;}
    function filter_section_textarea($element_name,$element_title,$col_count,$options=array()) {$this->form->filter_section_textarea($element_name,$element_title,$col_count,$options) ;}

    function element_input($options=array()) { $this->form->element_input($options) ; }

    function form_checkbox($title,$comment,$var_name,$value=0,$check_value=1) {$this->form->form_checkbox($title,$comment,$var_name,$value,$check_value) ;}
    function form_checkbox_left($title,$comment,$var_name,$value=0,$check_value=1) {$this->form->form_checkbox_left($title,$comment,$var_name,$value,$check_value) ;}
    function form_checkbox_to_arr($title,$comment,$var_name,$var_name2) {$this->form->form_checkbox_to_arr($title,$comment,$var_name,$var_name2) ;}
    function form_element_input($title,$comment,$var_name,$options=array()) {$this->form->form_element_input($title,$comment,$var_name,$options) ;}
    function form_element_textarea($title,$comment,$var_name,$options=array()) {$this->form->form_element_textarea($title,$comment,$var_name,$options) ;}
    function form_element_select($title,$comment,$var_name,$recs,$options=array()) {$this->form->form_element_select($title,$comment,$var_name,$recs,$options) ;}

    function section_input($options=array()) {$this->form->section_input($options);}
    function section_select($options=array()) {$this->form->section_select($options);}
    function section_text($options=array()) {$this->form->section_text($options);}
    function section_textarea($options=array()) {$this->form->section_textarea($options);}
    function section_radio($options=array()) {$this->form->section_radio($options);}
    function section_checkbox($options=array()) {$this->form->section_checkbox($options);}

    function panel_report_buttons(){}
    function panel_buttons()  {$this->form->panel_buttons();}
    function button($title,$cmd='',$options=array())  {$this->form->button($title,$cmd,$options);}
    function panel_button_apply($options=array())  {$this->form->panel_button_apply($options);}
    function panel_buttons_action()  {$this->form->panel_buttons_action();}


    function convert_tree_to_select_options_arr($arr_tree,&$recs,&$options_list,$level=0)
        {  $pref=($level)? str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$level-1).'|--':"" ;
           $level++ ;
           if (_sizeof($arr_tree)) foreach ($arr_tree as $id=>$arr_childs)
           {   $options_list[$id]=$pref.$recs[$id]['obj_name'] ;
               if (_sizeof($arr_childs)) $this->convert_tree_to_select_options_arr($arr_childs,$recs,$options_list,$level) ;
           }
        }

    function panel_require_moduls_not_found()
    {
        ?><p style="font-size:18px;">Для данной страницы необходимо активировать сдедующие модули: <strong><? echo implode(', ',$this->require_moduls_not_found)  ;?></strong></p><?
    }


    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //
    //  меню табов
    //
    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



    // пример описания табов
    // public $tabs = ['cert_info'=>['title'=>'Выбранный ЭЦП','method'=>'panel_cert_info','default'=>1],
    //                    'select_cert'=>['title'=>'Выбор ЭЦП сотрудника','method'=>'panel_select_usr_sert'],
    //                    'emu_mode'=>['title'=>'Режим эмуляции ЭЦП','method'=>'panel_emulate'],
    //                    'mhd'=>['title'=>'МЧД','method'=>'panel_mhd'],
    //                   ];
    function panel_tabs()
    {   $current_tab=null ;

        ?><div id="setting_container_settings" class="setting_container_settings search_cnt" style="    margin: inherit; width: 100%;">
                <div class="setting_vertical_menu">
                    <?if (sizeof($this->tabs)) foreach ($this->tabs as $tab_id=>$rec_tab)
                    { $class='' ;
                      if ($_GET['tab']==$tab_id or (!$_GET['tab'] and $rec_tab['default'])) { $class='select_group' ; $current_tab=$tab_id ; }
                      ?><a href="<? echo _CUR_PAGE_DIR?>?tab=<?echo $tab_id?>" id="setting_block_<?echo $tab_id?>" onclick="sel_setting_block(this);" class="<?echo $class?>"><?echo $rec_tab['title']?></a>
                    <?}?>
                </div>

                <div id="setting_body_container" class="setting_body_container">
                    <?
                    if ($current_tab!=null)
                    {  $tab_method_name=$this->tabs[$current_tab]['method'] ;
                        //echo '$current_tab='.$current_tab.'<br>' ;
                        //echo '$tab_method_name='.$tab_method_name.'<br>' ;
                       ?><div class="container_setting_block" id="container_setting_block_<?echo $current_tab?>" style="display: block;"><?
                             if (method_exists($this, $tab_method_name)) $this->$tab_method_name() ;
                       ?></div><?
                    }
                    ?>
                </div>
            </div>
            <?
    }


}

?>
