<?php
include_once(_DIR_EXT."/esmo_magnit_pmo/i_event_pmo.php");
include_once(_DIR_EXT."/esmo_magnit_instruction/i_event_instruction.php");
include_once(_DIR_TO_CLASS."/c_page.php");
class c_page_cab_events extends c_page
{
 public $h1='Планировщик событий' ;

 function get_cur_events_count()
 {  $recs=execSQL_row('select ext,count(pkey) as cnt from obj_site_events_schedule where parent>0 group by ext') ;
    $events=array() ;
    if (_sizeof($recs)) foreach($recs as $ext=>$cnt)
    { list($event_type,$event_obj)=explode('/',$ext) ;
         if ($events[$event_type]) $events[$event_type]+=$cnt ;
         else                      $events[$event_type]=$cnt ;
    }
    return($events) ;

 }

 function second_menu_config()
 { $events=$this->get_cur_events_count() ; //damp_array($events);
   //$this->second_menu['/cab/events/']=array('title'=>'Все мероприятия') ;
   if ($events['esmo_magnit_instruction']) $this->second_menu['/cab/esmo_magnit_instruction/']=array('title'=>'Инструктажи') ;
   if ($events['esmo_magnit_pmo']) $this->second_menu['/cab/esmo_magnit_pmo/']=array('title'=>'ПМО') ;
   if ($events['events_opo']) $this->second_menu['/cab/events_opo/']=array('title'=>'ОПО') ;
   if ($events['events_docs']) $this->second_menu['/cab/events_docs/']=array('title'=>'Выдача документов') ;
   if ($events['events_meeting']) $this->second_menu['/cab/events_meeting/']=array('title'=>'Собрания') ;
   if ($events['event_docs_intro'] and $GLOBALS['_SETTING']['plugins']['esmo_intro']) $this->second_menu['/cab/esmo_intro/']=array('title'=>'Внедрение ЭСМО') ;
   if ($events['events_quiz'] and $GLOBALS['_SETTING']['modules']['quiz']) $this->second_menu['/cab/events_quiz/events/']=array('title'=>'Контроль знаний') ;
   if ($events['events_poll'] and $GLOBALS['_SETTING']['modules']['poll']) $this->second_menu['/cab/events_poll/events/']=array('title'=>'Опросы') ;
   if ($events['events_media'] and $GLOBALS['_SETTING']['modules']['media_content']) $this->second_menu['/cab/events_media/events/']=array('title'=>'Доведение контента') ;
   //$this->second_menu['/cab/events/arhive/']=array('title'=>'Архив мероприятий') ;
   $this->second_menu['/cab/events/new/']=array('title'=>'Новое мероприятие') ;
 }

 function block_main()
 { $this->page_title() ;
   reset($this->second_menu) ;
   redirect_301_to(key($this->second_menu));
   //$this->panel_report_scan() ;
 }

}



?>
