<?php
include_once(_DIR_EXT."/esmo_magnit_pmo/i_event_pmo.php");
include_once(_DIR_TO_CLASS."/c_page.php");
class c_page_cab_esmo_magnit_pmo_card extends c_page
{
  public $h1='Карточка мероприятия' ;
  var $rec_event ;
  var $obj_event ;

 function select_obj_info()
 { if (_CUR_ID and function_exists('EVENTS'))
   { $this->rec_event=EVENTS()->get_event_by_id(_CUR_ID) ;
     if ($this->rec_event['pkey'])
     {
         $this->obj_event=EVENTS()->get_event_obj_by_ext($this->rec_event['ext']) ;
         $this->obj_event->rec_event=$this->rec_event ;
         $this->h1=EVENT_PMO()->name.' "'.$this->rec_event['obj_name'].'" - '.$this->h1 ;
         //damp_array($this->rec_event['_ext_info']['pmo_len_union']);
     }

     if (!$this->rec_event['pkey']) $this->result=404 ;
   } else $this->result=404 ;

 }

 var $arr_sanction=array(0=>'Нет',1=>'Запрет прохождения МО') ;

 function menu_config()
 { if (!function_exists('EVENTS')) return ;
   // вкладки для сотрудника
   $arr_cnt=EVENTS()->get_event_personals_status($this->rec_event['pkey']) ;
   $arr_cnt[2]=(int)($arr_cnt[2]+$arr_cnt[22]+$arr_cnt[3]+$arr_cnt[4]+$arr_cnt[5]+$arr_cnt[6]);
   //damp_array($this->rec_event) ;
   if ($this->rec_event['pkey'] and $this->rec_event['enabled'])
      { $this->menu[$this->rec_event['__href']]='Карточка мероприятия' ;
        $this->menu[$this->rec_event['__href'].'edit/step1/']='Редактировать' ;
        $this->menu[$this->rec_event['__href'].'personals/']='Все участники' ;
        if ($arr_cnt[1]) $this->menu[$this->rec_event['__href'].'personals/free/']=array('title'=>'Не направлен на ПМО','info_value'=>(($arr_cnt[1])? '<span>'.$arr_cnt[1].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals/in_process/']=array('title'=>'Подлежит ПМО','info_value'=>(($arr_cnt[2])? '<span>'.$arr_cnt[2].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals_block/']=array('title'=>'Заблокированы по ПМО','info_value'=>(($arr_cnt[7])? '<span>'.$arr_cnt[7].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals/ext/']=array('title'=>'Дообследование','info_value'=>(($arr_cnt[10])? '<span>'.$arr_cnt[10].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals_success/']=array('title'=>'ПМО пройден, годен','info_value'=>(($arr_cnt[8])? '<span>'.$arr_cnt[8].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals_failed/']=array('title'=>'ПМО пройден, негоден','info_value'=>(($arr_cnt[9])? '<span>'.$arr_cnt[9].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'log/']='История' ;
        $this->menu[$this->rec_event['__href'].'db/']='Исходные данные' ;
        $this->menu[$this->rec_event['__href'].'check_status/']='Проверка статусов' ;
        $this->page_type='window' ;
      }
   elseif ($this->rec_event['pkey'])
      { $this->menu[$this->rec_event['__href'].'edit/step1/']='Параметры ПМО' ;
        $this->page_type='window' ;
      }
   else parent::menu_config() ;
 }


 function block_main()
 { $this->page_title() ;
   //damp_array($this->rec_event) ;
   ?><div id="panel_filter">
         <form id="sky-form" class="sky-form">
             <fieldset>
             <?$this->panel_event_info();?><br>
             <h2>Участники мероприятия</h2><br>
             <? $this->panel_personal_info();?>
             <!--<button class="button v2" cmd="events/event_check_personals" event_id="<?echo $this->rec_event['pkey']?>">Обновить список подлежащих мероприятию</button>-->
             </fieldset>
         </form>
     </div><?
     $this->panel_stats_by_atp() ;

 }

 function panel_stats_by_atp()
  { ?><h2>Статистика прохождения по АТП:</h2><?
     include_once(_DIR_EXT.'/esmo_magnit_pmo/report_event_pmo_info.php') ;
        $report_obj=new report_event_pmo_info() ;
    $report_obj->event_id=$this->rec_event['pkey'] ;
    $report_obj->filter['group_id']=MEMBER()->cur_group_id ;
    //$report_obj->setting() ;
    $report_obj->view() ;
 }

 function panel_event_info()
   {  ?><div class="row event_info">
           <section class="col col-2">
             <label class="label">Срок действия мероприятия:<br>&nbsp;</label>
             <strong><?echo $_SESSION['ARR_events_mode'][$this->rec_event['mode']]?></strong>
            </section>

           <section class="col col-2">
             <label class="label">Переодичность прохождения ПМО:<br>&nbsp;</label>
             <strong><?echo EVENT_PMO()->arr_pmo_len[$this->rec_event['_ext_info']['pmo_len']]?></strong>
            </section>

            <!--<section class="col col-2">
               <label class="label">Срок ожидания<br>получения документов:</label>
                <strong><?echo ($this->rec_event['_ext_info']['period_to_status_5'])? $this->rec_event['_ext_info']['period_to_status_5'].' дней' :'нет'?></strong>
            </section>

            <section class="col col-2">
               <label class="label">Срок ожидания<br>возврата заключения</label>
                <strong><?echo ($this->rec_event['_ext_info']['period_to_status_7'])? $this->rec_event['_ext_info']['period_to_status_7'].' дней' :'нет'?></strong>
            </section>

            <section class="col col-2">
               <label class="label">Срок начала увемлений<br> о возврате документов:</label>
                <strong><?echo ($this->rec_event['_ext_info']['period_to_status_3'])? $this->rec_event['_ext_info']['period_to_status_3'].' дней' :'нет'?></strong>
            </section>-->

            <section class="col col-2">
               <label class="label">Срок возврата сотрудника <br> на повторное прохождение ПМО:</label>
                <strong> за <?echo ($this->rec_event['_ext_info']['pmo_before'])? $this->rec_event['_ext_info']['pmo_before'].' дней до окончания срока действия ПМО' :'нет'?></strong>
            </section>
	  </div><?
   }

    function panel_personal_info()
    {   // данные по участникам мероприятия с учетом группы текущего аккаунта
        $arr_personals_status=EVENTS()->get_event_personals_status($this->rec_event['pkey']) ;
        $personals_count=array_sum($arr_personals_status) ;
        ?><div class="row event_info">
            <section class="col col-3">
                   <label class="label">Условие отбора участников</label>
                   <?PERSONALS_FILTER()->get_personals_filter_info_to_item($this->rec_event['_reffer'])?>
            </section>
            <section class="col col-3">
                   <label class="label">Сотрудники</label>
                   <strong><?echo $personals_count.' '.get_case_by_count_1_2_5($personals_count,'сотрудник,сотрудника,сотрудников')?></strong>
            </section>
 	  </div><?
    }




}



?>
