<?php
include_once('c_rmv.php') ;
class c_page_cab_rmv_hand_mo extends c_page_cab_rmv
{
 public $h1='Ручная проверка' ;
 public $page_type='window' ;
 public $rec_personal=array() ;
    

 function select_obj_info()
 {
   $arr=explode('/',_CUR_PAGE_DIR) ; //damp_array($arr,1,-1) ;
   if ($arr[4])
    { $this->rec_personal=PERSONAL()->get_personal_by_id($arr[4],array('set_rules'=>1)) ;
      $this->h1='Проверка сотрудника '.$this->rec_personal['obj_name'] ;
      $this->title='Проверка сотрудника '.$this->rec_personal['obj_name'] ;
    }
   else $this->result=404 ;

   //damp_array($member,1,-1) ;
 }

 function menu_config() {}

 function block_main()
 { if (!$this->rec_personal['pkey']) return ;
   $this->page_title() ;
   $rec_active_dopusk=ESMO()->get_last_mo_rec_in_dopusk_time($this->rec_personal['pkey']) ;
   if (!$GLOBALS['LS_mo_check_access_go_doctor_by_DA'] and $rec_active_dopusk['dopusk']==1) $rec_active_dopusk=array() ; 
   include_once(_DIR_EXT.'/aspmo_personal/panel_personal_info.php') ;
   include_once('panel_hand_check.php');
   ?><div id="panel_mo">
           <table class="col3x">
             <tr><td class="img"><img class="shadow main" src="<?echo img_clone($this->rec_personal,'200')?>"><img class=qrcode src="/services/qrcode/<?echo $this->rec_personal['propusk']?>/" /></td>
                 <td class="info"><? panel_personal_info($this->rec_personal,array('button'=>array('pupilometr'=>1,'med_card'=>0)));?></td>
                 <? if (!$rec_active_dopusk['pkey'] or  $this->rec_personal['demo_access']) {?><td class="krit" ><?  panel_hand_check($this->rec_personal) ; ?></td><?}
                    elseif ($rec_active_dopusk['dopusk']==1)  {?><td class="krit" style="vertical-align:middle;text-align:center;font-size:30px;color:green;">ДОПУСК УЖЕ ПОЛУЧЕН, до <?echo date('d.m.Y H:i:s',$rec_active_dopusk['dopusk_time_end'])?></td><?}
                    elseif ($rec_active_dopusk['dopusk']==2)  {?><td class="krit" style="vertical-align:middle;text-align:center;font-size:30px;color:red;">ДОПУСК ЗАПРЕЩЕН, до <?echo date('d.m.Y H:i:s',$rec_active_dopusk['dopusk_time_end'])?></td><?}
                 ?>
             </tr>
           </table>
        </div>
     <div class="buttons"><button class="cancel close_window">Закрыть</button></div>
   <?
   $this->panel_list_mo_to_member($this->rec_personal['pkey'],array('limit'=>10,'view_name'=>'obj_site_mo_session')) ;
   $this->panel_view_krit_proverka() ;
   //damp_array($this->rec_personal) ;
 }

 // таблица, показывающая набор критериев оценки в сыром виде
 function panel_view_krit_proverka()
 {   $rules_info=ESMO_RULES()->get_mo_rules_to_personal($this->rec_personal) ;
     $rules=$rules_info['_rules'] ;
     ?><table id="panel_view_krit_proverka">
       <tr><td>Уровень параметров</td><td>Систолическое давление</td><td>Диастолическое давление</td><td>Пульс</td><td>Температура</td><td>Алкоголь</td><td>ЦНС</td></tr>
       <tr><td>Общие настройки системы</td><td><?echo $GLOBALS['LS_check_sd']?></td><td><?echo $GLOBALS['LS_check_sd']?></td><td><?echo $GLOBALS['LS_check_p']?></td><td><?echo $GLOBALS['LS_check_t']?></td><td><?echo $GLOBALS['LS_check_a']?></td><td><?echo $GLOBALS['LS_check_n']?></td></tr>
       <tr><td>Используемый критерий осмотра</td><td><?echo $this->rec_personal['_rules_krit']['s']?></td><td><?echo $this->rec_personal['_rules_krit']['d']?></td><td><?echo $this->rec_personal['_rules_krit']['p']?></td><td><?echo $this->rec_personal['_rules_krit']['t']?></td><td><?echo $this->rec_personal['_rules_krit']['a']?></td><td><?echo $this->rec_personal['_rules_krit']['n']?></td></tr>
       <tr><td>Собственные критерии сотрудника</td><td><?echo ($this->rec_personal['s_min'] or $this->rec_personal['s_max'])? 1:'-';?></td><td><?echo ($this->rec_personal['d_min'] or $this->rec_personal['d_max'])? 1:'-';?></td><td><?echo ($this->rec_personal['p_min'] or $this->rec_personal['p_max'])? 1:'-';?></td><td><?echo ($this->rec_personal['t_min'] or $this->rec_personal['t_max'])? 1:'-';?></td><td><?if ($this->rec_personal['a']==2) echo 'Да' ; else if ($this->rec_personal['n']==1) echo 'Нет' ; else echo '-'?></td><td><?if ($this->rec_personal['n']==2) echo 'Да' ; else if ($this->rec_personal['n']==1) echo 'Нет' ; else echo '-'?></td></tr>
       <tr><td>Проверяемые параметры</td><td><?echo $rules['s']?></td><td><?echo $rules['d']?></td><td><?echo $rules['p']?></td><td><?echo $rules['t']?></td><td><?echo $rules['a']?></td><td><?echo $rules['n']?></td></tr>

     </table><?
 }

  function panel_list_mo_to_member($personal_id,$options=array())
   { ?><div id="panel_list_mo_to_member"><h2>Предыдущие проверки сотрудника <?if ($options['limit']) echo '<span class="small">последние '.$options['limit'].' МО</span>'?></h2><label>Показывать только успешные допуски к МО <input type="checkbox" name="view_only_success" class=v2 cmd=aspmo/set_view_only_success <?if ($GLOBALS['LS_setting_mo_pers_view_only_success']) echo 'checked'?>></label><?
     //if ($member->info['rol']>1)  $options['doctor_id']=$member->id ; // только с терминалов своей группы
     if (!is_array($options)) $options=array() ;
     $options['only_check_success']=$GLOBALS['LS_setting_mo_pers_view_only_success'] ;
     $recs=ESMO()->get_mo_recs_to_personal($personal_id,$options) ;
     print_template($recs,'aspmo/list_mo_sessions_small') ;
     ?></div><?
   }



}

?>