<?php include_once('c_kt_rmv.php') ;
class c_page_cab_kt_hand extends c_page_cab_kt_rmv
{
  public $h1='Ручной контроль трезвости' ;
  public $page_type='' ;
  public $rec_personal=array() ;

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

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

 function block_main()
 { if (!_CUR_ID) $this->panel_input_propusk() ;
   else          $this->panel_hand_mo() ;
 }

 function panel_input_propusk()
 {
     ?><h2>Введите номер пропуска</h2><?
     $form=new i_form() ;
     $form->form_open(array('id'=>'panel_hand_mo')) ;
     $form->row_open() ;
     $form->filter_section_input_text('propusk_id','',2,array('lang'=>"LAT",'case'=>"UPPER",'id'=>'propusk','required'=>1)) ;
     $form->row_close_open() ;
     $form->button('Начать','kt/start_hand_mo');
     $form->row_close() ;
     $form->form_close() ;
     ?>
     <span id="pass_reading_time" style="display: none"><?echo $GLOBALS['LS_mo_pass_reading_time']?></span>

     <script type="text/javascript">
         let reading_time = document.getElementById("pass_reading_time").textContent;
         $j('input#propusk')[0].focus() ;

         $j('input#propusk').on('keyup',function()
         {
             RFHIDtimeout = Date.now();
         }) ;

         $j(document).ready(function()
         {
             $j("body").stopTime('check_pass_number');
             $j('body').everyTime(100,'check_pass_number',function(){
                 let propusk = $j('input#propusk').val();
                 if (typeof RFHIDtimeout == "number" && (Date.now() - RFHIDtimeout)>reading_time && propusk !== '') {
                     send_ajax_request({cmd:"kt/start_hand_mo",propusk_id:propusk}) ;
                     $j('input#propusk').val('') ;
                     $j('input#propusk').focus() ;
                     RFHIDtimeout = false;
                 } else if (propusk === '') {
                     $j('input#propusk').focus() ;
                     RFHIDtimeout = false;
                 }
             })
         }) ;
     </script>
    <?
 }

 function panel_hand_mo()
    { if (!$this->rec_personal['pkey']) return ;
      $this->page_title() ;
      include_once(_DIR_EXT.'/kt/panel_personal_info.php') ;
      include_once(_DIR_EXT.'/kt/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>
                    <td class="krit" ><?  panel_hand_check($this->rec_personal) ; ?></td>
                </tr>
              </table>
           </div>
        <div class="buttons"><button class="v1" href="/cab/kt/hand/">Отмена</button></div>
      <?
      $this->panel_prev_kt() ;  
    }

 function panel_prev_kt()
 {  ?><h2>Предыдущие проверки КТ сотрудника <? echo '<span class="small">последние 10 КТ</span>'?></h2><?
    include_once(_DIR_EXT.'/kt/report_kt_small.php') ;
    $report_obj=new report_kt_small() ;
    $report_obj->no_view_title=1 ;
    $report_obj->filter['personal_id']=$this->rec_personal['pkey'] ; // только с терминалов своей группы
    $report_obj->order='pkey desc';
    $report_obj->view(array('limit'=>'limit 10')) ;
 }


}
?>