<?php
include_once('c_rmv.php') ;
class c_page_cab_rmv_mo extends c_page_cab_rmv
{
 public $h1='Провести МО' ;

 function block_main()
 {
   $this->panel_input_propusk() ;
 }

 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('hand_mo[propusk_id]','',2,array('lang'=>"LAT",'case'=>"UPPER",'id'=>'propusk','required'=>1)) ;
     $form->row_close_open() ;
     $form->button('Начать','aspmo_rmv/start_hand_mo',['button_apply_id'=>'start_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('button#start_mo').bind('click',function()
         {
             RFHIDtimeout = false;
         }) ;

         $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:"aspmo_rmv/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>
 <?
 }
          }
?>