
<div class="row">
    <div class="col-xs-12">
        <div class="box box-danger">
            <div class="row">
                <div class="col-xs-12">
                    <div class="pull-right">
                        <a data-menu-action="sciezka_akceptacji" href="/sciezka_akceptacji" class="btn btn-success btn-flat">
                            <span style="margin-right: 10px;"><i class="fa fa-plus"></i> Dodaj</span>
                            <label class="switch"></label>
                        </a>
                    </div>
                </div>
            </div>
            <div class="box-body table-responsive table-fixed-height" style="max-height: 85vh!important;">
                <?php if (!empty($paths)): ?>
                    <table id="SciezkiAkceptacjiTable" class="table hover-rows custom-table" data-start-height="65vh">
                        <thead>
                        <tr>
                            <th>Ścieżka</th>
                            <th class="no-sortable text-right"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($paths as $path): ?>
                            <tr>
                                <td class="vertical-align"><strong><?php echo $path['bSymbol']; ?></strong><br/>
                                    <?php echo $path['bOpis']; ?>
                                </td>
                                <td class="text-right table-actions">
                                    <a data-menu-action="sciezka_akceptacji/<?php echo $path['bGid']; ?>" href="/sciezka_akceptacji/<?php echo $path['bGid']; ?>"
                                       class="btn btn-primary">
                                        <i class="fa fa-pencil"></i>
                                    </a>

                                    <a class="btn btn-danger" data-remove-entry data-gid="<?php echo $path['bGid']; ?>" data-url="usun_sciezke_akceptacji" data-title="Na pewno usunąć?"><i class="fa fa-trash"></i></a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                <?php endif; ?>
            </div>
        </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'); ?>
