<?php
include_once("c_kt_setting.php");
class c_page_cab_kt_setting_terminal extends c_page_cab_kt_setting
{
    public $h1='Карточка терминала' ;
    public $rec_terminal ;

    function select_obj_info()
    {
        $cur_id=(_CUR_ID)? _CUR_ID:MEMBER()->id ;
        $this->rec_terminal=DEVICE()->get_terminal_by_pkey($cur_id,['device'=>1]) ;
        if (!$this->rec_terminal['pkey']) $this->result=404 ;
        else $this->h1='Карточка терминала "'.$this->rec_terminal['obj_name'].'"' ;
    }

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

    function menu_config()
    {
        if (_CUR_ROOT_DIR_NAME=='cab') parent::menu_config() ;
        elseif ($this->rec_terminal['pkey'])
        {
            $this->menu['/window/kt/setting/terminal/'.$this->rec_terminal['pkey'].'/']=array('title'=>'Карточка терминала','_class'=>'fa fa-user-md') ;
        }
    }

    function panel_group_edit()
    {
        $zone=SKD()->get_list_zone() ;
        ?>
        <div id="panel_filter">
            <form id="sky-form" class="sky-form">
                <fieldset>
                    <div class="row">
                        <label class="input" style="display: none;"><input id="new_terminal_name" type="text" data-required name="filter[terminal_id]" value="<?echo $this->rec_terminal['pkey']?>"></label>
                        <section class="col col-3">
                            <label class="label">Название терминала:</label>
                            <label class="input"><input id="new_terminal_name" type="text" data-required name="filter[new_name]" value="<?echo $this->rec_terminal['obj_name']?>"></label>
                        </section>
                        <section class="col col-3">
                            <label class="label">Зона доступа:</label>
                            <label class="select">
                                <select id="zone_name" name="filter[parent]" data-required >
                                    <?if (_sizeof($zone)) foreach($zone as $rec){?><option value="<?echo $rec['pkey']?>" <?if ($this->rec_terminal['parent']==$rec['pkey']) echo 'selected'?>><?echo SKD()->get_full_zone_path($rec['pkey']) ?></option><?}?>
                                </select>
                            </label>
                        </section>
                        <section class="col col-2">
                            <label class="label">ID терминала:</label>
                            <label class="input"><input id="id_terminal" type="text" data-required name="filter[id]" value="<?echo $this->rec_terminal['id']?>"></label>
                        </section>
                        <section class="col col-2">
                            <label class="label">IP адрес:</label>
                            <label class="input"><input id="ip_terminal" type="text" data-required name="filter[ip]" value="<?echo $this->rec_terminal['ip']?>"></label>
                        </section>
                        <section class="col col-2">
                            <label class="label">Тип контроля:</label>
                            <label class="select">
                                <select name="filter[kt_type]">
                                    <option value="0" <?if (!$this->rec_terminal['kt_type']) echo 'selected';?>></option>
                                    <option value="1" <?if ($this->rec_terminal['kt_type'] == 1) echo 'selected';?>>только предсменный</option>
                                    <option value="2" <?if ($this->rec_terminal['kt_type'] == 2) echo 'selected';?>>только послесменный</option>
                                </select>
                            </label>
                        </section>
                    </div>
                </fieldset>
                <div id="panel_buttons">
                    <input class="button v2" type="submit" cmd="kt/terminal_edit" value="Сохранить изменения">
                    <button class="button v2" cmd="kt/confirmation_terminal_delete">Удалить терминал</button>
                </div>
            </form>
        </div><?
    }

}



?>
