<?php
include_once("c_skd.php");
class c_page_cab_skd_setting_zone extends c_page_cab_skd
{
    public $h1='Карточка зоны доступа' ;
    public $rec_zone ;

    function select_obj_info()
    {
        $cur_id=(_CUR_ID)? _CUR_ID:MEMBER()->id ;
        $this->rec_zone=SKD()->get_zone_by_pkey($cur_id) ;
        if (!$this->rec_zone['pkey']) $this->result=404 ;
        else $this->h1='Карточка зоны доступа "'.$this->rec_zone['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_zone['pkey'])
        {
            $this->menu['/window/skd/setting/zone/'.$this->rec_zone['pkey'].'/']=array('title'=>'Карточка группы "'.$this->rec_zone['obj_name'].'"','_class'=>'fa fa-user-md') ;
            $this->menu['/window/skd/setting/zone/'.$this->rec_zone['pkey'].'/terminal/']=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_zone['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_zone['obj_name']?>"></label>
                    </section>
                    <section class="col col-4">
                        <label class="label">Родительская зона доступа:</label>
                        <?if (!$this->rec_zone['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_zone['parent']==$rec['pkey']) echo 'selected'?>><?echo SKD()->get_full_zone_path($rec['pkey']) ?></option><?}?>
                                </select>
                            </label>
                        <?}?>
                    </section>
                </div>
            </fieldset>
            <div id="panel_buttons">
                <input class="button v2" type="submit" cmd="skd/zone_edit" value="Сохранить изменения">
                <?if ($this->rec_zone['parent']) {?><input class="button v2" type="submit" cmd="skd/before_delete" value="Удалить зону"><?}?>
            </div>
        </form>
        </div><?
    }

}



?>
