<?php
//include_once("c_esmo_gateway_upload.php");
include_once("c_ot_working_vpf.php");
//include_once(_DIR_TO_ENGINE.'/admin/i_admin_system.php') ;
class c_page_cab_ot_working_vpf_doctor extends c_page_cab_ot_working_vpf
{
 public $h1='ВПФ для должности: врачи-специалисты для МО' ;

 function block_main()
 {
    $this->panel_filter_info() ;
    $this->get_panel_setting_vpf_ball() ;
 }


    function get_panel_setting_vpf_ball()
      {   $_usl=array() ;
          $_usl[]='t1.clss=232' ;
          $_usl[]='t3.clss=230' ;
          if ($this->filter['org_id']) $_usl[]='org_id='.$this->filter['org_id'] ;
          if ($this->filter['otdel_id']) $_usl[]='otdel_id='.$this->filter['otdel_id'] ;
          if ($this->filter['working_id']) $_usl[]='work_id='.$this->filter['working_id'] ;
          $usl=implode(' and ',$_usl) ;
          $recs=execSQL('select t1.*,
                       t4.obj_name as org_name, 
                       t5.obj_name as otdel_name, 
                       t2.obj_name as work_name, 
                       t3.number as vpf_number,t3.obj_name as vpf_name,t3.parent2 as vpf_parent2,t3.parent3 as vpf_parent3,t3.parent4 as vpf_parent4,t3.doctors as vpf_doctors,t3.checked as vpf_checked,t3.comment as vpf_comment,t3.period as vpf_period 
                       from list_workings_fvp t1
                       left join list_workings t2 on t2.pkey=t1.work_id 
                       left join list_vpf t3 on t3.pkey=t1.vpf_id 
                       left join obj_site_personals t4 on t4.pkey=t1.org_id 
                       left join obj_site_personals t5 on t5.pkey=t1.otdel_id 
                       where '.$usl.'
                       order by vpf_number
                       ') ;
          $arr_doctors=array() ; $arr_isl=array() ; $max_period=0 ;  $arr_comment=array() ;
          $arr_stop_words=array('по','показаниям') ;
          if (_sizeof($recs)) foreach($recs as $rec)
          {  $arr=explode(" ",$rec['vpf_doctors']) ;
             if (_sizeof($arr)) foreach($arr as $name)
             {   $name=str_replace(array('*',' ',chr(194).chr(160)),'',$name) ;
                 if ($name and array_search($name,$arr_stop_words)===false) $arr_doctors[]=$name ;
             }
             $arr_isl[]=$rec['vpf_checked'] ;
             $arr_comment[]=$rec['vpf_comment'] ;
             if ($max_period<$rec['vpf_period']) $max_period=$rec['vpf_period'] ;
          }

          $arr_doctors=array_unique($arr_doctors)  ;
          $arr_isl=array_unique($arr_isl)  ;
          $arr_comment=array_unique($arr_comment)  ;
          natcasesort($arr_doctors) ;

          ?><h2>Переодический медицинский осмотр:</h2><ul><?
          if ($max_period==1) echo '<li><strong>1 раз в два года</strong></li>' ;
          if ($max_period==2) echo '<li><strong>1 раз в год</strong></li>' ;
          ?></ul><?

          if (_sizeof($arr_doctors))
          { ?><h2>Требуются осмотры у врачей-специалистов:</h2><ul><?
            foreach($arr_doctors as $name) {?><li><?echo $name?></li><?}
            ?></ul><?
          }
          if (_sizeof($arr_isl))
          { ?><h2>Лабораторные и функциональные исследования:</h2><ul><?
            foreach($arr_isl as $name) {?><li><?echo $name?></li><?}
            ?></ul><?
          }
          if (_sizeof($arr_comment))
          { ?><h2>Дополнительные медицинские противопоказания:</h2><ul><?
            foreach($arr_comment as $name) {?><li><?echo $name?></li><?}
            ?></ul><?
          }
          //damp_array($arr_doctors) ;
      }

}



?>
