<div class="row">
    <div class="col-xs-12" id="message_list_filters">
        <a href="#" data-active="1" class="btn btn-tile btn-danger" data-message="wiadomosci" data-type="Odbiorcza">
            <i class="fa fa-envelope-open-o"></i>
            <span>Odebrane</span>
        </a>
        <a href="#" data-active="0" class="btn btn-tile btn-danger" data-message="wiadomosci" data-type="Nadawcza">
            <i class="fa fa-envelope-o"></i>
            <span>Wysłane</span>
        </a>
        <a href="#" data-active="0" class="btn btn-tile btn-danger" data-message="wiadomosci" data-type="Robocze">
            <i class="fa fa-envelope-open"></i>
            <span>Robocze</span>
        </a>
        <a href="#" data-active="0" class="btn btn-tile btn-danger" data-message="wiadomosci" data-type="Wszystkie">
            <i class="fa fa-envelope"></i>
            <span>Wszystkie</span>
        </a>
        <?php if ($uprawnienia['ModulWiadomosci']['bCzyDodawanie'] == 'true') : ?>
            <a data-menu-action="dodaj_wiadomosc/<?php echo $this->request->getParam('action'); ?>" href="/dodaj_wiadomosc"
               class="btn btn-tile btn-success">
                <i class="fa fa-plus-circle"></i>
                <span>Nowa wiadomość</span>
            </a>
        <?php endif; ?>
    </div>
</div>

<div class="row">
    <div class="col-xs-12 home-messages-container">
        <div class="box box-danger table-fixed-height"
             style="max-height: 85vh!important; overflow-x: hidden!important;">
            <div class="row">
                <div class="col-xs-12">
                    <div class="pull-right">
                        <a class="btn btn-danger btn-flat hidden-messages-toggle">
                            <span style="margin-right: 10px;">Ukryte</span>
                            <label class="switch">
                                <input type="checkbox" name="is_hidden" id="MessageIsHidden"/>
                            </label>
                        </a>
                    </div>
                    <div id="ChangeMessagePriorContainer" class="pull-right hidden" style="margin-left: 10px;">
                        <label style="margin-right: 5px;">Priorytety: </label>
                        <select id="" class="form-control">
                            <option value="x">Wszystkie priorytety</option>
                            <?php foreach ($priorytety as $k => $r) : ?>
                                <option value="<?php echo $r; ?>"><?php echo $r; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>
            </div>
            <?php echo $this->Element('table_loading'); ?>
            <div data-container="table" class="box-body table-responsive">
                <div class="no-data"><p>Brak danych</p></div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.page-name:first-of-type').html('<?php echo $pageName; ?>');
    })
</script>

<script>
    var initMsg = true;

    $(function(){
        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->Html->script('messages'); ?>

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