<?php
include_once(_DIR_TO_CLASS.'/c_page.php');
class c_page_cab_personals_org_card extends c_page
{
    public $h1='Карточка организации';
    public $rec_section ;
    var $use_fusioncharts=1 ;

    function __construct($options=array())
    {   if (_CUR_ROOT_DIR_NAME=='frame') $this->body_class='no_menu';
        parent::__construct($options);
    }

    function set_head_tags()
    {   parent::set_head_tags();
        $this->HEAD['css'][]=_PATH_TO_EXT.'/personals/style.css';
    }

    function select_obj_info()
     { if (_CUR_ID)
       { $this->rec_section=PERSONAL()->get_org_by_id(_CUR_ID) ;
         if ($this->rec_section['pkey'])
         { //$arr=TREE('view_deps')->get_arr_parents_names($this->rec_section['pkey'],array('from_level'=>2)) ;
           //$this->h1=implode(' / ',$arr) ;
           $this->h1='Организация "'.$this->rec_section['obj_name'].'"' ;
           $_SESSION['cur_obj_page_dir'][_CUR_ROOT_DIR_NAME][$this->rec_section['tkey']][$this->rec_section['clss']]=str_replace(_CUR_ID,'***',_CUR_PAGE_DIR) ;
         }
         if (!$this->rec_section['pkey']) $this->result=404 ;
       } else $this->result=404 ;

     }


     function prepare_menu_config()
     {
         $cnt_sections=execSQL_value('select count(pkey) from view_deps where parent='.$this->rec_section['pkey'].' and clss=208 and enabled=1') ;
         $cnt_personals=execSQL_value('select count(pkey) from view_personals_active where parent'.$this->rec_section['level'].'='.$this->rec_section['pkey'].' and clss=211') ;

         $menu=[] ;
         $BASE_URL_org_CARD='/'._CUR_ROOT_DIR_NAME.'/personals/org/card/'.$this->rec_section['pkey'] ;

         $menu[$BASE_URL_org_CARD.'/']='Карточка организации' ;
         $menu[$BASE_URL_org_CARD.'/stats/']='Статистика' ;
         $menu[$BASE_URL_org_CARD.'/editor/']='Редактировать' ;
         if ($cnt_sections)  $menu[$BASE_URL_org_CARD.'/otdels/']=['title'=>'Подразделения','info_value'=>'<span>'.$cnt_sections.'</span>'] ;
         if ($cnt_personals) $menu[$BASE_URL_org_CARD.'/personals/']=['title'=>'Сотрудники','info_value'=>'<span>'.$cnt_personals.'</span>'] ;
         $menu[$BASE_URL_org_CARD.'/append/']='Добавить...' ;
         $menu[$BASE_URL_org_CARD.'/db/']='Исходные данные' ;

         return($menu) ;
     }

     function menu_config()
     {
        if (_CUR_ROOT_DIR_NAME=='window') $this->menu=$this->prepare_menu_config() ;
     }

     function panel_main_menu()
     {
         if (_CUR_ROOT_DIR_NAME!='frame') parent::panel_main_menu() ;
     }

     function second_menu_config()
     {
         if (_CUR_ROOT_DIR_NAME=='frame') $this->second_menu=$this->prepare_menu_config() ;
     }

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


}

?>
