<?php
include_once(_DIR_TO_CLASS."/c_page.php");
class c_page_cab_esmo_setting_terminal_card extends c_page
{
 public $h1='Карточка терминала' ;
 public $rec_terminal ;
 public $arr_types=[] ;

 function select_obj_info()
 { if (_CUR_ID)
   { $this->rec_terminal=ESMO()->get_terminal_by_pkey(_CUR_ID,array('include_diabled'=>1)) ;
     if ($this->rec_terminal['pkey'])
     { $this->h1='Карточка терминала "'.$this->rec_terminal['obj_name'].'"' ;
     }
     else $this->result=404 ;
   }
 }

 function menu_config()
 { if ($this->rec_terminal['pkey'])
   {   $this->menu[$this->rec_terminal['__href']]=array('title'=>'Параметры терминала') ;
       $this->menu[$this->rec_terminal['__href'].'log_view/']=array('title'=>'Журнал терминала') ;
       $this->menu[$this->rec_terminal['__href'].'errors_report/']=array('title'=>'Отчет по ошибкам') ;
       $this->menu[$this->rec_terminal['__href'].'log_req/']=array('title'=>'Журнал обмена') ;
       $this->menu[$this->rec_terminal['__href'].'log_events/']=array('title'=>'Журнал событий') ;
       $this->menu[$this->rec_terminal['__href'].'db/']=array('title'=>'Исходные данные') ;
   }
 }

 function block_main()
 { $this->page_title() ;

   if (function_exists('ESMO')) $this->arr_types['mt']='Медицинский терминал';
   if (function_exists('KT')) $this->arr_types['kt']='Терминал контроля трезвости';
   if (function_exists('QUIZ')) $this->arr_types['kz']='Терминал контроля знаний';

   $options_list=ACCOUNTS()->get_arr_groups_select_options(array('full_tree'=>1)) ;
   //print_r($options_list);


     ?><div id="panel_filter"><form id="sky-form" class="sky-form">
         <fieldset id="fieldset_group">
             <div class="row">
               <? $this->filter_section_select('term[parent]',$GLOBALS['LS_person_group_title'].':',2,$options_list,array('nospace_element'=>1,'cur_value'=>$this->rec_terminal['parent'])) ;

               ?>
                <section class="col col-2">
                    <label class="label">ID терминала:</label>
                    <label class="input"><input type="text" data-required name="term[id]" class=terminal_id value="<?echo $this->rec_terminal['id']?>" readonly></label>
                </section>
                <section class="col col-2">
                    <label class="label">IP адрес:</label>
                    <label class="input"><input type="text" data-required name="term[ip]" value="<?echo $this->rec_terminal['ip']?>" readonly></label>
                </section>
                 <section class="col col-2">
                     <label class="label">Наименование:</label>
                     <label class="input"><input type="text" data-required name="term[obj_name]"  value="<?echo addslashes($this->rec_terminal['obj_name'])?>"></label>
                 </section>

                <section class="col col-2">
                 <label class="label">Профиль</label>
                 <label class="select">
                     <select name="term[profil]">
                        <?if (_sizeof(_IL('IL_term_prof')->recs)) foreach(_IL('IL_term_prof')->recs as $id=>$rec){?><option value="<?echo $id?>" <?if ($this->rec_terminal['profil']==$id) echo 'selected'?>><?echo $rec['obj_name']?></option><?}?>
                     </select>
                 </label>
                </section>
                 <? $this->filter_section_select('term[terminal_type]','Тип:',2,$this->arr_types,array('nospace_element'=>1,'cur_value'=>$this->rec_terminal['terminal_type'])) ; ?>


           </div>
               </fieldset>
           <div id="panel_buttons">

               <?if ($this->rec_terminal['enabled'])
               {   ?><input type="submit" class="button v2" cmd="esmo_setting/terminal_save" value="Сохранить"  validate="form"  terminal_id="<?echo $this->rec_terminal['pkey']?>"><?
                   ?><button class="button v2" cmd="esmo_setting/terminal_disabled" terminal_id="<?echo $this->rec_terminal['pkey']?>">Заблокировать терминал</button><?
               }
                if (!$this->rec_terminal['enabled']){?>

                    <input type="submit" class="button v2" cmd="esmo_setting/terminal_enabled" value="Разблокировать терминал"  validate="form"  terminal_id="<?echo $this->rec_terminal['pkey']?>">
                <?}
                ?>
               <button class="button v2" cmd="esmo_setting/terminal_delete" terminal_id="<?echo $this->rec_terminal['pkey']?>">Удалить терминал</button>
           </div>
           </form>
           </div>
           <?

     ?><h2>Информация по устройствам</h2><?
     print_2x_arr($this->rec_terminal['_devices']) ;

 }


}



?>
