<?php
include_once("c_skd.php");
class c_page_cab_skd_setting_terminal extends c_page_cab_skd
{
    public $h1='Карточка турникета' ;
    public $rec_terminal ;

    function select_obj_info()
    {
        $cur_id=(_CUR_ID)? _CUR_ID:MEMBER()->id ;
        $this->rec_terminal=SKD()->get_device_by_pkey($cur_id) ;
        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/skd/setting/terminal/'.$this->rec_terminal['pkey'].'/']=array('title'=>'Карточка турникета "'.$this->rec_terminal['obj_name'].'"','_class'=>'fa fa-user-md') ;
//            $this->menu['/window/skd/setting/terminal/'.$this->rec_zone['pkey'].'/access_point/']=array('title'=>'Точки доступа','_class'=>'fa fa-user-md') ;
        }
    }

    function second_menu_config()
    {}

    function panel_group_edit()
    {
        $arr_groups=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_name_zone" type="text" data-required name="filter[id]" value="<?echo $this->rec_terminal['pkey']?>"></label>
                    <section class="col col-4">
                        <label class="label">Название турникета</label>
                        <label class="input"><input id="new_name_zone" type="text" data-required name="filter[name]" value="<?echo $this->rec_terminal['obj_name']?>"></label>
                    </section>
                    <section class="col col-4">
                        <label class="label">Зона доступа:</label>
                        <?if (!$this->rec_terminal['parent']) {?>
                            <label class="input"><input id="new_name_zone" type="text" data-required value="" disabled></label>
                            <label class="input" style="display: none"><input id="new_name_zone" type="text" data-required value="0" name="filter[parent]"></label>
                        <?} else {?>
                            <label class="select">
                                <select id="zone_parent" name="filter[parent]">
                                    <?if (_sizeof($arr_groups)) foreach($arr_groups as $id=>$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>
                </div>
                <div class="row">
                    <section class="col col-2">
                        <label class="label">ID терминала:</label>
                        <label class="input"><input id="id_terminal" type="text" data-required name="filter[terminal_id]" value="<?echo $this->rec_terminal['device_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="input"><input id="ip_terminal" type="text" data-required name="filter[version]" value="<?echo $this->rec_terminal['version']?>" disabled></label>
                    </section>
                </div>
            </fieldset>
            <div id="panel_buttons">
                <input class="button v2" type="submit" cmd="skd/terminal_edit" value="Сохранить изменения">
                <button class="button v2" cmd="skd/before_delete">Удалить турникет</button>
            </div>
        </form>
        </div><?
    }

}



?>
