<div class="row" id="EdytujRoleFormContainer">
    <div class="col-xs-12">
        <div class="box box-danger">
            <?php echo $this->Form->create(null, ['templates' => ['submitContainer' => '{{content}}',], 'id' => 'tem:pRola', 'name' => 'tem:pRola', 'class' => 'form-horizontal']); ?>
            <div class="box-body">
                <?php echo $this->Form->input('tem:pRola.dat:Gid', array('type' => 'hidden')); ?>
                <h2 style="margin-left: 0.5em;">Dane podstawowe</h2>
                <div class="form-group">
                    <label class="col-xs-12 col-md-2 control-label">Nazwa roli</label>
                    <div class="col-xs-12 col-md-10">
                        <?php echo $this->Form->input('tem:pRola.dat:Nazwa', array('readonly' => true, 'class' => 'form-control disabled', 'div' => false, 'label' => false)); ?>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-md-2 control-label">Opis</label>
                    <div class="col-xs-12 col-md-10">
                        <?php echo $this->Form->input('tem:pRola.dat:Opis', array('class' => 'form-control', 'div' => false, 'label' => false)); ?>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-md-2 control-label">E-mail zwierzchnika</label>
                    <div class="col-xs-12 col-md-10">
                        <?php echo $this->Form->input('tem:pRola.dat:Email', array('class' => 'form-control', 'id' => 'email', 'div' => false, 'label' => false)); ?>
                    </div>
                </div>
                <div class="form-group" style="display: none; visibility: hidden;">
                    <label class="col-xs-12 col-md-2 control-label" for="ukryta">Rola ukryta</label>
                    <div class="col-xs-12 col-md-10">
                        <?php
                        $hiddenCheck = true;
                        if ($this->request->getData('tem:pRola')['dat:CzyUkryta'] == 'false') {
                            $hiddenCheck = false;
                        }
                        ?>
                        <?php echo $this->Form->checkbox('tem:pRola.dat:CzyUkryta', array('id' => 'ukryta', 'div' => false, 'label' => false, 'checked' => $hiddenCheck)); ?>
                    </div>
                </div>
                <div style="display: none; visibility: hidden;">
                    <div class="form-group">
                        <label class="col-xs-12 col-md-2 control-label" for="wbudowana">Rola wbudowana</label>
                        <div class="col-xs-12 col-md-10">
                            <?php
                            $builtInCheck = true;
                            if ($this->request->getData()['tem:pRola']['dat:CzyWbudowana'] == 'false') {
                                $builtInCheck = false;
                            }
                            ?>
                            <?php echo $this->Form->checkbox('tem:pRola.dat:CzyWbudowana', array('id' => 'wbudowana', 'div' => false, 'label' => false, 'checked' => $builtInCheck)); ?>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-md-2 control-label" for="zaznaczenie">Zaznaczenie</label>
                        <div class="col-xs-12 col-md-10">
                            <?php
                            $checkedCheck = true;
                            if ($this->request->getData()['tem:pRola']['dat:CzyZaznaczenie'] == 'false') {
                                $checkedCheck = false;
                            }
                            ?>
                            <?php echo $this->Form->checkbox('tem:pRola.dat:CzyZaznaczenie', array('id' => 'zaznaczenie', 'div' => false, 'label' => false, 'checked' => $checkedCheck)); ?>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-md-2 control-label"></label>
                    <div class="col-xs-12 col-md-10">
                        <a data-menu-action="administracja_role" class="btn btn-default pull-left margin-r-5" href="administracja_role">Anuluj</a>
                        <?php echo $this->Form->submit('Zapisz', array('id' => 'submitForm-EdytujRole', 'class' => 'btn btn-success pull-left')); ?>
                    </div>
                </div>
            </div>
            <?php echo $this->Form->end(); ?>
        </div>
    </div>
</div>

<script>
    const elemsData = document.querySelectorAll('[data-menu-action]')
    elemsData.forEach(elem => elem.onclick = testFun)

    function testFun(e) {
        e.preventDefault();

        $(this).parents('.sidebar').find('li.active:not(.treeview)').removeClass('active');
        $(this).parents('li').addClass('active');

        var url = $(this).data('menu-action');
        localStorage.setItem('menu_action', url);

        loadAjaxView(url);
    }
</script>

<?php echo $this->element('alert_close'); ?>
