<?php
include_once("c_personal_person.php");

class c_page_cab_personal_person_pp extends c_page_cab_personal_person
{
  public $h1='Карточка сотрудника - пупиллометрия' ;
  public $use_fusioncharts=1;


 function set_head_tags()
 {  parent::set_head_tags() ;
    $this->HEAD['css'][]='/'._CLASS_.'/ext/aspmo_pp/style.css' ;
    $this->HEAD['js'][]='/'._CLASS_.'/ext/aspmo_pp/script.js' ;
 }

 function get_cur_page_meta_tags()
 {
   if ($this->rec_personal['pkey']) $this->h1='Результаты пупиллометрии '.$this->rec_personal['obj_name'] ;
 }

 function panel_filter()
 {
     ?><div id="panel_filter">
     <form id="sky-form" class="sky-form"><input type="hidden" name="filter_dir" value="/cab/personal/person/<?echo $this->rec_personal['pkey']?>/pp/">
         <fieldset>
             <div class="row">
                 <section class="col col-3">
                     <label class="label">Результаты пупиллометрии:</label>
                     <label class="select">
                         <select name="filter[pp_result]">
                             <option value="0"></option>
                             <?
                             $pp_result_list=PP()->getPPResultList();
                             if (_sizeof($pp_result_list)) foreach($pp_result_list as $key=>$rec) {?><option value="<?echo $key?>" <?if ($this->filter['pp_result']==$key) echo 'selected'?>><?echo $rec?></option><?}?>
                         </select>
                     </label>
                 </section>
                 <section class="col col-2">
                     <label class="label">Время измерения от:</label>
                     <label class="input"><input type="text" name="filter[timepick_from]" class="timepicker_test" value="<?echo $this->filter['timepick_from']?>"></label>
                 </section>
                 <section class="col col-2">
                     <label class="label">Время измерения до:</label>
                     <label class="input"><input type="text" name="filter[timepick_to]" class="timepicker_test"  value="<?echo $this->filter['timepick_to']?>"></label>
                 </section>
                 <section class="col col-2">
                     <label class="label">Дата измерения от:</label>
                     <label class="input"><input type="text" name="filter[data_from]" class="datepicker" value="<?echo $this->filter['data_from']?>"></label>
                 </section>
                 <section class="col col-2">
                     <label class="label">Дата измерения до:</label>
                     <label class="input"><input type="text" name="filter[data_to]" class="datepicker" value="<?echo $this->filter['data_to']?>"></label>
                 </section>
             </div>
             <div class="row">
                 <section class="col col-3">
                     <label class="checkbox"><input type="checkbox" name="filter[no_approximate]" value="1" <?if ($this->filter['no_approximate']) echo 'checked'?>><i></i>Отображать исходный график</label>
                 </section>
             </div>
         </fieldset>
         <input type="submit" class="v2" cmd="set_filter" value="Обновить данные">
     </form>
     </div><br>
     <?
 }

 function block_main()
 {   $this->page_title() ;
     $pp_usl='';
     $pp_link_array=[];
     if ($this->filter['pp_result']) $pp_link_array[]='result_code='.$this->filter['pp_result'];
     if ($this->filter['timepick_from'] and $this->filter['timepick_to']){ //условие по времени результата ПП
         $pp_link_array[]=PP()->getTimepickQuery(0,$this->filter['timepick_from'],$this->filter['timepick_to']);
     } elseif ($this->filter['timepick_from'])  {
         $pp_link_array[]=PP()->getTimepickQuery(1,$this->filter['timepick_from']);
     } elseif ($this->filter['timepick_to']) {
         $pp_link_array[]=PP()->getTimepickQuery(2,$this->filter['timepick_to']);
     }
     if ($this->filter['data_from']) $pp_link_array[]='c_data>='.strtotime($this->filter['data_from']);
     if ($this->filter['data_to']) $pp_link_array[]='c_data<='.strtotime($this->filter['data_to'] . ' 23:59:59');
     $pp_usl=implode(' and ',$pp_link_array);
     if ($pp_usl) $pp_usl=' and '.$pp_usl;

     $res = execSQL("select * from obj_site_narko_data where id_mo>0 and personal_id=".$this->rec_personal['pkey'].$pp_usl." order by pkey");
     if (_sizeof($res)) foreach ($res as &$rec){
         $rec['leftEye']=PP()->get_pp_value($rec['pkey'],'left');
         $rec['rightEye']=PP()->get_pp_value($rec['pkey'],'right');
     }
     $norms = execSQL_van("select * from obj_site_narko_data_out_303 where user_id=".$this->rec_personal['pkey']);

     $colors=['#be1e2d','#666699','#92d5ea','#ee8310','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744'];
     $count=0;
     $rec_norm=execSQL_van("select * from obj_site_narko_data_out_303 where user_id=".$this->rec_personal['pkey']);

     include_once(_DIR_EXT.'/aspmo_pp/panel_personal_norma.php') ;
     panel_personal_norma($rec_norm) ;
     if ($rec_norm['koof_p'] and $rec_norm['koof_m']){?><div class="green">Используется собственные значения разброса нормы</div><?}else{?><div class="red">Используется стандартные значения разброса нормы</div><?}
     if ($rec_norm['pkey'])
     {  if (!$rec_norm['koof_p']) $rec_norm['koof_p']=$GLOBALS['LS_pp_norma_koof_m'] ;
        if (!$rec_norm['koof_m']) $rec_norm['koof_m']=$GLOBALS['LS_pp_norma_koof_p'] ;
        ?><form>
                Разбос нормы: - <input type="text" class="v2 koof_m" name="koof_m" value="<?echo $rec_norm['koof_m']?>"> %
                              + <input type="text" class="v2 koof_p" name="koof_p" value="<?echo $rec_norm['koof_p']?>"> %
          <button class="v2" cmd="aspmo_pp/set_norma_koof" personal_id="<?echo $this->rec_personal['pkey']?>">Применить</button>
        </form>
     <?}?>
     <br>
     <?

     include_once(_DIR_EXT . '/aspmo_pp/report_pp_result2.php');
     $report_obj = new report_pp_result2();
     $report_obj->filter['personal_id']=$this->rec_personal['pkey'];
     $report_obj->setting();
     $report_obj->view();

 }

}



?>
