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

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

 function panel_personal_PMO()
 {
 	?><div id="panel_personal_info"><?

    $rec_event=EVENTS()->get_event_by_id($GLOBALS['LS_esmo_PMO_event']) ;
    $rec_pass=EVENTS()->get_event_pass($rec_event['pkey'],$this->rec_personal['pkey']) ;
     $pmo_ot_info=EVENT_PMO()->get_pmo_len_info_to_person($rec_event,$this->rec_personal['pkey']) ;
    //damp_array($pmo_ot_info,1,-1);
    ?><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 (sizeof($this->rec_personal['_groups_medic']))? implode(',',$this->rec_personal['_groups_medic']):'-'?></strong></td></tr>
      <tr><td>ИНРМ:</td><td><strong id="name"><?echo $pmo_ot_info['inrm']?></strong></td></tr>
      <tr><td>ВПФ:</td><td><strong id="name"><?echo ($pmo_ot_info['vfp_numbers'])? $pmo_ot_info['vfp_numbers']:'-'?></strong></td></tr>
      <tr><td>Переодичность ПМО по ВПФ</td><td><strong id="name"><?echo ($pmo_ot_info['vpf_len_srok'])? $pmo_ot_info['vpf_len_srok']:'-'?></strong></td></tr>
      <tr><td>Переодичность ПМО в мероприятии</td><td><strong id="name"><?echo $pmo_ot_info['srok']?></strong> (<?echo $pmo_ot_info['comment']?>)</td></tr>
      <tr><td>Текущий статус ПМО</td><td style="font-size:20px;color:<?echo EVENT_PMO()->arr_status_color[$rec_pass['status']]?>"><?echo EVENT_PMO()->arr_status[$rec_pass['status']]?></td></tr>
      <? if ($rec_pass['data_from']) {?><tr><td>Срок действия статуса, от:</td><td class="left"><?echo date('d.m.Y H:i',$rec_pass['data_from'])?></td></tr><?} ?>
      <? if ($rec_pass['data_to']) {?><tr><td>Срок действия статуса, до:</td><td class="left"><?echo date('d.m.Y H:i',$rec_pass['data_to'])?></td></tr><?} ?>

      </table>

    <? // $pass_recs=execSQL('select * from obj_site_events_pass where event_id='.$GLOBALS['LS_esmo_PMO_event'].' and personal_id='.$this->rec_personal['pkey'],2) ;
    //$pass_status_recs=execSQL('select * from obj_site_events_pass_status where event_id='.$GLOBALS['LS_esmo_PMO_event'].' and personal_id='.$this->rec_personal['pkey'].' order by pkey',2) ;
    //$scan_recs=execSQL('select * from obj_site_scan where personal_id='.$this->rec_personal['pkey'].' order by pkey',2) ;
    //$PMO_pass=execSQL('select * from obj_site_events_pass where pkey=531',2) ;

    // для корректного отображения срок действия ПМО по скану заключения надо получить запись из obj_site_events_pass_status связанной с сканом по полю scan_id
    // так как в мероприятии будет старый
    // !!! в сканах показываем только дату приема скана заключения!!!
    // сроки ПМО в сканах показывать нельзя, так как их потом можно загрузить через вкладку "Загрузка данных"
    ?><br><h2>Сдача сканов заключений ПМО:</h2><?
    $scan_recs=execSQL('select t1.*,
                        t4.obj_name as doc_name 
                        from view_scan t1 
                        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_PMO_event'].'
                        order by data_doc') ;

    ?><table class="basic fz_small full auto">
        <tr>
            <th>ID</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><?echo $rec_scan['pkey']?></td>
            <td class="nowrap left"><?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['_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.'/esmo_magnit_pmo/report_personals_in_event_pmo.php') ;
     $report_obj=new report_personals_in_event_pmo() ;
     $report_obj->no_view_title=1;
     $report_obj->report_paginator=0 ;
     $report_obj->filter['order']='obj_name';
     $report_obj->event_id=$GLOBALS['LS_esmo_PMO_event'] ;
     $report_obj->personal_id=$this->rec_personal['pkey'] ;
     $report_obj->init();
     $report_obj->view(['small_personal_info'=>1,'no_pages'=>1]) ;

     ?><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_PMO_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) ;
 }





}



?>
