<?php
include_once("c_skd_access_point.php");
class c_page_cab_skd_setting_access_point extends c_page_cab_skd_access_point
{
    public $h1='Карточка точки доступа' ;
    public $rec_point ;

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

    function second_menu_config()
    {}

    function panel_group_edit()
    {
        $arr_groups=SKD()->get_list_zone() ;
        $med_groups = $this->get_med_groups();
        ?>
        <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_point['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_point['obj_name']?>"></label>
                    </section>
                    <section class="col col-4">
                        <label class="label">Турникет:</label>
                        <?if (!$this->rec_point['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_point['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-3">
                        <label class="label">Рабочая группа:</label>
                        <label class="select">
                            <select name="filter[med_group]">
                                <?if (_sizeof($med_groups)) foreach($med_groups as $rec){?><option value="<?echo $rec['pkey']?>" <?if ($this->rec_point['med_group_id'] == $rec['pkey']) echo 'selected'?>><?echo $rec['obj_name'] ?></option><?}?>
                            </select>
                        </label>
                    </section>
                    <section class="col col-2">
                        <label class="label">Зона:</label>
                        <label class="select">
                            <select name="filter[zone]">
                                <option value="zone0" <?if($this->rec_point['zone_name']=='zone0') echo 'selected'?>>Вход</option>
                                <option value="zone1" <?if($this->rec_point['zone_name']=='zone1') echo 'selected'?>>Выход</option>
                            </select>
                        </label>
                    </section>
                </div>
            </fieldset>
            <div id="panel_buttons">
                <input class="button v2" type="submit" cmd="skd/access_point_edit" value="Сохранить изменения">
                <button class="button v2" cmd="skd/before_delete">Удалить точку доступа</button>
            </div>
        </form>
        </div><?
    }

}



?>
