<?php
include_once("c_personal_person.php");
class c_page_cab_personal_person_opo extends c_page_cab_personal_person
{
  public $h1='Карточка сотрудника - ОПО' ;

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

 function panel_personal_OPO()
 {



    //$arr_vpf_sections=execSQL_row('select pkey as id,obj_name from list_vpf where clss=233 and level=2 order by indx') ;

 	?><div id="panel_personal_info"><?

    $rec_event=EVENTS()->get_event_by_id($GLOBALS['LS_esmo_OPO_event']) ;
    $opo_ot_info=OPO()->get_opo_len_info_to_person($rec_event,$this->rec_personal['pkey']) ;
    $rec_pass=EVENTS()->get_event_pass($rec_event['pkey'],$this->rec_personal['pkey']) ;
    //damp_array($opo_ot_info);
    ?><table class="info">
      <tr><td>Должность:</td><td><strong id="name"><?echo $this->rec_personal['_work_name']?></strong></td></tr>
      <tr><td>ИНРМ:</td><td><strong id="name"><?echo $opo_ot_info['inrm']?></strong></td></tr>
      <tr><td>ВПФ:</td><td><strong id="name"><?echo $opo_ot_info['vfp_numbers']?></strong><br><?echo  $opo_ot_info['vfp_text']?></td></tr>
      <tr><td>Переодичность ОПО по ВПФ</td><td><strong id="name"><?echo $opo_ot_info['vpf_len_srok']?></strong></td></tr>
      <tr><td>Переодичность ОПО в мероприятии</td><td><strong id="name"><?echo $opo_ot_info['srok']?></strong> (<?echo $opo_ot_info['comment']?>)</td></tr>
      <tr><td>Текущий статус ОПО</td><td style="font-size:20px;color:<?echo OPO()->arr_status_color[$rec_pass['status']]?>"><?echo OPO()->arr_status[$rec_pass['status']]?></td></tr>

      </table>

    <? ?><br><h2>Сдача сканов заключений ОПО:</h2><?
    $scan_recs=execSQL('select t1.*,
                        t2.data_from as status_data_from,t2.data_to as status_data_to, 
                        t3.data_from as pass_data_from,t3.data_to as pass_data_to, 
                        t4.obj_name as doc_name 
                        from view_scan t1 
                        left join obj_site_events_pass_status t2 on t2.scan_id=t1.pkey
                        left join obj_site_events_pass t3 on t3.personal_id=t1.personal_id and t3.event_id='.$GLOBALS['LS_esmo_OPO_event'].'
                        left join obj_site_docs t4 on t4.pkey=t1.doc_id
                        where t1.personal_id='.$this->rec_personal['pkey'].' and (t1.event_id='.$GLOBALS['LS_esmo_OPO_event'].' or t1.doc_type="zaklyuchenie_o_psihiatricheskom_osvidetelstvovanii")
                        order by data_doc
                        
                        ') ;

    ?><table class="basic fz_small full auto">
        <tr>
            <th>Наименование документа</th>
            <th>Дата заключения ОПО</th>
            <th>Статус документа</th>
            <th>Диагноз в заключении</th>
            <th>Срок действия ОПО, от</th>
            <th>Срок действия ОПО, до</th>
            <th>Оператор</th>
            <th>Дата обработки заключения ОПО</th>
            <th>Скан заключения</th>
        </tr>
     <?
    if (_sizeof($scan_recs)) foreach($scan_recs as $rec_scan)
    {  DOCS()->prepare_public_info_to_scan($rec_scan) ;
       ?><tr>

            <td class="nowrap"><?echo $rec_scan['doc_name']?></td>
            <td><?echo date('d.m.Y',$rec_scan['data_doc'])?></td>
            <td><?echo $_SESSION['ARR_status_scan'][$rec_scan['status']]?></td>
            <td><?echo $rec_scan['diagnoz']?></td>
            <td><?echo ($rec_scan['status_data_from'])? date('d.m.Y',$rec_scan['status_data_from']):(($rec_scan['pass_data_from'])? date('d.m.Y',$rec_scan['pass_data_from']):'-')?></td>
            <td><?echo ($rec_scan['status_data_to'])? date('d.m.Y',$rec_scan['status_data_to']):(($rec_scan['pass_data_to'])? date('d.m.Y',$rec_scan['pass_data_to']):'-')?></td>
            <td><?echo $rec_scan['_account_work_name']?></td>
            <td><?echo date('d.m.Y H:i:s',$rec_scan['data_set'])?></td>
            <td><span class="nowrap"><a href="<?echo $rec_scan['__href']?>" class="new_window" target="_blank" title="window_scan">Открыть скан</a></span></td>
        </tr>
      <?

    }
    ?></table><?

     ?><br><h2>Участие сотрудника в мероприятии:</h2><?
     include_once(_DIR_EXT_LOCAL.'/events_opo/report_personals_in_event_opo.php') ;
     $report_obj=new report_personals_in_event_opo() ;
     $report_obj->no_view_title=1;
     $report_obj->filter['order']='obj_name';
     $report_obj->event_id=$GLOBALS['LS_esmo_OPO_event'] ;
     $report_obj->personal_id=$this->rec_personal['pkey'] ;
     $report_obj->init();
     $report_obj->view() ;

     ?><br><?
     include_once(_DIR_EXT.'/events/doc_event_personal_history.php') ;
        $report_obj=new doc_event_personal_history() ;
        $report_obj->event_pass_id=execSQL_value('select pkey from obj_site_events_pass where event_id='.$GLOBALS['LS_esmo_OPO_event'].' and personal_id='.$this->rec_personal['pkey']);
        $report_obj->init();
        //$report_obj->setting();
        $report_obj->view(['no_view_person_info'=>1]) ;


     ?>



    </div><?
 }



 function generate_vpf_list($vpf_by_section,$section_id)
 {   $f1='' ;
     if (_sizeof($vpf_by_section[$section_id]))
     { $arr_number=array() ;  $arr_names=array() ;
       foreach($vpf_by_section[$section_id] as $vpf_number=>$vpf_name) { $arr_number[]=$vpf_number ; $arr_names[]=$vpf_name ; }
       //$f1=implode(', ',$arr_number).' ('.implode(';',$arr_names).')' ;
       $f1=implode(', ',$arr_number) ;
     }
     return($f1) ;
 }





}



?>
