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

 function select_obj_info()
 { if (_CUR_ID and function_exists('OPO'))
   { $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=$this->rec_event['obj_name'].' - '.$this->h1 ; ;
     }

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

 }

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

 function menu_config()
 { if (!function_exists('OPO')) 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'=>OPO()->arr_status[1],'info_value'=>(($arr_cnt[1])? '<span>'.$arr_cnt[1].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals/in_process/']=array('title'=>OPO()->arr_status[2],'info_value'=>(($arr_cnt[2])? '<span>'.$arr_cnt[2].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals/block/']=array('title'=>OPO()->arr_status[7],'info_value'=>(($arr_cnt[7])? '<span>'.$arr_cnt[7].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals/success/']=array('title'=>OPO()->arr_status[8],'info_value'=>(($arr_cnt[8])? '<span>'.$arr_cnt[8].'</span>':'')) ;
        $this->menu[$this->rec_event['__href'].'personals/failed/']=array('title'=>OPO()->arr_status[9],'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();
             ?>
             <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('report_event_opo_info.php') ;
        $report_obj=new report_event_opo_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 OPO()->arr_opo_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><?
    }




}



?>
